︙ | | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
+
|
static Uint8*inputs;
static int inputs_size,inputs_count;
static Uint8 side_mode=255;
static Uint8 should_record_solution;
static Uint8 replay_speed;
static Uint8 replay_time;
static Uint8 solved;
static Uint8 inserting,saved_inserting;
static void record_solution(void);
static void setup_game(void) {
const char*v;
optionquery[1]=Q_showInventory;
v=xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"";
|
︙ | | |
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
-
+
|
snprintf(buf,8,"%5d",replay_count);
draw_text(8,screen->h-8,buf,0xF0,solution_replay?0xFA:0xFC);
for(y=44,x=replay_pos-(screen->h-68)/32;;x++) {
y+=16;
if(y+24>screen->h) break;
if(x>=0 && x<replay_count) draw_key(16,y,replay_list[x],0xF8,0xFB);
if(x==replay_count) draw_key(16,y,1,0xF0,0xF8);
if(x==replay_pos) draw_text(0,y,"~~",0xF0,0xFE);
if(x==replay_pos) draw_text(0,y,inserting?"I~":"~~",0xF0,0xFE);
if(x==replay_mark) draw_text(32,y,"~~",0xF0,0xFD);
}
SDL_UnlockSurface(screen);
}
if(quiz_text) draw_popup(quiz_text);
SDL_Flip(screen);
set_cursor(XC_arrow);
|
︙ | | |
305
306
307
308
309
310
311
312
313
314
315
316
317
318
|
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
|
+
|
static void begin_level(int id) {
const char*t;
replay_time=0;
if(replay_count) save_replay();
inputs_count=0;
replay_pos=0;
solved=0;
inserting=0;
t=load_level(id)?:init_level();
load_replay();
if(t) {
gameover=-1;
screen_message(t);
} else {
gameover=0;
|
︙ | | |
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
|
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
|
+
+
|
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: // Replay
saved_inserting=inserting; inserting=0;
replay_time=0;
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
saved_inserting=inserting;
number=replay_pos-number;
if(number<0) number=0;
//fallthru
case '= ': restart: // Restart
begin_level(level_id);
if(!number) return 1;
if(number>replay_count) number=replay_count;
|
︙ | | |
725
726
727
728
729
730
731
732
733
734
735
736
737
738
|
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
|
+
+
+
+
+
+
+
+
+
+
+
|
case '^<': // Rewind to mark
number=replay_mark;
goto restart;
case '^>': // Replay to mark
inputs_count=0;
number=replay_mark-replay_pos;
goto replay;
case '^-': // Delete move
inputs_count=0;
if(replay_pos==replay_count) return 0;
memmove(replay_list+replay_pos,replay_list+replay_pos+1,replay_count-replay_pos-1);
replay_count--;
if(replay_mark>replay_pos) replay_mark--;
return 0;
case '^+': // Insert moves
inputs_count=0;
inserting^=1;
return 0;
case '^E': // Edit
return main_options['r']?1:-2;
case '^I': // Toggle inventory display
side_mode^=1;
return prev;
case '^M': // Mark replay position
replay_mark=replay_pos+inputs_count;
|
︙ | | |
828
829
830
831
832
833
834
835
836
837
838
839
840
841
|
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
|
+
+
+
+
+
+
+
+
+
+
+
+
+
|
if(replay_pos==65534 && !gameover) t="Too many moves played";
if(t) {
screen_message(t);
gameover=-1;
return;
}
if(!key_ignored) {
if(inserting) {
if(replay_pos>=0xFFFE || replay_pos==replay_count) {
inserting=0;
} else {
if(replay_count>=0xFFFE) replay_count=0xFFFD;
if(replay_size<0xFFFF) {
replay_list=realloc(replay_list,replay_size=0xFFFF);
if(!replay_list) fatal("Allocation failed\n");
}
memmove(replay_list+replay_pos+1,replay_list+replay_pos,replay_count-replay_pos);
replay_count++;
}
}
if(replay_pos>=replay_size) {
if(replay_size>0xFDFF) replay_size=0xFDFF;
if(replay_size+0x200<=replay_pos) fatal("Confusion in input_move function\n");
replay_list=realloc(replay_list,replay_size+=0x200);
if(!replay_list) fatal("Allocation failed\n");
}
replay_list[replay_pos++]=k;
|
︙ | | |
944
945
946
947
948
949
950
951
952
953
954
955
956
957
|
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
|
+
|
save_replay();
return;
}
replay:
if(inputs_count) {
for(i=0;i<inputs_count && !gameover;i++) if(inputs[i]) input_move(inputs[i]);
inputs_count=0;
if(saved_inserting) inserting=1,saved_inserting=0;
no_dead_anim=0;
if(gameover==1 && should_record_solution) record_solution();
}
redraw_game();
timerflag=0; // ensure we have not missed a timer event
break;
}
|
︙ | | |