Reduce dependencies on trio

This commit is contained in:
twinaphex 2014-06-19 19:52:26 +02:00
parent 5a23737a61
commit 47901cd797
8 changed files with 32 additions and 41 deletions

View File

@ -18,7 +18,6 @@
#include "../mednafen.h"
#include "../general.h"
#include "CDAccess_CCD.h"
#include <trio/trio.h>
#include <limits>
#include <limits.h>
@ -206,7 +205,7 @@ void CDAccess_CCD::Load(const char *path, bool image_memcache)
for(unsigned te = 0; te < toc_entries; te++)
{
char tmpbuf[64];
trio_snprintf(tmpbuf, sizeof(tmpbuf), "ENTRY %u", te);
snprintf(tmpbuf, sizeof(tmpbuf), "ENTRY %u", te);
CCD_Section& ts = Sections[std::string(tmpbuf)];
unsigned session = CCD_ReadInt<unsigned>(ts, "SESSION");
uint8 point = CCD_ReadInt<uint8>(ts, "POINT");

View File

@ -37,7 +37,6 @@
#include <string.h>
#include <errno.h>
#include <time.h>
#include <trio/trio.h>
#include "../general.h"
#include "../FileStream.h"
@ -241,12 +240,12 @@ void CDAccess_Image::ParseTOCFileLineInfo(CDRFILE_TRACK_INFO *track, const int t
if(track->SubchannelMode)
sector_mult += 96;
if(binoffset && trio_sscanf(binoffset, "%ld", &tmp_long) == 1)
if(binoffset && sscanf(binoffset, "%ld", &tmp_long) == 1)
{
offset += tmp_long;
}
if(msfoffset && trio_sscanf(msfoffset, "%d:%d:%d", &m, &s, &f) == 3)
if(msfoffset && sscanf(msfoffset, "%d:%d:%d", &m, &s, &f) == 3)
{
offset += ((m * 60 + s) * 75 + f) * sector_mult;
}
@ -259,7 +258,7 @@ void CDAccess_Image::ParseTOCFileLineInfo(CDRFILE_TRACK_INFO *track, const int t
{
tmp_long = sectors;
if(trio_sscanf(length, "%d:%d:%d", &m, &s, &f) == 3)
if(sscanf(length, "%d:%d:%d", &m, &s, &f) == 3)
tmp_long = (m * 60 + s) * 75 + f;
else if(track->DIFormat == DI_FORMAT_AUDIO)
{
@ -519,7 +518,7 @@ void CDAccess_Image::ImageOpen(const char *path, bool image_memcache)
throw(MDFN_Error(0, _("Command %s is outside of a TRACK definition!\n"), cmdbuf.c_str()));
}
int m,s,f;
trio_sscanf(args[0].c_str(), "%d:%d:%d", &m, &s, &f);
sscanf(args[0].c_str(), "%d:%d:%d", &m, &s, &f);
TmpTrack.pregap = (m * 60 + s) * 75 + f;
} // end to PREGAP
else if(cmdbuf == "START")
@ -529,7 +528,7 @@ void CDAccess_Image::ImageOpen(const char *path, bool image_memcache)
throw(MDFN_Error(0, _("Command %s is outside of a TRACK definition!\n"), cmdbuf.c_str()));
}
int m,s,f;
trio_sscanf(args[0].c_str(), "%d:%d:%d", &m, &s, &f);
sscanf(args[0].c_str(), "%d:%d:%d", &m, &s, &f);
TmpTrack.pregap = (m * 60 + s) * 75 + f;
}
else if(cmdbuf == "TWO_CHANNEL_AUDIO")
@ -668,7 +667,7 @@ void CDAccess_Image::ImageOpen(const char *path, bool image_memcache)
{
unsigned int m,s,f;
if(trio_sscanf(args[1].c_str(), "%u:%u:%u", &m, &s, &f) != 3)
if(sscanf(args[1].c_str(), "%u:%u:%u", &m, &s, &f) != 3)
{
throw MDFN_Error(0, _("Malformed m:s:f time in \"%s\" directive: %s"), cmdbuf.c_str(), args[0].c_str());
}
@ -685,7 +684,7 @@ void CDAccess_Image::ImageOpen(const char *path, bool image_memcache)
{
unsigned int m,s,f;
if(trio_sscanf(args[0].c_str(), "%u:%u:%u", &m, &s, &f) != 3)
if(sscanf(args[0].c_str(), "%u:%u:%u", &m, &s, &f) != 3)
{
throw MDFN_Error(0, _("Malformed m:s:f time in \"%s\" directive: %s"), cmdbuf.c_str(), args[0].c_str());
}
@ -699,7 +698,7 @@ void CDAccess_Image::ImageOpen(const char *path, bool image_memcache)
{
unsigned int m,s,f;
if(trio_sscanf(args[0].c_str(), "%u:%u:%u", &m, &s, &f) != 3)
if(sscanf(args[0].c_str(), "%u:%u:%u", &m, &s, &f) != 3)
{
throw MDFN_Error(0, _("Malformed m:s:f time in \"%s\" directive: %s"), cmdbuf.c_str(), args[0].c_str());
}

View File

@ -26,7 +26,6 @@
#include "../clamp.h"
#include <math.h>
#include <algorithm>
#include <trio/trio.h>
#include "scsicd.h"
#include "cdromif.h"
#include "SimpleFIFO.h"
@ -3104,11 +3103,11 @@ uint32 SCSICD_Run(scsicd_timestamp_t system_timestamp)
log_buffer[0] = 0;
lb_pos = trio_snprintf(log_buffer, 1024, "Command: %02x, %s%s ", cd.command_buffer[0], cmd_info_ptr->pretty_name ? cmd_info_ptr->pretty_name : "!!BAD COMMAND!!",
lb_pos = snprintf(log_buffer, 1024, "Command: %02x, %s%s ", cd.command_buffer[0], cmd_info_ptr->pretty_name ? cmd_info_ptr->pretty_name : "!!BAD COMMAND!!",
(cmd_info_ptr->flags & SCF_UNTESTED) ? "(UNTESTED)" : "");
for(int i = 0; i < RequiredCDBLen[cd.command_buffer[0] >> 4]; i++)
lb_pos += trio_snprintf(log_buffer + lb_pos, 1024 - lb_pos, "%02x ", cd.command_buffer[i]);
lb_pos += snprintf(log_buffer + lb_pos, 1024 - lb_pos, "%02x ", cd.command_buffer[i]);
SCSILog("SCSI", "%s", log_buffer);
//puts(log_buffer);

View File

@ -1,8 +1,6 @@
#ifndef __MDFN_HUC6280_H
#define __MDFN_HUC6280_H
#include <trio/trio.h>
class HuC6280_Support
{
public:
@ -236,7 +234,7 @@ class HuC6280
value = P;
if(special)
{
trio_snprintf(special, special_len, "N: %d, V: %d, T: %d, D: %d, I: %d, Z: %d, C: %d", (int)(bool)(value & N_FLAG),
snprintf(special, special_len, "N: %d, V: %d, T: %d, D: %d, I: %d, Z: %d, C: %d", (int)(bool)(value & N_FLAG),
(int)(bool)(value & V_FLAG),
(int)(bool)(value & T_FLAG),
(int)(bool)(value & D_FLAG),
@ -250,7 +248,7 @@ class HuC6280
value = speed;
if(special)
{
trio_snprintf(special, special_len, "%s(%s)", speed ? "High" : "Low", speed ? "7.16MHz" : "1.79MHz");
snprintf(special, special_len, "%s(%s)", speed ? "High" : "Low", speed ? "7.16MHz" : "1.79MHz");
}
break;
@ -266,7 +264,7 @@ class HuC6280
if(special)
{
trio_snprintf(special, special_len, "0x%02X * 0x2000 = 0x%06X", value, (uint32)value * 0x2000);
snprintf(special, special_len, "0x%02X * 0x2000 = 0x%06X", value, (uint32)value * 0x2000);
}
break;
@ -275,7 +273,7 @@ class HuC6280
if(special)
{
trio_snprintf(special, special_len, "IRQ2: %s, IRQ1: %s, Timer: %s", (value & IQIRQ2) ? "Disabled" : "Enabled",
snprintf(special, special_len, "IRQ2: %s, IRQ1: %s, Timer: %s", (value & IQIRQ2) ? "Disabled" : "Enabled",
(value & IQIRQ1) ? "Disabled" : "Enabled", (value & IQTIMER) ? "Disabled" : "Enabled");
}
break;
@ -285,7 +283,7 @@ class HuC6280
if(special)
{
trio_snprintf(special, special_len, "%s", (value & 1) ? "Enabled" : "Disabled");
snprintf(special, special_len, "%s", (value & 1) ? "Enabled" : "Disabled");
}
break;
@ -298,7 +296,7 @@ class HuC6280
if(special)
{
uint32 meowval = (value + 1) * 1024;
trio_snprintf(special, special_len, "(%d + 1) * 1024 = %d; 7,159,090.90... Hz / %d = %f Hz", value, meowval, meowval, (double)7159090.909090909091 / meowval);
snprintf(special, special_len, "(%d + 1) * 1024 = %d; 7,159,090.90... Hz / %d = %f Hz", value, meowval, meowval, (double)7159090.909090909091 / meowval);
}
break;

View File

@ -21,7 +21,6 @@
#include "mednafen/video.h"
#include "mednafen/lepacker.h"
#include <trio/trio.h>
#include <math.h>
#include "vdc.h"
@ -109,7 +108,7 @@ uint32 VDC::GetRegister(const unsigned int id, char *special, const uint32 speci
if(special)
{
trio_snprintf(special, special_len, "Sprite Hit IRQ: %s, Sprite Overflow IRQ: %s, RCR IRQ: %s, VBlank IRQ: %s, Sprites: %s, Background: %s", (value & 1) ? "On" : "Off", (value & 2) ? "On" : "Off",
snprintf(special, special_len, "Sprite Hit IRQ: %s, Sprite Overflow IRQ: %s, RCR IRQ: %s, VBlank IRQ: %s, Sprites: %s, Background: %s", (value & 1) ? "On" : "Off", (value & 2) ? "On" : "Off",
(value & 4) ? "On" : "Off", (value & 8) ? "On" : "Off", (value & 0x40) ? "On" : "Off", (value & 0x80) ? "On" : "Off");
}
break;
@ -131,7 +130,7 @@ uint32 VDC::GetRegister(const unsigned int id, char *special, const uint32 speci
if(special)
{
trio_snprintf(special, special_len, "CG Mode: %d, BAT Width: %d(tiles), BAT Height: %d(tiles)", (int)(bool)(value & 0x80),
snprintf(special, special_len, "CG Mode: %d, BAT Width: %d(tiles), BAT Height: %d(tiles)", (int)(bool)(value & 0x80),
bat_width_tab[(value >> 4) & 0x3],
bat_height_tab[(value >> 6) & 0x1]);
}
@ -141,7 +140,7 @@ uint32 VDC::GetRegister(const unsigned int id, char *special, const uint32 speci
value = HSR;
if(special)
{
trio_snprintf(special, special_len, "HSW: %02x, HDS: %02x", value & 0x1F, (value >> 8) & 0x7F);
snprintf(special, special_len, "HSW: %02x, HDS: %02x", value & 0x1F, (value >> 8) & 0x7F);
}
break;
@ -149,7 +148,7 @@ uint32 VDC::GetRegister(const unsigned int id, char *special, const uint32 speci
value = HDR;
if(special)
{
trio_snprintf(special, special_len, "HDW: %02x, HDE: %02x", value & 0x7F, (value >> 8) & 0x7F);
snprintf(special, special_len, "HDW: %02x, HDE: %02x", value & 0x7F, (value >> 8) & 0x7F);
}
break;
@ -158,7 +157,7 @@ uint32 VDC::GetRegister(const unsigned int id, char *special, const uint32 speci
value = VSR;
if(special)
{
trio_snprintf(special, special_len, "VSW: %02x, VDS: %02x", value & 0x1F, (value >> 8) & 0xFF);
snprintf(special, special_len, "VSW: %02x, VDS: %02x", value & 0x1F, (value >> 8) & 0xFF);
}
break;
@ -174,7 +173,7 @@ uint32 VDC::GetRegister(const unsigned int id, char *special, const uint32 speci
value = DCR;
if(special)
{
trio_snprintf(special, special_len, "SATB DMA IRQ: %s, VRAM DMA IRQ: %s, DMA Source Address: %s, DMA Dest Address: %s, Auto SATB DMA: %s",
snprintf(special, special_len, "SATB DMA IRQ: %s, VRAM DMA IRQ: %s, DMA Source Address: %s, DMA Dest Address: %s, Auto SATB DMA: %s",
(DCR & 0x1) ? "On" : "Off", (DCR & 0x2) ? "On" : "Off", (DCR & 0x4) ? "Decrement" : "Increment", (DCR & 0x8) ? "Decrement" : "Increment",
(DCR & 0x10) ? "On" : "Off");
}

View File

@ -21,7 +21,6 @@
#include "mednafen/video.h"
#include "mednafen/lepacker.h"
#include <trio/trio.h>
#include <math.h>
#include "vdc.h"
@ -119,7 +118,7 @@ uint32 VDC::GetRegister(const unsigned int id, char *special, const uint32 speci
if(special)
{
trio_snprintf(special, special_len, "Sprite Hit IRQ: %s, Sprite Overflow IRQ: %s, RCR IRQ: %s, VBlank IRQ: %s, Sprites: %s, Background: %s", (value & 1) ? "On" : "Off", (value & 2) ? "On" : "Off",
snprintf(special, special_len, "Sprite Hit IRQ: %s, Sprite Overflow IRQ: %s, RCR IRQ: %s, VBlank IRQ: %s, Sprites: %s, Background: %s", (value & 1) ? "On" : "Off", (value & 2) ? "On" : "Off",
(value & 4) ? "On" : "Off", (value & 8) ? "On" : "Off", (value & 0x40) ? "On" : "Off", (value & 0x80) ? "On" : "Off");
}
break;
@ -141,7 +140,7 @@ uint32 VDC::GetRegister(const unsigned int id, char *special, const uint32 speci
if(special)
{
trio_snprintf(special, special_len, "CG Mode: %d, BAT Width: %d(tiles), BAT Height: %d(tiles)", (int)(bool)(value & 0x80),
snprintf(special, special_len, "CG Mode: %d, BAT Width: %d(tiles), BAT Height: %d(tiles)", (int)(bool)(value & 0x80),
bat_width_tab[(value >> 4) & 0x3],
bat_height_tab[(value >> 6) & 0x1]);
}
@ -151,7 +150,7 @@ uint32 VDC::GetRegister(const unsigned int id, char *special, const uint32 speci
value = HSR;
if(special)
{
trio_snprintf(special, special_len, "HSW: %02x, HDS: %02x", value & 0x1F, (value >> 8) & 0x7F);
snprintf(special, special_len, "HSW: %02x, HDS: %02x", value & 0x1F, (value >> 8) & 0x7F);
}
break;
@ -159,7 +158,7 @@ uint32 VDC::GetRegister(const unsigned int id, char *special, const uint32 speci
value = HDR;
if(special)
{
trio_snprintf(special, special_len, "HDW: %02x, HDE: %02x", value & 0x7F, (value >> 8) & 0x7F);
snprintf(special, special_len, "HDW: %02x, HDE: %02x", value & 0x7F, (value >> 8) & 0x7F);
}
break;
@ -168,7 +167,7 @@ uint32 VDC::GetRegister(const unsigned int id, char *special, const uint32 speci
value = VSR;
if(special)
{
trio_snprintf(special, special_len, "VSW: %02x, VDS: %02x", value & 0x1F, (value >> 8) & 0xFF);
snprintf(special, special_len, "VSW: %02x, VDS: %02x", value & 0x1F, (value >> 8) & 0xFF);
}
break;
@ -184,7 +183,7 @@ uint32 VDC::GetRegister(const unsigned int id, char *special, const uint32 speci
value = DCR;
if(special)
{
trio_snprintf(special, special_len, "SATB DMA IRQ: %s, VRAM DMA IRQ: %s, DMA Source Address: %s, DMA Dest Address: %s, Auto SATB DMA: %s",
snprintf(special, special_len, "SATB DMA IRQ: %s, VRAM DMA IRQ: %s, DMA Source Address: %s, DMA Dest Address: %s, Auto SATB DMA: %s",
(DCR & 0x1) ? "On" : "Off", (DCR & 0x2) ? "On" : "Off", (DCR & 0x4) ? "Decrement" : "Increment", (DCR & 0x8) ? "Decrement" : "Increment",
(DCR & 0x10) ? "On" : "Off");
}

View File

@ -18,7 +18,6 @@
#include "../mednafen.h"
#include "../clamp.h"
#include <math.h>
#include <trio/trio.h>
#include "pcecd_drive.h"
#include "../cdrom/cdromif.h"
#include "../cdrom/SimpleFIFO.h"
@ -1123,10 +1122,10 @@ uint32 PCECD_Drive_Run(pcecd_drive_timestamp_t system_timestamp)
log_buffer[0] = 0;
lb_pos = trio_snprintf(log_buffer, 1024, "Command: %02x, %s ", cd.command_buffer[0], cmd_info_ptr->pretty_name ? cmd_info_ptr->pretty_name : "!!BAD COMMAND!!");
lb_pos = snprintf(log_buffer, 1024, "Command: %02x, %s ", cd.command_buffer[0], cmd_info_ptr->pretty_name ? cmd_info_ptr->pretty_name : "!!BAD COMMAND!!");
for(int i = 0; i < RequiredCDBLen[cd.command_buffer[0] >> 4]; i++)
lb_pos += trio_snprintf(log_buffer + lb_pos, 1024 - lb_pos, "%02x ", cd.command_buffer[i]);
lb_pos += snprintf(log_buffer + lb_pos, 1024 - lb_pos, "%02x ", cd.command_buffer[i]);
SCSILog("SCSI", "%s", log_buffer);
//puts(log_buffer);

View File

@ -19,7 +19,6 @@
#include <string.h>
#include <trio/trio.h>
#include "driver.h"
#include "general.h"
#include "state.h"
@ -170,7 +169,7 @@ static bool SubWrite(StateMem *st, SFORMAT *sf, const char *name_prefix = NULL)
char nameo[1 + 256];
int slen;
slen = trio_snprintf(nameo + 1, 256, "%s%s", name_prefix ? name_prefix : "", sf->name);
slen = snprintf(nameo + 1, 256, "%s%s", name_prefix ? name_prefix : "", sf->name);
nameo[0] = slen;
if(slen >= 255)