diff options
author | Franklin Wei <git@fwei.tk> | 2019-07-09 17:34:09 -0400 |
---|---|---|
committer | Franklin Wei <git@fwei.tk> | 2019-07-09 17:34:09 -0400 |
commit | 152e415b0d0d11078578e3268776465ffc58871a (patch) | |
tree | 8c02b91f4c4bdc74878a90499efd0ed2774d281d /apps/plugins/sdl/progs/wolf3d/fmopl_gpl.c | |
parent | b1f16371b0c729ac12ff2cd654cd34a6121fa02a (diff) | |
download | rockbox-152e415b0d0d11078578e3268776465ffc58871a.tar.gz rockbox-152e415b0d0d11078578e3268776465ffc58871a.zip |
wolf3d: fix FM OPL alignment bug in a cleaner way
wl_def.h has a #pragma pack(1), which causes issues when we take the
address of an unaligned struct field. This fixes the issue by
disabling packing in fmopl_gpl.c.
Change-Id: I526880fa73226e8028855896f7efc3a66571b3ec
Diffstat (limited to 'apps/plugins/sdl/progs/wolf3d/fmopl_gpl.c')
-rw-r--r-- | apps/plugins/sdl/progs/wolf3d/fmopl_gpl.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/apps/plugins/sdl/progs/wolf3d/fmopl_gpl.c b/apps/plugins/sdl/progs/wolf3d/fmopl_gpl.c index 41178d6bd9..9f0ce3aecd 100644 --- a/apps/plugins/sdl/progs/wolf3d/fmopl_gpl.c +++ b/apps/plugins/sdl/progs/wolf3d/fmopl_gpl.c | |||
@@ -82,7 +82,9 @@ verify volume of the FM part on the Y8950 | |||
82 | 82 | ||
83 | #include "fmopl.h" | 83 | #include "fmopl.h" |
84 | 84 | ||
85 | 85 | // Don't pack structs in here. This causes dangerous things on ARM | |
86 | // regarding alignment. | ||
87 | #pragma pack() | ||
86 | 88 | ||
87 | /* output final shift */ | 89 | /* output final shift */ |
88 | #if (OPL_SAMPLE_BITS==16) | 90 | #if (OPL_SAMPLE_BITS==16) |
@@ -207,8 +209,6 @@ static FILE * cymfile = NULL; | |||
207 | #define OPL_TYPE_YM3812 (OPL_TYPE_WAVESEL) | 209 | #define OPL_TYPE_YM3812 (OPL_TYPE_WAVESEL) |
208 | #define OPL_TYPE_Y8950 (OPL_TYPE_ADPCM|OPL_TYPE_KEYBOARD|OPL_TYPE_IO) | 210 | #define OPL_TYPE_Y8950 (OPL_TYPE_ADPCM|OPL_TYPE_KEYBOARD|OPL_TYPE_IO) |
209 | 211 | ||
210 | |||
211 | |||
212 | struct OPL_SLOT | 212 | struct OPL_SLOT |
213 | { | 213 | { |
214 | UINT32 ar; /* attack rate: AR<<2 */ | 214 | UINT32 ar; /* attack rate: AR<<2 */ |
@@ -267,10 +267,6 @@ typedef struct OPL_CH OPL_CH; | |||
267 | /* OPL state */ | 267 | /* OPL state */ |
268 | struct FM_OPL | 268 | struct FM_OPL |
269 | { | 269 | { |
270 | // moved to beginning to fix alignment | ||
271 | signed int phase_modulation __attribute__((aligned)); /* phase modulation input (SLOT 2) */ | ||
272 | signed int output[1] __attribute__((aligned)); | ||
273 | |||
274 | /* FM channel slots */ | 270 | /* FM channel slots */ |
275 | OPL_CH P_CH[9]; /* OPL/OPL2 chips have 9 channels*/ | 271 | OPL_CH P_CH[9]; /* OPL/OPL2 chips have 9 channels*/ |
276 | 272 | ||
@@ -326,7 +322,6 @@ struct FM_OPL | |||
326 | void *IRQParam; /* IRQ parameter */ | 322 | void *IRQParam; /* IRQ parameter */ |
327 | OPL_UPDATEHANDLER UpdateHandler;/* stream update handler */ | 323 | OPL_UPDATEHANDLER UpdateHandler;/* stream update handler */ |
328 | void *UpdateParam; /* stream update parameter */ | 324 | void *UpdateParam; /* stream update parameter */ |
329 | |||
330 | UINT8 type; /* chip type */ | 325 | UINT8 type; /* chip type */ |
331 | UINT8 address; /* address register */ | 326 | UINT8 address; /* address register */ |
332 | UINT8 status; /* status flag */ | 327 | UINT8 status; /* status flag */ |
@@ -339,10 +334,13 @@ struct FM_OPL | |||
339 | double TimerBase; /* Timer base time (==sampling time)*/ | 334 | double TimerBase; /* Timer base time (==sampling time)*/ |
340 | device_t *device; | 335 | device_t *device; |
341 | 336 | ||
337 | signed int phase_modulation; /* phase modulation input (SLOT 2) */ | ||
338 | signed int output[1]; | ||
339 | |||
342 | #if BUILD_Y8950 | 340 | #if BUILD_Y8950 |
343 | INT32 output_deltat[4]; /* for Y8950 DELTA-T, chip is mono, that 4 here is just for safety */ | 341 | INT32 output_deltat[4]; /* for Y8950 DELTA-T, chip is mono, that 4 here is just for safety */ |
344 | #endif | 342 | #endif |
345 | } __attribute__((aligned)); | 343 | }; |
346 | 344 | ||
347 | typedef struct FM_OPL FM_OPL; | 345 | typedef struct FM_OPL FM_OPL; |
348 | 346 | ||