Add some std library functions

This commit is contained in:
drmortalwombat 2024-11-19 16:22:09 +01:00
parent df18dc273e
commit e7b0d17a83
5 changed files with 62 additions and 5 deletions

View File

@ -323,10 +323,7 @@ void putch(char c)
void clrscr(void) void clrscr(void)
{ {
__asm putrch(147);
{
jsr bsinit
}
} }
void textcursor(bool show) void textcursor(bool show)
@ -350,6 +347,24 @@ void textcolor(char c)
*(volatile char *)0x0286 = c; *(volatile char *)0x0286 = c;
} }
void bgcolor(char c)
{
*(volatile char *)0xd021 = c;
}
void bordercolor(char c)
{
*(volatile char *)0xd020 = c;
}
void revers(char r)
{
if (r)
putrch(18);
else
putrch(18 + 128);
}
char wherex(void) char wherex(void)
{ {
#if defined(__C128__) || defined(__C128B__) || defined(__C128E__) #if defined(__C128__) || defined(__C128B__) || defined(__C128E__)

View File

@ -43,6 +43,26 @@ void dispmode80col(void);
#define PETSCII_F7 0x88 #define PETSCII_F7 0x88
#define PETSCII_F8 0x8c #define PETSCII_F8 0x8c
enum ConioColors
{
COLOR_BLACK,
COLOR_WHITE,
COLOR_RED,
COLOR_CYAN,
COLOR_PURPLE,
COLOR_GREEN,
COLOR_BLUE,
COLOR_YELLOW,
COLOR_ORANGE,
COLOR_BROWN,
COLOR_LT_RED,
COLOR_DARK_GREY,
COLOR_MED_GREY,
COLOR_LT_GREEN,
COLOR_LT_BLUE,
COLOR_LT_GREY
};
// Lowlevel console in/out // Lowlevel console in/out
// using petscii translation // using petscii translation
@ -74,6 +94,12 @@ void gotoxy(char x, char y);
inline void textcolor(char c); inline void textcolor(char c);
inline void bgcolor(char c);
inline void bordercolor(char c);
inline void revers(char r);
inline char wherex(void); inline char wherex(void);
inline char wherey(void); inline char wherey(void);

View File

@ -417,7 +417,7 @@ char * sformat(char * buff, const char * fmt, int * fps, bool print)
si.precision = i; si.precision = i;
} }
if (c == 'd' || c == p'd') if (c == 'd' || c == p'd' || c == 'i' || c == p'i')
{ {
bi = nformi(&si, bp, *fps++, true); bi = nformi(&si, bp, *fps++, true);
} }

View File

@ -138,6 +138,20 @@ char * cpycat(char * dst, const char * src)
#pragma native(cpycat) #pragma native(cpycat)
char* strchr( const char* str, int ch )
{
char * p = (char *)str;
while (*p != (char)ch)
{
if (!*p)
return nullptr;
p++;
}
return p;
}
void * memset(void * dst, int value, int size) void * memset(void * dst, int value, int size)
{ {
__asm __asm

View File

@ -21,6 +21,8 @@ int memcmp(const void * ptr1, const void * ptr2, int size);
void * memmove(void * dst, const void * src, int size); void * memmove(void * dst, const void * src, int size);
char* strchr( const char* str, int ch );
#pragma intrinsic(strcpy) #pragma intrinsic(strcpy)
#pragma intrinsic(memcpy) #pragma intrinsic(memcpy)