📄 ifo.c
字号:
case 0x05: printf( "PTT 0x%02x", OP_VAL_16(2) ); break; case 0x06: printf( "Program 0x%02x this PGC", OP_VAL_8(5) ); break; case 0x07: printf( "Cell 0x%02x this PGC", OP_VAL_8(5) ); break; default: return; } if( i_button ) { printf( ", Highlight 0x%02x", OP_VAL_8(4)>>2 ); }}void IfoSetSystem( ifo_command_t com ){ switch( com.i_cmd ) { case 1: { int i; for( i=1; i<=3; i++ ) { if( OP_VAL_8(i)&0x80 ) { if( com.i_direct ) { printf ("s[%s] = 0x%02x;", ifo_reg[i], OP_VAL_8(i)&0xf); } else { printf ("s[%s] = r[0x%02x];", ifo_reg[i], OP_VAL_8(i)&0xf); } } }#if 0 if(op->direct) { if(OP_VAL_8(1]&0x80) printf ("s[%s] = 0x%02x;", reg_name[1], OP_VAL_8(1]&0xf); if(OP_VAL_8(2)&0x80)/*DENT: lwhat about 0x7f here ??? */ printf ("s[%s] = 0x%02x;", reg_name[2], OP_VAL_8(2)&0x7f); if(OP_VAL_8(3)&0x80) printf ("s[%s] = 0x%02x;", reg_name[3], OP_VAL_8(3)&0xf); } else { if(OP_VAL_8(1)&0x80) printf ("s[%s] = r[0x%02x];", reg_name[1], OP_VAL_8(1)&0xf); if(OP_VAL_8(2)&0x80) printf ("s[%s] = r[0x%02x];", reg_name[2], OP_VAL_8(2)&0xf); if(OP_VAL_8(3)&0x80) printf ("s[%s] = r[0x%02x];", reg_name[3], OP_VAL_8(3)&0xf); }#endif } break; case 2: if( com.i_direct ) { printf( "s[%s] = 0x%02x", ifo_reg[9], OP_VAL_16(0) ); } else { printf( "s[%s] = r[0x%02x]", ifo_reg[9], OP_VAL_8(1)&0x0f ); } printf( "s[%s] = (s[%s]&0x7FFF)|0x%02x", ifo_reg[10], ifo_reg[10], OP_VAL_16(1)&0x8000); break; case 3: if( com.i_direct ) { printf( "r[0x%02x] = 0x%02x", OP_VAL_8(3)&0x0f, OP_VAL_16(0) ); } else { printf ("r[r[0x%02x]] = r[0x%02x]", OP_VAL_8(3)&0x0f, OP_VAL_8(1)&0x0f); } break; case 4: /*actually only bits 00011100 00011100 are set */ if( com.i_direct ) { printf ("s[%s] = 0x%02x", ifo_reg[11], OP_VAL_16(1)); } else { printf ("s[%s] = r[0x%02x]", ifo_reg[11], OP_VAL_8(3)&0x0f ); } break; case 6: /*actually, */ /*s[%s]=(r[%s]&0x3FF) | (0x%02x << 0xA); */ /*but it is way too ugly */ if( com.i_direct ) { printf( "s[%s] = 0x%02x", ifo_reg[8], OP_VAL_8(2)>>2 ); } else { printf( "s[%s] = r[0x%02x]", ifo_reg[8], OP_VAL_8(3)&0x0f ); } break; default: printf ("unknown"); }}static void IfoSet( ifo_command_t com ){ IfoRegister( OP_VAL_16(0), 0 ); printf( " %s ", IfoMath( com.i_cmd ) ); IfoRegister( OP_VAL_16(1), com.i_direct );}/***************************************************************************** * CommandRead : translates the command strings in ifo into command * structures. *****************************************************************************/void CommandRead( ifo_command_t com ){ uint8_t * pi_code = (uint8_t*)(&com); switch( com.i_type ) { /* Goto */ case 0: /* Main command */ if( !pi_code[1] ) { printf( "NOP\n" ); } else { if( com.i_cmp ) { printf ("if (r[0x%02x] %s ", OP_VAL_8(1)&0x0f, ifo_cmp[com.i_cmp]); IfoRegister (OP_VAL_16(1), com.i_dir_cmp); printf (") "); } /* Sub command */ switch( com.i_sub_cmd ) { case 1: printf( "goto Line 0x%02x", OP_VAL_16(2) ); break; case 2: printf( "stop VM" ); break; case 3: printf( "Set Parental Level To %s and goto Line 0x%02x", ifo_parental[OP_VAL_8(4)&0x7], OP_VAL_8(5) ); break; default: printf( "Illegal" ); break; } } break; /* Lnk */ case 1: /* Main command */ if( !pi_code[1] ) { printf( "NOP\n" ); } else { if( com.i_direct ) { if( com.i_cmp ) { printf( "if (r[0x%02x] %s ", OP_VAL_8(4)&0x0f, ifo_cmp[com.i_cmp] ); IfoRegister( OP_VAL_8(5), 0 ); printf( ") " ); } /* Sub command */ IfoJmp( com ); } else { if( com.i_cmp ) { printf( "if (r[0x%02x] %s ", OP_VAL_8(1)&0x0f, ifo_cmp[com.i_cmp] ); IfoRegister( OP_VAL_16(1), com.i_dir_cmp ); printf( ") " ); } /* Sub command */ IfoLnk( com ); } } break; /* SetSystem */ case 2: if( !pi_code[1] ) { IfoSetSystem( com ); } else if( com.i_cmp && !com.i_sub_cmd ) { printf ("if (r[0x%02x] %s ", OP_VAL_8(4)&0x0f, ifo_cmp[com.i_cmp]); IfoRegister( OP_VAL_8(5), 0 ); printf (") "); IfoSetSystem( com ); } else if( !com.i_cmp && com.i_sub_cmd ) { printf( "if (" ); IfoSetSystem( com ); printf( ") " ); IfoLnk( com ); } else { printf("nop"); } break; /* Set */ case 3: if( ! pi_code[1] ) { IfoSet( com ); } else if( com.i_cmp && !com.i_sub_cmd ) { printf ("if (r[0x%02x] %s ", OP_VAL_8(0)&0x0f, ifo_cmp[com.i_cmp]); IfoRegister( OP_VAL_16(2), com.i_dir_cmp ); printf (") "); IfoSet( com ); } else if( !com.i_cmp && com.i_sub_cmd ) { printf ("if ("); IfoSet( com ); printf (") "); IfoLnk( com ); } else { printf( "nop" ); } break; /* * math command on r[opcode[1]] and * direct?be2me_16(OP_VAL_8(0)):reg[OP_VAL_8(1)] is executed * ( unless command is swap; then r[opcode[1]] and r[OP_VAL_8(1)] * are swapped ) * boolean operation cmp on r[opcode[1]] and * dir_cmp?be2me_16(OP_VAL_8(1)[1]):reg[OP_VAL_8(3)] is executed * on true result, buttons(c[6], c[7]) is called * problem is 'what is buttons()' */ case 4: printf( "r[0x%X] ", pi_code[1] ); printf( " %s ", IfoMath( com.i_cmd ) ); if( com.i_cmd == 2 ) { printf( "r[0x%X] ", OP_VAL_8(1) ); } else { IfoRegister( OP_VAL_16(0), com.i_direct ); } printf("; "); printf( "if ( r[%d] %s ", pi_code[1], ifo_cmp[com.i_cmp] ); IfoRegister( OP_VAL_8(1), com.i_dir_cmp ); printf( " ) then {" ); IfoAdvanced( &OP_VAL_8(4) ); printf( "}" ); break; /* * opposite to case 4: boolean, math and buttons. */ case 5: case 6: printf("if ("); if( !com.i_direct && com.i_dir_cmp ) { printf( "0x%X", OP_VAL_16(1) ); } else { IfoRegister( OP_VAL_8(3), 0 ); if( OP_VAL_8(3)&0x80 ) { printf( "s[%s]", ifo_reg[OP_VAL_8(3)&0x1F] ); } else { printf( "r[0x%X]", OP_VAL_8(3)&0x1F); /* 0x1F is either not a mistake, */ /* or Microsoft programmer's mistake!!! */ } } printf( " %s r[0x%X] ", ifo_cmp[com.i_cmp], com.i_direct ? OP_VAL_8(2) : OP_VAL_8(1) ); printf( " ) then {" ); printf( "r[0x%X] ", pi_code[1] & 0xF ); printf( " %s ", IfoMath( com.i_cmd ) ); if( com.i_cmd == 0x02 ) /* swap */ { printf("r[0x%X] ", OP_VAL_8(0)&0x1F); } else { if( com.i_direct ) { printf( "0x%X", OP_VAL_16(0) ); } else { if( OP_VAL_8(0) & 0x80 ) { printf("s[%s]", ifo_reg[OP_VAL_8(0) & 0x1F] ); } else { printf("r[0x%X]", OP_VAL_8(0) & 0x1F ); } } } printf("; "); IfoAdvanced( &OP_VAL_8(4) ); printf("}"); break; default: printf( "Unknown Command\n" ); break; } return;}/***************************************************************************** * CommandPrint : print in clear text (I hope so !) what a command does *****************************************************************************/void CommandPrint( ifo_t ifo ){ return;}#endif/***************************************************************************** * ReadByte and so *****************************************************************************/static uint8_t* FillBuffer( ifo_t* p_ifo, uint8_t* p_buf, int i_pos ){ p_ifo->i_pos = dvdcss_seek( p_ifo->dvdhandle, i_pos, DVDCSS_NOFLAGS ); dvdcss_read( p_ifo->dvdhandle, p_buf, 1, DVDCSS_NOFLAGS ); return p_buf;}static void ReadBytes( ifo_t* p_ifo, uint8_t* p_buf, uint8_t** pp_tmp, uint8_t* pi_dest, int i_nb ){ if( i_nb > DVD_LB_SIZE ) {#if 0 intf_Err( p_input, "excessive ReadBytes call (%i)", i_nb );#endif } if( *pp_tmp + i_nb >= p_buf + DVD_LB_SIZE ) { int i_spare = (int)( (p_buf + DVD_LB_SIZE) - *pp_tmp ); /* Copy the bytes remaining in the current buffer */ memcpy( pi_dest, *pp_tmp, i_spare ); pi_dest += i_spare; i_nb -= i_spare; /* Load the next buffer */ *pp_tmp = FillBuffer( p_ifo, p_buf, p_ifo->i_pos + 1 ); } memcpy( pi_dest, *pp_tmp, i_nb ); *pp_tmp += i_nb; return;}static void DumpBytes( ifo_t* p_ifo, uint8_t* p_buf, uint8_t** pp_tmp, int i_nb ){ if( i_nb > DVD_LB_SIZE ) {#if 0 intf_Er
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -