diff --git a/desktop_version/src/Map.cpp b/desktop_version/src/Map.cpp index 565eecb2..23357046 100644 --- a/desktop_version/src/Map.cpp +++ b/desktop_version/src/Map.cpp @@ -1012,65 +1012,7 @@ void mapclass::gotoroom(int rx, int ry) game.currentroomdeaths = roomdeaths[game.roomx - 100 + (20 * (game.roomy - 100))]; //Alright, change music depending on where we are: - //Tower - if (game.roomx == 107 && game.roomy == 106) music.niceplay(4); - if (game.roomx == 107 && game.roomy == 107) music.niceplay(4); - if (game.roomx == 107 && game.roomy == 108) music.niceplay(4); - if (game.roomx == 107 && game.roomy == 109) music.niceplay(4); - if (game.roomx == 108 && game.roomy == 109) - { - if (graphics.setflipmode) - { - music.niceplay(9); - } - else - { - music.niceplay(2); - } - } - if (game.roomx == 109) - { - if (graphics.setflipmode) - { - music.niceplay(9); - } - else - { - music.niceplay(2); - } - } - //Warp Zone - if (game.roomx == 112 && game.roomy == 101) music.niceplay(4); - if (game.roomx == 113 && game.roomy == 101) music.niceplay(4); - if (game.roomx == 113 && game.roomy == 102) music.niceplay(4); - if (game.roomx == 114 && game.roomy == 101) music.niceplay(12); - if (game.roomx == 115 && game.roomy == 101) music.niceplay(12); - if (game.roomx == 115 && game.roomy == 102) music.niceplay(12); - //Lab - if (game.roomx == 101 && game.roomy == 115) music.niceplay(4); - if (game.roomx == 100 && game.roomy == 115) music.niceplay(4); - if (game.roomx == 101 && game.roomy == 116) music.niceplay(4); - if (game.roomx == 100 && game.roomy == 116) music.niceplay(4); - if (game.roomx == 102 && game.roomy == 116) music.niceplay(3); - if (game.roomx == 102 && game.roomy == 117) music.niceplay(3); - if (game.roomx == 101 && game.roomy == 117) music.niceplay(3); - //Space Station - if (game.intimetrial) - { - if (game.roomx == 111 && game.roomy == 112) music.niceplay(1); - if (game.roomx == 111 && game.roomy == 113) music.niceplay(1); - if (game.roomx == 112 && game.roomy == 114) music.niceplay(1); - if (game.roomx == 112 && game.roomy == 115) music.niceplay(1); - } - else - { - if (game.roomx == 111 && game.roomy == 112) music.niceplay(1); - if (game.roomx == 111 && game.roomy == 113) music.niceplay(1); - if (game.roomx == 112 && game.roomy == 114) music.niceplay(4); - if (game.roomx == 112 && game.roomy == 115) music.niceplay(4); - } - //Leaving the Ship - if (game.roomx == 104 && game.roomy == 112) music.niceplay(4); + music.changemusicarea(game.roomx - 100, game.roomy - 100); } int temp = rx + (ry * 100); loadlevel(game.roomx, game.roomy); diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index a6af5c1e..7fdcbadd 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -6,7 +6,9 @@ #include "BinaryBlob.h" #include "Game.h" +#include "Graphics.h" #include "Map.h" +#include "Script.h" #include "UtilityClass.h" musicclass::musicclass(void) @@ -419,40 +421,81 @@ void musicclass::niceplay(int t) nicechange = t; } +static const int areamap[] = { + 4, 3, 3, 3, 3, 3, 3, 3, 4,-2, 4, 4, 4,12,12,12,12,12,12,12, + 4, 3, 3, 3, 3, 3, 3, 4, 4,-2, 4, 4, 4, 4,12,12,12,12,12,12, + 4, 4, 4, 4, 3, 4, 4, 4, 4,-2, 4, 4, 4, 4,12,12,12,12,12,12, + 4, 4, 4, 4, 3, 4, 4, 4, 4,-2, 4, 4, 1, 1, 1, 1,12,12,12,12, + 4, 4, 3, 3, 3, 4, 4, 4, 4,-2,-2,-2, 1, 1, 1, 1, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 1, 1, 1, 1, 1, 1,11,11,-1, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 1, 1, 1, 1, 1, 1, 1,11,11,11, + 4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 1, 1, 1, 1, 1, 1, 1, 1, 1,11, + 4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4, 4, 4, 1, 1, 1, 1, 1, 1, 3, + 4, 4, 4, 4, 4, 4, 4, 4,-2,-2, 4, 4, 4, 1, 1, 1, 1, 1, 1, 4, + 4, 4,-1,-1,-1, 4, 4, 4, 4,-2, 4, 4, 4, 1, 1, 1, 1, 1, 1, 4, + 4, 4,-1,-1,-1, 4, 4, 4, 4,-2, 4, 1, 1, 1, 1, 1, 1, 1, 1, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4, 1, 1, 1, 1, 1, 1, 4, 1, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4, 1, 1, 1, 1, 1, 1, 4, 1, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4,-1,-3, 4, 4, 4, 4, 4, 1, 4, + 4, 4, 4, 4, 4, 3, 3, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 3, 3, 3, 3, 3, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 3, 3, 3, 3, 3, 3, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 3, 3, 3, 3, 3, 4, 4, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 3, 3, 3, 3, 3, 4, 4, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 +}; + +SDL_COMPILE_TIME_ASSERT(areamap, SDL_arraysize(areamap) == 20 * 20); + void musicclass::changemusicarea(int x, int y) { - switch(musicroom(x, y)) + int room; + int track; + + if (script.running) { - case musicroom(11, 4): - niceplay(2); - break; + return; + } - case musicroom(2, 4): - case musicroom(7, 15): - niceplay(3); - break; + room = musicroom(x, y); - case musicroom(18, 1): - case musicroom(15, 0): - niceplay(12); - break; + if (!INBOUNDS_ARR(room, areamap)) + { + SDL_assert(0 && "Music map index out-of-bounds!"); + return; + } - case musicroom(0, 0): - case musicroom(0, 16): - case musicroom(2, 11): - case musicroom(7, 9): - case musicroom(8, 11): - case musicroom(13, 2): - case musicroom(17, 12): - case musicroom(14, 19): - case musicroom(17, 17): - niceplay(4); - break; + track = areamap[room]; - default: - niceplay(1); + switch (track) + { + case -1: + /* Don't change music. */ + return; + case -2: + /* Special case: Tower music, changes with Flip Mode. */ + if (graphics.setflipmode) + { + track = 9; /* ecroF evitisoP */ + } + else + { + track = 2; /* Positive Force */ + } + break; + case -3: + /* Special case: start of Space Station 2. */ + if (game.intimetrial) + { + track = 1; /* Pushing Onwards */ + } + else + { + track = 4; /* Passion for Exploring */ + } break; } + + niceplay(track); } void musicclass::playef(int t) diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 01175b23..310a3be7 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -3361,13 +3361,11 @@ void scriptclass::teleport(void) else { //change music based on location - if (graphics.setflipmode && game.teleport_to_x == 11 && game.teleport_to_y == 4) + if (game.teleport_to_x == 2 && game.teleport_to_y == 11) { - music.niceplay(9); - } - else - { - music.changemusicarea(game.teleport_to_x, game.teleport_to_y); + /* Special case: Ship music needs to be set here; + * ship teleporter on music map is -1 for jukebox. */ + music.niceplay(4); } game.savetele_textbox(); }