
#ifndef __SYS_CONSOLE_H__ #define __SYS_CONSOLE_H__ // ------------------------------------ // --- Public function declarations --- // ------------------------------------ void SYS_console__init(const char* _info); void SYS_console__write(char* _input, ...); void SYS_console__cleanup(void); #endif
#include "SYS_console.h"
#include <proto/dos.h>
#include <stdio.h>
// --------------------------------
// --- Private global variables ---
// --------------------------------
// Pointer to my output console.
static BPTR console_ptr;
// -----------------------------------
// --- Public function definitions ---
// -----------------------------------
void SYS_console__init(const char* _info)
{
console_ptr = Open(_info, MODE_NEWFILE);
}
void SYS_console__write(char* _input, ...)
{
char output[256];
memset(output, 0, sizeof(output));
va_list args;
va_start(args, _input);
vsprintf(output, _input, args);
va_end(args);
if (console_ptr) Write(console_ptr, output, strlen(output));
else printf(output);
}
void SYS_console__cleanup()
{
if (console_ptr)
Close(console_ptr);
}#include "SYS_console.h"
#include <proto/dos.h>
#define CON_NAME "MyConsole..."
#define CON_X0 "30/"
#define CON_Y0 "35/"
#define CON_WIDTH "480/"
#define CON_HEIGHT "280/"
#define CON_INIT_INFO "CON:" CON_X0 CON_Y0 CON_WIDTH CON_HEIGHT CON_NAME
int main(int _argc, char **_argv)
{
// Init system console.
SYS_console__init(CON_INIT_INFO);
// Write out some info.
SYS_console__write("\n\nHello World...\n\n");
int foo = 123;
float bar = 10.0f;
SYS_console__write("Foo is: \t%d\nBar is: \t%f\n\n", foo, bar);
// Wait.
Delay(100);
// Cleanup console.
SYS_console__cleanup();
return 0;
} @mateusz_s, post #1
@Krashan, post #2