showpic.pas 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. {
  2. Copyright (c) 2020 Karoly Balogh
  3. Shows an Atari DEGAS picture on full screen
  4. Example program for Free Pascal's Atari TOS bindings
  5. This example program is in the Public Domain under the terms of
  6. Unlicense: http://unlicense.org/
  7. **********************************************************************}
  8. {$APPTYPE CONSOLE}
  9. program showpic;
  10. uses
  11. xbios, gemdos;
  12. {$i showpic.inc}
  13. type
  14. Tdegas_picture = record
  15. mode: smallint;
  16. palette: array[0..15] of smallint;
  17. data: array[0..31999] of byte;
  18. end;
  19. Pdegas_picture = ^Tdegas_picture;
  20. var
  21. old_palette: array[0..16] of smallint;
  22. old_rez: smallint;
  23. screen: pword;
  24. pic: Pdegas_picture;
  25. procedure save_palette(palette: pword);
  26. var
  27. i: smallint;
  28. begin
  29. for i:=0 to 15 do
  30. palette[i]:=xbios_setcolor(i,-1);
  31. end;
  32. procedure init(mode: smallint);
  33. begin
  34. { obtain the old resolution and palette }
  35. old_rez:=xbios_getrez;
  36. save_palette(@old_palette[0]);
  37. { set the screen mode and get the framebuffer address }
  38. xbios_setscreen(pointer(-1),pointer(-1),mode);
  39. screen:=xbios_logbase;
  40. end;
  41. procedure done;
  42. begin
  43. { restore original screen resolution and palette }
  44. xbios_setscreen(pointer(-1),pointer(-1),old_rez);
  45. xbios_setpalette(@old_palette);
  46. end;
  47. begin
  48. { this uses a compiled-in picture, but it's easy to load
  49. something from disk at this point instead }
  50. pic:=Pdegas_picture(@cheetah_pic);
  51. init(pic^.mode);
  52. { set the palette and move picture data to the framebuffer }
  53. xbios_setpalette(@pic^.palette);
  54. system.move(pic^.data,screen^,sizeof(pic^.data));
  55. { wait for keypress }
  56. gemdos_cnecin;
  57. done;
  58. end.