diff options
author | Javier <dev.git@javispedro.com> | 2022-03-29 01:15:53 +0200 |
---|---|---|
committer | Javier <dev.git@javispedro.com> | 2022-03-29 01:15:53 +0200 |
commit | a816d1a09b1045fb5c155ac73f3231fcf9d93180 (patch) | |
tree | c4e31e850b9f2afb36acd6119483cf350c33f596 /dlog.h | |
parent | 67ebca92621aef31ff97705013456e95e60f7fbe (diff) | |
download | vbados-a816d1a09b1045fb5c155ac73f3231fcf9d93180.tar.gz vbados-a816d1a09b1045fb5c155ac73f3231fcf9d93180.zip |
initial import of DOS mouse driver
Diffstat (limited to 'dlog.h')
-rw-r--r-- | dlog.h | 87 |
1 files changed, 87 insertions, 0 deletions
@@ -0,0 +1,87 @@ +#ifndef DLOG_H +#define DLOG_H + +#define ENABLE_DLOG 1 + +#if ENABLE_DLOG + +#if 1 +#include "vbox.h" +#define dlog_putc vbox_log_putc +#endif + +static inline void dlog_endline(void) +{ + dlog_putc('\n'); +} + +static inline void dlog_print(const char *s) +{ + char c; + while (c = *s++) { + dlog_putc(c); + } +} + +static inline void dlog_printu(unsigned int num, int base) +{ + char buf[4]; + int i = 0; + + do { + int digit = num % base; + + if (digit < 10) { + buf[i] = '0' + digit; + } else { + buf[i] = 'a' + (digit - 10); + } + + i++; + num /= base; + } while (num > 0); + + while (i--) { + dlog_putc(buf[i]); + } +} + +static inline void dlog_printx(unsigned int num) +{ + dlog_printu(num, 16); +} + +static inline void dlog_printd(int num, int base) +{ + unsigned int unum; + + // TODO + if (num < 0) { + dlog_putc('-'); + unum = -num; + } else { + unum = num; + } + + dlog_printu(unum, base); +} + +static inline void dlog_puts(const char *s) +{ + dlog_print(s); + dlog_endline(); +} + +#else + +#define dlog_putc(c) +#define dlog_endline() +#define dlog_print(s) +#define dlog_printu(n) +#define dlog_printx(n) +#define dlog_printd(n,b) +#define dlog_puts(s) + +#endif + +#endif |