Steve,
I have cls,locate,color working. I think it would be best for now to change settextcolor to a "c" proc instead of asm code.
Using invoke color,fg,bg
I put them all in one object file as I didn't figure it needed to be anymore granular than that.
I added the protos to bxb.inc for now
I'm going to try to do the same on the windows side.
Using this basic source:
CLS
DIM Row = 0, Column = 0
LET Row = 10
LET Column = 5
COLOR 4,7
LOCATE Column,Row
PRINT "Hello World"
END
I modified the asm listing by hand before compiling with jwasm
;mov eax, 4
;mov ebx, 7
;call setcolortext
invoke color,4,7
This is the console.c compiled to an object and added to libbxbasm.a with ar and linked to the demo executable
#include <stdio.h>
#include <curses.h>
#include <termios.h>
//void cls(void);
void cls(void)
{
printf("%c%s%c%s",27,"[2J",27,"[H");
}
//==============================================================================
//void locate(int,int);
void locate(int col, int row)
{
printf("%c%s%u%s%u%s",27,"[",row,";",col,"H");
}
//==============================================================================
//void color (int, int)
void color (int fg,int bg)
{
printf("%c%s%u%s%u%s",27,"[",30+(fg&7),";",40+(bg&7),"m");
}
//==============================================================================
//int _getch_(int);
int _getch_(int waitkey)
{
struct termios initial_settings, new_settings;
unsigned char ch;
tcgetattr(0,&initial_settings);
new_settings = initial_settings;
new_settings.c_lflag &= ~ICANON;
new_settings.c_lflag &= ~ECHO;
new_settings.c_lflag &= ~ISIG;
new_settings.c_cc[VMIN] = waitkey;
new_settings.c_cc[VTIME] = 0;
tcsetattr(0, TCSANOW, &new_settings);
ch = getchar();
tcsetattr(0, TCSANOW, &initial_settings);
return ch;
}
//void bxbPause(void)
void _getch(void)
{
int ch;
printf("Press any key to continue . . .\n");
ch = _getch_(1);
}
//==============================================================================
James