|
19 | 19 | {$INCLUDE defines.inc}
|
20 | 20 |
|
21 | 21 | uses
|
22 |
| - SysUtils, SDL2, SDL2_image, SDL2_mixer, |
| 22 | + SysUtils, Math, |
| 23 | + SDL2, SDL2_image, SDL2_mixer, |
23 | 24 | Assets, Colours, ConfigFiles, FloatingText, Fonts, Game, Images, Objects, MathUtils, Rooms, Shared
|
24 | 25 | ;
|
25 | 26 |
|
|
576 | 577 |
|
577 | 578 | Function Startup():Boolean;
|
578 | 579 | Var
|
579 |
| - Title, S:AnsiString; Timu:Comp; GM:TGameMode; |
| 580 | + Title, ErrStr: AnsiString; |
| 581 | + Timu: Comp; |
| 582 | + GM: TGameMode; |
| 583 | + OldMask, NewMask: TFPUExceptionMask; |
580 | 584 | Begin
|
581 | 585 | Timu:=GetMSecs(); Randomize();
|
582 | 586 |
|
|
585 | 589 |
|
586 | 590 | LoadConfig();
|
587 | 591 | For GM:=Low(GM) to High(GM) do SaveExists[GM]:=IHasGame(GM);
|
588 |
| - |
| 592 | + |
| 593 | + // Disable Floating Poing Exception checking while initializing the video stack. |
| 594 | + // See: https://github.com/PascalGameDevelopment/SDL2-for-Pascal/issues/56 |
| 595 | + OldMask := Math.GetExceptionMask(); |
| 596 | + NewMask := OldMask; |
| 597 | + Include(NewMask, exInvalidOp); |
| 598 | + Include(NewMask, exZeroDivide); |
| 599 | + Math.SetExceptionMask(NewMask); |
| 600 | + |
589 | 601 | Write('Initializing SDL2 video... ');
|
590 | 602 | If (SDL_Init(SDL_Init_Video or SDL_Init_Timer)<>0) then begin
|
591 | 603 | Writeln('Failed!');
|
|
647 | 659 | SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, 'nearest');
|
648 | 660 | SDL_RenderSetLogicalSize(Shared.Renderer, RESOL_W, RESOL_H)
|
649 | 661 | end;
|
650 |
| - |
| 662 | + |
| 663 | + // Restore the old mask after we disabled FPE checks. |
| 664 | + Math.SetExceptionMask(OldMask); |
| 665 | + |
651 | 666 | Write('Creating render target texture... ');
|
652 | 667 | Shared.Display := SDL_CreateTexture(Shared.Renderer, SDL_GetWindowPixelFormat(Shared.Window), SDL_TEXTUREACCESS_TARGET, RESOL_W, RESOL_H);
|
653 | 668 | if(Shared.Display = NIL) then begin
|
|
658 | 673 |
|
659 | 674 | Write('Loading assets... ');
|
660 | 675 | RegisterAllAssets();
|
661 |
| - If Not LoadAssets(S, @LoadUpdate) then begin |
662 |
| - Writeln('ERROR'); Writeln(S); Exit(False); |
| 676 | + If Not LoadAssets(ErrStr, @LoadUpdate) then begin |
| 677 | + Writeln('ERROR'); Writeln(ErrStr); Exit(False); |
663 | 678 | end else
|
664 | 679 | Writeln('Success!');
|
665 | 680 |
|
|
0 commit comments