407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
|
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
|
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
|
case '\' ': // Play a move
if(inputs_count>=inputs_size) {
inputs=realloc(inputs,inputs_size+=32);
if(!inputs) fatal("Allocation failed\n");
}
inputs[inputs_count++]=number;
return 0;
case '+ ': // Replay
case '+ ': replay: // Replay
if(number>replay_count-replay_pos) number=replay_count-replay_pos;
if(number<=0) return prev;
if(inputs_count+number>=inputs_size) {
inputs=realloc(inputs,inputs_size+=number+1);
if(!inputs) fatal("Allocation failed\n");
}
memcpy(inputs+inputs_count,replay_list+replay_pos,number);
inputs_count+=number;
return 0;
case '- ': // Rewind
number=replay_pos-number;
if(number<0) number=0;
//fallthru
case '= ': // Restart
case '= ': restart: // Restart
begin_level(level_id);
if(!number) return 1;
if(number>replay_count) number=replay_count;
if(number>=inputs_size) {
inputs=realloc(inputs,inputs_size=number+1);
if(!inputs) fatal("Allocation failed\n");
}
memcpy(inputs,replay_list,inputs_count=number);
return 1;
case '^<': // Rewind to mark
number=replay_mark;
goto restart;
case '^>': // Replay to mark
inputs_count=0;
number=replay_mark-replay_pos;
goto replay;
case '^E': // Edit
return -2;
case '^M': // Mark replay position
replay_mark=replay_pos+inputs_count;
return prev;
case '^Q': // Quit
return -1;
case '^T': // Show title
modal_draw_popup(level_title);
return prev;
case '^d': // Describe object
describe_at(number-65);
|