| 1869 | #endif |
| 1870 | |
| 1871 | void LoadBytecode(int stageListID, int scriptID) |
| 1872 | { |
| 1873 | char scriptPath[0x40]; |
| 1874 | if (Engine.bytecodeMode == BYTECODE_MOBILE) { |
| 1875 | switch (stageListID) { |
| 1876 | case STAGELIST_PRESENTATION: |
| 1877 | case STAGELIST_REGULAR: |
| 1878 | case STAGELIST_BONUS: |
| 1879 | case STAGELIST_SPECIAL: |
| 1880 | StrCopy(scriptPath, "Data/Scripts/ByteCode/"); |
| 1881 | StrAdd(scriptPath, stageList[stageListID][stageListPosition].folder); |
| 1882 | StrAdd(scriptPath, ".bin"); |
| 1883 | break; |
| 1884 | |
| 1885 | case 4: StrCopy(scriptPath, "Data/Scripts/ByteCode/GlobalCode.bin"); break; |
| 1886 | |
| 1887 | default: break; |
| 1888 | } |
| 1889 | } |
| 1890 | else { |
| 1891 | StrCopy(scriptPath, "Data/Scripts/ByteCode/GS000.bin"); |
| 1892 | int pos = StrLength(scriptPath) - 9; |
| 1893 | if (stageListID < STAGELIST_MAX) { |
| 1894 | char listIDs[4] = { 'P', 'R', 'B', 'S' }; |
| 1895 | scriptPath[pos] = listIDs[stageListID]; |
| 1896 | scriptPath[pos + 2] = stageListPosition / 100 + '0'; |
| 1897 | scriptPath[pos + 3] = stageListPosition % 100 / 10 + '0'; |
| 1898 | scriptPath[pos + 4] = stageListPosition % 10 + '0'; |
| 1899 | } |
| 1900 | } |
| 1901 | |
| 1902 | FileInfo info; |
| 1903 | if (LoadFile(scriptPath, &info)) { |
| 1904 | byte fileBuffer = 0; |
| 1905 | int *scriptCodePtr = &scriptCode[scriptCodePos]; |
| 1906 | int *jumpTablePtr = &jumpTable[jumpTablePos]; |
| 1907 | |
| 1908 | FileRead(&fileBuffer, 1); |
| 1909 | int scriptCodeSize = fileBuffer; |
| 1910 | FileRead(&fileBuffer, 1); |
| 1911 | scriptCodeSize |= fileBuffer << 8; |
| 1912 | FileRead(&fileBuffer, 1); |
| 1913 | scriptCodeSize |= fileBuffer << 16; |
| 1914 | FileRead(&fileBuffer, 1); |
| 1915 | scriptCodeSize |= fileBuffer << 24; |
| 1916 | |
| 1917 | while (scriptCodeSize > 0) { |
| 1918 | FileRead(&fileBuffer, 1); |
| 1919 | int blockSize = fileBuffer & 0x7F; |
| 1920 | |
| 1921 | if (fileBuffer >= 0x80) { |
| 1922 | while (blockSize > 0) { |
| 1923 | FileRead(&fileBuffer, 1); |
| 1924 | *scriptCodePtr = fileBuffer; |
| 1925 | FileRead(&fileBuffer, 1); |
| 1926 | *scriptCodePtr |= fileBuffer << 8; |
| 1927 | FileRead(&fileBuffer, 1); |
| 1928 | *scriptCodePtr |= fileBuffer << 16; |