File: FastTracker2.c

package info (click to toggle)
fs-uae 3.2.35-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 28,376 kB
  • sloc: cpp: 257,557; ansic: 121,965; sh: 4,895; makefile: 1,577; python: 446; asm: 275; xml: 10
file content (99 lines) | stat: -rw-r--r-- 2,762 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/* testXM() */
/* Rip_XM() */


#include "globals.h"
#include "extern.h"


short testXM ( void )
{
  /* test #1 */
  PW_Start_Address = PW_i;
  if ( (PW_Start_Address + 336) > PW_in_size)
  {
    /*printf ( "#1 Start:%ld\n" , PW_Start_Address );*/
    return BAD;
  }

  if ( (in_data[PW_Start_Address + 37] != 0x1A ) || (in_data[PW_Start_Address+58] != 0x04) )
  {
    /*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/
    return BAD;
  }

  /* get header siz */
  PW_l = ( (in_data[PW_Start_Address+63]*256*256*256)+
	   (in_data[PW_Start_Address+62]*256*256)+
	   (in_data[PW_Start_Address+61]*256)+
	   in_data[PW_Start_Address+60] );
  /* get number of patterns */
  PW_j = (in_data[PW_Start_Address + 71]*256) + in_data[PW_Start_Address + 70];
  /* get number of instruments */
  PW_k = (in_data[PW_Start_Address + 73]*256) + in_data[PW_Start_Address + 72];

  if ( (PW_j>256)||(PW_k>128) )
  {
    /*printf ( "#3 Start:%ld\n" , PW_Start_Address );*/
    return BAD;
  }

  PW_l += 60; /* points now on the first pattern data */
  

  /* PW_l is the header size and points on the first pattern */
  /* PW_j is the number of pattern */
  /* PW_k is the number of instruments */
  return GOOD;
}



void Rip_XM ( void )
{
  /* PW_l is the header size and points on the first pattern */
  /* PW_j is the number of pattern */
  /* PW_k is the number of instruments */

  /* get whole pattern data siz */
  for ( PW_o=0 ; PW_o<PW_j ; PW_o++ )
  {
    /* getting siz of one pattern */
    PW_m = (in_data[PW_Start_Address+PW_l+8]*256) + in_data[PW_Start_Address+PW_l+7];
    /* adding it to current pointer + 9 being the pat header siz */
    PW_l += (PW_m + 9);
  }

  /* PW_l is now on the first inst .. PW_j is free :)*/
  /* get whole insts data siz */
  for ( PW_o=0 ; PW_o<PW_k ; PW_o++ )
  {
    long siz=0;
    /* getting siz of one inst header */
    PW_m = (in_data[PW_Start_Address+PW_l+1]*256) + in_data[PW_Start_Address+PW_l];
    /* getting nbr of samples in this inst */
    PW_j = (in_data[PW_Start_Address+PW_l+28]*256) + in_data[PW_Start_Address+PW_l+27];
    /* getting sizes of samples */
    PW_l += PW_m; /* so that it points on first sample header */
    for ( PW_n=0 ; PW_n<PW_j ; PW_n++ )
    {
      /* siz of this samples */
      siz += ( (in_data[PW_Start_Address+PW_l+3]*256*256*256) +
	       (in_data[PW_Start_Address+PW_l+2]*256*256) +
	       (in_data[PW_Start_Address+PW_l+1]*256) +
  	       in_data[PW_Start_Address+PW_l]);
      /* move pointer onto the next sample header if one exists*/
      PW_l += 40;
    }
    /* add sample datas of this instrument now */
    PW_l += siz;
  }

  OutputSize = PW_l;

  CONVERT = BAD;
  Save_Rip ( "Fastracker (XM) 2.0 module", XM );
  
  if ( Save_Status == GOOD )
    PW_i += 2;
}