1 /* _______ ____ __ ___ ___ 2 * \ _ \ \ / \ / \ \ / / ' ' ' 3 * | | \ \ | | || | \/ | . . 4 * | | | | | | || ||\ /| | 5 * | | | | | | || || \/ | | ' ' ' 6 * | | | | | | || || | | . . 7 * | |_/ / \ \__// || | | 8 * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque 9 * / \ 10 * / . \ 11 * internal/it.h - Internal stuff for IT playback / / \ \ 12 * and MOD/XM/S3M conversion. | < / \_ 13 * | \/ /\ / 14 * This header file provides access to the \_ / > / 15 * internal structure of DUMB, and is liable | \ / / 16 * to change, mutate or cease to exist at any | ' / 17 * moment. Include it at your own peril. \__/ 18 * 19 * ... 20 * 21 * Seriously. You don't need access to anything in this file. All right, you 22 * probably do actually. But if you use it, you will be relying on a specific 23 * version of DUMB, so please check DUMB_VERSION defined in dumb.h. Please 24 * contact the authors so that we can provide a public API for what you need. 25 */ 26 27 #ifndef INTERNAL_IT_H 28 #define INTERNAL_IT_H 29 30 31 #define BIT_ARRAY_BULLSHIT 32 33 #include <stddef.h> 34 35 #include "barray.h" 36 #include "tarray.h" 37 38 39 /** TO DO: THINK ABOUT THE FOLLOWING: 40 41 sigdata->flags & IT_COMPATIBLE_GXX 42 43 Bit 5: On = Link Effect G's memory with Effect E/F. Also 44 Gxx with an instrument present will cause the 45 envelopes to be retriggered. If you change a 46 sample on a row with Gxx, it'll adjust the 47 frequency of the current note according to: 48 49 NewFrequency = OldFrequency * NewC5 / OldC5; 50 */ 51 52 53 54 /* These #defines are TEMPORARY. They are used to write alternative code to 55 * handle ambiguities in the format specification. The correct code in each 56 * case will be determined most likely by experimentation. 57 */ 58 //#define STEREO_SAMPLES_COUNT_AS_TWO 59 #define INVALID_ORDERS_END_SONG 60 #define SUSTAIN_LOOP_OVERRIDES_NORMAL_LOOP 61 #define VOLUME_OUT_OF_RANGE_SETS_MAXIMUM 62 63 64 65 #define SIGTYPE_IT DUMB_ID('I', 'T', ' ', ' ') 66 67 #define IT_SIGNATURE DUMB_ID('I', 'M', 'P', 'M') 68 #define IT_INSTRUMENT_SIGNATURE DUMB_ID('I', 'M', 'P', 'I') 69 #define IT_SAMPLE_SIGNATURE DUMB_ID('I', 'M', 'P', 'S') 70 71 // olivier sux 72 #define IT_MPTX_SIGNATURE DUMB_ID('X', 'T', 'P', 'M') 73 #define IT_INSM_SIGNATURE DUMB_ID('M', 'S', 'N', 'I') 74 75 76 /* This is divided by the tempo times 256 to get the interval between ticks. 77 */ 78 #define TICK_TIME_DIVIDEND (65536 * 5 * 128) 79 80 81 82 /* I'm not going to try to explain this, because I didn't derive it very 83 * formally ;) 84 */ 85 /* #define AMIGA_DIVISOR ((float)(4.0 * 14317056.0)) */ 86 /* I believe the following one to be more accurate. */ 87 //#define AMIGA_DIVISOR ((float)(8.0 * 7159090.5)) 88 #define AMIGA_CLOCK 3546895 89 #define AMIGA_DIVISOR ((float)(16.0 * AMIGA_CLOCK)) 90 91 92 93 typedef struct IT_MIDI IT_MIDI; 94 typedef struct IT_FILTER_STATE IT_FILTER_STATE; 95 typedef struct IT_ENVELOPE IT_ENVELOPE; 96 typedef struct IT_INSTRUMENT IT_INSTRUMENT; 97 typedef struct IT_SAMPLE IT_SAMPLE; 98 typedef struct IT_ENTRY IT_ENTRY; 99 typedef struct IT_PATTERN IT_PATTERN; 100 typedef struct IT_PLAYING_ENVELOPE IT_PLAYING_ENVELOPE; 101 typedef struct IT_PLAYING IT_PLAYING; 102 typedef struct IT_CHANNEL IT_CHANNEL; 103 typedef struct IT_CHECKPOINT IT_CHECKPOINT; 104 typedef struct IT_CALLBACKS IT_CALLBACKS; 105 106 107 108 struct IT_MIDI 109 { 110 unsigned char SFmacro[16][16]; // read these from 0x120 111 unsigned char SFmacrolen[16]; 112 unsigned short SFmacroz[16]; /* Bitfield; bit 0 set = z in first position */ 113 unsigned char Zmacro[128][16]; // read these from 0x320 114 unsigned char Zmacrolen[128]; 115 }; 116 117 118 119 struct IT_FILTER_STATE 120 { 121 sample_t currsample, prevsample; 122 }; 123 124 125 126 #define IT_ENVELOPE_ON 1 127 #define IT_ENVELOPE_LOOP_ON 2 128 #define IT_ENVELOPE_SUSTAIN_LOOP 4 129 #define IT_ENVELOPE_CARRY 8 130 #define IT_ENVELOPE_PITCH_IS_FILTER 128 131 132 struct IT_ENVELOPE 133 { 134 unsigned char flags; 135 unsigned char n_nodes; 136 unsigned char loop_start; 137 unsigned char loop_end; 138 unsigned char sus_loop_start; 139 unsigned char sus_loop_end; 140 signed char node_y[25]; 141 unsigned short node_t[25]; 142 }; 143 144 145 146 #define NNA_NOTE_CUT 0 147 #define NNA_NOTE_CONTINUE 1 148 #define NNA_NOTE_OFF 2 149 #define NNA_NOTE_FADE 3 150 151 #define DCT_OFF 0 152 #define DCT_NOTE 1 153 #define DCT_SAMPLE 2 154 #define DCT_INSTRUMENT 3 155 156 #define DCA_NOTE_CUT 0 157 #define DCA_NOTE_OFF 1 158 #define DCA_NOTE_FADE 2 159 160 struct IT_INSTRUMENT 161 { 162 unsigned char name[27]; 163 unsigned char filename[14]; 164 165 int fadeout; 166 167 IT_ENVELOPE volume_envelope; 168 IT_ENVELOPE pan_envelope; 169 IT_ENVELOPE pitch_envelope; 170 171 unsigned char new_note_action; 172 unsigned char dup_check_type; 173 unsigned char dup_check_action; 174 signed char pp_separation; 175 unsigned char pp_centre; 176 unsigned char global_volume; 177 unsigned char default_pan; 178 unsigned char random_volume; 179 unsigned char random_pan; 180 181 unsigned char filter_cutoff; 182 unsigned char filter_resonance; 183 184 unsigned char map_note[120]; 185 unsigned short map_sample[120]; 186 187 //int output; 188 }; 189 190 191 192 #define IT_SAMPLE_EXISTS 1 193 #define IT_SAMPLE_16BIT 2 194 #define IT_SAMPLE_STEREO 4 195 #define IT_SAMPLE_LOOP 16 196 #define IT_SAMPLE_SUS_LOOP 32 197 #define IT_SAMPLE_PINGPONG_LOOP 64 198 #define IT_SAMPLE_PINGPONG_SUS_LOOP 128 199 200 #define IT_VIBRATO_SINE 0 201 #define IT_VIBRATO_SAWTOOTH 1 202 #define IT_VIBRATO_SQUARE 2 203 #define IT_VIBRATO_RANDOM 3 204 #define IT_VIBRATO_XM_SQUARE 4 205 #define IT_VIBRATO_RAMP_DOWN 5 206 #define IT_VIBRATO_RAMP_UP 6 207 208 struct IT_SAMPLE 209 { 210 unsigned char name[35]; 211 unsigned char filename[15]; 212 unsigned char flags; 213 unsigned char global_volume; 214 unsigned char default_volume; 215 unsigned char default_pan; 216 /* default_pan: 217 * 0-255 for XM 218 * ignored for MOD 219 * otherwise, 0-64, and add 128 to enable 220 */ 221 222 long length; 223 long loop_start; 224 long loop_end; 225 long C5_speed; 226 long sus_loop_start; 227 long sus_loop_end; 228 229 unsigned char vibrato_speed; 230 unsigned char vibrato_depth; 231 unsigned char vibrato_rate; 232 unsigned char vibrato_waveform; 233 234 signed short finetune; 235 236 void *data; 237 238 int max_resampling_quality; 239 }; 240 241 242 243 #define IT_ENTRY_NOTE 1 244 #define IT_ENTRY_INSTRUMENT 2 245 #define IT_ENTRY_VOLPAN 4 246 #define IT_ENTRY_EFFECT 8 247 248 #define IT_SET_END_ROW(entry) ((entry)->channel = 255) 249 #define IT_IS_END_ROW(entry) ((entry)->channel >= DUMB_IT_N_CHANNELS) 250 251 #define IT_NOTE_OFF 255 252 #define IT_NOTE_CUT 254 253 254 #define IT_ENVELOPE_SHIFT 8 255 256 #define IT_SURROUND 100 257 #define IT_IS_SURROUND(pan) ((pan) > 64) 258 #define IT_IS_SURROUND_SHIFTED(pan) ((pan) > 64 << IT_ENVELOPE_SHIFT) 259 260 #define IT_SET_SPEED 1 261 #define IT_JUMP_TO_ORDER 2 262 #define IT_BREAK_TO_ROW 3 263 #define IT_VOLUME_SLIDE 4 264 #define IT_PORTAMENTO_DOWN 5 265 #define IT_PORTAMENTO_UP 6 266 #define IT_TONE_PORTAMENTO 7 267 #define IT_VIBRATO 8 268 #define IT_TREMOR 9 269 #define IT_ARPEGGIO 10 270 #define IT_VOLSLIDE_VIBRATO 11 271 #define IT_VOLSLIDE_TONEPORTA 12 272 #define IT_SET_CHANNEL_VOLUME 13 273 #define IT_CHANNEL_VOLUME_SLIDE 14 274 #define IT_SET_SAMPLE_OFFSET 15 275 #define IT_PANNING_SLIDE 16 276 #define IT_RETRIGGER_NOTE 17 277 #define IT_TREMOLO 18 278 #define IT_S 19 279 #define IT_SET_SONG_TEMPO 20 280 #define IT_FINE_VIBRATO 21 281 #define IT_SET_GLOBAL_VOLUME 22 282 #define IT_GLOBAL_VOLUME_SLIDE 23 283 #define IT_SET_PANNING 24 284 #define IT_PANBRELLO 25 285 #define IT_MIDI_MACRO 26 //see MIDI.TXT 286 287 /* Some effects needed for XM compatibility */ 288 #define IT_XM_PORTAMENTO_DOWN 27 289 #define IT_XM_PORTAMENTO_UP 28 290 #define IT_XM_FINE_VOLSLIDE_DOWN 29 291 #define IT_XM_FINE_VOLSLIDE_UP 30 292 #define IT_XM_RETRIGGER_NOTE 31 293 #define IT_XM_KEY_OFF 32 294 #define IT_XM_SET_ENVELOPE_POSITION 33 295 296 /* More effects needed for PTM compatibility */ 297 #define IT_PTM_NOTE_SLIDE_DOWN 34 298 #define IT_PTM_NOTE_SLIDE_UP 35 299 #define IT_PTM_NOTE_SLIDE_DOWN_RETRIG 36 300 #define IT_PTM_NOTE_SLIDE_UP_RETRIG 37 301 302 /* More effects needed for OKT compatibility */ 303 #define IT_OKT_NOTE_SLIDE_DOWN 38 304 #define IT_OKT_NOTE_SLIDE_DOWN_ROW 39 305 #define IT_OKT_NOTE_SLIDE_UP 40 306 #define IT_OKT_NOTE_SLIDE_UP_ROW 41 307 #define IT_OKT_ARPEGGIO_3 42 308 #define IT_OKT_ARPEGGIO_4 43 309 #define IT_OKT_ARPEGGIO_5 44 310 #define IT_OKT_VOLUME_SLIDE_DOWN 45 311 #define IT_OKT_VOLUME_SLIDE_UP 46 312 313 #define IT_N_EFFECTS 47 314 315 /* These represent the top nibble of the command value. */ 316 #define IT_S_SET_FILTER 0 /* Greyed out in IT... */ 317 #define IT_S_SET_GLISSANDO_CONTROL 1 /* Greyed out in IT... */ 318 #define IT_S_FINETUNE 2 /* Greyed out in IT... */ 319 #define IT_S_SET_VIBRATO_WAVEFORM 3 320 #define IT_S_SET_TREMOLO_WAVEFORM 4 321 #define IT_S_SET_PANBRELLO_WAVEFORM 5 322 #define IT_S_FINE_PATTERN_DELAY 6 323 #define IT_S7 7 324 #define IT_S_SET_PAN 8 325 #define IT_S_SET_SURROUND_SOUND 9 326 #define IT_S_SET_HIGH_OFFSET 10 327 #define IT_S_PATTERN_LOOP 11 328 #define IT_S_DELAYED_NOTE_CUT 12 329 #define IT_S_NOTE_DELAY 13 330 #define IT_S_PATTERN_DELAY 14 331 #define IT_S_SET_MIDI_MACRO 15 332 333 /* 334 S0x Set filter 335 S1x Set glissando control 336 S2x Set finetune 337 338 339 S3x Set vibrato waveform to type x 340 S4x Set tremelo waveform to type x 341 S5x Set panbrello waveform to type x 342 Waveforms for commands S3x, S4x and S5x: 343 0: Sine wave 344 1: Ramp down 345 2: Square wave 346 3: Random wave 347 S6x Pattern delay for x ticks 348 S70 Past note cut 349 S71 Past note off 350 S72 Past note fade 351 S73 Set NNA to note cut 352 S74 Set NNA to continue 353 S75 Set NNA to note off 354 S76 Set NNA to note fade 355 S77 Turn off volume envelope 356 S78 Turn on volume envelope 357 S79 Turn off panning envelope 358 S7A Turn on panning envelope 359 S7B Turn off pitch envelope 360 S7C Turn on pitch envelope 361 S8x Set panning position 362 S91 Set surround sound 363 SAy Set high value of sample offset yxx00h 364 SB0 Set loopback point 365 SBx Loop x times to loopback point 366 SCx Note cut after x ticks 367 SDx Note delay for x ticks 368 SEx Pattern delay for x rows 369 SFx Set parameterised MIDI Macro 370 */ 371 372 struct IT_ENTRY 373 { 374 unsigned char channel; /* End of row if channel >= DUMB_IT_N_CHANNELS */ 375 unsigned char mask; 376 unsigned char note; 377 unsigned char instrument; 378 unsigned char volpan; 379 unsigned char effect; 380 unsigned char effectvalue; 381 }; 382 383 384 385 struct IT_PATTERN 386 { 387 int n_rows; 388 int n_entries; 389 IT_ENTRY *entry; 390 }; 391 392 393 394 #define IT_STEREO 1 395 #define IT_USE_INSTRUMENTS 4 396 #define IT_LINEAR_SLIDES 8 /* If not set, use Amiga slides */ 397 #define IT_OLD_EFFECTS 16 398 #define IT_COMPATIBLE_GXX 32 399 400 /* Make sure IT_WAS_AN_XM and IT_WAS_A_MOD aren't set accidentally */ 401 #define IT_REAL_FLAGS 63 402 403 #define IT_WAS_AN_XM 64 /* Set for both XMs and MODs */ 404 #define IT_WAS_A_MOD 128 405 406 #define IT_WAS_AN_S3M 256 407 408 #define IT_WAS_A_PTM 512 409 410 #define IT_WAS_A_669 1024 411 412 #define IT_WAS_AN_OKT 2048 413 414 #define IT_WAS_AN_STM 4096 415 416 #define IT_WAS_PROCESSED 8192 /* Will be set the first time a sigdata passes through a sigrenderer */ 417 418 #define IT_ORDER_END 255 419 #define IT_ORDER_SKIP 254 420 421 struct DUMB_IT_SIGDATA 422 { 423 unsigned char name[65]; 424 425 unsigned char *song_message; 426 427 int n_orders; 428 int n_instruments; 429 int n_samples; 430 int n_patterns; 431 int n_pchannels; 432 433 int flags; 434 435 int global_volume; 436 int mixing_volume; 437 int speed; 438 int tempo; 439 int pan_separation; 440 441 unsigned char channel_pan[DUMB_IT_N_CHANNELS]; 442 unsigned char channel_volume[DUMB_IT_N_CHANNELS]; 443 444 unsigned char *order; 445 unsigned char restart_position; /* for XM compatiblity */ 446 447 IT_INSTRUMENT *instrument; 448 IT_SAMPLE *sample; 449 IT_PATTERN *pattern; 450 451 IT_MIDI *midi; 452 453 IT_CHECKPOINT *checkpoint; 454 }; 455 456 457 458 struct IT_PLAYING_ENVELOPE 459 { 460 int next_node; 461 int tick; 462 int value; 463 }; 464 465 466 467 #define IT_PLAYING_BACKGROUND 1 468 #define IT_PLAYING_SUSTAINOFF 2 469 #define IT_PLAYING_FADING 4 470 #define IT_PLAYING_DEAD 8 471 #define IT_PLAYING_REVERSE 16 472 473 struct IT_PLAYING 474 { 475 int flags; 476 477 int resampling_quality; 478 479 IT_CHANNEL *channel; 480 IT_SAMPLE *sample; 481 IT_INSTRUMENT *instrument; 482 IT_INSTRUMENT *env_instrument; 483 484 unsigned short sampnum; 485 unsigned char instnum; 486 487 unsigned char declick_stage; 488 489 float float_volume[2]; 490 float ramp_volume[2]; 491 float ramp_delta[2]; 492 493 unsigned char channel_volume; 494 495 unsigned char volume; 496 unsigned short pan; 497 498 signed char volume_offset, panning_offset; 499 500 unsigned char note; 501 502 unsigned char enabled_envelopes; 503 504 unsigned char filter_cutoff; 505 unsigned char filter_resonance; 506 507 unsigned short true_filter_cutoff; /* These incorporate the filter envelope, and will not */ 508 unsigned char true_filter_resonance; /* be changed if they would be set to 127<<8 and 0. */ 509 510 unsigned char vibrato_speed; 511 unsigned char vibrato_depth; 512 unsigned char vibrato_n; /* May be specified twice: volpan & effect. */ 513 unsigned char vibrato_time; 514 unsigned char vibrato_waveform; 515 516 unsigned char tremolo_speed; 517 unsigned char tremolo_depth; 518 unsigned char tremolo_time; 519 unsigned char tremolo_waveform; 520 521 unsigned char panbrello_speed; 522 unsigned char panbrello_depth; 523 unsigned char panbrello_time; 524 unsigned char panbrello_waveform; 525 signed char panbrello_random; 526 527 unsigned char sample_vibrato_time; 528 unsigned char sample_vibrato_waveform; 529 int sample_vibrato_depth; /* Starts at rate?0:depth, increases by rate */ 530 531 int slide; 532 float delta; 533 int finetune; 534 535 IT_PLAYING_ENVELOPE volume_envelope; 536 IT_PLAYING_ENVELOPE pan_envelope; 537 IT_PLAYING_ENVELOPE pitch_envelope; 538 539 int fadeoutcount; 540 541 IT_FILTER_STATE filter_state[2]; /* Left and right */ 542 543 DUMB_RESAMPLER resampler; 544 545 /* time_lost is used to emulate Impulse Tracker's sample looping 546 * characteristics. When time_lost is added to pos, the result represents 547 * the position in the theoretical version of the sample where all loops 548 * have been expanded. If this is stored, the resampling helpers will 549 * safely convert it for use with new loop boundaries. The situation is 550 * slightly more complicated if dir == -1 when the change takes place; we 551 * must reflect pos off the loop end point and set dir to 1 before 552 * proceeding. 553 */ 554 long time_lost; 555 556 //int output; 557 }; 558 559 560 561 #define IT_CHANNEL_MUTED 1 562 563 #define IT_ENV_VOLUME 1 564 #define IT_ENV_PANNING 2 565 #define IT_ENV_PITCH 4 566 567 struct IT_CHANNEL 568 { 569 int flags; 570 571 unsigned char volume; 572 signed char volslide; 573 signed char xm_volslide; 574 signed char panslide; 575 576 /* xm_volslide is used for volume slides done in the volume column in an 577 * XM file, since it seems the volume column slide is applied first, 578 * followed by clamping, followed by the effects column slide. IT does 579 * not exhibit this behaviour, so xm_volslide is maintained at zero. 580 */ 581 582 unsigned char pan; 583 unsigned short truepan; 584 585 unsigned char channelvolume; 586 signed char channelvolslide; 587 588 unsigned char instrument; 589 unsigned char note; 590 591 unsigned char SFmacro; 592 593 unsigned char filter_cutoff; 594 unsigned char filter_resonance; 595 596 unsigned char key_off_count; 597 unsigned char note_cut_count; 598 unsigned char note_delay_count; 599 IT_ENTRY *note_delay_entry; 600 601 unsigned char new_note_action; 602 603 unsigned char const* arpeggio_table; 604 signed char arpeggio_offsets[3]; 605 606 int arpeggio_shift; 607 unsigned char retrig; 608 unsigned char xm_retrig; 609 int retrig_tick; 610 611 unsigned char tremor; 612 unsigned char tremor_time; /* Bit 6 set if note on; bit 7 set if tremor active. */ 613 614 unsigned char vibrato_waveform; 615 unsigned char tremolo_waveform; 616 unsigned char panbrello_waveform; 617 618 int portamento; 619 int toneporta; 620 int toneslide; 621 unsigned char toneslide_tick, last_toneslide_tick, ptm_toneslide, ptm_last_toneslide, okt_toneslide; 622 unsigned char destnote; 623 unsigned char toneslide_retrig; 624 625 unsigned char glissando; 626 627 /** WARNING - for neatness, should one or both of these be in the IT_PLAYING struct? */ 628 unsigned short sample; 629 unsigned char truenote; 630 631 unsigned char midi_state; 632 633 signed char lastvolslide; 634 unsigned char lastDKL; 635 unsigned char lastEF; /* Doubles as last portamento up for XM files */ 636 unsigned char lastG; 637 unsigned char lastHspeed; 638 unsigned char lastHdepth; 639 unsigned char lastRspeed; 640 unsigned char lastRdepth; 641 unsigned char lastYspeed; 642 unsigned char lastYdepth; 643 unsigned char lastI; 644 unsigned char lastJ; /* Doubles as last portamento down for XM files */ 645 unsigned char lastN; 646 unsigned char lastO; 647 unsigned char high_offset; 648 unsigned char lastP; 649 unsigned char lastQ; 650 unsigned char lastS; 651 unsigned char pat_loop_row; 652 unsigned char pat_loop_count; 653 unsigned char pat_loop_end_row; /* Used to catch infinite pattern loops */ 654 unsigned char lastW; 655 656 unsigned char xm_lastE1; 657 unsigned char xm_lastE2; 658 unsigned char xm_lastEA; 659 unsigned char xm_lastEB; 660 unsigned char xm_lastX1; 661 unsigned char xm_lastX2; 662 663 unsigned char inv_loop_delay; 664 unsigned char inv_loop_speed; 665 int inv_loop_offset; 666 667 IT_PLAYING *playing; 668 669 #ifdef BIT_ARRAY_BULLSHIT 670 void * played_patjump; 671 int played_patjump_order; 672 #endif 673 674 //int output; 675 }; 676 677 678 679 struct DUMB_IT_SIGRENDERER 680 { 681 DUMB_IT_SIGDATA *sigdata; 682 683 int n_channels; 684 685 int resampling_quality; 686 687 unsigned char globalvolume; 688 signed char globalvolslide; 689 690 int tempo; 691 signed char temposlide; 692 693 IT_CHANNEL channel[DUMB_IT_N_CHANNELS]; 694 695 IT_PLAYING *playing[DUMB_IT_N_NNA_CHANNELS]; 696 697 int tick; 698 int speed; 699 int rowcount; 700 701 int order; /* Set to -1 if the song is terminated by a callback. */ 702 int row; 703 int processorder; 704 int processrow; 705 int breakrow; 706 707 int restart_position; 708 709 int n_rows; 710 711 IT_ENTRY *entry_start; 712 IT_ENTRY *entry; 713 IT_ENTRY *entry_end; 714 715 long time_left; /* Time before the next tick is processed */ 716 int sub_time_left; 717 718 DUMB_CLICK_REMOVER **click_remover; 719 720 IT_CALLBACKS *callbacks; 721 722 #ifdef BIT_ARRAY_BULLSHIT 723 /* bit array, which rows are played, only checked by pattern break or loop commands */ 724 void * played; 725 726 /* 727 Loop indicator for internal processes, may also be useful for external processes 728 0 - Not looped 729 1 - Looped 730 -1 - Continued past loop 731 */ 732 int looped; 733 734 /* 735 Kept until looped 736 */ 737 LONG_LONG time_played; 738 739 void * row_timekeeper; 740 #endif 741 742 long gvz_time; 743 int gvz_sub_time; 744 745 int ramp_style; 746 747 //int max_output; 748 }; 749 750 751 752 struct IT_CHECKPOINT 753 { 754 IT_CHECKPOINT *next; 755 long time; 756 DUMB_IT_SIGRENDERER *sigrenderer; 757 }; 758 759 760 761 struct IT_CALLBACKS 762 { 763 int (*loop)(void *data); 764 void *loop_data; 765 /* Return 1 to prevent looping; the music will terminate abruptly. If you 766 * want to make the music stop but allow samples to fade (beware, as they 767 * might not fade at all!), use dumb_it_sr_set_speed() and set the speed 768 * to 0. Note that xm_speed_zero() will not be called if you set the 769 * speed manually, and also that this will work for IT and S3M files even 770 * though the music can't stop in this way by itself. 771 */ 772 773 int (*xm_speed_zero)(void *data); 774 void *xm_speed_zero_data; 775 /* Return 1 to terminate the mod, without letting samples fade. */ 776 777 int (*midi)(void *data, int channel, unsigned char byte); 778 void *midi_data; 779 /* Return 1 to prevent DUMB from subsequently interpreting the MIDI bytes 780 * itself. In other words, return 1 if the Zxx macros in an IT file are 781 * controlling filters and shouldn't be. 782 */ 783 784 int (*global_volume_zero)(void *data); 785 void *global_volume_zero_data; 786 /* Return 1 to terminate the module when global volume is set to zero. */ 787 }; 788 789 790 791 void _dumb_it_end_sigrenderer(sigrenderer_t *sigrenderer); 792 void _dumb_it_unload_sigdata(sigdata_t *vsigdata); 793 794 extern DUH_SIGTYPE_DESC _dumb_sigtype_it; 795 796 797 798 #define XM_APPREGIO 0 799 #define XM_PORTAMENTO_UP 1 800 #define XM_PORTAMENTO_DOWN 2 801 #define XM_TONE_PORTAMENTO 3 802 #define XM_VIBRATO 4 803 #define XM_VOLSLIDE_TONEPORTA 5 804 #define XM_VOLSLIDE_VIBRATO 6 805 #define XM_TREMOLO 7 806 #define XM_SET_PANNING 8 807 #define XM_SAMPLE_OFFSET 9 808 #define XM_VOLUME_SLIDE 10 /* A */ 809 #define XM_POSITION_JUMP 11 /* B */ 810 #define XM_SET_CHANNEL_VOLUME 12 /* C */ 811 #define XM_PATTERN_BREAK 13 /* D */ 812 #define XM_E 14 /* E */ 813 #define XM_SET_TEMPO_BPM 15 /* F */ 814 #define XM_SET_GLOBAL_VOLUME 16 /* G */ 815 #define XM_GLOBAL_VOLUME_SLIDE 17 /* H */ 816 #define XM_KEY_OFF 20 /* K (undocumented) */ 817 #define XM_SET_ENVELOPE_POSITION 21 /* L */ 818 #define XM_PANNING_SLIDE 25 /* P */ 819 #define XM_MULTI_RETRIG 27 /* R */ 820 #define XM_TREMOR 29 /* T */ 821 #define XM_X 33 /* X */ 822 #define XM_N_EFFECTS (10+26) 823 824 #define XM_E_SET_FILTER 0x0 825 #define XM_E_FINE_PORTA_UP 0x1 826 #define XM_E_FINE_PORTA_DOWN 0x2 827 #define XM_E_SET_GLISSANDO_CONTROL 0x3 828 #define XM_E_SET_VIBRATO_CONTROL 0x4 829 #define XM_E_SET_FINETUNE 0x5 830 #define XM_E_SET_LOOP 0x6 831 #define XM_E_SET_TREMOLO_CONTROL 0x7 832 #define XM_E_SET_PANNING 0x8 833 #define XM_E_RETRIG_NOTE 0x9 834 #define XM_E_FINE_VOLSLIDE_UP 0xA 835 #define XM_E_FINE_VOLSLIDE_DOWN 0xB 836 #define XM_E_NOTE_CUT 0xC 837 #define XM_E_NOTE_DELAY 0xD 838 #define XM_E_PATTERN_DELAY 0xE 839 #define XM_E_SET_MIDI_MACRO 0xF 840 841 #define XM_X_EXTRAFINE_PORTA_UP 1 842 #define XM_X_EXTRAFINE_PORTA_DOWN 2 843 844 /* To make my life a bit simpler during conversion, effect E:xy is converted 845 * to effect number EBASE+x:y. The same applies to effect X, and IT's S. That 846 * way, these effects can be manipulated like regular effects. 847 */ 848 #define EBASE (XM_N_EFFECTS) 849 #define XBASE (EBASE+16) 850 #define SBASE (IT_N_EFFECTS) 851 852 #define EFFECT_VALUE(x, y) (((x)<<4)|(y)) 853 #define HIGH(v) ((v)>>4) 854 #define LOW(v) ((v)&0x0F) 855 #define SET_HIGH(v, x) v = (((x)<<4)|((v)&0x0F)) 856 #define SET_LOW(v, y) v = (((v)&0xF0)|(y)) 857 #define BCD_TO_NORMAL(v) (HIGH(v)*10+LOW(v)) 858 859 860 861 #if 0 862 unsigned char **_dumb_malloc2(int w, int h); 863 void _dumb_free2(unsigned char **line); 864 #endif 865 866 void _dumb_it_xm_convert_effect(int effect, int value, IT_ENTRY *entry, int mod); 867 int _dumb_it_fix_invalid_orders(DUMB_IT_SIGDATA *sigdata); 868 869 870 #define PTM_APPREGIO 0 871 #define PTM_PORTAMENTO_UP 1 872 #define PTM_PORTAMENTO_DOWN 2 873 #define PTM_TONE_PORTAMENTO 3 874 #define PTM_VIBRATO 4 875 #define PTM_VOLSLIDE_TONEPORTA 5 876 #define PTM_VOLSLIDE_VIBRATO 6 877 #define PTM_TREMOLO 7 878 #define PTM_SAMPLE_OFFSET 9 879 #define PTM_VOLUME_SLIDE 10 /* A */ 880 #define PTM_POSITION_JUMP 11 /* B */ 881 #define PTM_SET_CHANNEL_VOLUME 12 /* C */ 882 #define PTM_PATTERN_BREAK 13 /* D */ 883 #define PTM_E 14 /* E */ 884 #define PTM_SET_TEMPO_BPM 15 /* F */ 885 #define PTM_SET_GLOBAL_VOLUME 16 /* G */ 886 #define PTM_RETRIGGER 17 /* H */ 887 #define PTM_FINE_VIBRATO 18 /* I */ 888 #define PTM_NOTE_SLIDE_UP 19 /* J */ 889 #define PTM_NOTE_SLIDE_DOWN 20 /* K */ 890 #define PTM_NOTE_SLIDE_UP_RETRIG 21 /* L */ 891 #define PTM_NOTE_SLIDE_DOWN_RETRIG 22 /* M */ 892 #define PTM_N_EFFECTS 23 893 894 #define PTM_E_FINE_PORTA_DOWN 0x1 895 #define PTM_E_FINE_PORTA_UP 0x2 896 #define PTM_E_SET_VIBRATO_CONTROL 0x4 897 #define PTM_E_SET_FINETUNE 0x5 898 #define PTM_E_SET_LOOP 0x6 899 #define PTM_E_SET_TREMOLO_CONTROL 0x7 900 #define PTM_E_SET_PANNING 0x8 901 #define PTM_E_RETRIG_NOTE 0x9 902 #define PTM_E_FINE_VOLSLIDE_UP 0xA 903 #define PTM_E_FINE_VOLSLIDE_DOWN 0xB 904 #define PTM_E_NOTE_CUT 0xC 905 #define PTM_E_NOTE_DELAY 0xD 906 #define PTM_E_PATTERN_DELAY 0xE 907 908 /* To make my life a bit simpler during conversion, effect E:xy is converted 909 * to effect number EBASE+x:y. The same applies to effect X, and IT's S. That 910 * way, these effects can be manipulated like regular effects. 911 */ 912 #define PTM_EBASE (PTM_N_EFFECTS) 913 914 void _dumb_it_ptm_convert_effect(int effect, int value, IT_ENTRY *entry); 915 916 long _dumb_it_read_sample_data_adpcm4(IT_SAMPLE *sample, DUMBFILE *f); 917 918 void _dumb_it_interleave_stereo_sample(IT_SAMPLE *sample); 919 920 /* Calling either of these is optional */ 921 void _dumb_init_cubic(); 922 #ifdef _USE_SSE 923 void _dumb_init_sse(); 924 #endif 925 926 #endif /* INTERNAL_IT_H */ 927