summaryrefslogtreecommitdiff
path: root/audio/xmp/patches/patch-an
blob: e5e1d05f25dfedc3ccbf2d6d0136a19ef2995bca (plain)
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
$NetBSD: patch-an,v 1.1 2006/06/30 12:54:38 tron Exp $

--- src/loaders/med_load.c.orig	2001-01-13 19:58:02.000000000 +0000
+++ src/loaders/med_load.c	2006-06-30 13:48:59.000000000 +0100
@@ -31,6 +31,25 @@
 
 static int bpmon, bpmlen;
 
+static void big_endian_uint16_t(void *p)
+{
+	uint16	*x16p, x16;
+
+	x16p = p;
+	x16 = *x16p;
+	B_ENDIAN16(x16);
+	*x16p = x16; 
+}
+
+static void big_endian_uint32_t(void *p)
+{
+	uint32	*x32p, x32;
+
+	x32p = p;
+	x32 = *x32p;
+	B_ENDIAN32(x32);
+	*x32p = x32; 
+}
 
 static void xlat_fx (uint8 *fxt, uint8 *fxp)
 {
@@ -136,11 +155,11 @@
 
     header = (struct MMD0 *)mmd;
 
-    B_ENDIAN32 ((uint32)header->modlen);
-    B_ENDIAN32 ((uint32)header->song);
-    B_ENDIAN32 ((uint32)header->blockarr);
-    B_ENDIAN32 ((uint32)header->smplarr);
-    B_ENDIAN32 ((uint32)header->expdata);
+    big_endian_uint32_t(&header->modlen);
+    big_endian_uint32_t(&header->song);
+    big_endian_uint32_t(&header->blockarr);
+    big_endian_uint32_t(&header->smplarr);
+    big_endian_uint32_t(&header->expdata);
 
     song = (struct MMD0song *)(mmd + (uint32)header->song);
     song2 = (struct MMD2song *)(mmd + (uint32)header->song);
@@ -148,21 +167,21 @@
 	(uint32)header->expdata) : NULL;
 
     if (expdata) {
-	B_ENDIAN32 ((uint32)expdata->nextmod);
-	B_ENDIAN32 ((uint32)expdata->exp_smp);
-	B_ENDIAN16 ((uint16)expdata->s_ext_entries);
-	B_ENDIAN16 ((uint16)expdata->s_ext_entrsz);
-	B_ENDIAN32 ((uint32)expdata->annotxt);
-	B_ENDIAN32 ((uint32)expdata->annolen);
-	B_ENDIAN32 ((uint32)expdata->iinfo);
-	B_ENDIAN16 ((uint16)expdata->i_ext_entries);
-	B_ENDIAN16 ((uint16)expdata->i_ext_entrsz);
-	B_ENDIAN32 ((uint32)expdata->jumpmask);
-	B_ENDIAN32 ((uint32)expdata->rgbtable);
-	B_ENDIAN32 ((uint32)expdata->n_info);
-	B_ENDIAN32 ((uint32)expdata->songname);
-	B_ENDIAN32 ((uint32)expdata->songnamelen);
-	B_ENDIAN32 ((uint32)expdata->dumps);
+	big_endian_uint32_t(&expdata->nextmod);
+	big_endian_uint32_t(&expdata->exp_smp);
+	big_endian_uint16_t(&expdata->s_ext_entries);
+	big_endian_uint16_t(&expdata->s_ext_entrsz);
+	big_endian_uint32_t(&expdata->annotxt);
+	big_endian_uint32_t(&expdata->annolen);
+	big_endian_uint32_t(&expdata->iinfo);
+	big_endian_uint16_t(&expdata->i_ext_entries);
+	big_endian_uint16_t(&expdata->i_ext_entrsz);
+	big_endian_uint32_t(&expdata->jumpmask);
+	big_endian_uint32_t(&expdata->rgbtable);
+	big_endian_uint32_t(&expdata->n_info);
+	big_endian_uint32_t(&expdata->songname);
+	big_endian_uint32_t(&expdata->songnamelen);
+	big_endian_uint32_t(&expdata->dumps);
     }
 
     for (i = 0; i < 63; i++) {
@@ -198,7 +217,7 @@
 
     for (i = 0; i < xxh->ins; i++) {
 	bytecopy(&instr, mmd + (uint32)header->smplarr + i * 4, 4);
-	B_ENDIAN32 ((uint32)instr);
+	big_endian_uint32_t(&instr);
 	if (!instr)
 	    continue;
 	instr = (struct InstrHdr *)(mmd + (uint32)instr);
@@ -225,16 +244,16 @@
     if (ver < 2) {
 	memcpy (xxo, song->playseq, xxh->len);
     } else {
-	B_ENDIAN32 ((uint32)song2->playseqtable);
+	big_endian_uint32_t(&song2->playseqtable);
 	playseq = (struct PlaySeq **)(mmd + (uint32)song2->playseqtable);
-	B_ENDIAN32 ((uint32)playseq[0]);
+	big_endian_uint32_t(&playseq[0]);
 	playseq[0] = (struct PlaySeq *)(mmd + (uint32)playseq[0]);
-	B_ENDIAN16 ((uint16)playseq[0]->length);
+	big_endian_uint16_t(&playseq[0]->length);
 	xxh->len = playseq[0]->length;
 	if (xxh->len > 0xff)
 	    xxh->len = 0xff;
 	for (i = 0; i < xxh->len; i++) {
-	    B_ENDIAN16 ((uint16)playseq[0]->seq[i]);
+	    big_endian_uint16_t(&playseq[0]->seq[i]);
 	    xxo[i] = playseq[0]->seq[i];
 	}
     }
@@ -243,7 +262,7 @@
 
     for (i = 0; i < xxh->pat; i++) {
 	bytecopy(&block0, mmd + (uint32)header->blockarr + i * 4, 4);
-	B_ENDIAN32 ((uint32)block0);
+	big_endian_uint32_t(&block0);
 	block0 = (struct MMD0Block *)(mmd + (uint32)block0);
 	block1 = (struct MMD1Block *)block0;
 
@@ -283,7 +302,7 @@
 
     for (i = 0; i < xxh->pat; i++) {
 	bytecopy(&block0, mmd + (uint32)header->blockarr + i * 4, 4);
-	B_ENDIAN32 ((uint32)block0);
+	big_endian_uint32_t(&block0);
 	block0 = (struct MMD0Block *)(mmd + (uint32)block0);
 	block1 = (struct MMD1Block *)block0;
 
@@ -345,7 +364,7 @@
 
     for (smp_idx = i = 0; i < xxh->ins; i++) {
 	bytecopy(&instr, mmd + (uint32)header->smplarr + i * 4, 4);
-	B_ENDIAN32 ((uint32)instr);
+	big_endian_uint32_t(&instr);
 	if (!instr)
 	    continue;
 	instr = (struct InstrHdr *)(mmd + (uint32)instr);
@@ -381,7 +400,7 @@
 	    xxih[i].vts = synth->volspeed;
 	    xxih[i].wts = synth->wfspeed;
 
-	    B_ENDIAN32 ((uint32)synth->wf[0]);
+	    big_endian_uint32_t(&synth->wf[0]);
 	    instr = (struct InstrHdr *)((char *)synth + (uint32)synth->wf[0]);
 	    B_ENDIAN32 (instr->length);
 	    B_ENDIAN16 (instr->type);
@@ -438,7 +457,7 @@
 	    xxih[i].wts = synth->wfspeed;
 
 	    for (j = 0; j < synth->wforms; j++) {
-	        B_ENDIAN32 ((uint32)synth->wf[j]);
+	        big_endian_uint32_t(&synth->wf[j]);
 
 		xxi[i][j].pan = 0x80;
 		xxi[i][j].vol = song->sample[i].svol;