From 14156fa6d891446da30854a562d62652fb5d30b9 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Thu, 29 Dec 2022 07:14:25 +0200 Subject: [PATCH] moved dos tgfx.c to src/dos --- .gitignore | 3 ++ Makefile | 12 +++++-- src/dos/tgfx.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/tgfx.c | 104 -------------------------------------------------------- src/tgfx.h | 2 +- 5 files changed, 117 insertions(+), 108 deletions(-) create mode 100644 src/dos/tgfx.c delete mode 100644 src/tgfx.c diff --git a/.gitignore b/.gitignore index 9a0d302..1ec8f24 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ *.d oftp *.exe +*.obj +*.lnk +*.map diff --git a/Makefile b/Makefile index 26c7bac..dd0f1bf 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,26 @@ obj = main.obj tgfx.obj tui.obj darray.obj util.obj bin = oftp.exe +!ifdef __UNIX__ +incpath = -Isrc -Isrc/dos +!else +incpath = -Isrc -Isrc\dos +!endif + #opt = -otexan warn = -w=3 dbg = -d3 CC = wcc386 LD = wlink -CFLAGS = $(warn) $(dbg) $(opt) $(def) -zq -bt=dos +CFLAGS = $(warn) $(dbg) $(opt) $(incpath) $(def) -zq -bt=dos $(bin): $(obj) %write objects.lnk $(obj) $(LD) debug all option map name $@ system dos4g file { @objects } $(LDFLAGS) -.c: src -.asm: src +.c: src;src/dos +.asm: src;src/dos .c.obj: .autodepend $(CC) -fo=$@ $(CFLAGS) $< diff --git a/src/dos/tgfx.c b/src/dos/tgfx.c new file mode 100644 index 0000000..9818286 --- /dev/null +++ b/src/dos/tgfx.c @@ -0,0 +1,104 @@ +#include +#include +#include +#include +#include "tgfx.h" + +static unsigned short attr = 0x0700; +static int bgcol = 0, fgcol = 7; +static int bgchar = ' '; +static unsigned short *framebuf = (unsigned short*)0xb8000; + +#define UPD_ATTR attr = (fgcol << 8) | (bgcol << 12) + +void tg_clear(void) +{ + tg_rect(0, 0, 0, 80, 25, 0); +} + +void tg_fgcolor(int col) +{ + fgcol = col & 0xf; + UPD_ATTR; +} + +void tg_bgcolor(int col) +{ + bgcol = col & 0xf; + UPD_ATTR; +} + +void tg_color(int col) +{ + fgcol = col & 0xf; + bgcol = (col >> 4) & 0xf; + attr = col << 8; +} + +void tg_bgchar(int c) +{ + bgchar = c; +} + +#define CRTC_ADDR_PORT 0x3d4 +#define CRTC_DATA_PORT 0x3d5 +#define REG_CRTC_CURH 0xe +#define REG_CRTC_CURL 0xf + +void tg_setcursor(int x, int y) +{ + unsigned int addr = y * 80 + x; + + outpw(CRTC_ADDR_PORT, (addr & 0xff00) | REG_CRTC_CURH); + outpw(CRTC_ADDR_PORT, (addr << 8) | REG_CRTC_CURL); +} + +void tg_text(int x, int y, const char *fmt, ...) +{ + va_list ap; + char buf[128], *ptr; + unsigned short *fbptr = framebuf + y * 80 + x; + + va_start(ap, fmt); + vsprintf(buf, fmt, ap); + va_end(ap); + + ptr = buf; + while(*ptr) { + *fbptr++ = *ptr++ | attr; + } +} + +void tg_rect(const char *label, int x, int y, int xsz, int ysz, unsigned int flags) +{ + int i, j; + unsigned short *fbptr = framebuf + y * 80 + x; + + for(i=0; i -#include -#include -#include -#include "tgfx.h" - -static unsigned short attr = 0x0700; -static int bgcol = 0, fgcol = 7; -static int bgchar = ' '; -static unsigned short *framebuf = (unsigned short*)0xb8000; - -#define UPD_ATTR attr = (fgcol << 8) | (bgcol << 12) - -void tg_clear(void) -{ - tg_rect(0, 0, 0, 80, 25, 0); -} - -void tg_fgcolor(int col) -{ - fgcol = col & 0xf; - UPD_ATTR; -} - -void tg_bgcolor(int col) -{ - bgcol = col & 0xf; - UPD_ATTR; -} - -void tg_color(int col) -{ - fgcol = col & 0xf; - bgcol = (col >> 4) & 0xf; - attr = col << 8; -} - -void tg_bgchar(int c) -{ - bgchar = c; -} - -#define CRTC_ADDR_PORT 0x3d4 -#define CRTC_DATA_PORT 0x3d5 -#define REG_CRTC_CURH 0xe -#define REG_CRTC_CURL 0xf - -void tg_setcursor(int x, int y) -{ - unsigned int addr = y * 80 + x; - - outpw(CRTC_ADDR_PORT, (addr & 0xff00) | REG_CRTC_CURH); - outpw(CRTC_ADDR_PORT, (addr << 8) | REG_CRTC_CURL); -} - -void tg_text(int x, int y, const char *fmt, ...) -{ - va_list ap; - char buf[128], *ptr; - unsigned short *fbptr = framebuf + y * 80 + x; - - va_start(ap, fmt); - vsprintf(buf, fmt, ap); - va_end(ap); - - ptr = buf; - while(*ptr) { - *fbptr++ = *ptr++ | attr; - } -} - -void tg_rect(const char *label, int x, int y, int xsz, int ysz, unsigned int flags) -{ - int i, j; - unsigned short *fbptr = framebuf + y * 80 + x; - - for(i=0; i