SONGS.C 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: f:/miner/source/main/rcs/songs.c $
  15. * $Revision: 2.1 $
  16. * $Author: john $
  17. * $Date: 1995/05/02 16:15:21 $
  18. *
  19. * Routines to manage the songs in Descent.
  20. *
  21. * $Log: songs.c $
  22. * Revision 2.1 1995/05/02 16:15:21 john
  23. * Took out printf.
  24. *
  25. * Revision 2.0 1995/02/27 11:27:13 john
  26. * New version 2.0, which has no anonymous unions, builds with
  27. * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
  28. *
  29. * Revision 1.2 1995/02/11 12:42:12 john
  30. * Added new song method, with FM bank switching..
  31. *
  32. * Revision 1.1 1995/02/11 10:20:33 john
  33. * Initial revision
  34. *
  35. *
  36. */
  37. #pragma off (unreferenced)
  38. static char rcsid[] = "$Id: songs.c 2.1 1995/05/02 16:15:21 john Exp $";
  39. #pragma on (unreferenced)
  40. #include <stdlib.h>
  41. #include <string.h>
  42. #include "error.h"
  43. #include "types.h"
  44. #include "songs.h"
  45. #include "mono.h"
  46. #include "cfile.h"
  47. #include "digi.h"
  48. song_info Songs[MAX_SONGS];
  49. int Songs_initialized = 0;
  50. void songs_init()
  51. {
  52. int i;
  53. char inputline[80+1];
  54. CFILE * fp;
  55. if ( Songs_initialized ) return;
  56. fp = cfopen( "descent.sng", "rb" );
  57. if ( fp == NULL ) {
  58. Error( "Couldn't open descent.sng" );
  59. }
  60. i = 0;
  61. while (cfgets(inputline, 80, fp )) {
  62. char *p = strchr(inputline,'\n');
  63. if (p) *p = '\0';
  64. if ( strlen( inputline ) ) {
  65. Assert( i < MAX_SONGS );
  66. sscanf( inputline, "%s %s %s", Songs[i].filename, Songs[i].melodic_bank_file, Songs[i].drum_bank_file );
  67. //printf( "%d. '%s' '%s' '%s'\n",i, Songs[i].filename, Songs[i].melodic_bank_file, Songs[i].drum_bank_file );
  68. i++;
  69. }
  70. }
  71. Songs_initialized = 1;
  72. cfclose(fp);
  73. }
  74. void songs_play_song( int songnum, int repeat )
  75. {
  76. if ( !Songs_initialized ) songs_init();
  77. digi_play_midi_song( Songs[songnum].filename, Songs[songnum].melodic_bank_file, Songs[songnum].drum_bank_file, repeat );
  78. }
  79. void songs_play_level_song( int levelnum )
  80. {
  81. int songnum;
  82. Assert( levelnum != 0 );
  83. if ( !Songs_initialized ) songs_init();
  84. if (levelnum < 0)
  85. songnum = (-levelnum) % NUM_GAME_SONGS;
  86. else
  87. songnum = (levelnum-1) % NUM_GAME_SONGS;
  88. songnum += SONG_LEVEL_MUSIC;
  89. digi_play_midi_song( Songs[songnum].filename, Songs[songnum].melodic_bank_file, Songs[songnum].drum_bank_file, 1 );
  90. }
  91.