Moved itoa to osd

This commit is contained in:
recompileorg 2020-04-18 07:19:39 -04:00 committed by GitHub
parent 5107499177
commit 44a0c0b329
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 44 deletions

View File

@ -16,7 +16,6 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include "memory.h"
#include "cart.h"
#include "osd.h"
@ -37,10 +36,6 @@ void load7(void);
void load8(void);
void load9(void);
void itoa2(int num, char*buffer, int base); // we need to roll our own for PSP...
const char *title[0x40];
int data[0x20000]; // rom data loaded from file
int size = 0; // size of file read
@ -74,10 +69,8 @@ int LoadCart(const char *path)
return 0;
}
char buffer[16];
itoa2(size, buffer, 10);
OSD_drawText(8, 4, "SIZE:");
OSD_drawText(14, 4, buffer);
OSD_drawInt(14, 4, size, 10);
if(isIntellicart()) // intellicart format
{
@ -479,38 +472,3 @@ int getLoadMethod() // lazy, but it works
}
return -1;
}
void itoa2(int num, char* buffer, int base)
{
int i = 0;
int r = 0;
if(num<0)
{
num = 0-num;
buffer[i] = '-';
i++;
}
if(num==0)
{
buffer[i]='0';
i++;
}
else
{
while(num>0)
{
r = num % base;
num = (num-r) / base;
if(r>9)
{
buffer[i] = 'A' + r;
}
else
{
buffer[i] = '0' + r;
}
i++;
}
}
buffer[i] = '\0';
}

View File

@ -344,4 +344,44 @@ void OSD_drawTextCenterBG(int y, const char *text)
OSD_drawTextFree(x+1, y+1, text);
}
}
}
void OSD_drawInt(int x, int y, int num, int base)
{
char buffer[2] = {0,0};
int r = 0;
if(base>2) { base = 10; }
if(num<0)
{
num = 0-num;
buffer[0] = '-';
OSD_drawText(x, y, buffer);
x++;
}
if(num==0)
{
buffer[0] = '0';
OSD_drawText(x, y, buffer);
x++;
}
else
{
while(num>0)
{
r = num % base;
num = (num-r) / base;
if(r>9)
{
buffer[0] = 'A' + r;
}
else
{
buffer[0] = '0' + r;
}
OSD_drawText(x, y, buffer);
x++;
}
}
}

View File

@ -47,6 +47,8 @@ void OSD_drawLetter(int x, int y, int c);
void OSD_drawText(int x, int y, const char *text);
void OSD_drawInt(int x, int y, int num, int base);
void OSD_drawTextFree(int x, int y, const char *text);
void OSD_drawTextBG(int x, int y, const char *text);