Kyra/Opcodes

From ScummVM :: Wiki
< Kyra
Revision as of 19:32, 15 June 2005 by Clem (talk | contribs) (pointing out inconsistency in numbering some more, putting org numbers after text again for reference, adding note for 0F)
Jump to navigation Jump to search

This page is a work-in-progress document listing VM opcodes of the Kyrandia games. Unless otherwise noted, these opcodes are based on Kyrandia 1. Cyx created the list of Cmd functions, clem and Lordhoto will try to fill in parameters and usage notes. If you have any additions, contact the ScummVM team on IRC.

Hint: To disable an opcode/command pair in the compiled scripts, overwrite it with 4C 00 (add sp,00).

Opcodes

There are more complete disassemblers around, will add their info ASAP.

 44 = push
 45 = ? compare [sp], [xx] ?
 49 = ? copy [xx], [sp] ?
 4C = add sp,xx   ; what would be dec sp,xx? maybe 4B or 4E?
 4E = execute command (see below)

Commands

There's still a little confusion about the numbering, so don't take anything below for granted.

 00?	Cmd_Magic_In_Mouse_Item		00
 01	Cmd_Character_Says			3 args (unk, unk, stringID) - also see 34
 02?	Cmd_Pause_Ticks			02
 03?	Cmd_Draw_Scene_Anim_Shape	03
 04?	Cmd_Query_Game_Flag		04
 05?	Cmd_Set_Game_Flag		05
 06?	Cmd_Reset_Game_Flag		06
 07?	Cmd_Run_NPC_Script		07
 08?	Cmd_Set_Special_Exit_List	08
 09?	Cmd_Block_In_Walkable_Region	09
 0A?	Cmd_Block_Out_Walkable_Region	0A
 0B	Cmd_Walk_Player_To_Point		4 args (unk, x, x, y) - x may be be greater than 0xFF, y must not, so only 1 byte for that
 0C?	Cmd_Drop_Item_In_Scene		0C
 0D	Cmd_Draw_Anim_Shape_Into_Scene		4 args (remove item from screen?) (removes note from desk)
 0E	Cmd_Create_Mouse_Item			1 arg  (itemID) - pick up item; ie mousecursor=item id
 0F	Cmd_Save_Page_To_Disk			tries to write sth to disk, filename = string ID of last push
 
 10?	Cmd_Load_Page_From_Disk		10
 11?	Cmd_Scene_Anim_On		11
 12?	Cmd_Scene_Anim_Off		12
 13?	Cmd_Elapsed_Seconds		13
 14?	Cmd_Mouse_Is_Pointer		14
 15?	Cmd_Destroy_Mouse_Item		15
 16?	Cmd_Run_Scene_Anim_Until_Done	16
 17?	Cmd_Fade_Special_Palette	17
 18?	Cmd_Play_AdLib_Sound		18
 19?	Cmd_Play_AdLib_Score		19
 1A?	Cmd_Phase_In_Same_Scene		1A
 1B?	Cmd_Set_Scene_Phasing_Flag	1B
 1C?	Cmd_Reset_Scene_Phasing_Flag	1C
 1D?	Cmd_Query_Scene_Phasing_Flag	1D
 1E?	Cmd_Scene_To_Direction		1E
 1F?	Cmd_Set_Birthstone_Gem		1F
 
 20?	Cmd_Place_Item_In_Generic_Map_Scene	20
 21?	Cmd_Set_Brandon_Status_Bit		21
 22?	Cmd_Pause_Seconds			22
 23?	Cmd_Get_Characters_Location		23
 24?	Cmd_Run_NPC_Subscript			24
 25?	Cmd_Magic_Out_Mouse_Item		25 // I think this is really "24", clears mouse cursor, plays magic sound
 26?	Cmd_Internal_Anim_On			26
 27?	Cmd_Force_Brandon_To_Normal		27
 28?	Cmd_Poison_Death_Now			28
 29?	Cmd_Set_Scale_Mode			29
 28 looks more like "Cmd_Set_Scale_Mode", when executing it Brandon becomes tiny
 note: this looks more like 2A, check numbering
 29              4               ; play WSA file? (or just load it? coords?)
 2A?	Cmd_Open_WSA_File			2A // I think this should be '29', so there's another problem here
 2B?	Cmd_Close_WSA_File			2B
 2C?	Cmd_Run_WSA_From_Beginning_To_End	2C
 2D?	Cmd_Display_WSA_Frame			2D
 2E?	Cmd_Enter_New_Scene			2E
 2F?	Cmd_Set_Special_Enter_X_And_Y		2F
 
 30?	Cmd_Run_WSA_Frames			30
 31?	Cmd_Pop_Brandon_Into_Scene		31
 32?	Cmd_Restore_All_Object_Backgrounds	32
 33?	Cmd_Set_Custom_Palette_Range		33
 34	Cmd_Custom_Print_Talk_String		4 args (color, unk, unk, stringid) - see also 01
 35	Cmd_Restore_Custom_Print_Background	0 args ; restore text background?
 36	Cmd_Hide_Mouse				0 args
 37	Cmd_Show_Mouse				0 args
 38?	Cmd_Get_Character_X			38
 39?	Cmd_Get_Character_Y			39
 3A?	Cmd_Change_Characters_Facing		3A
 3B?	Cmd_Copy_WSA_Region			3B
 3C	Cmd_Text_Print				// (y,x,stringID) debug message? - debug only?
 3D?	Cmd_Random				3D
 3E?	Cmd_Load_Sound_File			3E
 3F?	Cmd_Display_WSA_Frame_On_HidPage	3F
 
 40?	Cmd_Display_WSA_Sequential_Frames	40
 41?	Cmd_Draw_Character_Standing		41
 42?	Cmd_Internal_Anim_Off			42
 43?	Cmd_Change_Characters_X_And_Y		43
 44?	Cmd_Clear_Scene_Animator_Beacon		44
 45?	Cmd_Query_Scene_Animator_Beacon		45
 46?	Cmd_Refresh_Scene_Animator		46
 47?	Cmd_Place_Item_In_Off_Scene		47
 48	Cmd_Wipe_Down_Mouse_Item			// destroys picked up item, sets mouse cursor to normal
 49?	Cmd_Place_Character_In_Other_Scene	49
 4A?	Cmd_Get_Key				4A
 4B?	Cmd_Specific_Item_In_Inventory		4B
 4C?	Cmd_Pop_Mobile_NPC_Into_Scene		4C
 4D?	Cmd_Mobile_Character_In_Scene		4D
 4E?	Cmd_Hide_Mobile_Character		4E
 4F?	Cmd_Unhide_Mobile_Character		4F
 
 50?	Cmd_Set_Characters_Location		50
 51?	Cmd_Walk_Character_To_Point		51
 52?	Cmd_Special_Event_Display_Brynns_Note	52
 53?	Cmd_Special_Event_Remove_Brynns_Note	53
 54?	Cmd_Set_Logic_Page			54
 55?	Cmd_Fat_Print				55
 
 Cmd_Preserve_All_Object_Backgrounds		// 0x57
 Cmd_Update_Scene_Animations			// 0x58
 Cmd_Scene_Animation_Active			// 0x59
 Cmd_Set_Characters_Movement_Delay		// 0x5A
 Cmd_Get_Characters_Facing			// 0x5B
 Cmd_Bkgd_Scroll_Scene_And_Masks_Right		// 0x5C
 Cmd_Find_Brightest_Fireberry			// 0x5D
 Cmd_Set_Fireberry_Glow_Palette		// 0x5E
 Cmd_Set_Death_Handler_Flag			// 0x5F
 
 60	Cmd_Drink_Potion_Animation		// 0x60
 61	Cmd_Make_Amulet_Appear			// 0x61 // used in altar.emc?
 Cmd_Draw_Item_Shape_Into_Scene		// 0x62
 Cmd_Set_Characters_Current_Frame		// 0x63
 64	Cmd_Wait_For_Confirmation_Mouse_Click		// 0x64
 Cmd_Page_Flip					// 0x65
 Cmd_Set_Scene_File				// 0x66
 Cmd_What_Item_In_Marble_Vase			// 0x67
 Cmd_Set_Item_In_Marble_Vase			// 0x68
 Cmd_Add_Item_To_Inventory			// 0x69
 6A	Cmd_Int_Print				// 0x6A // prints last pushed value to top left corner? (debug only?)
 6B	Cmd_Shake_Screen			// 0x6B
 6C	Cmd_Create_Amulet_Jewel			// 0x6C (last param pushed before: 01=yellow, 02=red, 03=pink, 04=blue)
 Cmd_Set_Scene_Anim_Curr_XY			// 0x6D
 6E	Cmd_Poison_Brandon_And_Remaps		// 0x6E
 6F	Cmd_Fill_Flask_With_Water		// 0x6F
 
 Cmd_Get_Characters_Movement_Delay		// 0x70
 Cmd_Get_Birthstone_Gem			// 0x71
 Cmd_Query_Brandon_Status_Bit			// 0x72
 73	Cmd_Play_Flute_Animation		// 0x73
 74	Cmd_Play_Winter_Scroll_Sequence		// 0x74
 Cmd_Get_Idol_Gem				// 0x75
 Cmd_Set_Idol_Gem				// 0x76
 Cmd_Total_Items_In_Scene			// 0x77
 Cmd_Restore_Brandons_Movement_Delay		// 0x78
 Cmd_Set_Mouse_Pos				// 0x79
 Cmd_Get_Mouse_State				// 0x7A
 Cmd_Set_Entrance_Mouse_Cursor_Track		// 0x7B
 Cmd_Item_Appears_On_Ground			// 0x7C
 Cmd_Set_No_Draw_Shapes_Flag			// 0x7D
 Cmd_Fade_Entire_Palette			// 0x7E
 Cmd_Item_On_Ground_Here			// 0x7F
 
 Cmd_Query_Cauldron_State			// 0x80
 Cmd_Set_Cauldron_State			// 0x81
 Cmd_Query_Crystal_State			// 0x82
 Cmd_Set_Crystal_State				// 0x83
 Cmd_Set_Palette_Range				// 0x84
 85	Cmd_Shrink_Brandon_Down			// 0x85
 86	Cmd_Grow_Brandon_Up			// 0x86
 Cmd_Set_Brandon_Scale_X_And_Y			// 0x87
 Cmd_Reset_Scale_Mode				// 0x88
 Cmd_Get_Scale_Depth_Table_Value		// 0x89
 Cmd_Set_Scale_Depth_Table_Value		// 0x8A
 8B	Cmd_Message					// 0x8B - set room name/status text (unk, stringID)
 Cmd_Check_Click_On_NPC			// 0x8C
 Cmd_Get_Foyer_Item				// 0x8D
 Cmd_Set_Foyer_Item				// 0x8E
 Cmd_Dispel_Magic_Animation			// 0x8F
 
 Cmd_Set_No_Item_Drop_Region			// 0x90
 Cmd_Walk_Malcolm_On				// 0x91
 91	Cmd_Passive_Protection		0 args	// 0x92
 Cmd_Set_Playing_Loop				// 0x93
 93	Cmd_Brandon_To_Stone_Sequence	0 args	// 0x94
 94	Cmd_Brandon_Healing_Sequence		// 0x95
 Cmd_Protect_Command_Line			// 0x96
 Cmd_Pause_Music_Seconds			// 0x97
 Cmd_Reset_Mask_Region				// 0x98
 Cmd_Set_Palette_Change_Flag			// 0x99
 Cmd_Fill_Rect					// 0x9A
 Cmd_Dummy					// 0x9B