1 /**
2 * FreeDink (not FreeDinkEdit) screen update
3
4 * Copyright (C) 1997, 1998, 1999, 2002, 2003 Seth A. Robinson
5 * Copyright (C) 2005, 2006 Dan Walma
6 * Copyright (C) 2005, 2007, 2008, 2009, 2010, 2011, 2012 Sylvain Beucler
7
8 * This file is part of GNU FreeDink
9
10 * GNU FreeDink is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 3 of the
13 * License, or (at your option) any later version.
14
15 * GNU FreeDink is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see
22 * <http://www.gnu.org/licenses/>.
23 */
24
25 #ifdef HAVE_CONFIG_H
26 #include <config.h>
27 #endif
28
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <time.h>
33 /* #include <windows.h> */
34 /* #include <ddraw.h> */
35 #include "SDL.h"
36 #include "SDL_framerate.h"
37
38 #include "dinkvar.h"
39 #include "game_engine.h"
40 #include "screen.h"
41 #include "freedink.h"
42 #include "gfx.h"
43 /* For printing strings in debug mode */
44 #include "gfx_fonts.h"
45 #include "gfx_sprites.h"
46 #include "gfx_tiles.h"
47 #include "bgm.h"
48 #include "log.h"
49 #include "rect.h"
50 #include "dinkc_console.h"
51 #include "input.h"
52 #include "sfx.h"
53
54 #include "update_frame.h"
55
56 enum speed_type { v107, v108 };
57 static Uint32 fps_lasttick = 0;
58 static int frames = 0;
59 static int fps = 0;
60 static int drawthistime = /*true*/1;
61 static /*bool*/int turn_on_plane = /*FALSE*/0;
62 static /*bool*/int plane_process = /*TRUE*/1;
63
updateFrame(void)64 void updateFrame( void )
65 {
66 /* Refresh frame counter twice per second */
67 if ((SDL_GetTicks() - fps_lasttick) > 500)
68 {
69 fps = frames * (1000/500);
70 frames = 0;
71 fps_lasttick = SDL_GetTicks();
72 }
73 frames++;
74
75 /* RECT box_crap,box_real; */
76 SDL_Rect GFX_box_crap;
77
78 /* DDBLTFX ddbltfx; */
79 char msg[100];
80
81 /* HDC hdc; */
82 /* HRESULT ddrval; */
83
84 int move_result ;
85
86 /* Probably a debug variable, only set in a "if (5 > 9)" block. I
87 don't know what this allows to debug though; this involves
88 copying the screen to lpDDSTrick2 */
89 /*bool*/int get_frame = /*false*/0;
90
91 int max_s;
92 int rank[MAX_SPRITES_AT_ONCE];
93
94 abort_this_flip = /*false*/0;
95
96 if (5 > 9)
97 {
98 trigger_start:
99 trig_man = /*false*/0;
100 get_frame = /*true*/1;
101 }
102
103 check_joystick();
104
105 if (GetKeyboard('m') && (GetKeyboard(SDLK_LALT) || GetKeyboard(SDLK_RALT)))
106 {
107 //shutdown music
108 StopMidi();
109 return;
110 }
111
112 if (GetKeyboard('d') && (GetKeyboard(SDLK_LALT) || GetKeyboard(SDLK_RALT)))
113 {
114 if (debug_mode)
115 {
116 log_debug_off();
117 }
118 else
119 {
120 log_debug_on();
121 }
122 }
123
124
125
126 if (GetKeyboard('q') && (GetKeyboard(SDLK_LALT) || GetKeyboard(SDLK_RALT)))
127 {
128 //shutdown game
129 // PostMessage(hWndMain, WM_CLOSE, 0, 0);
130 SDL_Event ev;
131 ev.type = SDL_QUIT;
132 SDL_PushEvent(&ev);
133 return;
134 }
135
136 if (mode == 1) Scrawl_OnMouseInput(); else
137 {
138 if (keep_mouse)
139 {
140 if ((talk.active) || (spr[1].brain == 13))
141 Scrawl_OnMouseInput();
142 }
143
144 }
145
146 /* demon: */
147
148 /* while(GetTickCount() < (lastTickCount+ 20))
149 {
150 //wait
151 }
152 */
153
154 lastTickCount = thisTickCount;
155 thisTickCount = game_GetTicks();
156
157
158 {
159 //Use to test at 30 fps
160 //Sleep(66);
161
162 //redink1 - 'lock the framerate to 83 FPS'... Seth told me to.
163 /* Beuc: that doesn't work. Waiting for 1ms is not guaranteed
164 to work accurately, most often computer will wait for
165 delays such as 10ms or 15ms. My tests give framerates of
166 respectively 50 and 60 FPS. */
167 /* Woe: */
168 /* while (thisTickCount - lastTickCount < 12) */
169 /* { */
170 /* Sleep (1); */
171 /* thisTickCount = GetTickCount (); */
172 /* } */
173
174 /* SDL */
175 /* while (thisTickCount - lastTickCount < 12) */
176 /* { */
177 /* SDL_Delay (1); */
178 /* thisTickCount = SDL_GetTicks (); */
179 /* } */
180
181 /* SDL_gfx has a more clever algorithm, which accurately sets
182 the framerate to a fixed value. */
183 SDL_framerateDelay(&framerate_manager);
184
185
186 thisTickCount = game_GetTicks();
187
188 fps_final = thisTickCount - lastTickCount;
189
190 //redink1 changed to 12-12 from 10-15... maybe work better on faster computers?
191 if (fps_final < 12)
192 fps_final = 12;
193 if (fps_final > 68)
194 fps_final = 68;
195 base_timing = fps_final / 3;
196 if (base_timing < 4)
197 base_timing = 4;
198 int junk3;
199
200 //redink1 added these changes to set Dink's speed correctly, even on fast machines.
201 //junk3 = (fps_average / dinkspeed) - (fps_average / 8);
202 if (dinkspeed <= 0)
203 junk3 = 0;
204
205 else if (dinkspeed == 1)
206 junk3 = 12;
207
208 else if (dinkspeed == 2)
209 junk3 = 6;
210
211 else if (dinkspeed == 3)
212 junk3 = 3;
213
214 else
215 junk3 = 1;
216
217 //redink1... weird bug, only do this for normal mode, as it breaks mouse support
218 //if (mode == 2)
219 {
220 junk3 *= (base_timing / 4);
221 }
222 spr[1].speed = junk3;
223 }
224
225
226 if (showb.active)
227 {
228 process_show_bmp();
229 if (!abort_this_flip)
230 flip_it();
231
232 return;
233 }
234
235 mbase_count++;
236
237 if (thisTickCount > mold+100)
238 {
239 mold = thisTickCount;
240 if (bow.active) bow.hitme = /*true*/1;
241 if (*pupdate_status == 1) update_status_all();
242
243
244 update_sound();
245 process_animated_tiles();
246 }
247
248
249
250 //figure out frame rate
251 drawthistime = /*true*/1;
252
253 if (show_inventory)
254 {
255 process_item();
256 return;
257 }
258
259
260 if (total_trigger)
261
262 {
263 if (transition()) goto flip; else return;
264 }
265
266
267 /* Fade to black, etc. */
268 if (process_upcycle) up_cycle();
269 if (process_warp > 0) process_warp_man();
270 if (process_downcycle) CyclePalette();
271
272
273 if (plane_process)
274 {
275 max_s = last_sprite_created;
276 screen_rank_game_sprites(rank);
277 }
278 else
279 {
280 //not processing planes
281 max_s = MAX_SPRITES_AT_ONCE;
282 }
283
284 //Blit from Two, which holds the base scene.
285 SDL_BlitSurface(GFX_lpDDSTwo, NULL, GFX_lpDDSBack, NULL);
286
287
288 if (stop_entire_game == 1)
289 {
290 if (talk.active) process_talk();
291
292 else
293 {
294 stop_entire_game = 0;
295
296 draw_map_game_background();
297 draw_status_all();
298
299 }
300 goto flip;
301
302 }
303
304
305
306
307 int j = 0;
308 for (; j <= max_s; j++)
309 {
310 //h = 1;
311 int h = 0;
312 if (plane_process)
313 h = rank[j];
314 else
315 h = j;
316 //Msg( "Ok, rank %d is %d", j,h);
317
318 if (h > 0)
319 if (spr[h].active && spr[h].disabled == 0)
320 {
321
322 //check_sprite_status_full(h);
323
324 spr[h].moveman = 0; //init thing that keeps track of moving path
325 spr[h].lpx[0] = spr[h].x;
326 spr[h].lpy[0] = spr[h].y; //last known legal cords
327
328 spr[h].skiptimer++;
329 //inc delay, used by "skip" by all sprites
330 /* box_crap = k[getpic(h)].box; */
331 if (spr[h].kill > 0)
332 {
333 if (spr[h].kill_timer == 0) spr[h].kill_timer = thisTickCount;
334 if (spr[h].kill_timer + spr[h].kill < thisTickCount)
335 {
336
337 spr[h].active = /*false*/0;
338 // Msg("Killing sprite %d.", h);
339
340 get_last_sprite();
341 if (spr[h].callback > 0)
342 {
343 // Msg("Callback running script %d.", spr[h].script);
344
345 run_script(spr[h].callback);
346
347
348 }
349
350
351 }
352
353 }
354
355 if (spr[h].timer > 0)
356 {
357 if (thisTickCount > spr[h].wait)
358 {
359 spr[h].wait = thisTickCount + spr[h].timer;
360
361 }else
362 {
363 goto animate;
364 }
365
366 }
367
368
369 //brains - predefined bahavior patterns available to any sprite
370
371 if (spr[h].notouch) if (thisTickCount > spr[h].notouch_timer) spr[h].notouch = /*false*/0;
372 if (get_frame == /*false*/0)
373 {
374 if ( (spr[h].brain == 1)/* || (spr[h].brain == 9) || (spr[h].brain == 3) */ )
375 {
376
377 run_through_touch_damage_list(h);
378
379
380 }
381
382 if (spr[h].brain == 1)
383 {
384 if (process_warp == 0)
385 human_brain(h);
386 }
387
388 if (spr[h].brain == 2) bounce_brain(h);
389 if (spr[h].brain == 0) no_brain(h);
390 if (spr[h].brain == 3) duck_brain(h);
391 if (spr[h].brain == 4) pig_brain(h);
392 if (spr[h].brain == 5) one_time_brain(h);
393 if (spr[h].brain == 6) repeat_brain(h);
394 if (spr[h].brain == 7) one_time_brain_for_real(h);
395 if (spr[h].brain == 8) text_brain(h);
396 if (spr[h].brain == 9) pill_brain(h);
397 if (spr[h].brain == 10) dragon_brain(h);
398 if (spr[h].brain == 11) missile_brain(h, /*true*/1);
399 if (spr[h].brain == 12) scale_brain(h);
400 if (spr[h].brain == 13) mouse_brain(h);
401 if (spr[h].brain == 14) button_brain(h);
402 if (spr[h].brain == 15) shadow_brain(h);
403 if (spr[h].brain == 16) people_brain(h);
404 if (spr[h].brain == 17) missile_brain_expire(h);
405 } else
406 {
407 goto past;
408 }
409 if (g_b_kill_app) return;
410 animate:
411
412 move_result = check_if_move_is_legal(h);
413
414 if (flub_mode != -500)
415 {
416 log_debug("move result is %d", flub_mode);
417 move_result = flub_mode;
418 flub_mode = -500;
419 }
420
421 if (spr[h].brain == 1) if (move_result > 100)
422 {
423 if (pam.sprite[move_result-100].is_warp == 1)
424 special_block(move_result - 100);
425 }
426
427
428 if (spr[h].reverse)
429 {
430
431 //reverse instructions
432 if (spr[h].seq > 0)
433 {
434 if (spr[h].frame < 1)
435 {
436 // new anim
437 spr[h].pseq = spr[h].seq;
438 spr[h].pframe = seq[spr[h].seq].len;
439 spr[h].frame = seq[spr[h].seq].len;
440 if (spr[h].frame_delay != 0) spr[h].delay = (thisTickCount+ spr[h].frame_delay); else
441 spr[h].delay = (thisTickCount + seq[spr[h].seq].delay[seq[spr[h].seq].len]);
442 } else
443 {
444 // not new anim
445
446 //is it time?
447
448 if (thisTickCount > spr[h].delay)
449 {
450
451
452 spr[h].frame--;
453
454
455 if (spr[h].frame_delay != 0) spr[h].delay = (thisTickCount + spr[h].frame_delay); else
456
457 spr[h].delay = (thisTickCount + seq[spr[h].seq].delay[spr[h].frame]);
458
459 spr[h].pseq = spr[h].seq;
460 spr[h].pframe = spr[h].frame;
461
462
463 if (seq[spr[h].seq].frame[spr[h].frame] < 2)
464 {
465
466 spr[h].pseq = spr[h].seq;
467 spr[h].pframe = spr[h].frame+1;
468
469 spr[h].frame = 0;
470 spr[h].seq_orig = spr[h].seq;
471 spr[h].seq = 0;
472 spr[h].nocontrol = /*false*/0;
473
474
475 if (h == 1) if (in_this_base(spr[h].seq_orig, dink_base_push))
476
477 {
478
479
480 play.push_active = /*false*/0;
481 if (play.push_dir == 2) if (sjoy.down) play.push_active = /*true*/1;
482 if (play.push_dir == 4) if (sjoy.left) play.push_active = /*true*/1;
483 if (play.push_dir == 6) if (sjoy.right) play.push_active = /*true*/1;
484 if (play.push_dir == 8) if (sjoy.up) play.push_active = /*true*/1;
485
486
487 goto past;
488
489 }
490 }
491 if (spr[h].seq > 0) if (seq[spr[h].seq].special[spr[h].frame] == 1)
492 {
493 //this sprite can damage others right now!
494 //lets run through the list and tag sprites who were hit with their damage
495
496 run_through_tag_list(h, spr[h].strength);
497
498 }
499
500
501
502
503 }
504 }
505 }
506
507
508 } else
509 {
510
511 if (spr[h].seq > 0) if (spr[h].picfreeze == 0)
512 {
513 if (spr[h].frame < 1)
514 {
515 // new anim
516 spr[h].pseq = spr[h].seq;
517 spr[h].pframe = 1;
518 spr[h].frame = 1;
519 if (spr[h].frame_delay != 0)
520 spr[h].delay = thisTickCount + spr[h].frame_delay;
521 else
522 spr[h].delay = (thisTickCount + seq[spr[h].seq].delay[1]);
523 } else
524 {
525 // not new anim
526
527 //is it time?
528
529 if (thisTickCount > spr[h].delay)
530 {
531
532
533 spr[h].frame++;
534 if (spr[h].frame_delay != 0)
535 spr[h].delay = thisTickCount + spr[h].frame_delay;
536 else
537 spr[h].delay = (thisTickCount + seq[spr[h].seq].delay[spr[h].frame]);
538
539 spr[h].pseq = spr[h].seq;
540 spr[h].pframe = spr[h].frame;
541
542 if (seq[spr[h].seq].frame[spr[h].frame] == -1)
543 {
544 spr[h].frame = 1;
545 spr[h].pseq = spr[h].seq;
546 spr[h].pframe = spr[h].frame;
547 if (spr[h].frame_delay != 0) spr[h].delay = thisTickCount + spr[h].frame_delay; else
548
549 spr[h].delay = (thisTickCount + seq[spr[h].seq].delay[spr[h].frame]);
550
551 }
552
553 if (seq[spr[h].seq].frame[spr[h].frame] < 1)
554 {
555
556 spr[h].pseq = spr[h].seq;
557 spr[h].pframe = spr[h].frame-1;
558
559 spr[h].frame = 0;
560 spr[h].seq_orig = spr[h].seq;
561 spr[h].seq = 0;
562 spr[h].nocontrol = /*false*/0;
563
564
565 if (h == 1) if (in_this_base(spr[h].seq_orig, dink_base_push))
566
567 {
568
569
570 play.push_active = /*false*/0;
571 if (play.push_dir == 2) if (sjoy.down) play.push_active = /*true*/1;
572 if (play.push_dir == 4) if (sjoy.left) play.push_active = /*true*/1;
573 if (play.push_dir == 6) if (sjoy.right) play.push_active = /*true*/1;
574 if (play.push_dir == 8) if (sjoy.up) play.push_active = /*true*/1;
575
576
577 goto past;
578
579 }
580 }
581 if (spr[h].seq > 0) if (seq[spr[h].seq].special[spr[h].frame] == 1)
582 {
583 //this sprite can damage others right now!
584 //lets run through the list and tag sprites who were hit with their damage
585
586 run_through_tag_list(h, spr[h].strength);
587
588 }
589
590
591
592
593 }
594 }
595 }
596
597
598 }
599
600
601 if (spr[h].active) if (spr[h].brain == 1)
602 {
603 did_player_cross_screen(/*true*/1, h);
604 }
605
606 past:
607 check_seq_status(spr[h].seq);
608
609
610 // TODO: this seems to be copy
611 // protection. What does it do if we
612 // remove the draw_sprite_game line?
613
614 // if (mcc == sound_support)
615 draw_sprite_game(GFX_lpDDSBack, h);
616
617
618 //draw a dot to show where the computer is guessing the start of the shadow is
619 /* Note: show_dot is never set to
620 true; that's a manual debugging
621 tool; maybe we could introduce a
622 command line option, or activate it
623 along with -debug */
624 /* TODO: test me! */
625 if (show_dot)
626 {
627
628
629 /* ddbltfx.dwSize = sizeof(ddbltfx); */
630 if (drawthistime)
631 {
632 int oo;
633 /* ddbltfx.dwFillColor = 1; */
634
635 /* box_crap = k[getpic(h)].hardbox; */
636 //box_crap.bottom = spr[h].y + k[spr[h].pic].hardbox.bottom;
637 //box_crap.left = spr[h].x + k[spr[h].pic].hardbox.left;
638 //box_crap.right = spr[h].x + k[spr[h].pic].hardbox.right;
639
640 //OffsetRect(&box_crap, spr[h].x, spr[h].y);
641
642 // ddrval = lpDDSBack->Blt(&box_crap ,NULL, &box_real, DDBLT_COLORFILL| DDBLT_WAIT, &ddbltfx);
643
644
645 //to show center pixel
646 /* ddbltfx.dwFillColor = 100; */
647
648 /* box_crap.top = spr[h].y; */
649 /* box_crap.bottom = spr[h].y+1; */
650 /* box_crap.left = spr[h].x ; */
651 /* box_crap.right = spr[h].x + 1; */
652 // GFX
653 GFX_box_crap.x = spr[h].x;
654 GFX_box_crap.y = spr[h].y;
655 GFX_box_crap.w = 1;
656 GFX_box_crap.h = 1;
657
658 /* ddrval = lpDDSBack->Blt(&box_crap ,NULL, &box_real, DDBLT_COLORFILL| DDBLT_WAIT, &ddbltfx); */
659 // GFX
660 SDL_FillRect(GFX_lpDDSBack, &GFX_box_crap,
661 SDL_MapRGB(GFX_lpDDSBack->format,
662 GFX_real_pal[100].r,
663 GFX_real_pal[100].g,
664 GFX_real_pal[100].b));
665
666
667 for (oo=0; oo < spr[h].moveman+1; oo++)
668 {
669 /* ddbltfx.dwFillColor = 50; */
670
671 /* box_crap.top = spr[h].lpy[oo]; */
672 /* box_crap.bottom = box_crap.top+1; */
673 /* box_crap.left = spr[h].lpx[oo]; */
674 /* box_crap.right = box_crap.left+1; */
675 // GFX
676 GFX_box_crap.x = spr[h].lpx[oo];
677 GFX_box_crap.y = spr[h].lpy[oo];
678 GFX_box_crap.w = 1;
679 GFX_box_crap.h = 1;
680
681 /* ddrval = lpDDSBack->Blt(&box_crap ,NULL, NULL, DDBLT_COLORFILL|DDBLT_WAIT, &ddbltfx); */
682 // GFX
683 SDL_FillRect(GFX_lpDDSBack, &GFX_box_crap,
684 SDL_MapRGB(GFX_lpDDSBack->format,
685 GFX_real_pal[50].r,
686 GFX_real_pal[50].g,
687 GFX_real_pal[50].b));
688
689 }
690 /* ddbltfx.dwFillColor = 1; */
691
692 /* box_crap.top = spr[h].lpy[0]; */
693 /* box_crap.bottom = box_crap.top+1; */
694 /* box_crap.left = spr[h].lpx[0]; */
695 /* box_crap.right = box_crap.left+1; */
696 // GFX
697 GFX_box_crap.x = spr[h].lpx[0];
698 GFX_box_crap.y = spr[h].lpy[0];
699 GFX_box_crap.w = 1;
700 GFX_box_crap.h = 1;
701
702 /* ddrval = lpDDSBack->Blt(&box_crap ,NULL, NULL, DDBLT_COLORFILL|DDBLT_WAIT, &ddbltfx); */
703 // GFX
704 SDL_FillRect(GFX_lpDDSBack, &GFX_box_crap,
705 SDL_MapRGB(GFX_lpDDSBack->format,
706 GFX_real_pal[1].r,
707 GFX_real_pal[1].g,
708 GFX_real_pal[1].b));
709 }
710 }
711 }
712 } /* for 0->max_s */
713
714
715 if (mode == 0)
716 {
717
718 memset(&spr[1], 0, sizeof(spr[1]));
719
720 spr[1].speed = 3;
721 /* init_mouse(hWndMain); */
722 /* g_pMouse->Acquire(); */
723
724 spr[1].timer = 0;
725 spr[1].brain = 1;
726 spr[1].hard = 1;
727 spr[1].pseq = 2;
728 spr[1].pframe = 1;
729 spr[1].seq = 2;
730 spr[1].dir = 2;
731 spr[1].damage = 0;
732 spr[1].strength = 10;
733 spr[1].defense = 0;
734 spr[1].skip = 0;
735 rect_set(&spr[1].alt,0,0,0,0);
736 spr[1].base_idle = 10;
737 spr[1].base_walk = -1;
738 spr[1].size = 100;
739 spr[1].base_hit = 100;
740 spr[1].active = /*TRUE*/1;
741
742 int crap2 = add_sprite(0,450,8,0,0);
743
744
745 spr[crap2].hard = 1;
746 spr[crap2].noclip = 1;
747 strcpy(spr[crap2].text, dversion_string);
748
749 spr[crap2].damage = -1;
750 spr[crap2].owner = 1000;
751
752
753
754 int scr = load_script("START",1000, /*true*/1);
755 if (locate(scr, "MAIN") == /*false*/0)
756 {
757 log_error("Can't locate MAIN in script START!");
758 }
759 run_script(scr);
760 mode = 1;
761
762 }
763
764
765
766 if (mode == 2)
767 {
768
769 // if ( (keypressed()) | (jinfo.dwButtons) | (sjoy.right) | (sjoy.left)
770 // | (sjoy.up) | (sjoy.down))
771 {
772 mode = 3;
773 load_map(map.loc[*pmap]);
774 draw_map_game();
775 flife = *plife;
776
777 if (keep_mouse == 0)
778 {
779
780
781 /* if (g_pMouse) */
782 /* { */
783 /* g_pMouse->Release(); */
784 /* g_pMouse = NULL; */
785 /* } */
786
787 /* if (g_hevtMouse) */
788 /* { */
789 /* CloseHandle(g_hevtMouse); */
790 /* g_hevtMouse = NULL; */
791 /* } */
792 /* if (g_pdi) */
793 /* { */
794 /* g_pdi->Release(); */
795 /* g_pdi = NULL; */
796 /* } */
797
798 }
799
800 // draw_status_all();
801 }
802 }
803
804
805
806 if (spr[1].active && spr[1].brain == 1)
807 did_player_cross_screen(/*false*/0, 1);
808
809 if (trig_man)
810 {
811 goto trigger_start;
812
813 }
814
815 if (get_frame)
816 {
817 /* RECT rcRect1; */
818
819 total_trigger = /*true*/1;
820 get_frame = /*false*/0;
821 /* rcRect1.left = playl; */
822 /* rcRect1.top = 0; */
823 /* rcRect1.right = 620; */
824 /* rcRect1.bottom = 400; */
825 //return;
826
827 /* ddrval = lpDDSTrick2->BltFast( 0, 0, lpDDSBack, */
828 /* &rcRect1, DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); */
829 /* if (ddrval != DD_OK) dderror(ddrval); */
830 // GFX
831 {
832 SDL_Rect src, dst;
833 src.x = playl;
834 src.y = 0;
835 src.w = 620 - playl;
836 src.h = 400;
837 dst.x = dst.y = 0;
838 SDL_BlitSurface(GFX_lpDDSBack, &src, GFX_lpDDSTrick2, &dst);
839 }
840
841 return;
842 }
843
844
845
846 if (screenlock == 1)
847 {
848 //Msg("Drawing screenlock.");
849 drawscreenlock();
850
851 }
852
853
854 if (debug_mode)
855 {
856 FONTS_SetTextColor(200, 200, 200);
857 if (mode == 0) strcpy(msg,"");
858 if (mode == 1)
859 {
860 int x;
861 sprintf(msg,"X is %d y is %d FPS: %d", spr[1].x, spr[1].y, fps);
862 //let's add the key info to it.
863 for (x = 0; x < 256; x++)
864 if (GetKeyboard(x))
865 sprintf(msg + strlen(msg), " (Key %i)", x);
866 }
867 if (mode == 3)
868 {
869 sprintf(msg, "Sprites: %d FPS: %d Show_dot: %d Plane_process: %d"
870 " Moveman X%d X%d: %d Y%d Y%d Map %d",
871 last_sprite_created, fps/*_show*/, show_dot, plane_process,
872 spr[1].lpx[0], spr[1].lpy[0], spr[1].moveman,
873 spr[1].lpx[1], spr[1].lpy[1], *pmap);
874 }
875
876 print_text_wrap_debug(msg, 0, 0);
877 if (strlen(last_debug) > 0)
878 {
879 //let's also draw this...
880 strcpy(msg, last_debug);
881 print_text_wrap_debug(msg, 0, 20);
882 }
883 }
884
885 /* Console */
886 if (console_active == 1)
887 {
888 char* line = dinkc_console_get_cur_line();
889 FONTS_SetTextColor(0, 0, 0);
890 print_text_wrap_debug(line, 20, 380);
891
892 char retval[20+1];
893 sprintf(retval, "%d", dinkc_console_get_last_retval());
894 FONTS_SetTextColor(255, 0, 0);
895 print_text_wrap_debug(retval, 20, 360);
896 }
897
898 int j2 = 0;
899 for (; j2 <= max_s; j2++)
900 {
901 int h = 0;
902 if (plane_process)
903 h = rank[j2];
904 else
905 h = j2;
906 if (h > 0 && spr[h].active && spr[h].brain == 8)
907 text_draw(h);
908 }
909
910
911 if (talk.active) process_talk();
912
913
914 process_callbacks();
915
916 flip:
917 if (g_b_kill_app) return;
918 if (!abort_this_flip)
919 flip_it();
920
921 if (turn_on_plane) plane_process = /*TRUE*/1;
922
923 } /* updateFrame */
924