1#[cfg(feature = "serde")]
2use serde::{Serialize, Deserialize};
3use crate::byte_utils::as_u32_be;
4use show_choice_command::ShowChoiceCommand;
5use show_text_command::ShowTextCommand;
6use crate::command::chip_management_command::ChipManagementCommand;
7use crate::command::common_event_command::CommonEventCommand;
8use crate::command::db_management_command::DBManagementCommand;
9use crate::command::effect_command::EffectCommand;
10use crate::command::event_control_command::EventControlCommand;
11use crate::command::input_key_command::InputKeyCommand;
12use crate::command::number_condition_command::NumberConditionCommand;
13use crate::command::party_graphics_command::PartyGraphicsCommand;
14use crate::command::picture_command::PictureCommand;
15use crate::command::save_load_command::SaveLoadCommand;
16use crate::command::set_string_command::SetStringCommand;
17use crate::command::set_variable_command::SetVariableCommand;
18use crate::command::set_variable_plus_command::SetVariablePlusCommand;
19use crate::command::signature::Signature;
20use crate::command::sound_command::SoundCommand;
21use crate::command::string_condition_command::StringConditionCommand;
22use crate::command::transfer_command::TransferCommand;
23
24pub mod show_choice_command;
25pub mod show_text_command;
26pub mod set_variable_command;
27pub mod db_management_command;
28pub mod common;
29pub mod set_string_command;
30pub mod set_variable_plus_command;
31pub mod number_condition_command;
32pub mod string_condition_command;
33pub mod input_key_command;
34pub mod picture_command;
35pub mod effect_command;
36pub mod sound_command;
37pub mod save_load_command;
38pub mod party_graphics_command;
39pub mod chip_management_command;
40pub mod transfer_command;
41pub mod event_control_command;
42pub mod common_event_command;
43mod signature;
44
45#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
51#[derive(PartialEq, Clone)]
52pub enum Command {
53 ShowMessage(ShowTextCommand),
54 Comment(ShowTextCommand),
55 DebugText(ShowTextCommand),
56 ForceCloseMessage(),
57 ClearDebugText(),
58 ShowChoice(ShowChoiceCommand),
59 SetVariable(SetVariableCommand),
60 DBManagement(DBManagementCommand),
61 SetString(SetStringCommand),
62 SetVariablePlus(SetVariablePlusCommand),
63 NumberCondition(NumberConditionCommand),
64 StringCondition(StringConditionCommand),
65 InputKey(InputKeyCommand),
66 Picture(PictureCommand),
67 Effect(EffectCommand),
68 Sound(SoundCommand),
69 SaveLoad(SaveLoadCommand),
70 PartyGraphics(PartyGraphicsCommand),
71 ChipManagement(ChipManagementCommand),
72 Transfer(TransferCommand),
73 EventControl(EventControlCommand),
74 CommonEvent(CommonEventCommand),
75 Checkpoint(),
76 Exit(),
77}
78
79impl Command {
80 pub fn parse(bytes: &[u8]) -> (usize, u32, Self) {
95 let mut offset: usize = 0;
96 let commands: u32 = 1;
97
98 let signature: u32 = as_u32_be(&bytes[offset..offset+4]);
99 offset += 4;
100 offset += 1; let command_parser: fn(&[u8], u32) -> (usize, u32, Self) = match Signature::new(signature) {
103 Signature::ShowMessage => Self::parse_show_message,
104 Signature::Comment => Self::parse_comment,
105 Signature::DebugText => Self::parse_debug_text,
106 Signature::ForceCloseMessage => Self::parse_force_close_message,
107 Signature::ClearDebugText => Self::parse_clear_debug_text,
108 Signature::ShowChoice => Self::parse_show_choice,
109 Signature::SetVariableBase => Self::parse_set_variable_base,
110 Signature::SetVariableRange => Self::parse_set_variable_range,
111 Signature::SetVariableDB => Self::parse_set_variable_db,
112 Signature::DBManagementBase => Self::parse_db_management_base,
113 Signature::DBManagementString => Self::parse_db_management_string,
114 Signature::DBManagementCsv => Self::parse_db_management_csv,
115 Signature::SetStringBase => Self::parse_set_string_base,
116 Signature::SetStringDynamic => Self::parse_set_string_dynamic,
117 Signature::SetVariablePlusBase => Self::parse_set_variable_plus_base,
118 Signature::SetVariablePlusOther => Self::parse_set_variable_plus_other,
119
120 Signature::NumberCondition | Signature::NumberConditionDouble |
121 Signature::NumberConditionTriple => Self::parse_number_condition,
122
123 Signature::StringCondition | Signature::StringConditionTwo |
124 Signature::StringConditionThree | Signature::StringConditionFour |
125 Signature::StringConditionFive | Signature::StringConditionSix |
126 Signature::StringConditionSeven | Signature::StringConditionEight
127 => Self::parse_string_condition,
128
129 Signature::InputKeyBase => Self::parse_input_key_base,
130 Signature::InputKeyKeyboardOrPad => Self::parse_input_key_keyboard_or_pad,
131
132 Signature::AutomaticInputBasic | Signature::AutomaticInputMouse
133 => Self::parse_automatic_input_base,
134
135 Signature::AutomaticInputKeyboard => Self::parse_automatic_input_keyboard,
136
137 Signature::InputToggleBasic | Signature::InputToggleDevice
138 => Self::parse_input_toggle,
139
140 Signature::PictureShowBase | Signature::PictureShowBaseByVar
141 => Self::parse_picture_show_base,
142
143 Signature::PictureShowColors => Self::parse_picture_show_colors,
144 Signature::PictureShowDelay => Self::parse_picture_show_delay,
145 Signature::PictureShowRange => Self::parse_picture_show_range,
146 Signature::PictureShowColorValues => Self::parse_picture_show_color_values,
147 Signature::PictureShowZoom => Self::parse_picture_show_zoom,
148 Signature::PictureShowFreeTransform => Self::parse_picture_show_free_transform,
149 Signature::PictureEraseDelayReset => Self::parse_picture_erase_delay_reset,
150 Signature::PictureEraseBase => Self::parse_picture_erase_base,
151 Signature::PictureEraseDelay => Self::parse_picture_erase_delay,
152 Signature::PictureEraseRange => Self::parse_picture_erase_range,
153 Signature::EffectBase => Self::parse_effect_base,
154 Signature::EffectMapShake => Self::parse_effect_map_shake,
155 Signature::EffectScrollScreen => Self::parse_effect_scroll_screen,
156 Signature::EffectChangeColor => Self::parse_effect_change_color,
157
158 Signature::SoundFilename | Signature::SoundFilenameSe => Self::parse_sound_filename,
159
160 Signature::SoundVariable => Self::parse_sound_variable,
161
162 Signature::SoundFreeAll | Signature::SoundFreeAllVariable => Self::parse_sound_free_all,
163
164 Signature::SaveLoadBase => Self::parse_save_load_base,
165 Signature::LoadVariable => Self::parse_load_variable,
166 Signature::SaveVariable => Self::parse_save_variable,
167
168 Signature::PartyGraphicsBase | Signature::PartyGraphicsVariable |
169 Signature::PartyGraphicsNoMember => Self::parse_party_graphics,
170
171 Signature::ChipManagementSettings => Self::parse_chip_management_settings,
172 Signature::ChipManagementSwitchSet => Self::parse_chip_management_switch_set,
173 Signature::ChipManagementOverwrite => Self::parse_chip_management_overwrite,
174 Signature::Transfer => Self::parse_transfer,
175 Signature::Loop => Self::parse_loop,
176 Signature::BreakLoop => Self::parse_break_loop,
177 Signature::GotoLoopStart => Self::parse_goto_loop_start,
178 Signature::PrepareTransition => Self::parse_prepare_transition,
179 Signature::ExecuteTransition => Self::parse_execute_transition,
180 Signature::SetTransition => Self::parse_set_transition,
181 Signature::Move => Self::parse_move,
182 Signature::WaitForMove => Self::parse_wait_for_move,
183 Signature::MoveDuringEventsOn => Self::parse_move_during_events_on,
184 Signature::MoveDuringEventsOff => Self::parse_move_during_events_off,
185 Signature::GotoTitle => Self::parse_goto_title,
186 Signature::GameEnd => Self::parse_game_end,
187 Signature::StopNonPictureGraphicUpdates => Self::parse_stop_non_picture_graphic_updates,
188 Signature::ResumeNonPictureGraphicUpdates
189 => Self::parse_resume_non_picture_graphic_updates,
190 Signature::ForceExitEvent => Self::parse_force_exit_event,
191 Signature::EraseEvent => Self::parse_erase_event,
192 Signature::Wait => Self::parse_wait,
193 Signature::LoopCount => Self::parse_loop_count,
194 Signature::LabelPoint => Self::parse_label_point,
195 Signature::LabelJump => Self::parse_label_jump,
196
197 Signature::CallEvent1 | Signature::CallEvent2 |
198 Signature::CallEvent3 | Signature::CallEventByName1 |
199 Signature::CallEventByName2 | Signature::CallEventByName3 |
200 Signature::CallEventByName4 | Signature::CallEventByName5 |
201 Signature::CallEventByName6 | Signature::CallEventByName7 |
202 Signature::CallEventByVariable1 | Signature::CallEventByVariable2
203 => Self::parse_call_common_event,
204
205 Signature::ReserveEvent => Self::parse_reserve_common_event,
206
207 Signature::Checkpoint => Self::parse_checkpoint,
208 Signature::Exit => Self::parse_exit,
209 _ => |_: &[u8], signature: u32| {
210 panic!("Unknown command code {:08x}", signature)
211 }
212 };
213
214 let (bytes_read, commands_read, command): (usize, u32, Self)
215 = command_parser(&bytes[offset..], signature);
216
217 (offset + bytes_read, commands + commands_read, command)
218 }
219
220 pub fn parse_multiple(bytes: &[u8]) -> (usize, u32, Vec<Command>) {
235 let mut offset: usize = 0;
236 let mut command_count: u32 = 0;
237 let mut commands: Vec<Command> = vec![];
238
239 let mut exit: bool = false;
240
241 while !exit {
242 let (bytes_read, commands_read, command): (usize, u32, Command)
243 = Command::parse(&bytes[offset..]);
244
245 exit = matches!(command, Command::Exit());
246
247 offset += bytes_read;
248 command_count += commands_read;
249 commands.push(command);
250 }
251
252 (offset, command_count, commands)
253 }
254
255 fn parse_show_message(bytes: &[u8], _: u32) -> (usize, u32, Self) {
256 let (bytes_read, command): (usize, ShowTextCommand) = ShowTextCommand::parse(bytes);
257
258 (bytes_read, 0, Command::ShowMessage(command))
259 }
260
261 fn parse_comment(bytes: &[u8], _: u32) -> (usize, u32, Self) {
262 let (bytes_read, command): (usize, ShowTextCommand) = ShowTextCommand::parse(bytes);
263
264 (bytes_read, 0, Command::Comment(command))
265 }
266
267 fn parse_debug_text(bytes: &[u8], _: u32) -> (usize, u32, Self) {
268 let (bytes_read, command): (usize, ShowTextCommand) = ShowTextCommand::parse(bytes);
269
270 (bytes_read, 0, Command::DebugText(command))
271 }
272
273 fn parse_force_close_message(_: &[u8], _: u32) -> (usize, u32, Self) {
274 Self::parse_empty(Self::ForceCloseMessage())
275 }
276
277 fn parse_clear_debug_text(_: &[u8], _: u32) -> (usize, u32, Self) {
278 Self::parse_empty(Self::ClearDebugText())
279 }
280
281 fn parse_show_choice(bytes: &[u8], _: u32) -> (usize, u32, Self) {
282 let (bytes_read, commands_read, command): (usize, u32, ShowChoiceCommand)
283 = ShowChoiceCommand::parse(bytes);
284
285 (bytes_read, commands_read, Command::ShowChoice(command))
286 }
287
288 fn parse_set_variable_base(bytes: &[u8], _: u32) -> (usize, u32, Self) {
289 let (bytes_read, command): (usize, SetVariableCommand)
290 = SetVariableCommand::parse_base(bytes);
291
292 (bytes_read, 0, Command::SetVariable(command))
293 }
294
295 fn parse_set_variable_range(bytes: &[u8], _: u32) -> (usize, u32, Self) {
296 let (bytes_read, command): (usize, SetVariableCommand)
297 = SetVariableCommand::parse_range(bytes);
298
299 (bytes_read, 0, Command::SetVariable(command))
300 }
301
302 fn parse_set_variable_db(bytes: &[u8], _: u32) -> (usize, u32, Self) {
303 let (bytes_read, command): (usize, SetVariableCommand)
304 = SetVariableCommand::parse_db(bytes);
305
306 (bytes_read, 0, Command::SetVariable(command))
307 }
308
309 fn parse_db_management_base(bytes: &[u8], _: u32) -> (usize, u32, Self) {
310 let (bytes_read, command): (usize, DBManagementCommand)
311 = DBManagementCommand::parse_base(bytes);
312
313 (bytes_read, 0, Command::DBManagement(command))
314 }
315
316 fn parse_db_management_string(bytes: &[u8], _: u32) -> (usize, u32, Self) {
317 let (bytes_read, command): (usize, DBManagementCommand)
318 = DBManagementCommand::parse_string(bytes);
319
320 (bytes_read, 0, Command::DBManagement(command))
321 }
322
323 fn parse_db_management_csv(bytes: &[u8], _: u32) -> (usize, u32, Self) {
324 let (bytes_read, command): (usize, DBManagementCommand)
325 = DBManagementCommand::parse_csv(bytes);
326
327 (bytes_read, 0, Command::DBManagement(command))
328 }
329
330 fn parse_set_string_base(bytes: &[u8], _: u32) -> (usize, u32, Self) {
331 let (bytes_read, command): (usize, SetStringCommand) = SetStringCommand::parse_base(bytes);
332
333 (bytes_read, 0, Command::SetString(command))
334 }
335
336 fn parse_set_string_dynamic(bytes: &[u8], _: u32) -> (usize, u32, Self) {
337 let (bytes_read, command): (usize, SetStringCommand)
338 = SetStringCommand::parse_dynamic(bytes);
339
340 (bytes_read, 0, Command::SetString(command))
341 }
342
343 fn parse_set_variable_plus_base(bytes: &[u8], _: u32) -> (usize, u32, Self) {
344 let (bytes_read, command): (usize, SetVariablePlusCommand)
345 = SetVariablePlusCommand::parse_base(bytes);
346
347 (bytes_read, 0, Command::SetVariablePlus(command))
348 }
349
350 fn parse_set_variable_plus_other(bytes: &[u8], _: u32) -> (usize, u32, Self) {
351 let (bytes_read, command): (usize, SetVariablePlusCommand)
352 = SetVariablePlusCommand::parse_other(bytes);
353
354 (bytes_read, 0, Command::SetVariablePlus(command))
355 }
356
357 fn parse_number_condition(bytes: &[u8], _: u32) -> (usize, u32, Self) {
358 let (bytes_read, commands_read, command): (usize, u32, NumberConditionCommand)
359 = NumberConditionCommand::parse(bytes);
360
361 (bytes_read, commands_read, Command::NumberCondition(command))
362 }
363
364 fn parse_string_condition(bytes: &[u8], signature: u32) -> (usize, u32, Self) {
365 let (bytes_read, commands_read, command): (usize, u32, StringConditionCommand)
366 = StringConditionCommand::parse(bytes, signature);
367
368 (bytes_read, commands_read, Command::StringCondition(command))
369 }
370
371 fn parse_input_key_base(bytes: &[u8], _: u32) -> (usize, u32, Self) {
372 let (bytes_read, command): (usize, InputKeyCommand)
373 = InputKeyCommand::parse_input_key_base(bytes);
374
375 (bytes_read, 0, Command::InputKey(command))
376 }
377
378 fn parse_input_key_keyboard_or_pad(bytes: &[u8], _: u32) -> (usize, u32, Self) {
379 let (bytes_read, command): (usize, InputKeyCommand)
380 = InputKeyCommand::parse_input_key_keyboard_or_pad(bytes);
381
382 (bytes_read, 0, Command::InputKey(command))
383 }
384
385 fn parse_automatic_input_base(bytes: &[u8], _: u32) -> (usize, u32, Self) {
386 let (bytes_read, command): (usize, InputKeyCommand)
387 = InputKeyCommand::parse_automatic_input_base(bytes);
388
389 (bytes_read, 0, Command::InputKey(command))
390 }
391
392 fn parse_automatic_input_keyboard(bytes: &[u8], _: u32) -> (usize, u32, Self) {
393 let (bytes_read, command): (usize, InputKeyCommand)
394 = InputKeyCommand::parse_automatic_input_keyboard(bytes);
395
396 (bytes_read, 0, Command::InputKey(command))
397 }
398
399 fn parse_input_toggle(bytes: &[u8], _: u32) -> (usize, u32, Self) {
400 let (bytes_read, command): (usize, InputKeyCommand)
401 = InputKeyCommand::parse_input_toggle(bytes);
402
403 (bytes_read, 0, Command::InputKey(command))
404 }
405
406 fn parse_picture_show_base(bytes: &[u8], _: u32) -> (usize, u32, Self) {
407 let (bytes_read, command): (usize, PictureCommand)
408 = PictureCommand::parse_show_base(bytes);
409
410 (bytes_read, 0, Command::Picture(command))
411 }
412
413 fn parse_picture_show_colors(bytes: &[u8], _: u32) -> (usize, u32, Self) {
414 let (bytes_read, command): (usize, PictureCommand)
415 = PictureCommand::parse_show_colors(bytes);
416
417 (bytes_read, 0, Command::Picture(command))
418 }
419
420 fn parse_picture_show_delay(bytes: &[u8], _: u32) -> (usize, u32, Self) {
421 let (bytes_read, command): (usize, PictureCommand)
422 = PictureCommand::parse_show_delay(bytes);
423
424 (bytes_read, 0, Command::Picture(command))
425 }
426
427 fn parse_picture_show_range(bytes: &[u8], _: u32) -> (usize, u32, Self) {
428 let (bytes_read, command): (usize, PictureCommand)
429 = PictureCommand::parse_show_range(bytes);
430
431 (bytes_read, 0, Command::Picture(command))
432 }
433
434 fn parse_picture_show_color_values(bytes: &[u8], _: u32) -> (usize, u32, Self) {
435 let (bytes_read, command): (usize, PictureCommand)
436 = PictureCommand::parse_color_values(bytes);
437
438 (bytes_read, 0, Command::Picture(command))
439 }
440
441 fn parse_picture_show_zoom(bytes: &[u8], _: u32) -> (usize, u32, Self) {
442 let (bytes_read, command): (usize, PictureCommand)
443 = PictureCommand::parse_show_zoom(bytes);
444
445 (bytes_read, 0, Command::Picture(command))
446 }
447
448 fn parse_picture_show_free_transform(bytes: &[u8], _: u32) -> (usize, u32, Self) {
449 let (bytes_read, command): (usize, PictureCommand)
450 = PictureCommand::parse_show_free_transform(bytes);
451
452 (bytes_read, 0, Command::Picture(command))
453 }
454
455 fn parse_picture_erase_delay_reset(bytes: &[u8], _: u32) -> (usize, u32, Self) {
456 let (bytes_read, command): (usize, PictureCommand)
457 = PictureCommand::parse_erase_delay_reset(bytes);
458
459 (bytes_read, 0, Command::Picture(command))
460 }
461
462 fn parse_picture_erase_base(bytes: &[u8], _: u32) -> (usize, u32, Self) {
463 let (bytes_read, command): (usize, PictureCommand)
464 = PictureCommand::parse_erase_base(bytes);
465
466 (bytes_read, 0, Command::Picture(command))
467 }
468
469 fn parse_picture_erase_delay(bytes: &[u8], _: u32) -> (usize, u32, Self) {
470 let (bytes_read, command): (usize, PictureCommand)
471 = PictureCommand::parse_erase_delay(bytes);
472
473 (bytes_read, 0, Command::Picture(command))
474 }
475
476 fn parse_picture_erase_range(bytes: &[u8], _: u32) -> (usize, u32, Self) {
477 let (bytes_read, command): (usize, PictureCommand)
478 = PictureCommand::parse_erase_range(bytes);
479
480 (bytes_read, 0, Command::Picture(command))
481 }
482
483 fn parse_effect_base(bytes: &[u8], _: u32) -> (usize, u32, Self) {
484 let (bytes_read, command): (usize, EffectCommand)
485 = EffectCommand::parse_base(bytes);
486
487 (bytes_read, 0, Command::Effect(command))
488 }
489
490 fn parse_effect_map_shake(bytes: &[u8], _: u32) -> (usize, u32, Self) {
491 let (bytes_read, command): (usize, EffectCommand)
492 = EffectCommand::parse_map_shake(bytes);
493
494 (bytes_read, 0, Command::Effect(command))
495 }
496
497 fn parse_effect_scroll_screen(bytes: &[u8], _: u32) -> (usize, u32, Self) {
498 let (bytes_read, command): (usize, EffectCommand)
499 = EffectCommand::parse_scroll_screen(bytes);
500
501 (bytes_read, 0, Command::Effect(command))
502 }
503
504 fn parse_effect_change_color(bytes: &[u8], _: u32) -> (usize, u32, Self) {
505 let (bytes_read, command): (usize, EffectCommand)
506 = EffectCommand::parse_change_color(bytes);
507
508 (bytes_read, 0, Command::Effect(command))
509 }
510
511 fn parse_sound_filename(bytes: &[u8], _: u32) -> (usize, u32, Self) {
512 let (bytes_read, command): (usize, SoundCommand)
513 = SoundCommand::parse_filename(bytes);
514
515 (bytes_read, 0, Command::Sound(command))
516 }
517
518 fn parse_sound_variable(bytes: &[u8], _: u32) -> (usize, u32, Self) {
519 let (bytes_read, command): (usize, SoundCommand)
520 = SoundCommand::parse_variable(bytes);
521
522 (bytes_read, 0, Command::Sound(command))
523 }
524
525 fn parse_sound_free_all(bytes: &[u8], _: u32) -> (usize, u32, Self) {
526 let (bytes_read, command): (usize, SoundCommand)
527 = SoundCommand::parse_free_all(bytes);
528
529 (bytes_read, 0, Command::Sound(command))
530 }
531
532 fn parse_save_load_base(bytes: &[u8], _: u32) -> (usize, u32, Self) {
533 let (bytes_read, command): (usize, SaveLoadCommand)
534 = SaveLoadCommand::parse_base(bytes);
535
536 (bytes_read, 0, Command::SaveLoad(command))
537 }
538
539 fn parse_load_variable(bytes: &[u8], _: u32) -> (usize, u32, Self) {
540 let (bytes_read, command): (usize, SaveLoadCommand)
541 = SaveLoadCommand::parse_load_variable(bytes);
542
543 (bytes_read, 0, Command::SaveLoad(command))
544 }
545
546 fn parse_save_variable(bytes: &[u8], _: u32) -> (usize, u32, Self) {
547 let (bytes_read, command): (usize, SaveLoadCommand)
548 = SaveLoadCommand::parse_save_variable(bytes);
549
550 (bytes_read, 0, Command::SaveLoad(command))
551 }
552
553 fn parse_party_graphics(bytes: &[u8], _: u32) -> (usize, u32, Self) {
554 let (bytes_read, command): (usize, PartyGraphicsCommand)
555 = PartyGraphicsCommand::parse(bytes);
556
557 (bytes_read, 0, Command::PartyGraphics(command))
558 }
559
560 fn parse_chip_management_settings(bytes: &[u8], _: u32) -> (usize, u32, Self) {
561 let (bytes_read, command): (usize, ChipManagementCommand)
562 = ChipManagementCommand::parse_map_chip_settings(bytes);
563
564 (bytes_read, 0, Command::ChipManagement(command))
565 }
566
567 fn parse_chip_management_switch_set(bytes: &[u8], _: u32) -> (usize, u32, Self) {
568 let (bytes_read, command): (usize, ChipManagementCommand)
569 = ChipManagementCommand::parse_switch_chipset(bytes);
570
571 (bytes_read, 0, Command::ChipManagement(command))
572 }
573
574 fn parse_chip_management_overwrite(bytes: &[u8], _: u32) -> (usize, u32, Self) {
575 let (bytes_read, command): (usize, ChipManagementCommand)
576 = ChipManagementCommand::parse_overwrite_map_chips(bytes);
577
578 (bytes_read, 0, Command::ChipManagement(command))
579 }
580
581 fn parse_transfer(bytes: &[u8], _: u32) -> (usize, u32, Self) {
582 let (bytes_read, command): (usize, TransferCommand)
583 = TransferCommand::parse(bytes);
584
585 (bytes_read, 0, Command::Transfer(command))
586 }
587
588 fn parse_loop(bytes: &[u8], _: u32) -> (usize, u32, Self) {
589 let (bytes_read, commands_read, command): (usize, u32, EventControlCommand)
590 = EventControlCommand::parse_loop(bytes);
591
592 (bytes_read, commands_read, Command::EventControl(command))
593 }
594
595 fn parse_break_loop(bytes: &[u8], _: u32) -> (usize, u32, Self) {
596 let (bytes_read, command): (usize, EventControlCommand)
597 = EventControlCommand::parse_break_loop(bytes);
598
599 (bytes_read, 0, Command::EventControl(command))
600 }
601
602 fn parse_goto_loop_start(bytes: &[u8], _: u32) -> (usize, u32, Self) {
603 let (bytes_read, command): (usize, EventControlCommand)
604 = EventControlCommand::parse_goto_loop_start(bytes);
605
606 (bytes_read, 0, Command::EventControl(command))
607 }
608
609 fn parse_prepare_transition(bytes: &[u8], _: u32) -> (usize, u32, Self) {
610 let (bytes_read, command): (usize, EventControlCommand)
611 = EventControlCommand::parse_prepare_transition(bytes);
612
613 (bytes_read, 0, Command::EventControl(command))
614 }
615
616 fn parse_execute_transition(bytes: &[u8], _: u32) -> (usize, u32, Self) {
617 let (bytes_read, command): (usize, EventControlCommand)
618 = EventControlCommand::parse_execute_transition(bytes);
619
620 (bytes_read, 0, Command::EventControl(command))
621 }
622
623 fn parse_set_transition(bytes: &[u8], _: u32) -> (usize, u32, Self) {
624 let (bytes_read, command): (usize, EventControlCommand)
625 = EventControlCommand::parse_set_transition(bytes);
626
627 (bytes_read, 0, Command::EventControl(command))
628 }
629
630 fn parse_move(bytes: &[u8], _: u32) -> (usize, u32, Self) {
631 let (bytes_read, command): (usize, EventControlCommand)
632 = EventControlCommand::parse_move_route(bytes);
633
634 (bytes_read, 0, Command::EventControl(command))
635 }
636
637 fn parse_wait_for_move(bytes: &[u8], _: u32) -> (usize, u32, Self) {
638 let (bytes_read, command): (usize, EventControlCommand)
639 = EventControlCommand::parse_wait_for_move_route(bytes);
640
641 (bytes_read, 0, Command::EventControl(command))
642 }
643
644 fn parse_move_during_events_on(bytes: &[u8], _: u32) -> (usize, u32, Self) {
645 let (bytes_read, command): (usize, EventControlCommand)
646 = EventControlCommand::parse_move_during_events_on(bytes);
647
648 (bytes_read, 0, Command::EventControl(command))
649 }
650
651 fn parse_move_during_events_off(bytes: &[u8], _: u32) -> (usize, u32, Self) {
652 let (bytes_read, command): (usize, EventControlCommand)
653 = EventControlCommand::parse_move_during_events_off(bytes);
654
655 (bytes_read, 0, Command::EventControl(command))
656 }
657
658 fn parse_goto_title(bytes: &[u8], _: u32) -> (usize, u32, Self) {
659 let (bytes_read, command): (usize, EventControlCommand)
660 = EventControlCommand::parse_goto_title(bytes);
661
662 (bytes_read, 0, Command::EventControl(command))
663 }
664
665 fn parse_game_end(bytes: &[u8], _: u32) -> (usize, u32, Self) {
666 let (bytes_read, command): (usize, EventControlCommand)
667 = EventControlCommand::parse_game_end(bytes);
668
669 (bytes_read, 0, Command::EventControl(command))
670 }
671
672 fn parse_stop_non_picture_graphic_updates(bytes: &[u8], _: u32) -> (usize, u32, Self) {
673 let (bytes_read, command): (usize, EventControlCommand)
674 = EventControlCommand::parse_stop_non_picture_graphic_updates(bytes);
675
676 (bytes_read, 0, Command::EventControl(command))
677 }
678
679 fn parse_resume_non_picture_graphic_updates(bytes: &[u8], _: u32) -> (usize, u32, Self) {
680 let (bytes_read, command): (usize, EventControlCommand)
681 = EventControlCommand::parse_resume_non_picture_graphic_updates(bytes);
682
683 (bytes_read, 0, Command::EventControl(command))
684 }
685
686 fn parse_force_exit_event(bytes: &[u8], _: u32) -> (usize, u32, Self) {
687 let (bytes_read, command): (usize, EventControlCommand)
688 = EventControlCommand::parse_force_exit_event(bytes);
689
690 (bytes_read, 0, Command::EventControl(command))
691 }
692
693 fn parse_erase_event(bytes: &[u8], _: u32) -> (usize, u32, Self) {
694 let (bytes_read, command): (usize, EventControlCommand)
695 = EventControlCommand::parse_erase_event(bytes);
696
697 (bytes_read, 0, Command::EventControl(command))
698 }
699
700 fn parse_wait(bytes: &[u8], _: u32) -> (usize, u32, Self) {
701 let (bytes_read, command): (usize, EventControlCommand)
702 = EventControlCommand::parse_wait(bytes);
703
704 (bytes_read, 0, Command::EventControl(command))
705 }
706
707 fn parse_loop_count(bytes: &[u8], _: u32) -> (usize, u32, Self) {
708 let (bytes_read, commands_read, command): (usize, u32, EventControlCommand)
709 = EventControlCommand::parse_loop_count(bytes);
710
711 (bytes_read, commands_read, Command::EventControl(command))
712 }
713
714 fn parse_label_point(bytes: &[u8], _: u32) -> (usize, u32, Self) {
715 let (bytes_read, command): (usize, EventControlCommand)
716 = EventControlCommand::parse_label_point(bytes);
717
718 (bytes_read, 0, Command::EventControl(command))
719 }
720
721 fn parse_label_jump(bytes: &[u8], _: u32) -> (usize, u32, Self) {
722 let (bytes_read, command): (usize, EventControlCommand)
723 = EventControlCommand::parse_label_jump(bytes);
724
725 (bytes_read, 0, Command::EventControl(command))
726 }
727
728 fn parse_call_common_event(bytes: &[u8], _: u32) -> (usize, u32, Self) {
729 let (bytes_read, command): (usize, CommonEventCommand)
730 = CommonEventCommand::parse_call_event(bytes);
731
732 (bytes_read, 0, Command::CommonEvent(command))
733 }
734
735 fn parse_reserve_common_event(bytes: &[u8], _: u32) -> (usize, u32, Self) {
736 let (bytes_read, command): (usize, CommonEventCommand)
737 = CommonEventCommand::parse_reserve_event(bytes);
738
739 (bytes_read, 0, Command::CommonEvent(command))
740 }
741
742 fn parse_checkpoint(_: &[u8], _: u32) -> (usize, u32, Self) {
743 (7, 0, Self::Checkpoint())
744 }
745
746 fn parse_exit(_: &[u8], _: u32) -> (usize, u32, Self) {
747 Self::parse_empty(Self::Exit())
748 }
749
750 fn parse_empty(ret: Self) -> (usize, u32, Self) {
751 (3, 0, ret)
752 }
753}