/*
   egfx.c
*/

cokerr Egfx_QueryVersion(char* query)  {
  Libcoke_SendStartcmd();
  Libcoke_SendByte(CMD_Egfx_QueryVersion);
  return (Libcoke_GetResponse(query));
}

cokerr Egfx_SetMode(cokebyte numColors, cokebyte refreshRate, cokebyte bufferRezID)  {
  Libcoke_SendStartcmd();
  Libcoke_SendByte(CMD_Egfx_SetMode);
  Libcoke_SendByte(numColors);
  Libcoke_SendByte(refreshRate);
  Libcoke_SendByte(bufferRezID);
  return (Libcoke_GetResponse(NULL));
}

cokerr Egfx_RestoreMode()  {
  Libcoke_SendStartcmd();
  Libcoke_SendByte(CMD_Egfx_RestoreMode);
  return (Libcoke_GetResponse(NULL));
}

cokerr Egfx_CheckBufferSpace(cokebyte width, cokebyte height)  {
  Libcoke_SendStartcmd();
  Libcoke_SendByte(CMD_Egfx_CheckBufferSpace);
  Libcoke_SendByte(width);
  Libcoke_SendByte(height);
  return (Libcoke_GetResponse(NULL));
}

cokerr Egfx_CreateBuffer(cokebyte width, cokebyte height, cokebyte* query)  {
  unsigned char buf[2];
  cokerr status;

  Libcoke_SendStartcmd();
  Libcoke_SendByte(CMD_Egfx_CreateBuffer);
  Libcoke_SendByte(width);
  Libcoke_SendByte(height);
  status = Libcoke_GetResponse((char*)buf);
  *query = (cokebyte)(*buf);
  return status;
}

cokerr Egfx_ScriptResource(cokebyte rezID)  {
  Libcoke_SendStartcmd();
  Libcoke_SendByte(CMD_Egfx_ScriptResource);
  Libcoke_SendByte(rezID);
  return (Libcoke_GetResponse(NULL));
}

cokerr Egfx_StartAutoScript(cokebyte rezID, cokeword speed)  {
  Libcoke_SendStartcmd();
  Libcoke_SendByte(CMD_Egfx_StartAutoScript);
  Libcoke_SendByte(rezID);
  Libcoke_SendWord(speed);
  return (Libcoke_GetResponse(NULL));
}

cokerr Egfx_StopAutoScript()  {
  Libcoke_SendStartcmd();
  Libcoke_SendByte(CMD_Egfx_StopAutoScript);
  return (Libcoke_GetResponse(NULL));
}

