Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New port: DOSVGA #84

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
53c766d
First functional version of PDCurses on DOSVGA
chasonr Feb 19, 2020
2c23a5a
Write like-colored characters in one pass
chasonr Feb 19, 2020
482d065
Remove some stray comments
chasonr Feb 19, 2020
fc2cec8
Support 4 bit VESA graphics modes
chasonr Feb 19, 2020
d1796bc
Fix problems with drawing the cursor
chasonr Feb 19, 2020
a6026d1
Add support for 8 bit color modes
chasonr Feb 21, 2020
26dd4ee
Fix the color selection
chasonr Feb 21, 2020
df1ec71
Fix mode selection problems
chasonr Feb 22, 2020
6636946
Support direct color modes
chasonr Feb 22, 2020
8a21ab2
Support 32 bit compile on Watcom
chasonr Feb 22, 2020
eba26e2
Support Watcom in 16 bit mode
chasonr Feb 22, 2020
10a68b4
Fix integer overflow in 16 bit compile
chasonr Feb 22, 2020
1e92287
Add support for the Borland compiler
chasonr Feb 22, 2020
081eb3c
Support 8 bit DACs in 8 bit color mode
chasonr Feb 22, 2020
d98641d
Add A_LEFT and A_RIGHT
chasonr Feb 22, 2020
6ea186e
Include dosvga in the READMEs
chasonr Feb 22, 2020
dcd159c
Support linear frame buffer in 32 bit builds
chasonr Feb 22, 2020
1e35536
Fail gracefully if no VGA installed
chasonr Feb 22, 2020
6e75f6d
Fix a bug in 24 bit pixel handling
chasonr Feb 23, 2020
36e05ea
Rewrite rendering functions for speed
chasonr Feb 23, 2020
e693878
Use LinBytesPerScanLine for linear frame buffer
chasonr Feb 28, 2020
556ba57
Simplify cursor rendering
chasonr Feb 28, 2020
e9f10e4
Add support for external PSF font
chasonr Mar 1, 2020
0ae1cee
Provide wcslen for the DJGPP build
chasonr Mar 1, 2020
7be7a7b
Support fonts of arbitrary size
chasonr Mar 2, 2020
b812ef5
Fix the default VGA mode
chasonr Mar 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ platforms.
Build instructions are in the README.md file for each platform:

- [DOS]
- [DOS with full VGA support]
- [OS/2]
- [SDL 1.x]
- [SDL 2.x]
Expand All @@ -58,6 +59,7 @@ William McBrine <[email protected]>
[History]: docs/HISTORY.md
[docs]: docs/README.md
[DOS]: dos/README.md
[DOS with full VGA support]: dosvga/README.md
[OS/2]: os2/README.md
[SDL 1.x]: sdl1/README.md
[SDL 2.x]: sdl2/README.md
Expand Down
15 changes: 14 additions & 1 deletion demos/testcurs.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

#if HAVE_WIDE
# include <wchar.h>
# ifdef __DJGPP__
static size_t wcslen(const wchar_t *);
# endif
#endif

#if defined(PDCURSES) && !defined(XCURSES)
Expand Down Expand Up @@ -1209,7 +1212,7 @@ void gradient(int tmarg)
move(tmarg + 3 + i, (COLS - 69) / 2);
for (j = 0; j < len; j++)
{
const int oval = j * 1000 / len;
const int oval = (int)(j * 1000L / len);
const int reverse = 1000 - oval;

if (!i)
Expand Down Expand Up @@ -1380,3 +1383,13 @@ void display_menu(int old_option, int new_option)
"Use Up and Down Arrows to select - Enter to run - Q to quit");
refresh();
}

#if HAVE_WIDE && defined(__DJGPP__)
/* wide character function missing in DJGPP */
static size_t wcslen(const wchar_t *str)
{
size_t i;
for (i = 0; str[i] != L'\0'; ++i) {}
return i;
}
#endif
89 changes: 89 additions & 0 deletions dosvga/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# GNU Makefile for PDCurses - DOS
#
# Usage: make [-f path\Makefile] [DEBUG=Y] [WIDE=Y] [target]
#
# where target can be any of:
# [all|libs|demos|pdcurses.a|testcurs.exe...]

O = o
E = .exe
RM = del

ifndef PDCURSES_SRCDIR
PDCURSES_SRCDIR = ..
endif

include $(PDCURSES_SRCDIR)/common/libobjs.mif

osdir = $(PDCURSES_SRCDIR)/dosvga

PDCURSES_DOS_H = $(osdir)/pdcdos.h

CC = gcc

ifeq ($(DEBUG),Y)
CFLAGS = -g -Wall -DPDCDEBUG
LDFLAGS = -g
else
CFLAGS = -O2 -Wall
LDFLAGS =
endif

CFLAGS += -I$(PDCURSES_SRCDIR)

ifeq ($(WIDE),Y)
CFLAGS += -DPDC_WIDE
endif

LINK = gcc

LIBEXE = ar
LIBFLAGS = rcv

LIBCURSES = pdcurses.a

.PHONY: all libs clean demos dist

all: libs

libs: $(LIBCURSES)

clean:
-$(RM) *.o
-$(RM) *.a
-$(RM) *.exe

demos: $(DEMOS)
ifneq ($(DEBUG),Y)
strip *.exe
endif

$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
$(LIBEXE) $(LIBFLAGS)S $@ addch.o addchstr.o addstr.o attr.o beep.o bkgd.o border.o clear.o color.o debug.o delch.o deleteln.o
$(LIBEXE) $(LIBFLAGS)S $@ getch.o getstr.o getyx.o inch.o inchstr.o initscr.o inopts.o insch.o insstr.o instr.o kernel.o keyname.o
$(LIBEXE) $(LIBFLAGS)S $@ mouse.o move.o outopts.o overlay.o pad.o panel.o pdcclip.o pdcdisp.o pdcgetsc.o pdckbd.o pdcscrn.o pdcsetsc.o
$(LIBEXE) $(LIBFLAGS) $@ pdcutil.o printw.o refresh.o scanw.o scr_dump.o scroll.o slk.o termattr.o touch.o util.o window.o

$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
$(PDCOBJS) : $(PDCURSES_DOS_H)
$(DEMOS) : $(PDCURSES_CURSES_H) $(LIBCURSES)
panel.o : $(PANEL_HEADER)

$(LIBOBJS) : %.o: $(srcdir)/%.c
$(CC) -c $(CFLAGS) $<

$(PDCOBJS) : %.o: $(osdir)/%.c
$(CC) -c $(CFLAGS) $<

firework.exe ozdemo.exe rain.exe testcurs.exe worm.exe xmas.exe \
ptest.exe: %.exe: $(demodir)/%.c
$(CC) $(CFLAGS) -o$@ $< $(LIBCURSES)

tuidemo.exe: tuidemo.o tui.o
$(LINK) $(LDFLAGS) -o$@ tuidemo.o tui.o $(LIBCURSES)

tui.o: $(demodir)/tui.c $(demodir)/tui.h $(PDCURSES_CURSES_H)
$(CC) -c $(CFLAGS) -I$(demodir) -o$@ $<

tuidemo.o: $(demodir)/tuidemo.c $(PDCURSES_CURSES_H)
$(CC) -c $(CFLAGS) -I$(demodir) -o$@ $<
82 changes: 82 additions & 0 deletions dosvga/Makefile.bcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Borland Makefile for PDCurses - DOS
#
# Usage: make -f [path\]Makefile.bcc [DEBUG=] [WIDE=Y] [MODEL=c|h|l|m|s] [target]
#
# where target can be any of:
# [all|demos|pdcurses.lib|testcurs.exe...]

!ifndef MODEL
MODEL = l
!endif

O = obj
E = .exe
RM = del

!ifndef PDCURSES_SRCDIR
PDCURSES_SRCDIR = ..
!endif

!include $(PDCURSES_SRCDIR)\common\libobjs.mif

osdir = $(PDCURSES_SRCDIR)\dosvga

!ifdef DEBUG
CFLAGS = -N -v -y -DPDCDEBUG
!else
CFLAGS = -O
!endif

!ifdef WIDE
WIDEOPT = -DPDC_WIDE
!else
WIDEOPT =
!endif

CPPFLAGS = -I$(PDCURSES_SRCDIR)

BUILD = $(CC) -1- -G -d -w-par -c -m$(MODEL) $(CFLAGS) $(CPPFLAGS) $(WIDEOPT)

LIBEXE = tlib /C /E

LIBCURSES = pdcurses.lib

all: $(LIBCURSES)

clean:
-$(RM) *.obj
-$(RM) *.lib
-$(RM) *.map
-$(RM) *.exe

demos: $(LIBCURSES) $(DEMOS)

$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
-$(RM) $@
$(LIBEXE) $@ @$(PDCURSES_SRCDIR)\common\borland.lrf

.autodepend

{$(srcdir)\}.c.obj:
$(BUILD) $<

{$(osdir)\}.c.obj:
$(BUILD) $<

{$(demodir)\}.c.obj:
$(BUILD) $<

.c.obj:
$(BUILD) $<

.obj.exe:
$(CC) -m$(MODEL) -e$@ $** $(LIBCURSES)

tuidemo.exe: tuidemo.obj tui.obj $(LIBCURSES)
$(CC) -m$(MODEL) -e$@ $**

tui.obj: $(demodir)\tui.c $(demodir)\tui.h $(PDCURSES_CURSES_H)
$(BUILD) -I$(demodir) $(demodir)\tui.c

tuidemo.obj: $(demodir)\tuidemo.c $(PDCURSES_CURSES_H)
$(BUILD) -I$(demodir) $(demodir)\tuidemo.c
39 changes: 39 additions & 0 deletions dosvga/Makefile.wcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Watcom Makefile for PDCurses - DOS
#
# Usage: wmake -f [path\]Makefile.wcc [DEBUG=Y] [WIDE=Y] [MODEL=c|h|l|m|s|f] [target]
#
# where target can be any of:
# [all|demos|pdcurses.lib|testcurs.exe...]

!ifndef MODEL
MODEL = l
!endif

!ifdef %PDCURSES_SRCDIR
PDCURSES_SRCDIR = $(%PDCURSES_SRCDIR)
!else
PDCURSES_SRCDIR = ..
!endif

osdir = $(PDCURSES_SRCDIR)/dosvga

!ifeq MODEL f
CC = wcc386
TARGET = dos4g
!else
CC = wcc
TARGET = dos
!endif

CFLAGS = -bt=$(TARGET) -m$(MODEL)

!ifeq WIDE Y
CFLAGS += -DPDC_WIDE
!endif

!include $(PDCURSES_SRCDIR)/common/watcom.mif

$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
%write wccdos.lrf $(LIBOBJS) $(PDCOBJS)
$(LIBEXE) $@ @wccdos.lrf
-$(RM) wccdos.lrf
58 changes: 58 additions & 0 deletions dosvga/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
PDCurses for DOS
================

This directory contains PDCurses source code files specific to the
VGA-capable DOS port.


Building
--------

- Choose the appropriate makefile for your compiler:

Makefile - DJGPP
Makefile.bcc - Borland C++
Makefile.wcc - Watcom

- For 16-bit compilers, you can change the memory MODEL as a command-
line option. (Large model is the default, and recommended.) With
Watcom, specifying "MODEL=f" (flat) will automatically switch to a
32-bit build.

- Optionally, you can build in a different directory than the platform
directory by setting PDCURSES_SRCDIR to point to the directory where
you unpacked PDCurses, and changing to your target directory:

set PDCURSES_SRCDIR=c:\pdcurses

- Build it:

make -f makefile

(For Watcom, use "wmake" instead of "make".) You'll get the library
(pdcurses.lib or .a, depending on your compiler) and a lot of object
files. Add the target "demos" to build the sample programs.

You can also give the optional parameter "WIDE=Y", to build the
library with wide-character (Unicode) support:

wmake -f Makefile.wcc WIDE=Y

(WIDE=Y is untested on the Borland compiler.)

The font can be set via the environment variable PDC_FONT. The font must
be in the PSF format, version 2.


Distribution Status
-------------------

The files in this directory are released to the public domain.


Acknowledgements
----------------

Watcom C port was provided by Pieter Kunst <[email protected]>

DJGPP port was provided by David Nugent <[email protected]>
Loading