I have been asked for an additional listing covering Steam achievements.
So this is my current unit "steam" which deals with achievements and stats (integer stats only).

Please note: This only works with the compiler target Win32 for now!

https://docs.google.com/document/d/10O1GtdrLxHQxYbDQ9KyG5DcGLofBRnRAWFbxprcDcpA/edit?usp=sharing

The following is a rough game framework in order to show how to use the unit.

Code:
program mygame;
uses
  ...
  steam;

procedure update_event;
begin
  steam_update;
  ...
end;

procedure run_level;
begin
  ...
  repeat
    update_event;
    ...
    if steam_overlay then begin
      if not gamepaused then start_break;
    end
    else begin
      if gamepaused then finish_break;
    end;
    ...
  until quit;
  ...
end;

procedure mainloop;
begin
  ...
  repeat
    update_event;
    steam_debuguserstats;
    ...
    run_level;
    ...
  until quit;

  if not mission_survived then begin
    incandstore_istat(1); // stat "NumLosses"
    i := get_istat(1);
    case i of
      // died 1x
      1: setandstore_achievement(0); // Lazarus
      // died 9x
      9: setandstore_achievement(1); // cat
      // died 99x
      99: setandstore_achievement(2); // Coyote
    end;
  end;
  ...
end;

begin
  ...
  if steam_init({your APP ID})=-1 then halt;
  ...
  mainloop
end.