/ppmckc/datamake.c
C | 5606 lines | 4789 code | 277 blank | 540 comment | 787 complexity | ec8af2f8f0773d4ea183522580841e27 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- #include <stddef.h>
- #include <ctype.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- #include "mckc.h"
-
- extern char *mml_names[MML_MAX];
- int mml_idx = 0;
- extern int mml_num;
- char songlabel[64];
- extern int debug_flag;
- extern char ef_name[256];
- extern char inc_name[256];
- extern char out_name[256];
- extern int warning_flag;
- extern int message_flag;
- extern int include_flag;
-
-
- extern int getFileSize( char *ptr );
- extern int Asc2Int( char *ptr, int *cnt );
- extern void strupper( char *ptr );
- extern char *readTextFile( char *filename );
- extern FILE *openDmc(char *name);
- extern char *skipSpaceOld( char *ptr );
- extern char *skipSpace( char *ptr );
-
- void putBankOrigin(FILE *fp, int bank);
- int checkBankRange(int bank);
- int double2int(double d);
- #define arraysizeof(x) ( sizeof(x) / sizeof(x[0]) )
-
-
- int error_flag; // ???????????0???
- int octave; // ?????????
- double length; // ??????
- int octave_flag = 0; // ????????? ("<" ">" ???)
- int gate_denom = 8; //q???????
- int pitch_correction = 0; //??????????????????????LFO?????
-
- int loop_flag; // ????????????0???
- int putAsm_pos; //
-
- char *mml_file_name; //???mml?????(???????????)
- int mml_line_pos; //
- int mml_trk; //
-
- int nest; // ?????????
- LEN track_count[MML_MAX][_TRACK_MAX][2]; // ??????????(??/????/?????/???????)
-
- int volume_flag; // ?????
- double tbase = 0.625; // ????[frame/count]??
-
- int transpose; // ???????????
-
- int sndgen_flag = 0; // ???????
- // ?????????
- unsigned long track_allow_flag = (TRACK(0)|TRACK(1)|TRACK(2)|NOISETRACK|DPCMTRACK);
- //??????????
- unsigned long actual_track_flag = 0;
- int dpcm_track_num = 1; // DPCM????
- int fds_track_num = 0; // FDS????
- int vrc7_track_num = 0; // VRC7????
- int vrc6_track_num = 0; // VRC6????
- int n106_track_num = 0; // ????(namco106)???????
- int fme7_track_num = 0; // FME7????
- int mmc5_track_num = 0; // MMC5????
-
-
- int bank_sel[_TRACK_MAX]; // 0 ? 127 = ??????? , 0xFF = ????
- int allow_bankswitching = 1;
- int dpcm_bankswitch = 0;
- int auto_bankswitch = 0;
- int curr_bank = 0x00;
- int bank_usage[128]; //bank_usage[0]?????????
- int bank_maximum = 0; //8KB
- int dpcm_extra_bank_num = 0; //8KB
-
- int tone_tbl[ _TONE_MAX][1024]; // Tone
- int envelope_tbl[ _ENVELOPE_MAX][1024]; // Envelope
- int pitch_env_tbl[_PITCH_ENV_MAX][1024]; // Pitch Envelope
- int pitch_mod_tbl[_PITCH_MOD_MAX][ 5]; // LFO
- int arpeggio_tbl[ _ARPEGGIO_MAX][1024]; // Arpeggio
- int fm_tone_tbl[ _FM_TONE_MAX][2+64]; // FM Tone
- int vrc7_tone_tbl[_VRC7_TONE_MAX][2+64]; // VRC7 Tone(???????????)
- int n106_tone_tbl[_N106_TONE_MAX][2+64]; // NAMCO106 Tone
- int hard_effect_tbl[_HARD_EFFECT_MAX][5]; // FDS Hardware Effect
- int effect_wave_tbl[_EFFECT_WAVE_MAX][33]; // Effect Wave (4088) Data
-
- DPCMTBL dpcm_tbl[_DPCM_MAX]; // DPCM
- unsigned char *dpcm_data; // DPCM?????
- int dpcm_size = 0;
- int dpcm_reststop = 0;
-
- char song_name[1024] = "Song Name\0";
- char composer[1024] = "Artist\0";
- char maker[1024] = "Maker\0";
- char programer_buf[1024] = "";
- char *programer = NULL;
-
- const char str_track[] = _TRACK_STR;
-
- // ?????
- enum {
- COMMAND_NOT_DEFINED = 0,
- DATA_ENDED_BY_LOOP_DEPTH_EXCEPT_0,
- DEFINITION_IS_WRONG,
- TONE_DEFINITION_IS_WRONG,
- ENVELOPE_DEFINITION_IS_WRONG,
- PITCH_ENVELOPE_DEFINITION_IS_WRONG,
- NOTE_ENVELOPE_DEFINITION_IS_WRONG,
- LFO_DEFINITION_IS_WRONG,
- DPCM_DEFINITION_IS_WRONG,
- DPCM_PARAMETER_IS_LACKING,
- FM_TONE_DEFINITION_IS_WRONG,
- ABNORMAL_PARAMETERS_OF_FM_TONE,
- N106_TONE_DEFINITION_IS_WRONG,
- ABNORMAL_PARAMETERS_OF_N106_TONE,
- ABNORMAL_VALUE_OF_REPEAT_COUNT,
- ABNORMAL_TONE_NUMBER,
- ABNORMAL_ENVELOPE_NUMBER,
- ABNORMAL_ENVELOPE_VALUE,
- ABNORMAL_PITCH_ENVELOPE_NUMBER,
- ABNORMAL_NOTE_ENVELOPE_NUMBER,
- ABNORMAL_LFO_NUMBER,
- ABNORMAL_PITCH_VALUE,
- ABNORMAL_VOLUME_VALUE,
- ABNORMAL_TEMPO_VALUE,
- ABNORMAL_QUANTIZE_VALUE,
- ABNORMAL_SHUFFLE_QUANTIZE_VALUE,
- ABNORMAL_SWEEP_VALUE,
- ABNORMAL_DETUNE_VALUE,
- ABNORMAL_SHIFT_AMOUNT,
- RELATIVE_VOLUME_WAS_USED_WITHOUT_SPECIFYING_VOLUME,
- VOLUME_RANGE_OVER_OF_RELATIVE_VOLUME,
- VOLUME_RANGE_UNDER_OF_RELATIVE_VOLUME,
- DATA_ENDED_BY_CONTINUATION_NOTE,
- DPCM_FILE_NOT_FOUND,
- DPCM_FILE_SIZE_OVER,
- DPCM_FILE_TOTAL_SIZE_OVER,
- INVALID_TRACK_HEADER,
- HARD_EFFECT_DEFINITION_IS_WRONG,
- EFFECT_WAVE_DEFINITION_IS_WRONG,
- ABNORMAL_HARD_EFFECT_NUMBER,
- ABNORMAL_TRANSPOSE_VALUE,
- TUPLET_BRACE_EMPTY,
- BANK_IDX_OUT_OF_RANGE,
- FRAME_LENGTH_LESSTHAN_0,
- ABNORMAL_NOTE_LENGTH_VALUE,
- PARAMETER_IS_LACKING,
- ABNORMAL_SELFDELAY_VALUE,
- CANT_USE_BANK_2_OR_3_WITH_DPCMBANKSWITCH,
- CANT_USE_SHIFT_AMOUNT_WITHOUT_PITCH_CORRECTION,
- UNUSE_COMMAND_IN_THIS_TRACK,
- };
-
- // ??????
- const char *ErrorlMessage[] = {
- "?????????????", "Command not defined",
- "??????0?????????????", "Data ended by loop depth except 0",
- "??????????", "Definition is wrong",
- "PSG????????????", "PSG Tone definition is wrong",
- "????????????????", "Envelope definition is wrong",
- "???????????????????", "Pitch envelope definition is wrong",
- "???????????????????", "Note envelope definition is wrong",
- "LFO??????????", "LFO definition is wrong",
- "DPCM??????????", "DPCM definition is wrong",
- "DPCM??????????????", "DPCM parameter is lacking",
- "FM????????????", "FM tone definition is wrong",
- "FM??????????????", "Abnormal parameters of FM tone",
- "namco106????????????", "namco106 tone definition is wrong",
- "namco106??????????????", "Abnormal parameters of namco106 tone",
- "?????????????", "Abnormal value of repeat count",
- "?????????", "Abnormal tone number",
- "?????????????", "Abnormal envelope number",
- "?????????????", "Abnormal envelope value",
- "??????????????????", "Abnormal pitch envelope number",
- "??????????????????", "Abnormal note envelope number",
- "LFO?????????", "Abnormal LFO number",
- "?????????", "Abnormal pitch value",
- "?????????", "Abnormal volume value",
- "??????????", "Abnormal tempo value",
- "?????????????", "Abnormal quantize value",
- "??????????????????", "Abnormal shuffle quantize value",
- "???????????", "Abnormal sweep value",
- "?????????????", "Abnormal detune value",
- "??????????????", "Abnormal pitch shift amount value",
- "?????????????????????????", "Relative volume was used without specifying volume",
- "????(+)????????????", "Volume range over(+) of relative volume",
- "????(-)????????????", "Volume range under(-) of relative volume",
- "??????????????????", "Data ended by Continuation note",
- "DPCM??????????", "DPCM file not found",
- "DPCM????????4081byte??????", "DPCM file size over",
- "DPCM????????????????????", "DPCM file total size over",
- "???????????????", "Invalid track header",
- "??????????????????????", "Hardware effect definition is wrong",
- "??????????????????", "Effect wavetable definition is wrong",
- "?????????????????????", "Abnormal hardware effect number",
- "??????????????", "Abnormal transpose value",
- "???{}???????????", "Tuplet {} empty",
- "????????????", "Bank index out of range",
- "????????(unexpected error)", "Frame length is negative value (unexpected error)",
- "?????????", "Abnormal note length value",
- "??????????????", "Parameter is lacking",
- "??????????????", "Abnormal self-delay value",
- "DPCM????0x4000??????????2?3????????", "Cannot use bank 2 or 3 if DPCM size is greater than 0x4000",
- "#PITCH-CORRECTION???????????????????????????", "Cannot use SA<num> without #PITCH-CORRECTION",
- "????????????????????", "Unuse command in this track",
- };
-
-
-
- enum {
- TOO_MANY_INCLUDE_FILES = 0,
- FRAME_LENGTH_IS_0,
- REPEAT2_FRAME_ERROR_OVER_3,
- IGNORE_PMCKC_BANK_CHANGE,
- THIS_NUMBER_IS_ALREADY_USED,
- DPCM_FILE_SIZE_ERROR,
- };
-
- const char *WarningMessage[] = {
- "??????????????????", "Too many include files",
- "???????0???????", "frame length is 0",
- "????2????????3????????????", "Repeat2 frame error over 3 frames",
- "#BANK-CHANGE????#SETBANK, NB??????", "Ignoring #SETBANK and NB if #BANK-CHANGE used",
- "????????????", "This definition number is already used",
- "DPCM??? mod 16 ?1???????", "DPCM size mod 16 is not 1",
- };
-
-
-
- /*--------------------------------------------------------------
- ?????
- Input:
-
- Output:
- none
- --------------------------------------------------------------*/
- void dispError( int no, char *file, int line )
- {
- no = no*2;
- if( message_flag != 0 ) {
- no++;
- }
- if( file != NULL ) {
- printf( "Error : %s %6d: %s\n", file, line, ErrorlMessage[no] );
- } else {
- printf( "Error : %s\n", ErrorlMessage[no] );
- }
- error_flag = 1;
- }
-
-
-
- /*--------------------------------------------------------------
- ???????
- Input:
-
- Output:
- none
- --------------------------------------------------------------*/
- void dispWarning( int no, char *file, int line )
- {
- if( warning_flag != 0 ) {
- no = no*2;
- if( message_flag != 0 ) {
- no++;
- }
- if( file != NULL ) {
- printf( "Warning: %s %6d: %s\n", file, line, WarningMessage[no] );
- } else {
- printf( "Warning: %s\n", WarningMessage[no] );
- }
- }
- }
-
-
-
- /*--------------------------------------------------------------
- C?????????????
- Input:
- char *ptr :?????????
- Output:
- none
- --------------------------------------------------------------*/
- void deleteCRemark( char *ptr )
- {
- int within_com = 0;
- while ( *ptr != '\0' ) {
- if ( *ptr == '/' && *(ptr + 1) == '*' ) {
- within_com = 1;
- *ptr++ = ' ';
- *ptr++ = ' ';
- while (*ptr) {
- if (*ptr == '*' && *(ptr + 1) == '/') {
- *ptr++ = ' ';
- *ptr++ = ' ';
- within_com = 0;
- break;
- }
- if ( *ptr != '\n' ) {
- *ptr = ' ';
- }
- ptr++;
- }
- } else {
- ++ptr;
- }
- }
- if (within_com) {
- printf("Warning :");
- printf( message_flag ? "Reached EOF in comment"
- : "?????????????????????????");
- printf("\n");
- }
- }
-
-
- //??
- /*--------------------------------------------------------------
- ???????
- Input:
- char *ptr :?????????
- Output:
- ??
- --------------------------------------------------------------*/
- void deleteRemark( char *ptr )
- {
- while( *ptr != '\0' ) {
- if ( *ptr == '/' || *ptr == ';' ) {
- while( *ptr != '\0' ) {
- if( *ptr != '\n' ) {
- *ptr++ = ' ';
- } else {
- ptr++;
- break;
- }
- }
- } else {
- ptr++;
- }
- }
- }
-
-
-
- /*----------------------------------------------------------*/
- /* ?????????? */
- /* Input: */
- /* char *data :????????? */
- /* Output: */
- /* none */
- /*----------------------------------------------------------*/
- int getLineCount( char *ptr )
- {
- int line;
-
- line = 0;
-
- while( *ptr != '\0' ) {
- if( *ptr == '\n' ) {
- line++;
- }
- ptr++;
- }
- if( *(ptr-1) != '\n' ) {
- line++;
- }
- return line;
- }
-
-
- /*--------------------------------------------------------------
- --------------------------------------------------------------*/
- LINE *readMmlFile(char *fname)
- {
- LINE *lptr;
- int line_count;
- int i;
- char *filestr;
- filestr = readTextFile(fname);
-
- if (filestr == NULL) {
- error_flag = 1;
- return NULL;
- }
-
- deleteCRemark(filestr);
-
- //skipSpace?????
- //deleteRemark(filestr);
-
- line_count = getLineCount(filestr);
- lptr = (LINE *)malloc( (line_count+1)*sizeof(LINE) ); /* ?????????? */
-
- lptr[0].status = _HEADER; /* LINE?????[0]?malloc??? */
- lptr[0].str = filestr; /* ???????????????? */
- lptr[0].line = line_count;
- lptr[0].filename = fname;
- for( i = 1; i <= line_count; i++ ) {
- lptr[i].filename = fname;
- lptr[i].line = i;
- }
- return lptr;
- }
-
-
-
-
- /*--------------------------------------------------------------
- ??/EOF?0(NULL)???(?????????????)
- Input:
- char *ptr :?????????
- Output:
- ??
- --------------------------------------------------------------*/
- char *changeNULL( char *ptr )
- {
- while( *ptr != '\n' ) {
- if( *ptr == '\0' ) break;
- ptr++;
- }
- *ptr = '\0';
- ptr++;
-
- return ptr;
- }
-
-
- /*---------------------------------------------------------
- @hoge123 = { ag ae aeag g} ???
-
- @HOGE\s*(\d+)\s*(=|)\s*{.*?(}.*|)$
- -----------------------------------------------------------*/
- int setEffectSub(LINE *lptr, int line, int *ptr_status_end_flag, int min, int max, const int error_no)
- {
- int param, cnt;
- char *temp;
- temp = skipSpace( lptr[line].str );
- param = Asc2Int( temp, &cnt );
-
- if (cnt == 0)
- goto on_error;
- if (param < min || max <= param)
- goto on_error;
-
- lptr[line].param = param;
- temp = skipSpace( temp+cnt );
-
- if ( *temp == '=' ) {
- temp++;
- temp = skipSpace( temp );
- }
-
- if ( *temp != '{' )
- goto on_error;
-
- lptr[line].str = temp;
- *ptr_status_end_flag = 1;
-
- while ( *temp != '\0' ) {
- if( *temp == '}' ) {
- *ptr_status_end_flag = 0;
- }
- temp++;
- }
- return 1;
- on_error:
- lptr[line].status = 0;
- dispError( error_no, lptr[line].filename, line );
- return 0;
- }
-
-
-
-
- /*--------------------------------------------------------------
- ????????
- Input:
- char *ptr :?????????
- Output:
- ??
- --------------------------------------------------------------*/
- void getLineStatus(LINE *lptr, int inc_nest )
- {
- const HEAD head[] = {
- { "#TITLE", _TITLE },
- { "#COMPOSER", _COMPOSER },
- { "#MAKER", _MAKER },
- { "#PROGRAMER", _PROGRAMER },
- { "#OCTAVE-REV", _OCTAVE_REV },
- { "#GATE-DENOM", _GATE_DENOM },
- { "#INCLUDE", _INCLUDE },
- { "#EX-DISKFM", _EX_DISKFM },
- { "#EX-NAMCO106", _EX_NAMCO106 },
- { "#EX-VRC7", _EX_VRC7 },
- { "#EX-VRC6", _EX_VRC6 },
- { "#EX-FME7", _EX_FME7 },
- { "#EX-MMC5", _EX_MMC5 },
- { "#NO-BANKSWITCH", _NO_BANKSWITCH },
- { "#AUTO-BANKSWITCH", _AUTO_BANKSWITCH },
- { "#PITCH-CORRECTION", _PITCH_CORRECTION },
- { "#BANK-CHANGE", _BANK_CHANGE },
- { "#SETBANK", _SET_SBANK },
- { "#EFFECT-INCLUDE", _EFFECT_INCLUDE },
- { "#DPCM-RESTSTOP", _DPCM_RESTSTOP },
- { "@DPCM", _SET_DPCM_DATA },
- { "@MP", _SET_PITCH_MOD },
- { "@EN", _SET_ARPEGGIO },
- { "@EP", _SET_PITCH_ENV },
- { "@FM", _SET_FM_TONE },
- { "@MH", _SET_HARD_EFFECT},
- { "@MW", _SET_EFFECT_WAVE},
- { "@OP", _SET_VRC7_TONE },
- { "@N", _SET_N106_TONE },
- { "@V", _SET_ENVELOPE },
- { "@", _SET_TONE },
- { "", -1 },
- };
-
- int line, i, param, cnt, track_flag, status_end_flag, bank,bank_ch;
- char *temp, *temp2;
- char *ptr;
- ptr = lptr[0].str;
-
- status_end_flag = 0;
-
- for( line = 1; line <= lptr->line; line++ ) {
- ptr = skipSpace( ptr );
- /* ????????????????? */
- if( ((lptr[line-1].status&_SET_EFFECT) != 0) && (status_end_flag != 0) ) {
- lptr[line].status = lptr[line-1].status|_SAME_LINE;
- lptr[line].param = lptr[line-1].param;
- lptr[line].str = ptr;
- temp = ptr;
- ptr = changeNULL( ptr );
- status_end_flag = 1;
- while( *temp != '\0' ) {
- if( *temp == '}' ) {
- status_end_flag = 0;
- }
- temp++;
- }
- /* ?????????????????? */
- } else if( *ptr == '\n' || *ptr == '\0' ) {
- lptr[line].status = 0;
- lptr[line].str = ptr;
- ptr = changeNULL( ptr );
- } else {
- /* #/@???????????????????????? */
- if( *ptr == '#' || *ptr == '@' ) {
- i = 1;
- while( (*(ptr+i) != ' ') && (*(ptr+i) != '\t') && (*(ptr+i) != '\n') ) {
- *(ptr+i) = (char)toupper( *(ptr+i) );
- i++;
- }
- /* ?????????????????? */
- for( i = 0; head[i].status != -1; i++ ) {
- if( strncmp( ptr, head[i].str, strlen(head[i].str) ) == 0 ) {
- break;
- }
- }
- lptr[line].status = head[i].status;
- lptr[line].str = skipSpaceOld( ptr+strlen(head[i].str) ); /* ??????????????????? */
- } else if( strchr( str_track, *ptr ) ) {
- track_flag = 0;
- while( strchr( str_track, *ptr ) ) {
- temp = strchr( str_track, *ptr );
- if( temp == NULL ) {
- dispError( INVALID_TRACK_HEADER, lptr[line].filename, line );
- } else {
- track_flag |= (1<<(temp-str_track));
- }
- ptr++;
- }
- // ???????????
- for (i = 0; i < _TRACK_MAX; i++) {
- if( (TRACK(i) & track_flag) && !(TRACK(i) & track_allow_flag) ) {
- dispError( INVALID_TRACK_HEADER, lptr[line].filename, line );
- track_flag &= ~TRACK(i);
- }
- }
-
- if( track_flag != 0 ) {
- lptr[line].status = _TRACK;
- lptr[line].param = track_flag;
- lptr[line].str = skipSpace( ptr );
- actual_track_flag |= track_flag;
- } else {
- lptr[line].status = 0;
- lptr[line].param = 0;
- }
- } else {
- lptr[line].status = -1;
- lptr[line].str = skipSpace( ptr );
- }
- ptr = changeNULL( ptr );
-
- switch( lptr[line].status ) {
- /* Include??????? */
- case _INCLUDE:
- if( inc_nest > 16 ) { /* ????16???(???????????????) */
- dispWarning( TOO_MANY_INCLUDE_FILES, lptr[line].filename, line );
- lptr[line].status = 0;
- } else {
- LINE *ltemp;
- temp = skipSpaceOld( lptr[line].str ); /* /????????????? */
- ltemp = readMmlFile(temp);
- if( ltemp != NULL ) {
- lptr[line].inc_ptr = ltemp;
- ++inc_nest;
- getLineStatus(lptr[line].inc_ptr, inc_nest);
- --inc_nest;
- } else {
- lptr[line].status = 0; /* ???????????????? */
- error_flag = 1;
- }
- }
- break;
- /* LFO???? */
- case _SET_PITCH_MOD:
- setEffectSub(lptr, line, &status_end_flag, 0, _PITCH_MOD_MAX, LFO_DEFINITION_IS_WRONG);
- break;
- /* ????????????? */
- case _SET_PITCH_ENV:
- setEffectSub(lptr, line, &status_end_flag, 0, _PITCH_ENV_MAX, PITCH_ENVELOPE_DEFINITION_IS_WRONG);
- break;
- /* ???????????? */
- case _SET_ENVELOPE:
- setEffectSub(lptr, line, &status_end_flag, 0, _ENVELOPE_MAX, ENVELOPE_DEFINITION_IS_WRONG);
- break;
- /* ???? */
- case _SET_TONE:
- setEffectSub(lptr, line, &status_end_flag, 0, _TONE_MAX, TONE_DEFINITION_IS_WRONG);
- break;
- /* ????? */
- case _SET_ARPEGGIO:
- setEffectSub(lptr, line, &status_end_flag, 0, _ARPEGGIO_MAX, NOTE_ENVELOPE_DEFINITION_IS_WRONG);
- break;
- /* DPCM?????? */
- case _SET_DPCM_DATA:
- setEffectSub(lptr, line, &status_end_flag, 0, _DPCM_MAX, DPCM_DEFINITION_IS_WRONG);
- break;
- /* VRC7 Tone */
- case _SET_VRC7_TONE:
- setEffectSub(lptr, line, &status_end_flag, 0, _VRC7_TONE_MAX, FM_TONE_DEFINITION_IS_WRONG);
- break;
- /* FM?? */
- case _SET_FM_TONE:
- setEffectSub(lptr, line, &status_end_flag, 0, _FM_TONE_MAX, FM_TONE_DEFINITION_IS_WRONG);
- break;
- /* namco106???? */
- case _SET_N106_TONE:
- setEffectSub(lptr, line, &status_end_flag, 0, _N106_TONE_MAX, N106_TONE_DEFINITION_IS_WRONG);
- break;
- /* ??????????? */
- case _SET_HARD_EFFECT:
- setEffectSub(lptr, line, &status_end_flag, 0, _HARD_EFFECT_MAX, HARD_EFFECT_DEFINITION_IS_WRONG);
- break;
- /* ??????? */
- case _SET_EFFECT_WAVE:
- setEffectSub(lptr, line, &status_end_flag, 0, _EFFECT_WAVE_MAX, EFFECT_WAVE_DEFINITION_IS_WRONG);
- break;
- /* DISKSYSTEM FM??????? */
- case _EX_DISKFM:
- sndgen_flag |= BDISKFM;
- track_allow_flag |= FMTRACK;
- fds_track_num = 1;
- break;
- /* VRC7 FM??????? */
- case _EX_VRC7:
- sndgen_flag |= BVRC7;
- track_allow_flag |= VRC7TRACK;
- vrc7_track_num = 6;
- break;
- /* VRC6 ??????? */
- case _EX_VRC6:
- sndgen_flag |= BVRC6;
- track_allow_flag |= VRC6TRACK;
- vrc6_track_num = 3;
- break;
- /* FME7 ??????? */
- case _EX_FME7:
- sndgen_flag |= BFME7;
- track_allow_flag |= FME7TRACK;
- fme7_track_num = 3;
- break;
- /* MMC5 ??????? */
- case _EX_MMC5:
- sndgen_flag |= BMMC5;
- track_allow_flag |= MMC5TRACK;
- mmc5_track_num = 2;
- break;
- /* namco106 ????????? */
- case _EX_NAMCO106:
- temp = skipSpace( lptr[line].str );
- param = Asc2Int( temp, &cnt );
- if( cnt != 0 && (0 <= param && param <= 8) ) {
- if( param == 0 ) {
- param = 1;
- }
- lptr[line].param = param;
- n106_track_num = param;
- sndgen_flag |= BNAMCO106;
- for (i = 0; i < param; i++) {
- track_allow_flag |= TRACK(BN106TRACK+i);
- }
- } else {
- dispError( DEFINITION_IS_WRONG, lptr[line].filename, line );
- lptr[line].status = 0;
- }
- break;
- /* DPCM sound stops on 'r' command */
- case _DPCM_RESTSTOP:
- dpcm_reststop = 1;
- break;
- /* NSF mapper ? bankswitching ?? */
- case _NO_BANKSWITCH:
- allow_bankswitching = 0;
- break;
- /* ????????? */
- case _AUTO_BANKSWITCH:
- temp = skipSpace( lptr[line].str );
- param = Asc2Int( temp, &cnt );
- if ( cnt != 0 && (0 <= param && param <= 8192)) {
- // ?????????????
- if (!auto_bankswitch) {
- bank_usage[0] = 8192 - param;
- }
- auto_bankswitch = 1;
- } else {
- dispError( DEFINITION_IS_WRONG, lptr[line].filename, line );
- }
- break;
- /* ???????????(?????????) */
- case _BANK_CHANGE:
- /*
- #BANK-CHANGE <num0>,<num1>
- ?????????????????<num0>???????0?2???
- ?????<num1>????????1?14???????1?A?????
- ????????2=B?3=C?…P=7????????
- ??????????????????
- #BANK-CHANGE n
- #BANK-CHANGE 0,n
-
- #BANK-CHANGE?????????????????????
- ???????????????????????????????????
- ppmck????????????????????
-
- mckc????MML????????????
- ??????????
-
- */
- /*
- ???????????????
-
- mckc
- A B C D E | F | P Q R S T U V W
- 1 2 3 4 5 | 6 | 7 8 9 10 11 12 13 14
- pmckc
- A B C D E | F | G H I J K L | P Q R S T U V W
- 1 2 3 4 5 | 6 | 7 8 9 10 11 12 | 13 14 15 16 17 18 19 20
- ppmckc
- A B C D E | F | G H I J K L | M N O | P Q R S T U V W | X Y Z | a b
- 1 2 3 4 5 | 6 | 7 8 9 10 11 12 | 13 14 15 | 16 17 18 19 20 21 22 23 | 24 25 26 | 27 28
-
- mckc????MML????????????
- P??? ??? 9 ????OK?(????????????????)
- ??????????????????????(ry
- */
- temp = skipSpace( lptr[line].str );
- param = Asc2Int( temp, &cnt );
- if( cnt != 0 ) {
- temp += cnt;
- temp = skipSpace( temp );
- if( *temp == ',' ) {
- /* ???? */
- temp++;
- if( (0 <= param) && (param <= 2) ) {
- bank = param; /* 0,1,2?1,2,3??? */
- //printf( "bank: %d\n", bank );
- temp = skipSpace( temp );
- param = Asc2Int( temp, &cnt ); /* 1,2,3 ?ABC??? ??? 0,1,2??? */
- if( cnt != 0 && (1 <= param && param <= _TRACK_MAX) ) {
- //bank_change[bank] = param-1;
- bank_sel[param-1] = bank+1;
- } else {
- dispError( DEFINITION_IS_WRONG, lptr[line].filename, line );
- lptr[line].status = 0;
- //bank_change[bank] = 0xff;
- }
- } else {
- dispError( DEFINITION_IS_WRONG, lptr[line].filename, line );
- lptr[line].status = 0;
- }
- } else {
- /* ????? bank 1???? */
- if( cnt != 0 && (1 <= param && param <= _TRACK_MAX) ) {
- //bank_change[0] = param-1;
- bank_sel[param-1] = 1;
- } else {
- dispError( DEFINITION_IS_WRONG, lptr[line].filename, line );
- lptr[line].status = 0;
- //bank_change[0] = 0xff;
- }
- }
- } else {
- dispError( DEFINITION_IS_WRONG, lptr[line].filename, line );
- lptr[line].status = 0;
- }
- break;
- /* ??????? */
- case _SET_SBANK:
- temp = skipSpace( lptr[line].str );
-
- if ((temp2 = strchr(str_track, *temp)) != NULL) {
- /* ABC..????????? */
- param = (temp2 - str_track) + 1;
- temp++;
- } else {
- /* ??????????? */
- param = Asc2Int( temp, &cnt );
- if (cnt == 0) {
- dispError( DEFINITION_IS_WRONG, lptr[line].filename, line );
- lptr[line].status = 0;
- break;
- } else {
- temp += cnt;
- }
- }
-
- temp = skipSpace( temp );
- if( *temp == ',' ) { /* ????? */
- temp++;
- if( (1 <= param) && (param <= _TRACK_MAX) ) {
- bank_ch = param;
- // printf( "bank: %d\n", bank );
- temp = skipSpace( temp );
- param = Asc2Int( temp, &cnt );
- if( cnt != 0) {
- if (checkBankRange(param) == 0) {
- dispError( BANK_IDX_OUT_OF_RANGE, lptr[line].filename, line );
- break;
- }
- bank_sel[bank_ch-1] = param;
- } else {
- dispError( DEFINITION_IS_WRONG, lptr[line].filename, line );
- lptr[line].status = 0;
- }
- } else {
- dispError( DEFINITION_IS_WRONG, lptr[line].filename, line );
- lptr[line].status = 0;
- }
- } else {
- dispError( DEFINITION_IS_WRONG, lptr[line].filename, line );
- lptr[line].status = 0;
- }
- break;
-
- /* */
- case _EFFECT_INCLUDE:
- include_flag = 1;
- break;
- /* ???? */
- case _TITLE:
- temp = skipSpaceOld( lptr[line].str );
- strncpy( song_name, temp, 1023 );
- break;
- /* ??? */
- case _COMPOSER:
- temp = skipSpaceOld( lptr[line].str );
- strncpy( composer, temp, 1023 );
- break;
- /* ???? */
- case _MAKER:
- temp = skipSpaceOld( lptr[line].str );
- strncpy( maker, temp, 1023 );
- break;
- /* ????? */
- case _PROGRAMER:
- temp = skipSpaceOld( lptr[line].str );
- strncpy( programer_buf, temp, 1023 );
- programer = programer_buf;
- break;
- /* ?????????? */
- case _OCTAVE_REV:
- temp = skipSpace( lptr[line].str );
- param = Asc2Int( temp, &cnt );
- if( cnt != 0) {
- if( param == 0 ) {
- octave_flag = 0;
- } else {
- octave_flag = 1;
- }
- } else {
- octave_flag = 1;
- }
- break;
- /* q???????? */
- case _GATE_DENOM:
- temp = skipSpace( lptr[line].str );
- param = Asc2Int( temp, &cnt );
- if( cnt != 0 && param > 0) {
- gate_denom = param;
- } else {
- dispError( DEFINITION_IS_WRONG, lptr[line].filename, line );
- lptr[line].status = 0;
- }
- break;
- /*?????????????????LFO????? */
- case _PITCH_CORRECTION:
- pitch_correction = 1;
- break;
- /* ????? */
- case -1:
- if( (lptr[line-1].status&_SET_EFFECT) != 0 ) {
- lptr[line].status = lptr[line-1].status|_SAME_LINE;
- lptr[line].str = ptr;
- } else {
- /* ??????? */
- dispError( COMMAND_NOT_DEFINED, lptr[line].filename, line );
- lptr[line].status = 0;
- lptr[line].str = ptr;
- }
- break;
- }
- }
- }
- }
-
-
-
- /*--------------------------------------------------------------
- ?????
- Input:
-
- Output:
- ??
- --------------------------------------------------------------*/
- void getTone( LINE *lptr )
- {
- int line, i, no, end_flag, offset, num, cnt;
- char *ptr;
-
- cnt = 0;
-
- for( line = 1; line <= lptr->line; line++ ) {
- /* ???????? */
- if( lptr[line].status == _SET_TONE ) {
- no = lptr[line].param; /* ?????? */
- ptr = lptr[line].str;
- ptr++; /* '{'?????? */
- if (tone_tbl[no][0] != 0) {
- dispWarning( THIS_NUMBER_IS_ALREADY_USED, lptr[line].filename, line );
- }
- tone_tbl[no][0] = 0;
- offset = 0;
- i = 1;
- end_flag = 0;
- while( end_flag == 0 ) {
- ptr = skipSpace( ptr );
- switch( *ptr ) {
- case '}':
- if (tone_tbl[no][0] >= 1) {
- tone_tbl[no][i] = EFTBL_END;
- tone_tbl[no][0]++;
- } else {
- dispError( PARAMETER_IS_LACKING, lptr[line].filename, line );
- tone_tbl[no][0] = 0;
- }
- end_flag = 1;
- line += offset;
- break;
- case '|':
- tone_tbl[no][i] = EFTBL_LOOP;
- tone_tbl[no][0]++;
- i++;
- ptr++;
- break;
- case '\0':
- offset++;
- if( line+offset <= lptr->line ) {
- if( (lptr[line+offset].status&_SAME_LINE) == _SAME_LINE ) {
- ptr = lptr[line+offset].str;
- }
- } else {
- dispError( TONE_DEFINITION_IS_WRONG, lptr[line].filename, line );
- tone_tbl[no][0] = 0;
- end_flag = 1;
- }
- break;
- default:
- num = Asc2Int( ptr, &cnt );
- //vrc6???????(??????MMC5?3??)
- //if( cnt != 0 && (0 <= num && num <= 3) ) {
- if( cnt != 0 && (0 <= num && num <= 7) ) {
- tone_tbl[no][i] = num;
- tone_tbl[no][0]++;
- ptr += cnt;
- i++;
- } else {
- dispError( TONE_DEFINITION_IS_WRONG, lptr[line+offset].filename, line );
- tone_tbl[no][0] = 0;
- end_flag = 1;
- }
- break;
- }
- ptr = skipSpace( ptr );
- if( *ptr == ',' ) {
- ptr++;
- }
- }
- /* ???????_SAME_LINE?????? */
- } else if( lptr[line].status == (_SET_TONE|_SAME_LINE) ) {
- dispError( TONE_DEFINITION_IS_WRONG, lptr[line].filename, line );
- /* ???????????? */
- } else if( lptr[line].status == _INCLUDE ) {
- getTone( lptr[line].inc_ptr );
- }
- }
- }
-
-
-
- /*--------------------------------------------------------------
- ?????????
- Input:
-
- Output:
- ??
- --------------------------------------------------------------*/
- void getEnvelope( LINE *lptr )
- {
- int line, i, no, end_flag, offset, num, cnt;
- char *ptr;
-
- cnt = 0;
-
- for( line = 1; line <= lptr->line; line++ ) {
- /* ???????????? */
- if( lptr[line].status == _SET_ENVELOPE ) {
- no = lptr[line].param; /* ?????????? */
- ptr = lptr[line].str;
- ptr++; /* '{'?????? */
- if (envelope_tbl[no][0] != 0) {
- dispWarning( THIS_NUMBER_IS_ALREADY_USED, lptr[line].filename, line );
- }
- envelope_tbl[no][0] = 0;
- offset = 0;
- i = 1;
- end_flag = 0;
- while( end_flag == 0 ) {
- ptr = skipSpace( ptr );
- switch( *ptr ) {
- case '}':
- if (envelope_tbl[no][0] >= 1) {
- envelope_tbl[no][i] = EFTBL_END;
- envelope_tbl[no][0]++;
- } else {
- dispError( PARAMETER_IS_LACKING, lptr[line].filename, line );
- envelope_tbl[no][0] = 0;
- }
- end_flag = 1;
- line += offset;
- break;
- case '|':
- envelope_tbl[no][i] = EFTBL_LOOP;
- envelope_tbl[no][0]++;
- i++;
- ptr++;
- break;
- case '\0':
- offset++;
- if( line+offset <= lptr->line ) {
- if( (lptr[line+offset].status&_SAME_LINE) == _SAME_LINE ) {
- ptr = lptr[line+offset].str;
- }
- } else {
- dispError( ENVELOPE_DEFINITION_IS_WRONG, lptr[line].filename, line );
- envelope_tbl[no][0] = 0;
- end_flag = 1;
- }
- break;
- default:
- num = Asc2Int( ptr, &cnt );
- if( cnt != 0 && (0 <= num && num <= 63) ) {
- envelope_tbl[no][i] = num;
- envelope_tbl[no][0]++;
- ptr += cnt;
- i++;
- } else {
- dispError( ENVELOPE_DEFINITION_IS_WRONG, lptr[line+offset].filename, line );
- envelope_tbl[no][0] = 0;
- end_flag = 1;
- }
- break;
- }
- ptr = skipSpace( ptr );
- if( *ptr == ',' ) {
- ptr++;
- }
- }
- /* ???????????_SAME_LINE?????? */
- } else if( lptr[line].status == (_SET_ENVELOPE|_SAME_LINE) ) {
- dispError( ENVELOPE_DEFINITION_IS_WRONG, lptr[line].filename, line );
- /* ???????????? */
- } else if( lptr[line].status == _INCLUDE ) {
- getEnvelope( lptr[line].inc_ptr );
- }
- }
- }
-
- /*--------------------------------------------------------------
- ????????????
- Input:
-
- Output:
- ??
- --------------------------------------------------------------*/
- void getPitchEnv( LINE *lptr )
- {
- int line, i, no, end_flag, offset, num, cnt;
- char *ptr;
-
- cnt = 0;
-
- for( line = 1; line <= lptr->line; line++ ) {
- /* ??????????????? */
- if( lptr[line].status == _SET_PITCH_ENV ) {
- no = lptr[line].param; /* ????????????? */
- ptr = lptr[line].str;
- ptr++; /* '{'?????? */
- if (pitch_env_tbl[no][0] != 0) {
- dispWarning( THIS_NUMBER_IS_ALREADY_USED, lptr[line].filename, line );
- }
- pitch_env_tbl[no][0] = 0;
- offset = 0;
- i = 1;
- end_flag = 0;
- while( end_flag == 0 ) {
- ptr = skipSpace( ptr );
- switch( *ptr ) {
- case '}':
- if (pitch_env_tbl[no][0] >= 1) {
- pitch_env_tbl[no][i] = EFTBL_END;
- pitch_env_tbl[no][0]++;
- } else {
- dispError( PARAMETER_IS_LACKING, lptr[line].filename, line );
- pitch_env_tbl[no][0] = 0;
- }
- end_flag = 1;
- line += offset;
- break;
- case '|':
- pitch_env_tbl[no][i] = EFTBL_LOOP;
- pitch_env_tbl[no][0]++;
- i++;
- ptr++;
- break;
- case '\0':
- offset++;
- if( line+offset <= lptr->line ) {
- if( (lptr[line+offset].status&_SAME_LINE) == _SAME_LINE ) {
- ptr = lptr[line+offset].str;
- }
- } else {
- dispError( PITCH_ENVELOPE_DEFINITION_IS_WRONG, lptr[line].filename, line );
- pitch_env_tbl[no][0] = 0;
- end_flag = 1;
- }
- break;
- default:
- num = Asc2Int( ptr, &cnt );
- if( cnt != 0 && (-127 <= num && num <= 127) ) {
- pitch_env_tbl[no][i] = num;
- pitch_env_tbl[no][0]++;
- ptr += cnt;
- i++;
- } else {
- dispError( PITCH_ENVELOPE_DEFINITION_IS_WRONG, lptr[line+offset].filename, line );
- pitch_env_tbl[no][0] = 0;
- end_flag = 1;
- }
- break;
- }
- ptr = skipSpace( ptr );
- if( *ptr == ',' ) {
- ptr++;
- }
- }
- /* ??????????????_SAME_LINE?????? */
- } else if( lptr[line].status == (_SET_PITCH_ENV|_SAME_LINE) ) {
- dispError( PITCH_ENVELOPE_DEFINITION_IS_WRONG, lptr[line].filename, line );
- /* ???????????? */
- } else if( lptr[line].status == _INCLUDE ) {
- getPitchEnv( lptr[line].inc_ptr );
- }
- }
- }
-
- /*--------------------------------------------------------------
- ??????????????
- Input:
-
- Output:
- ??
- --------------------------------------------------------------*/
- void getPitchMod( LINE *lptr )
- {
- int line, i, no, end_flag, offset, num, cnt;
- char *ptr;
-
- cnt = 0;
-
- for( line = 1; line <= lptr->line; line++ ) {
- /* ???????? */
- if( lptr[line].status == _SET_PITCH_MOD ) {
- no = lptr[line].param; /* LFO???? */
- ptr = lptr[line].str;
- ptr++; /* '{'?????? */
- if (pitch_mod_tbl[no][0] != 0) {
- dispWarning( THIS_NUMBER_IS_ALREADY_USED, lptr[line].filename, line );
- }
- pitch_mod_tbl[no][0] = 0;
- offset = 0;
- i = 1;
- end_flag = 0;
- while( end_flag == 0 ) {
- ptr = skipSpace( ptr );
- switch( *ptr ) {
- case '}':
- if (pitch_mod_tbl[no][0] >= 3) {
- //OK.
- } else {
- dispError( PARAMETER_IS_LACKING, lptr[line].filename, line );
- pitch_mod_tbl[no][0] = 0;
- }
- end_flag = 1;
- line += offset;
- break;
- case '\0':
- offset++;
- if( line+offset <= lptr->line ) {
- if( (lptr[line+offset].status&_SAME_LINE) == _SAME_LINE ) {
- ptr = lptr[line+offset].str;
- }
- } else {
- dispError( LFO_DEFINITION_IS_WRONG, lptr[line].filename, line );
- pitch_mod_tbl[no][0] = 0;
- end_flag = 1;
- }
- break;
- default:
- num = Asc2Int( ptr, &cnt );
- if( cnt != 0 ) {
- switch( i ) {
- case 1:
- case 2:
- case 3:
- if( 0 <= num && num <= 255 ) {
- pitch_mod_tbl[no][i] = num;
- pitch_mod_tbl[no][0]++;
- ptr += cnt;
- i++;
- } else {
- dispError( LFO_DEFINITION_IS_WRONG, lptr[line+offset].filename, line );
- pitch_mod_tbl[no][0] = 0;
- end_flag = 1;
- }
- break;
- case 4:
- if( 0 <= num && num <= 255 ) {
- pitch_mod_tbl[no][i] = num;
- pitch_mod_tbl[no][0]++;
- ptr += cnt;
- i++;
- } else {
- dispError( LFO_DEFINITION_IS_WRONG, lptr[line+offset].filename, line );
- pitch_mod_tbl[no][0] = 0;
- end_flag = 1;
- }
- break;
- default:
- dispError( LFO_DEFINITION_IS_WRONG, lptr[line+offset].filename, line );
- pitch_mod_tbl[no][0] = 0;
- end_flag = 1;
- break;
- }
- } else {
- dispError( LFO_DEFINITION_IS_WRONG, lptr[line+offset].filename, line );
- pitch_mod_tbl[no][0] = 0;
- end_flag = 1;
- }
- break;
- }
- ptr = skipSpace( ptr );
- if( *ptr == ',' ) {
- ptr++;
- }
- }
- /* ???????_SAME_LINE?????? */
- } else if( lptr[line].status == (_SET_PITCH_MOD|_SAME_LINE) ) {
- dispError( LFO_DEFINITION_IS_WRONG, lptr[line].filename, line );
- /* ???????????? */
- } else if( lptr[line].status == _INCLUDE ) {
- getPitchMod( lptr[line].inc_ptr );
- }
- }
- }
-
-
-
- /*--------------------------------------------------------------
- ????????????
- Input:
-
- Output:
- ??
- --------------------------------------------------------------*/
- void getArpeggio( LINE *lptr )
- {
- int line, i, no, end_flag, offset, num, cnt;
- char *ptr;
-
- cnt = 0;
-
- for( line = 1; line <= lptr->line; line++ ) {
- /* ??????????? */
- if( lptr[line].status == _SET_ARPEGGIO ) {
- no = lptr[line].param; /* ?????????? */
- ptr = lptr[line].str;
- ptr++; /* '{'?????? */
- if (arpeggio_tbl[no][0] != 0) {
- dispWarning( THIS_NUMBER_IS_ALREADY_USED, lptr[line].filename, line );
- }
- arpeggio_tbl[no][0] = 0;
- offset = 0;
- i = 1;
- end_flag = 0;
- while( end_flag == 0 ) {
- ptr = skipSpace( ptr );
- switch( *ptr ) {
- case '}':
- if (arpeggio_tbl[no][0] >= 1) {
- arpeggio_tbl[no][i] = EFTBL_END;
- arpeggio_tbl[no][0]++;
- } else {
- dispError( PARAMETER_IS_LACKING, lptr[line].filename, line );
- arpeggio_tbl[no][0] = 0;
- }
- end_flag = 1;
- line += offset;
- break;
- case '|':
- arpeggio_tbl[no][i] = EFTBL_LOOP;
- arpeggio_tbl[no][0]++;
- i++;
- ptr++;
- break;
- case '\0':
- offset++;
- if( line+offset <= lptr->line ) {
- if( (lptr[line+offset].status&_SAME_LINE) == _SAME_LINE ) {
- ptr = lptr[line+offset].str;
- }
- } else {
- dispError( NOTE_ENVELOPE_DEFINITION_IS_WRONG, lptr[line].filename, line );
- arpeggio_tbl[no][0] = 0;
- end_flag = 1;
- }
- break;
- default:
- num = Asc2Int( ptr, &cnt );
- if( cnt != 0 ) {
- if( num >= 0 ) {
- arpeggio_tbl[no][i] = num;
- } else {
- arpeggio_tbl[no][i] = (-num)|0x80;
- }
- arpeggio_tbl[no][0]++;
- ptr += cnt;
- i++;
- } else {
- dispError( NOTE_ENVELOPE_DEFINITION_IS_WRONG, lptr[line+offset].filename, line );
- arpeggio_tbl[no][0] = 0;
- end_flag = 1;
- }
- break;
- }
- ptr = skipSpace( ptr );
- if( *ptr == ',' ) {
- ptr++;
- }
- }
- /* ??????????_SAME_LINE?????? */
- } else if( lptr[line].status == (_SET_ARPEGGIO|_SAME_LINE) ) {
- dispError( NOTE_ENVELOPE_DEFINITION_IS_WRONG, lptr[line].filename, line );
- /* ???????????? */
- } else if( lptr[line].status == _INCLUDE ) {
- getArpeggio( lptr[line].inc_ptr );
- }
- }
- }
-
-
-
- /*--------------------------------------------------------------
- DPCM???
- Input:
-
- Output:
- ??
- --------------------------------------------------------------*/
- void getDPCM( LINE *lptr )
- {
- int line, i, no, offset, end_flag, num, cnt;
- char *ptr;
- FILE *fp;
- DPCMTBL *tbl;
-
- cnt = 0;
-
- for( line = 1; line <= lptr->line; line++ ) {
- // DPCM??????
- if( lptr[line].status == _SET_DPCM_DATA ) {
- no = lptr[line].param; // DPCM????
- ptr = lptr[line].str;
- ptr++; // '{'??????
- tbl = &dpcm_tbl[no];
- if (tbl->flag != 0) {
- dispWarning( THIS_NUMBER_IS_ALREADY_USED, lptr[line].filename, line );
- }
- tbl->flag = 1; // ????????
- tbl->index = -1;
- tbl->fname = NULL;
- tbl->freq = 0;
- tbl->size = 0;
- tbl->delta_init = 0;
- offset = 0;
- i = 0;
- end_flag = 0;
- while( end_flag == 0 ) {
- ptr = skipSpace( ptr );
- switch( *ptr ) {
- // ?????
- case '}':
- switch( i ) {
- case 0:
- case 1:
- dispError( DPCM_PARAMETER_IS_LACKING, lptr[line].filename, line );
- tbl->flag = 0;
- break;
- default:
- line += offset;
- break;
- }
- end_flag = 1;
- break;
- // ??
- case '\0':
- offset++;
- if( line+offset <= lptr->line ) {
- if( (lptr[line+offset].status&_SAME_LINE) == _SAME_LINE ) {
- ptr = lptr[line+offset].str;
- }
- } else {
- dispError( DPCM_DEFINITION_IS_WRONG, lptr[line].filename, line );
- tbl->flag = 0;
- end_flag = 1;
- }
- break;
- default:
- switch( i ) {
- // ????????
- case 0:
- // ??????"..."????????
- if( *ptr == '\"' ) {
- ptr++;
- //ptr = skipSpace( ptr );
- //"file.dmc"?OK. " file.dmc"?NG.
- tbl->fname = ptr;
- while( *ptr != '\"' && *ptr != '\0' ) {
- ptr++;
- }
- } else {
- tbl->fname = ptr;
- //????????????????
- // '/'';'??????
- while( *ptr != ' ' && *ptr != '\t' && *ptr != '\0' ) {
- ptr++;
- }
- }
- *ptr = '\0';
- ptr++;
- // ??????????/???????
- if( (fp = openDmc( tbl->fname )) == NULL ) {
- dispError( DPCM_FILE_NOT_FOUND, lptr[line+offset].filename, line );
- tbl->flag = 0;
- end_flag = 1;
- } else {
- fseek( fp, 0, SEEK_END );
- tbl->size = ftell( fp );
- fseek( fp, 0, SEEK_SET );
- fclose( fp );
- }
- i++;
- break;
- // ????????
- case 1:
- num = Asc2Int( ptr, &cnt );
- if( cnt != 0 && (0 <= num && num <= 15) ) {
- tbl->freq = num;
- } else {
- dispError( DPCM_DEFINITION_IS_WRONG, lptr[line+offset].filename, line );
- tbl->flag = 0;
- end_flag = 1;
- }
- ptr += cnt;
- i++;
- break;
- // ????????
- case 2:
- num = Asc2Int( ptr, &cnt );
- if (cnt != 0 && num == 0) {
- //??0?????????
- ptr += cnt;
- i++;
- break;
- }
- if( cnt != 0 && (0 < num && num < 16384) ) {
- tbl->size = num;
- } else {
- dispError( DPCM_DEFINITION_IS_WRONG, lptr[line+offset].filename, line );
- tbl->flag = 0;
- end_flag = 1;
- }
- ptr += cnt;
- i++;
- break;
- // ???????($4011)??????
- case 3:
- num = Asc2Int(ptr, &cnt);
- if (cnt != 0 && ((0 <= num && num <= 0x7f) || num == 0xff)) {
- tbl->delta_init = num;
- } else {
- dispError( DPCM_DEFINITION_IS_WRONG, lptr[line+offset].filename, line );
- tbl->flag = 0;
- end_flag = 1;
- }
- ptr += cnt;
- i++;
- break;
- // ?????($4010?bit7,6)???
- case 4:
- num = Asc2Int(ptr, &cnt);
- if (cnt != 0 && (0 <= num && num <= 2)) {
- tbl->freq |= (num<<6);
- } else {
- dispError( DPCM_DEFINITION_IS_WRONG, lptr[line+offset].filename, line );
- tbl->flag = 0;
- end_flag = 1;
- }
- ptr += cnt;
- i++;
- break;
- default:
- dispError( DPCM_DEFINITION_IS_WRONG, lptr[line+offset].filename, line );
- tbl->flag = 0;
- end_flag = 1;
- break;
- }
- break;
- }
- ptr = skipSpace( ptr );
- if( *ptr == ',' ) {
- ptr++;
- }
- }
- if( tbl->size > (0xff)*16+1 ) {
- dispError( DPCM_FILE_SIZE_OVER, lptr[line+offset].filename, line );
- tbl->flag = 0;
- } else if ((tbl->size % 16) != 1) {
- dispWarning( DPCM_FILE_SIZE_ERROR, lptr[line+offset].filename, line );
- }
- // DPCM?????_SAME_LINE??????
- } else if( lptr[line].status == (_SET_DPCM_DATA|_SAME_LINE) ) {
- dispError( DPCM_DEFINITION_IS_WRONG, lptr[line].filename, line );
- // ????????????
- } else if( lptr[line].status == _INCLUDE ) {
- getDPCM( lptr[line].inc_ptr );
- }
- }
- }
-
-
-
- /*--------------------------------------------------------------
- FDS FM?????
- Input:
-
- Output:
- ??
- --------------------------------------------------------------*/
- void getFMTone( LINE *lptr )
- {
- int line, i, no, end_flag, offset, num, cnt;
- char *ptr;
-
- cnt = 0;
-
- for( line = 1; line <= lptr->line; line++ ) {
- /* ???????? */
- if( lptr[line].status == _SET_FM_TONE ) {
- no = lptr[line].param; /* ?????? */
- ptr = lptr[line].str;
- ptr++; /* '{'?????? */
- if (fm_tone_tbl[no][0] != 0) {
- dispWarning( THIS_NUMBER_IS_ALREADY_USED, lptr[line].filename, line );
- }
- fm_tone_tbl[no][0] = 0;
- offset = 0;
- i = 1;
- end_flag = 0;
- while( end_flag == 0 ) {
- ptr = skipSpace( ptr );
- switch( *ptr ) {
- case '}':
- if (fm_tone_tbl[no][0] == 64) {
- //OK.
- } else {
- dispError( PARAMETER_IS_LACKING, lptr[line].filename, line );
- fm_tone_tbl[no][0] = 0;
- }
- end_flag = 1;
- line += offset;
- break;
- case '\0':
- offset++;
- if( line+offset <= lptr->line ) {
- if( (lptr[line+offset].status&_SAME_LINE) == _SAME_LINE ) {
- ptr = lptr[line+offset].str;
- }
- } else {
- dispError( FM_TONE_DEFINITION_IS_WRONG, lptr[line].filename, line+offset );
- fm_tone_tbl[no][0] = 0;
- line += offset;
- end_flag = 1;
- }
- break;
- default:
- num = Asc2Int( ptr, &cnt );
- if( cnt != 0 && (0 <= num && num <= 0x3f) ) {
- fm_tone_tbl[no][i] = num;
- fm_tone_tbl[no][0]++;
- ptr += cnt;
- i++;
- if( i > 65 ) {
- dispError( ABNORMAL_PARAMETERS_OF_FM_TONE, lptr[line+offset].filename, line+offset );
- fm_tone_tbl[no][0] = 0;
- line += offset;
- end_flag = 1;
- }
- } else {
- dispError( FM_TONE_DEFINITION_IS_WRONG, lptr[line+offset].filename, line+offset );
- fm_tone_tbl[no][0] = 0;
- line += offset;
- end_flag = 1;
- }
- break;
- }
- ptr = skipSpace( ptr );
- if( *ptr == ',' ) {
- ptr++;
- }
- }
- /* ???????_SAME_LINE?????? */
- } else if( lptr[line].status == (_SET_FM_TONE|_SAME_LINE) ) {
- dispError( FM_TONE_DEFINITION_IS_WRONG, lptr[line].filename, line );
- /* ???????????? */
- } else if( lptr[line].status == _INCLUDE ) {
- getFMTone( lptr[line].inc_ptr );
- }
- }
- }
-
-
- /*--------------------------------------------------------------
- VRC7?????
- Input:
-
- Output:
- ??
- --------------------------------------------------------------*/
- void getVRC7Tone( LINE *lptr )
- {
- int line, i, no, end_flag, offset, num, cnt;
- char *ptr;
-
- cnt = 0;
-
- for( line = 1; line <= lptr->line; line++ ) {
- /* ???????? */
- if( lptr[line].status == _SET_VRC7_TONE ) {
- no = lptr[line].param; /* ?????? */
- ptr = lptr[line].str;
- ptr++; /* '{'?????? */
- if (vrc7_tone_tbl[no][0] != 0) {
- dispWarning( THIS_NUMBER_IS_ALREADY_USED, lptr[line].filename, line );
- }
- vrc7_tone_tbl[no][0] = 0;
- offset = 0;
- i = 1;
- end_flag = 0;
- while( end_flag == 0 ) {
- ptr = skipSpace( ptr );
- switch( *ptr ) {
- case '}':
- if (vrc7_tone_tbl[no][0] == 8) {
- //OK.
- } else {
- dispError( PARAMETER_IS_LACKING, lptr[line].filename, line );
- vrc7_tone_tbl[no][0] = 0;
- }
- end_flag = 1;
- line += offset;
- break;
- case '\0':
- offset++;
- if( line+offset <= lptr->line ) {
- if( (lptr[line+offset].status&_SAME_LINE) == _SAME_LINE ) {
- ptr = lptr[line+offset].str;
- }
- } else {
- dispError( FM_TONE_DEFINITION_IS_WRONG, lptr[line].filename, line+offset );
- vrc7_tone_tbl[no][0] = 0;
- line += offset;
- end_flag = 1;
- }
- break;
- default:
- num = Asc2Int( ptr, &cnt );
- if( cnt != 0 && (0 <= num && num <= 0xff) ) {
- vrc7_tone_tbl[no][i] = num;
- vrc7_tone_tbl[no][0]++;
- ptr += cnt;
- i++;
- if( i > 9 ) {
- dispError( ABNORMAL_PARAMETERS_OF_FM_TONE, lptr[line+offset].filename, line+offset );
- vrc7_tone_tbl[no][0] = 0;
- line += offset;
- end_flag = 1;
- }
- } else {
- dispError( FM_TONE_DEFINITION_IS_WRONG, lptr[line+offset].filename, line+offset );
- vrc7_tone_tbl[no][0] = 0;
- line += offset;
- end_flag = 1;
- }
- break;
- }
- ptr = skipSpace( ptr );
- if( *ptr == ',' ) {
- ptr++;
- }
- }
- if( i != 9 ) {
- if (!error_flag) {
- dispError( ABNORMAL_PARAMETERS_OF_FM_TONE, lptr[line].filename, line);
- vrc7_tone_tbl[no][0] = 0;
- }
- }
-
-
- /* ???????_SAME_LINE?????? */
- } else if( lptr[line].status == (_SET_VRC7_TONE|_SAME_LINE) ) {
- dispError( FM_TONE_DEFINITION_IS_WRONG, lptr[line].filename, line );
- /* ???????????? */
- } else if( lptr[line].status == _INCLUDE ) {
- getVRC7Tone( lptr[line].inc_ptr );
- }
- }
- }
-
-
-
- /*--------------------------------------------------------------
- namco106?????
- Input:
-
- Output:
- ??
- --------------------------------------------------------------*/
- void getN106Tone( LINE *lptr )
- {
- int line, i, no, end_flag, offset, num, cnt;
- char *ptr;
- // 16 14 12 10 8 6 4 2
- int n106_tone_max[] = { 4, 4, 5, 6, 8,10,16,32 };
- int n106_tone_num;
-
- cnt = 0;
- for( line = 1; line <= lptr->line; line++ ) {
- /* ???????? */
- if( lptr[line].status == _SET_N106_TONE ) {
- no = lptr[line].param; /* ?????? */
- ptr = lptr[line].str;
- ptr++; /* '{'?????? */
- if (n106_tone_tbl[no][0] != 0) {
- dispWarning( THIS_NUMBER_IS_ALREADY_USED, lptr[line].filename, line );
- }
- n106_tone_tbl[no][0] = 0;
- offset = 0;
- i = 1;
- end_flag = 0;
- while( end_flag == 0 ) {
- ptr = skipSpace( ptr );
- switch( *ptr ) {
- case '}':
- //?????while??????????
- end_flag = 1;
- line += offset;
- break;
- case '\0':
- offset++;
- if( line+offset <= lptr->line ) {
- …
Large files files are truncated, but you can click here to view the full file