Initiall commit from latest release

http://my.svgalib.org/svgalib/svgalib-1.9.25.tar.gz
http://my.svgalib.org/svgalib/
This commit is contained in:
Felisp 2023-11-23 00:11:45 +01:00
commit 84436a5ae0
586 changed files with 129057 additions and 0 deletions

957
0-README Normal file
View file

@ -0,0 +1,957 @@
svgalib(7) Svgalib User Manual svgalib(7)
1mNAME0m
svgalib - a low level graphics library for linux
1mTABLE OF CONTENTS0m
1m0. 22mIntroduction
1m1. 22mInstallation
1m2. 22mHow to use svgalib
1m3. 22mDescription of svgalib functions
1m4. 22mOverview of supported SVGA chipsets and modes
1m5. 22mDetailed comments on certain device drivers
1m6. 22mGoals
1m7. 22mReferences (location of latest version, apps etc.)
1m8. 22mKnown bugs
1m0. INTRODUCTION0m
This is a low level graphics library for Linux, originally based on
VGAlib 1.2 by Tommy Frandsen. VGAlib supported a number of standard VGA
graphics modes, as well as Tseng ET4000 high resolution 256-color
modes. As of now, support for many more chipsets has been added. See
section 1m4 Overview of supported SVGA chipsets and modes0m
It supports transparent virtual console switching, that is, you can
switch consoles to and from text and graphics mode consoles using
alt-[function key]. Also, svgalib corrects most of VGAlib's textmode
corruption behaviour by catching 1mSIGSEGV22m, 1mSIGFPE22m, 1mSIGILL22m, and other
fatal signals and ensuring that a program is running in the currently
visible virtual console before setting a graphics mode.
Note right here that 1mSIGUSR1 22mand 1mSIGUSR2 22mare used to manage console
switching internally in 1msvgalib22m. You can not use them in your pro-
grams. If your program needs to use one of those signals, svgalib can
be compiled to use other signals, by editing libvga.h
This version includes code to hunt for a free virtual console on its
own in case you are not starting the program from one (but instead over
a network or modem login, from within 1mscreen22m(1) or an 1mxterm22m(1)). Pro-
vided there is a free console, this succeeds if you are root or if the
svgalib calling user own the current console. This is to avoid people
not using the console being able to fiddle with it. On graceful exit
the program returns to the console from which it was started. Other-
wise it remains in text mode at the VC which svgalib allocated to allow
you to see any error messages. In any case, any I/O the svgalib makes
in text mode (after calling 1mvga_init22m(3)) will also take place at this
new console.
Alas, some games misuse their suid root privilege and run as full root
process. svgalib cannot detect this and allows Joe Blow User to open a
new VC on the console. If this annoys you, 1mROOT_VC_SHORTCUT 22min 4mMake-0m
4mfile.cfg24m allows you to disable allocating a new VC for root (except
when he owns the current console) when you compile svgalib. This is the
default.
When the library is used by a program at run-time, first the chipset is
detected and the appropriate driver is used. This means that a graphics
program will work on any card that is supported by svgalib, if the mode
it uses is supported by the chipset driver for that card. The library
is upwardly compatible with VGAlib.
The set of drawing functions provided by svgalib itself is limited
(unchanged from VGAlib) and unoptimized; you can however use 1mvga_set-0m
1mpage22m(3) and 1mvga_getgraphmem22m(3) (which points to the 64K VGA
framebuffer) in a program or graphics library. A fast external frame-
buffer graphics library for linear and banked 1, 2, 3 and 4 bytes per
pixel modes is included (it also indirectly supports planar VGA modes).
It is documented in 1mvgagl22m(7).
One obvious application of the library is a picture viewer. Several are
available, along with animation viewers. See the 1m7. References 22mat the
end of this document.
I have added a simple VGA textmode font restoration utility (1mrestore-0m
1mfont22m(1)) which may help if you suffer from XFree86 textmode font cor-
ruption. It can also be used to change the textmode font. It comes with
some other textmode utilities: 1mrestoretextmode22m(1) (which saves/restores
textmode registers), 1mrestorepalette22m(1), and the script 1mtextmode22m(1). If
you run the 1msavetextmode22m(1) script to save textmode information to
4m/tmp24m, you'll be able to restore textmode by running the 1mtextmode22m(1)
script.
1m1. INSTALLATION0m
Installation is easy in general but there are many options and things
you should keep in mind. This document however assumes that 1msvgalib 22mis
already installed.
If you need information on installation see 4m0-INSTALL24m which comes with
the svgalib distribution.
However, even after installation of the library you might need to con-
figure svgalib using the file 4m/etc/vga/libvga.config24m. Checkout section
1m4 Overview of supported SVGA chipsets and modes 22mand 1mlibvga.config22m(5)
for information.
1m2. HOW TO USE SVGALIB0m
For basic svgalib usage (no mouse, no raw keyboard) add 1m#include0m
1m<vga.h> 22mat the beginning your program. Use 1mvga_init22m(3) as your first
1msvgalib 22mcall. This will give up root privileges right after initializa-
tion, making setuid-root binaries relatively safe.
The function 1mvga_getdefaultmode22m(3) checks the environment variable
1mSVGALIB_DEFAULT_MODE 22mfor a default mode, and returns the corresponding
mode number. The environment string can either be a mode number or a
mode name as in (1mG640x480x222m, 1mG640x480x1622m, 1mG640x480x256 22m, 1mG640x480x32K22m,
1mG640x480x64K22m, 1mG640x480x16M22m). As an example, to set the default graph-
ics mode to 640x480, 256 colors, use:
1mexport SVGALIB_DEFAULT_MODE=G640x480x2560m
on the 1mbash(1) 22mcommand line. If a program needs just a linear VGA/SVGA
resolution (as required by 1mvgagl22m(7)), only modes where 1mbytesperpixel 22min
the 1mvga_modeinfo 22mstructure returned by 1mvga_getmodeinfo22m(3) is greater or
equal to 1 should be accepted (this is 0 for tweaked planar 256-color
VGA modes).
Use 1mvga_setmode(4m22mgraphicsmode24m1m) 22mto set a graphics mode. Use 1mvga_set-0m
1mmode(TEXT) 22mto restore textmode before program exit.
Programs that use svgalib must 1m#include<vga.h>22m; if they also use the
external graphics library 1mvgagl22m(7), you must also 1m#include<vgagl.h>22m.
Linking must be done with 1m-lvga 22m(and 1m-lvgagl 22mbefore 1m-lvga22m, if 1mvgagl22m(7)
is used). You can save binary space by removing the unused chipset
drivers in 4mMakefile.cfg24m if you only use specific chipsets. However this
reduces the flexibility of svgalib and has a significant effect only
when you use the static libraries. You should better use the shared
libraries and these will load only the really used parts anyway.
Functions in the 1mvgagl22m(7) library have the prefix 1mgl_22m. Please see
1mvgagl22m(7) for details.
There are demos with sources available which will also help to get you
started, in recomended order of interest: 1mvgatest22m(6), 1mkeytest22m(6),
1mmousetest22m(6), 1meventtest22m(6), 1mforktest22m(6), 1mbg_test22m(6), 1mscrolltest22m(6),
1mspeedtest22m(6), 1mfun22m(6), 1mspin22m(6), 1mtestlinear22m(6), 1mlineart22m(6), 1mtestgl22m(6),
1maccel22m(6), 1mtestaccel22m(6), 1mplane22m(6), and 1mwrapdemo22m(6).
Debugging your programs will turn out to be rather difficult, because
the svgalib application can not restore textmode when it returns to the
debugger.
Happy are the users with a serial terminal, X-station, or another way
to log into the machine from network. These can use
1mtextmode </dev/tty4m22mN0m
on the console where the program runs and continue.
However, the 1mvga_flip22m(3) function allows you to switch to textmode by
entering a call to it blindly into your debugger when your program
stops in graphics mode. 1mvga_flip22m(3) is not very robust though. You
shall not call it when svgalib is not yet initialized or in textmode.
Before continuing your program, you must then call 1mvga_flip22m(3) again to
return to graphics mode. If the program will not make any screen
accesses or svgalib calls before it returns to the debugger, you can
omit that, of course.
This will only work if your program and the debugger run in the same
virtual linux console.
1m3. DESCRIPTION OF SVGALIB FUNCTIONS0m
Each function has it's own section 3 manual page. For a list of 1mvgagl0m
functions see 1mvgagl22m(7).
1mInitialization0m
1mvga_init22m(3)
- initialize svgalib library.
1mvga_disabledriverreport22m(3)
- makes svgalib not emit any startup messages.
1mvga_claimvideomemory22m(3)
- declare the amount of video memory used.
1mvga_safety_fork22m(3)
- start a parallel process to restore the console at a crash.
1mvga_setchipset22m(3)
- force chipset.
1mvga_setchipsetandfeatures22m(3)
- force chipset and optional parameters.
1mInquire hardware configuration0m
1mvga_getmousetype22m(3)
- returns the mouse type configured.
1mvga_getcurrentchipset22m(3)
- returns the current SVGA chipset.
1mvga_getmonitortype22m(3)
- returns the monitor type configured.
1mSetting video modes0m
1mvga_setmode22m(3)
- sets a video mode.
1mvga_setdisplaystart22m(3)
- set the display start address.
1mvga_setlogicalwidth22m(3)
- set the logical scanline width.
1mvga_setlinearaddressing22m(3)
- switch to linear addressing mode.
1mvga_setmodeX22m(3)
- try to set Mode X-like memory organization .
1mvga_ext_set22m(3)
- set and query several extended features.
1mvga_screenoff22m(3), 1mvga_screenon22m(3)
- turn generation of the video signal on or off.
1mGet video mode information0m
1mvga_getxdim22m(3), 1mvga_getydim22m(3), 1mvga_getcolors22m(3)
- return the current screen resolution.
1mvga_white22m(3)
- return the color white in the current screen resolution.
1mvga_getcurrentmode22m(3)
- returns the current video mode.
1mvga_hasmode22m(3)
- returns if a video mode is supported.
1mvga_getmodeinfo22m(3)
- returns pointer to mode information structure for a mode.
1mvga_getdefaultmode22m(3)
- returns the default graphics mode number.
1mvga_lastmodenumber22m(3)
- returns the last video mode number.
1mvga_getmodename22m(3)
- return a name for the given video mode.
1mvga_getmodenumber22m(3)
- return a number for the given video mode.
1mDrawing primitives0m
1mvga_clear22m(3)
- clear the screen.
1mvga_setcolor22m(3)
- set the current color.
1mvga_setrgbcolor22m(3)
- set the current color.
1mvga_setegacolor22m(3)
- set the current color.
1mvga_drawpixel22m(3)
- draw a pixel on the screen.
1mvga_drawscanline22m(3)
- draw a horizontal line of pixels.
1mvga_drawscansegment22m(3)
- draw a horizontal line of pixels.
1mvga_drawline22m(3)
- draw a line on the screen.
1mvga_getpixel22m(3)
- get a pixels value from the screen.
1mvga_getscansegment22m(3)
- get a list of consecutive pixel values.
1mvga_waitretrace22m(3)
- wait for vertical retrace.
1mBasic (non raw) keyboard I/O0m
1mvga_getch22m(3)
- wait for a key.
1mvga_getkey22m(3)
- read a character from the keyboard without waiting.
1mvga_waitevent22m(3)
- wait for various I/O events.
1mDirect VGA memory access0m
1mvga_setpage22m(3)
- set the 64K SVGA page number.
1mvga_setreadpage22m(3)
- set the 64K SVGA page number.
1mvga_setwritepage22m(3)
- set the 64K SVGA page number.
1mvga_getgraphmem22m(3)
- returns the address of the VGA memory.
1mvga_copytoplanar25622m(3)
- copy linear pixmap into Mode X video memory.
1mvga_copytoplanar1622m(3)
- copy linear pixmap into VGA 16 color mode video memory.
1mvga_copytoplane22m(3)
- copy linear pixmap to some planes of VGA 16 color mode video
memory.
1mManage color lookup tables0m
1mvga_setpalette22m(3)
- set a color in the color lookup table.
1mvga_getpalette22m(3)
- get a color in the color lookup table.
1mvga_setpalvec22m(3)
- sets colors in the color lookup table.
1mvga_getpalvec22m(3)
- gets colors from the color lookup table.
1mMouse handling0m
1mvga_setmousesupport22m(3)
- enable mouse support.
1mmouse_init22m(3), 1mmouse_init_return_fd22m(3)
- specifically initialize a mouse.
1mmouse_close22m(3)
- explicitly close a mouse.
1mmouse_update22m(3)
- updates the mouse state.
1mmouse_waitforupdate22m(3)
- wait for an mouse update.
1mmouse_setscale22m(3)
- sets a mouse scale factor.
1mmouse_setwrap22m(3)
- set what happens at the mouse boundaries.
1mmouse_setxrange22m(3), 1mmouse_setyrange22m(3)
- define the boundaries for the mouse cursor.
1mmouse_getx22m(3), 1mmouse_gety22m(3), 1mmouse_getbutton22m(3)
- query the mouse state.
1mmouse_setposition22m(3)
- set the current mouse position.
1mmouse_getposition_6d22m(3), 1mmouse_setposition_6d22m(3), 1mmouse_setrange_6d22m(3)
- provide an interface to 3d mice.
1mmouse_seteventhandler22m(3), 1mmouse_setdefaulteventhandler22m(3)
- set a mouse event handler.
1mRaw keyboard handling0m
1mkeyboard_init22m(3), 1mkeyboard_init_return_fd22m(3)
- initialize the keyboard to raw mode.
1mkeyboard_close22m(3)
- return the keyboard to normal operation from raw mode.
1mkeyboard_update22m(3), 1mkeyboard_waitforupdate22m(3)
- process raw keyboard events.
1mkeyboard_translatekeys22m(3)
- modify scancode mappings in raw keyboard mode.
1mkeyboard_keypressed22m(3)
- check if a key is pressed when in raw keyboard mode.
1mkeyboard_getstate22m(3)
- get a pointer to a buffer holding the state of all keys in raw
keyboard mode.
1mkeyboard_clearstate22m(3)
- reset the state of all keys when in raw keyboard mode.
1mkeyboard_seteventhandler22m(3), 1mkeyboard_setdefaulteventhandler22m(3)
- define an event handler for keyboard events in raw mode.
1mJoystick handling0m
1mjoystick_init22m(3)
- initialize and calibrate joysticks.
1mjoystick_close22m(3)
- close a joystick device.
1mjoystick_update22m(3)
- query and process joystick state changes.
1mjoystick_sethandler22m(3), 1mjoystick_setdefaulthandler22m(3)
- define own joystick even handler.
1mjoystick_getnumaxes22m(3), 1mjoystick_getnumbuttons22m(3)
- query the capabilities of a joystick.
1mjoystick_getaxis22m(3), 1mjoystick_getbutton22m(3)
- query the state of a joystick.
1mjoystick_button1|2|3|422m(3), 1mjoystick_getb1|2|3|422m(3), 1mjoystick_x|y|z22m(3),
1mjoystick_getx|y|z22m(3)
- convenience macros to query the joystick position.
1mAccelerator interface (new style)0m
1mvga_accel22m(3)
- calls the graphics accelerator.
1mAccelerator interface (old style)0m
1mvga_bitblt22m(3)
- copy pixmap on screen using an accelerator.
1mvga_fillblt22m(3)
- fill rectangular area in video memory with a single color.
1mvga_hlinelistblt22m(3)
- draw horizontal scan lines.
1mvga_imageblt22m(3)
- copy a rectangular pixmap from system memory to video memory.
1mvga_blitwait22m(3)
- wait for any accelerator operation to finish.
1mControlling VC switches0m
1mvga_lockvc22m(3)
- disables virtual console switching for safety.
1mvga_unlockvc22m(3)
- re-enables virtual console switching.
1mvga_oktowrite22m(3)
- indicates whether the program has direct access to the SVGA.
1mvga_runinbackground22m(3)
- enable running of the program while there is no VGA access.
1mvga_runinbackground_version22m(3)
- returns the version of the current background support.
1mDebugging aids0m
1mvga_dumpregs22m(3)
- dump the contents of the SVGA registers.
1mvga_gettextfont22m(3), 1mvga_puttextfont22m(3)
- get/set the font used in text mode.
1mvga_gettextmoderegs22m(3), 1mvga_settextmoderegs22m(3)
- get/set the vga state used in text mode.
1mvga_flip22m(3)
- toggle between text and graphics mode.
1mvga_setflipchar22m(3)
- set the character causing a vga_flip().
1m4. OVERVIEW OF SUPPORTED SVGA CHIPSETS AND MODES0m
1mVGA and compatibles0m
320x200x256, and the series of 16-color and non-standard planar 256
color modes supported by VGAlib, as well as 720x348x2.
1mALI23010m
Supports 640x480x256, 800x600x256, 1024x768x256 SVGA modes
1mAT3D (AT25)0m
Also known as Promotion at25. Popular as the 2D part of a voodoo rush
card. As of this writing there are a few known problems with this
driver. Read below.
1mARK Logic ARK1000PV/2000PV0m
Full support, limited RAMDAC support. Only ARK1000PV tested. Supports
Clocks and Ramdac lines in config file.
1mATI SVGA (VGA Wonder and friends)0m
This is no real driver. I do not support any new modes. However it
saves additional card setup and thus allows use of the plain VGA modes
even when you are using non standard text modes. It is possible to
enforce use of this driver even on ATI Mach32 but not very useful.
1mATI Mach320m
The driver by Michael Weller supports all ATI BIOS-defined modes and
more... It hits the best out of your card. Some modes may not have
nice default timings but it uses the ATI's EEPROM for custom config or
allows to specify modes in 1mlibvga.config22m(5). Some problems may occur
with quite some third party cards (usually on board) Mach32 based con-
trollers as they do not completely conform to the Mach32 data sheets.
Check out 1msvgalib.mach3222m(7) (and 1mlibvga.config22m(5)).
1mATI Mach64 (rage)0m
A driver for ATi Mach64 based cards with internal DAC.
1mChips and Technologies chipsets 65525, 65535, 65546, 65548, 65550, and0m
1m65554 (usually in laptops).0m
This server was written using the SVGALIB patch from Sergio and Angelo
Masci as a starting point. This version of the code resembled the XFree
server code that was used up to XFree 3.1.2. As such it was incapable
of programming the clocks, using linear addressing, Hi-Color, True-
Color modes or the hardware acceleration. All of these features have
since been added to the code. The 64200 and 64300 chips are unsup-
ported, however these chips are very similar to the 6554x chips which
are supported.
1mCirrus Logic GD542x/3x0m
All the modes, including 256 color, 32K/64K color, 16M color (3 bytes
per pixel) and 32-bit pixel 16M color modes (5434). Some bitblt func-
tions are supported. The driver doesn't work with mode dumps, but uses
a SVGA abstraction with mode timings like the X drivers.
1mGenoa(?) GVGA6400 cards.0m
Supported.
1mHercules Stingray 64/Video0m
Is supported as an ARK2000PV
1mNV3 driver for the Riva128.0m
This driver was written by Matan Ziv-Av and is derived from the XFree86
driver by David J. Mckay. It lacks 24bit modes (can the card do them at
all?), acceleration support and pageflipping in threeDKit is broken.
1mOak Technologies OTI-037/67/77/870m
Driver by Christopher Wiles; includes 32K color modes for OTI-087.
1mS30m
The driver is not complete, but should work on a number of cards/RAM-
DACs, and 640x480x256 should work on most card. The best support is for
a 801/805 with AT&T20C490-compatible RAMDAC, and S3-864 + SDAC. All
256/32K/64K/16M works for them (within the bounds of video memory &
ramdac restrictions).
The supported cards include S3 Virge and S3 Trio64 cards.
None of the acceleration function is supported yet.
The chip level code should work with the 964/868/968, but most likely
the card they come on would use an unsupported ramdac/clock chip. Sup-
port for these chips is slowly being added.
Clocks and Ramdac lines in 1mlibvga.config22m(5) supported.
The maximum pixel clock (in MHz) of the ramdac can be set using a 1mDac-0m
1mspeed 22mline in the config file. A reasonable default is assumed if the
1mDacspeed 22mline is omitted. 1mClocks 22mshould be the same as in XFree86.
Supported ramdac IDs: 1mSierra32K22m, 1mSC1502522m, 1mSDAC22m, 1mGenDAC22m, 1mATT20C49022m,
1mATT20C49822m, 1mIBMRGB52x22m.
Example:
1mClocks 25.175 28.3 40 70 50 75 36 44.9 0 118 77 31.5 110 65 72 93.50m
1mRamdac att20c4900m
1mDacSpeed 850m
Also supported, at least in combination with the SC15025/26A ramdac, is
the ICD 2061A clock chip. Since it cannot be autodetected you need to
define it in the config file using a 1mClockchip 22mline. As there is no way
to read the current settings out of the 2061, you have the option to
specify the frequency used when switching back to text mode as second
argument in the 1mClockchip 22mline.
This is especially required if your text mode is an 132 column mode,
since these modes use a clock from the clock chip, while 80 column
modes use a fixed clock of 25 MHz. The text mode frequency defaults to
40 MHz, if omitted.
Example:
1mClockChip icd2061a 40.00m
1mTrident TVGA 8900C/9000 (and possibly also 8800CS/8900A/B) and also TVGA0m
1m94400m
Derived from tvgalib by Toomas Losin. TVGA 9440 support by ARK
<ark@lhq.com, root@ark.dyn.ml.or>.
Supports 640x480x256, 800x600x256, 1024x768x256 (interlaced and non-
interlaced) Might be useful to add 16-color modes (for those equipped
with a 512K TVGA9000) for the 8900 and 9000 cards.
320x200x{32K, 64K, 16M}, 640x480x{256, 32K, 64K, 16M}, 800x600x{256,
32K, 64K, 16M}, 1024x768x{16, 256}, 800x600x{16, 256, 32K, 64K} modes
are supported for the TVGA 9440.
Autodetection can be forced with a:
1mchipset TVGA 4m22mmemory24m 4mflags0m
line in the config file.
4mmemory24m is the amount of VGA memory in KB, 4mflags24m is composed of three
bits:
1mbit2 = false, bit1 = false0m
force 8900.
1mbit2 = false, bit1 = true0m
force 9440.
1mbit2 = true, bit1 = false0m
force 9680.
1mbit0 = true0m
force noninterlaced.
1mbit0 = false0m
force interlaced which only matters on 8900's with at
least 1M since there is no 512K interlaced mode on the
8900 or any of the other cards.
1mTseng ET4000/ET4000W32(i/p)0m
Derived from VGAlib; not the same register values. ET4000 register
values are not compatible; see 1msvgalib.et400022m(7).
Make sure the colors are right in hicolor mode; the vgatest program
should draw the same color bars for 256 and hicolor modes (the DAC type
is defined at compilation in 4met4000.regs24m or the dynamic registers
file). ET4000/W32 based cards usually have an AT&T or Sierra 15025/6
DAC. With recent W32p based cards, you might have some luck with the
AT&T DAC type. If the high resolution modes don't work, you can try
dumping the registers in DOS using the program in the 4met4000/24m directory
and putting them in a file (4m/etc/vga/libvga.et400024m is parsed at runtime
if 1mDYNAMIC 22mis defined in 4mMakefile.cfg24m at compilation (this is
default)).
Supported modes are 640x480x256, 800x600x256, 1024x768x256,
640x480x32K, 800x600x32K, 640x480x16M, etc.
Reports of ET4000/W32i/p functionality are welcome.
There may be a problem with the way the hicolor DAC register is han-
dled; dumped registers may use one of two timing methods, with the
value written to the register for a particular DAC for a hicolor mode
(in vgahico.c) being correct for just one of the these methods. As a
consequence some dumped resolutions may work while others don't.
1mTseng ET60000m
Most modes of which the card is capable are supported. The 8 15 16 24
and 32 bit modes are supported.
The ET6000 has a built in DAC and there is no problem coming from that
area. The ET6000 is capable of acceleration, but this as well as
sprites are not yet implemented in the driver.
The driver now uses modelines in libvga.config for user defined modes.
It is sometimes useful to add a modeline for a resolution which does
not display well. For example, the G400x600 is too far to the right of
the screen using standard modes. This is corrected by including in
1mlibvga.config 22mthe line
Modeline "400x600@72" 25.000 400 440 488 520 600 639 644 666
More examples are given below.
This driver was provided by Don Secrest.
1mVESA0m
Please read README.vesa and README.lrmi in doc subdirectory of the
standard distribution.
Go figure! I turned off autodetection in the release, as a broken bios
will be called too, maybe crashing the machine. Enforce 1mVESA 22mmode by
putting a 1mchipset VESA 22min the end of your 4mlibvga.config24m(5).
Note that it will leave protected mode and call the cards bios opening
the door to many hazards.
1m5. DETAILED COMMENTS ON CERTAIN DEVICE DRIVERS0m
This section contains detailed information by the authors on certain
chipsets.
1mAT3D (AT25)0m
Also known as Promotion at25. Popular as the 2D part of a voodoo rush
card.
I have written a driver for this chipset, based on the XF86 driver for
this chipset.
The programs that work with this driver include all the programs in the
demos directory, zgv and dvisvga (tmview).
I believe it should be easy to make it work on AT24, AT6422.
1mATI Mach320m
Please see 1msvgalib.mach3222m(7).
1mATI Mach640m
The rage.c driver works only on mach64 based cards with internal DAC.
The driver might misdetect the base frequency the card uses, so if when
setting any svgalib modes the screen blanks, or complains about out of
bound freqencies, or the display is unsynced, then try adding the
option 1mRageDoubleClock 22mto the config file.
1mChips and Technologies chipsets 65525, 65535, 65546, 65548, 65550, and0m
1m65554 (usually in laptops).0m
Please see 1msvgalib.chips22m(7).
1mTseng ET4000/ET4000W32(i/p)0m
Please see 1msvgalib.et400022m(7).
1mTseng ET60000m
I have only 2 Mbytes of memory on my ET6000 card, so I am not able to
get all possible modes running. I haven't even tried to do all of the
modes which I am capable of doing, but I am confident that I can manage
more modes when I have time. I have enough modes working to make the
card useful, so I felt it was worth while to add the driver to svgalib
now.
Linear graphics is working on this card, both with and without BACK-
GROUND enabled, and vga_runinbackground works.
I decided it was best to quit working on more modes and try to get
acceleration and sprites working.
My et6000 card is on a PCI bus. The card will run on a vesa bus, but
since I don't have one on my machine I couldn't develop vesa bus han-
dling. I quit if the bus is a vesa bus.
I check for an et6000 card, which can be unequivocally identified. The
et4000 driver does not properly identify et4000 cards. It thinks the
et6000 card is an et4000, but can only run it in vga modes.
I have found the following four modelines to be useful in 1mlibvga.config0m
or in 1m~/.svgalibrc 22mfor proper display of some modes.
Modeline "512x384@79" 25.175 512 560 592 640 384 428 436 494
Modeline "400x300@72" 25.000 400 456 472 520 300 319 332 350 DOUBLES-
CAN
Modeline "512x480@71" 25.175 512 584 600 656 480 500 510 550
Modeline "400x600@72" 25.000 400 440 488 520 600 639 644 666
Don Secrest <secrest@uiuc.edu> Aug 21, 1999
1mOak Technologies OTI-037/67/77/870m
First a few comments of me (Michael Weller <eowmob@exp-math.uni-
essen.de>):
As of this writing (1.2.8) fixes were made to the oak driver by Frodo
Looijaard <frodol@dds.nl> to reenable OTI-067 support. It is unknown
right now if they might have broken OTI-087 support. The author of the
'87 support Christopher Wiles <wileyc@moscow.com> owns no longer an
OTI-087 card and can thus no longer give optimal support to this
driver. Thus you might be better off contacting me or Frodo for ques-
tions. If you are a knowledgable OTI-087 user and experience problems
you are welcome to provide fixes. No user of a OTI-087 is currently
known to me, so if you are able to fix problems with the driver please
do so (and contact me) as noone else can.
Michael.
Now back to the original Oak information:
The original OTI driver, which supported the OTI-067/77 at 640x480x256,
has been augmented with the following features:
1m1) 22mSupported resolutions/colors have been expanded to 640x480x32K,
800x600x256/32K, 1024x768x256, and 1280x1024x16.
1m2) 22mThe OTI-087 (all variants) is now supported. Video memory is
correctly recognized.
The driver as it exists now is somewhat schizoid. As the '87 incorpo-
rates a completely different set of extended registers, I found it nec-
essary to split its routines from the others. Further, I did not have
access to either a '67 or a '77 for testing the new resolutions. If
using them causes your monitor/video card to fry, your dog to bite you,
and so forth, I warned you. The driver works on my '87, and that's all
I guarantee. Period.
Heh. Now, if someone wants to try them out ... let me know if they
work.
New from last release:
32K modes now work for 640x480 and 800x600. I found that the Sierra
DAC information in VGADOC3.ZIP is, well, wrong. But, then again, the
information for the '87 was wrong also.
64K modes 1mdo not 22mwork. I can't even get Oak's BIOS to enter those
modes.
I have included a 1280x1024x16 mode, but I haven't tested it. My moni-
tor can't handle that resolution. According to the documentation, with
2 megs the '87 should be able to do an interlaced 1280x1024x256 ...
again, I couldn't get the BIOS to do the mode. I haven't 2 megs any-
way, so there it sits.
I have included routines for entering and leaving linear mode. They
1mshould 22mwork, but they don't. It looks like a pointer to the frame
buffer is not being passed to SVGALIB. I've been fighting with this
one for a month. If anyone wants to play with this, let me know if it
can be make to work. I've got exams that I need to pass.
Tidbit: I pulled the extended register info out of the video BIOS.
When the information thus obtained failed to work, I procured the
OTI-087 data book. It appears that Oak's video BIOS sets various modes
incorrectly (e.g. setting 8-bit color as 4, wrong dot clock frequen-
cies, etc.). Sort of makes me wonder ...
Christopher M. Wiles (a0017097@wsuaix.csc.wsu.edu)
12 September 1994
1m6. GOALS0m
I think the ability to use a VGA/SVGA graphics resolution in one vir-
tual console, and being able to switch to any other virtual console
and back makes a fairly useful implementation of graphics modes in the
Linux console.
Programs that use 1msvgalib 22mmust be setuid root. I don't know how desir-
able it is to have this changed; direct port access can hardly be done
without. Root privileges can now be given up right after initializa-
tion. I noticed some unimplemented stuff in the kernel header files
that may be useful, although doing all register I/O via the kernel
would incur a significant context-switching overhead. An alternative
might be to have a pseudo 4m/dev/vga24m device that yields the required per-
missions when opened, the device being readable by programs in group
vga.
It is important that textmode is restored properly and reliably; it is
fairly reliable at the moment, but fast console switching back and
forth between two consoles running graphics can give problems. Wild
virtual console switching also sometimes corrupts the contents of the
textmode screen buffer (not the textmode registers or font). Also if a
program crashes it may write into the area where the saved textmode
registers are stored, causing textmode not be restored correctly. It
would be a good idea to somehow store this information in a 'safe' area
(say a kernel buffer). Note that the 1mvga_safety_fork22m(3) thing has the
same idea.
Currently, programs that are in graphics mode are suspended while not
in the current virtual console. Would it be a good idea to let them run
in the background, virtualizing framebuffer actions (this should not be
too hard for linear banked SVGA modes)? It would be nice to have, say,
a raytracer with a real-time display run in the background (although
just using a separate real-time viewing program is much more elegant).
Anyone wanting to rewrite it all in a cleaner way (something with load-
able kernel modules shouldn't hurt performance with linear frame-
buffer/vgagl type applications) is encouraged.
Also, if anyone feels really strongly about a low-resource and true-
color supporting graphical window environment with cut-and-paste, I
believe it would be surprisingly little work to come up with a simple
but very useful client-server system with shmem, the most useful appli-
cations being fairly trivial to write (e.g. shell window, bitmap
viewer). And many X apps would port trivially.
This is old information, please be sure to read 1msvgalib.faq22m(7) if you
are interested in further goals.
1m7. REFERENCES0m
The latest version of svgalib can be found on 4msunsite.unc.edu24m in
4m/pub/Linux/libs/graphics24m or 4mtsx-11.mit.edu24m in 4m/pub/linux/sources/libs0m
as 4msvgalib-X.X.X.tar.gz24m. As of this writing the latest version is
4msvgalib-1.4.1.tar.gz24m. There are countless mirrors of these ftp servers
in the world. Certainly a server close to you will carry it.
The original VGAlib is on 4mtsx-11.mit.edu24m,
4mpub/linux/sources/libs/vgalib12.tar.Z24m. 4mtvgalib-1.0.tar.Z24m is in the
same directory.
SLS has long been distributing an old version of VGAlib. Slackware
keeps a fairly up-to-date version of svgalib, but it may be installed
in different directories from what svgalib likes to do by default. The
current svgalib install tries to remove most of this. It also removes
4m/usr/bin/setmclk24m and 4m/usr/bin/convfont24m, which is a security risk if
setuid-root. Actually the recent makefiles try to do a really good job
to cleanup the mess which some distributions make.
If you want to recompile the a.out shared library, you will need the
DLL 'tools' package (found on 4mtsx-11.mit.edu24m, 4mGCC24m dir). To make it
work with recent ELF compiler's you actually need to hand patch it. You
should probably not try to compile it. Compiling the ELF library is
deadly simple.
And here is a list of other references which is horribly outdated.
There are many more svgalib applications as well as the directories
might have changed. However, these will give you a start point and
names to hunt for on CD's or in ftp archives.
1mViewers (in /pub/Linux/apps/graphics/viewers on sunsite.unc.edu):0m
1mspic 22mPicture viewer; JPG/PPM/GIF; truecolor; scrolling.
1mzgv 22mFull-featured viewer with nice file selector.
1msee-jpeg0m
Shows picture as it is being built up.
1mmpeg-linux0m
svgalib port of the Berkeley MPEG decoder (mpeg_play); it also
includes an X binary.
1mflip 22mFLI/FLC player (supports SVGA-resolution).
1mGames (in /pub/Linux/games on sunsite.unc.edu):0m
1mbdash 22mB*lderdash clone with sound.
1msasteroids0m
Very smooth arcade asteroids game.
1myatzy 22mNeat mouse controlled dice game.
1mvga_cardgames0m
Collection of graphical card games.
1mvga_gamespack0m
Connect4, othello and mines.
1mwt 22mFree state-of-the-art Doom-like engine.
1mMaelstrom0m
A very nice asteroids style game port from Mac.
1mKoules 22mA game. (I've no idea what it looks like)
1mDocs0m
In the vga directory of the 1mSIMTEL MSDOS 22mcollection, there is a package
called 4mvgadoc324m which is a collection of VGA/SVGA register information.
The XFree86 driver sources distributed with the link-kit may be help-
ful.
1mMiscellaneous0m
There's an alternative RAW-mode keyboard library by Russell Marks for
use with 1msvgalib 22mon 4msunsite.unc.edu24m.
1mLIBGRX22m, the extensive framebuffer library by Csaba Biegl distributed
with 1mDJGPP22m, has been ported to Linux. Contact Hartmut Schirmer
(phc27@rz.uni-kiel.d400.de, subject prefix "HARTMUT:"). A more up-to-
date port by Daniel Jackson (djackson@icomp.intel.com) is on 4msun-0m
4msite.unc.edu24m.
The vgalib ghostscript device driver sources can be found on 4msun-0m
4msite.unc.edu24m, 4m/pub/Linux/apps/graphics24m. Ghostscript patches from
Slackware: 4mftp.cdrom.com24m, 4m/pub/linux/misc24m. 1mgnuplot 22mpatches are on 4msun-0m
4msite.unc.edu24m.
Mitch D'Souza has written font functions that work in 16 color modes
and can use VGA textmode (codepage format) fonts; these can be found in
his 1mg3fax 22mpackage in 4msunsite.unc.edu24m. These functions may go into a
later version of 1msvgalib22m.
1m8. KNOWN BUGS0m
This section is most probably outdated, none of these problems are no
longer reported.
Using a 132 column textmode may cause graphics modes to fail. Try using
something like 80x28.
The console switching doesn't preserve some registers that may be used
to draw in planar VGA modes.
Wild console switching can cause the text screen to be corrupted, espe-
cially when switching between two graphics consoles.
On ET4000, having run XFree86 may cause high resolution modes to fail
(this is more XFree86's fault).
The Trident probing routine in the XFree86 server may cause standard
VGA modes to fail after exiting X on a Cirrus. Try putting a 'Chipset'
line in your Xconfig to avoid the Trident probe, or use the link kit to
build a server without the Trident driver. Saving and restoring the
textmode registers with savetextmode/textmode (restoretextmode) should
also work. [Note: svgalib now resets the particular extended register,
but only if the Cirrus driver is used (i.e. the chipset is not forced
to VGA)] [This is fixed in XFree86 v2.1]
Some Paradise VGA cards may not work even in standard VGA modes. Can
anyone confirm this?
Piping data into a graphics program has problems. I am not sure why. A
pity, since zcatting a 5Mb FLC file into flip on a 4Mb machine would be
fun.
The 1mtseng3.exe 22mDOS program include as source in the svgalib distribu-
tion doesn't recognize any modes on some ET4000 cards. Also ET4000
cards with a Acumos/Cirrus DAC may only work correctly in 64K color
mode.
1mFILES0m
4m/etc/vga/libvga.config0m
4m/etc/vga/libvga.et40000m
1mSEE ALSO0m
1msvgalib.et400022m(7), 1msvgalib.chips22m(7), 1msvgalib.mach3222m(7), 1mvgagl22m(7), 1mlib-0m
1mvga.config22m(5), 1m3d22m(6), 1maccel22m(6), 1mbg_test22m(6), 1meventtest22m(6), 1mforktest22m(6),
1mfun22m(6), 1mkeytest22m(6), 1mlineart22m(5), 1mmousetest22m(6), 1mjoytest22m(6), 1mmjoytest22m(6),
1mscrolltest22m(6), 1mspeedtest22m(6), 1mspin22m(6), 1mtestaccel22m(6), 1mtestgl22m(6), 1mtestlin-0m
1mear22m(6), 1mvgatest22m(6), 1mplane22m(6), 1mwrapdemo22m(6), 1mconvfont22m(1), 1mdumpreg22m(1),
1mfix132x4322m(1), 1mrestorefont22m(1), 1mrestorepalette22m(1), 1mrestoretextmode22m(1),
1mrunx22m(1), 1msavetextmode22m(1), 1msetmclk22m(1), 1mtextmode22m(1), 1mmach32info22m(1).
1mAUTHOR0m
There are many authors of svgalib. This page was edited by Michael
Weller <eowmob@exp-math.uni-essen.de>. The original documentation and
most of 1msvgalib 22mwas done by Harm Hanemaayer <H.Hanemaayer@inter.nl.net>
though.
Svgalib 1.4.1 16 December 1999 svgalib(7)

2
LICENSE Normal file
View file

@ -0,0 +1,2 @@
This package is copyrighted by the people who wrote it.
You may do with it whatever you want.

353
Makefile Normal file
View file

@ -0,0 +1,353 @@
#---------------------------------------------------------------------OU
# Makefile for SVGAlib.
#
# It's pretty unreadable, but just doing make install should be
# enough. This will install the header files and shared library first
# (which is enough to compile things), after which the static version is
# optionally compiled and installed (if it fails, the shared libraries
# should still work fine).
#
#----------------------------------------------------------------------
# *** NO SERVICIBLE PARTS HERE!
# All options are in Makefile.cfg.
#include Makefile.ppc
include Makefile.cfg
#----------------------------------------------------------------------
# Rules Section
#----------------------------------------------------------------------
# In case someone goes for the demos w/o installing svgalib make
# the static libs first.
ifdef INSTALLSHAREDLIB
PREDEMO =
else
PREDEMO = static
endif
# A flag if this is a distribution:
DISTRIBUTION = $(shell sh -c "echo sharedlib/DIST*")
UTILS = restorefont runx restorepalette restoretextmode textmode \
savetextmode dumpreg fix132x43
OBSOLETEHDIRS = /usr/include/ /usr/include/vga/ /usr/local/include/ /usr/local/include/vga/
OBSOLETEBDIRS = /usr/bin/ /usr/local/bin/
OBSOLETEHEADERS = /inc/vga.h /inc/vgakeyboard.h /inc/vgamouse.h /inc/vgagl.h /inc/vgajoystick.h
OBSOLETELIBLINKS = /lib/libvga.so /lib/libvga.so.1 /lib/libvgagl.so /lib/libvgagl.so.1
OBSOLETESHAREDIMAGES = /lib/libvga.so.1.* /lib/libvga.so
# for ELF
OBSOLETESHAREDIMAGES += /lib/libvgagl.so.1.* /lib/libvgagl.so
OBSOLETELDIRS = /lib/ /usr/lib/ /usr/local/lib/ /usr/share/lib/ \
$(shell sed 's?\#.*$$??' /etc/ld.so.conf 2>/dev/null | \
sed 's?\([^/]\)[ ]*$$?\1/ ?' | grep -v aout/ )
SHAREDLIBS = sharedlib/libvga.so.$(VERSION) sharedlib/libvgagl.so.$(VERSION)
SVGALIBSHAREDSTUBS =
JUMP =
BACKUP = ../svgalib-$(VERSION).tar.gz
default:
@echo "To install SVGAlib, do one of the following:"
@echo ""
@echo " make clean - clean every thing. Do this after every change"
@echo " of Makefile.cfg!"
@echo " make install - compile & install components specified in Makefile.cfg"
@echo " make demoprogs - make demo programs in demo/ and threeDKit/"
@echo ""
@echo " make uninstall - remove an existing installation from various"
@echo " common places. (old traces often confuse the"
@echo " compiler even when svgalib is not installed anew)"
@echo " (make install includes an uninstall first)"
@echo ""
@echo " Be sure to read the file 0-INSTALL!"
@echo ""
.PHONY: default all install installheaders installconfig
.PHONY: clean distclean indent uninstall
.PHONY: force_remake remake_shared shared static
.PHONY: indent-gnu
installheaders:
@echo Installing header files in $(includedir).
@mkdir -p $(includedir)
@cp $(SRCDIR)/src/vga.h $(includedir)/vga.h
@chmod a+r $(includedir)/vga.h
@cp $(SRCDIR)/gl/vgagl.h $(includedir)/vgagl.h
@chmod a+r $(includedir)/vgagl.h
@cp $(SRCDIR)/src/mouse/vgamouse.h $(includedir)/vgamouse.h
@chmod a+r $(includedir)/vgamouse.h
@cp $(SRCDIR)/src/joystick/vgajoystick.h $(includedir)/vgajoystick.h
@chmod a+r $(includedir)/vgajoystick.h
@cp $(SRCDIR)/src/keyboard/vgakeyboard.h $(includedir)/vgakeyboard.h
@chmod a+r $(includedir)/vgakeyboard.h
installsharedlib: $(SHAREDLIBS) $(SVGALIBSHAREDSTUBS)
@echo Installing shared library image as \
$(addprefix $(sharedlibdir)/,$(notdir $(SHAREDLIBS))).
@mkdir -p ${sharedlibdir};
@for foo in $(notdir $(SHAREDLIBS)); do \
$(INSTALL_SHLIB) sharedlib/$$foo $(sharedlibdir)/$$foo; \
(cd $(sharedlibdir); \
ln -sf $$foo `echo $$foo | sed 's/\.so\..*/.so/'` ); \
done
@./fixldsoconf
-ldconfig
installstaticlib: static
@echo Installing static libraries in $(libdir).
@mkdir -p $(libdir)
@$(INSTALL_DATA) staticlib/libvga.a $(libdir)/libvga.a
@chmod a+r $(libdir)/libvga.a
@$(INSTALL_DATA) staticlib/libvgagl.a $(libdir)/libvgagl.a
@chmod a+r $(libdir)/libvgagl.a
installutils: textutils $(LRMI)
@if [ ! -d $(bindir) ]; then \
echo No $(bindir) directory, creating it.; \
mkdir -p $(bindir); \
fi
@echo Installing textmode utilities in $(bindir):
@echo "restorefont: Save/restore textmode font."
@$(INSTALL_PROGRAM) utils/restorefont $(bindir)
@echo "restorepalette: Set standard VGA palette."
@$(INSTALL_PROGRAM) utils/restorepalette $(bindir)
@echo "dumpreg: Write ASCII dump of SVGA registers."
@$(INSTALL_PROGRAM) utils/dumpreg $(bindir)
@echo "restoretextmode: Save/restore textmode registers."
@$(INSTALL_PROGRAM) utils/restoretextmode $(bindir)
@echo "textmode: Script that tries to restore textmode."
@$(INSTALL_SCRIPT) utils/textmode $(bindir)
@echo "savetextmode: Script that saves textmode information used by 'textmode'."
@$(INSTALL_SCRIPT) utils/savetextmode $(bindir)
ifeq ($(LRMI),lrmi)
@echo "mode3: Restore textmode by setting VESA mode 3."
@$(INSTALL_PROGRAM) lrmi-0.6m/mode3 $(bindir)
endif
@echo "Installing keymap utilities in $(bindir):"
@echo "svgakeymap: Perl script that generates scancode conversion maps."
@$(INSTALL_SCRIPT) utils/svgakeymap $(bindir)
installconfig:
mkdir -p ${datadir};
@if [ \( -f /usr/local/lib/libvga.config -a ! -f $(datadir)/libvga.config \) ]; then \
echo "Moving old config file /usr/local/lib/libvga.config to $(datadir)." ; \
mv -f /usr/local/lib/libvga.config $(datadir)/libvga.config; \
fi
@if [ \( -f /usr/local/lib/libvga.et4000 -a ! -f $(datadir)/libvga.et4000 \) ]; then \
echo "Moving old config file /usr/local/lib/libvga.et4000 to $(datadir)." ; \
mv -f /usr/local/lib/libvga.et4000 $(datadir)/libvga.et4000; \
fi
@if [ \( -f /usr/local/lib/libvga.ega -a ! -f $(datadir)/libvga.ega \) ]; then \
echo "Moving old config file /usr/local/lib/libvga.ega to $(datadir)." ; \
mv -f /usr/local/lib/libvga.ega $(datadir)/libvga.ega; \
fi
@if [ \( -f /etc/mach32.eeprom -a ! -f $(datadir)/mach32.eeprom \) ]; then \
echo Consider moving your /etc/mach32.eeprom file to $(datadir) ; \
echo and changing $(datadir)/libvga.config appropriately. ; \
fi
@if [ ! -f $(datadir)/libvga.config ]; then \
echo Installing default configuration file in $(datadir).; \
cp $(CONFDIR)/libvga.config $(datadir)/libvga.config; \
fi
@if [ ! -f $(datadir)/libvga.et4000 ]; then \
echo Installing dynamically loaded ET4000 registers in $(datadir).; \
cp $(CONFDIR)/et4000.regs $(datadir)/libvga.et4000; \
fi
@if [ ! -f $(datadir)/default.keymap ]; then \
echo Installing default keymap file in $(datadir).; \
cp $(CONFDIR)/default.keymap $(datadir)/null.keymap; \
fi
@if [ ! -f $(datadir)/dvorak-us.keymap ]; then \
echo Installing Dvorak keymap file in $(datadir).; \
cp $(CONFDIR)/dvorak-us.keymap $(datadir)/dvorak-us.keymap; \
fi
installman:
(cd doc; $(MAKE) -f $(SRCDIR)/doc/Makefile SRCDIR="$(SRCDIR)" install )
installmodule:
(cd kernel/svgalib_helper ; $(MAKE) default modules_install )
installmodule.alt:
(cd kernel/svgalib_helper ; $(MAKE) -f Makefile.alt modules_install )
installdev:
(cd kernel/svgalib_helper ; $(MAKE) device )
lib3dkit-install:
(cd threeDKit/; $(MAKE) install)
install: installheaders $(INSTALLSHAREDLIB) installconfig \
$(INSTALLSTATICLIB) $(INSTALLUTILS) $(INSTALLMAN) $(INSTALLMODULE) $(INSTALLDEV) \
lib3dkit-install
@echo
@echo
@echo Now run "'make demoprogs'" to make the test and demo programs in
@echo demos/ and threedkit/.
uninstall:
@echo "Removing textmode utilities..."
@for i in $(OBSOLETEBDIRS); do \
for prog in $(UTILS); do \
rm -f $$i$$prog ; \
done ; \
done
@echo "Removing shared library stubs (old & current)..."
@for i in $(OBSOLETELDIRS); do \
rm -f `echo /lib/libvga.so.$(VERSION) /lib/libvgagl.so.$(VERSION) \
$(OBSOLETELIBLINKS) /lib/libvga.sa /lib/libvgagl.sa \
| sed s?/lib/?$$i?g`; \
done
ifndef KEEPSHAREDLIBS
@echo "Removing shared library images (old & current)..."
@for i in $(OBSOLETELDIRS); do \
rm -f `echo $(OBSOLETESHAREDIMAGES) | sed s?/lib/?$$i?g`; \
done
endif
@echo "Removing static libraries..."
@for i in $(OBSOLETELDIRS); do \
rm -f `echo /lib/libvga.a /lib/libvgagl.a | sed s?/lib/?$$i?g`; \
done
@echo "Removing header files..."
@for i in $(OBSOLETEHDIRS); do \
rm -f `echo $(OBSOLETEHEADERS) | sed s?/inc/?$$i?g`; \
done
(cd doc; $(MAKE) -f $(SRCDIR)/doc/Makefile SRCDIR="$(SRCDIR)" uninstall)
SHAREDDIRS0 = sharedlib/mouse sharedlib/keyboard sharedlib/ramdac \
sharedlib/clockchip sharedlib/joystick \
sharedlib/drivers
SHAREDDIRS = $(SHAREDDIRS0) $(JUMP)
STATICDIRS = staticlib/mouse staticlib/keyboard staticlib/ramdac \
staticlib/clockchip staticlib/joystick \
staticlib/drivers
UTILDIRS = utils
DEMODIRS = demos threeDKit
$(SHAREDDIRS0) $(STATICDIRS) $(DEMODIRS):
mkdir -p $@
utils:
mkdir -p utils
if [ ! -f utils/runx ]; then \
cp $(SRCDIR)/utils/runx $(SRCDIR)/utils/savetextmode \
$(SRCDIR)/utils/textmode utils; \
fi
static: staticlib/libvga.a staticlib/libvgagl.a
.PHONY: staticlib/libvgagl.a staticlib/libvga.a
staticlib/libvgagl.a staticlib/libvga.a: $(STATICDIRS)
(cd $(dir $@); \
$(MAKE) -f $(SRCDIR)/src/Makefile $(notdir $@) \
SRCDIR="$(SRCDIR)" DLLFLAGS="" \
)
# ELF
.PHONY: sharedlib/libvga.so.$(VERSION) sharedlib/libvgagl.so.$(VERSION)
shared: $(SHAREDLIBS) $(SVGALIBSHAREDSTUBS)
sharedlib/libvga.so.$(VERSION): $(SHAREDDIRS)
@rm -f sharedlib/DISTRIBUTION
(cd $(dir $@); \
$(MAKE) -f $(SRCDIR)/src/Makefile $(notdir $@) \
SRCDIR="$(SRCDIR)" DLLFLAGS="$(DLLFLAGS)"; \
ln -fs libvga.so.$(VERSION) libvga.so; \
)
sharedlib/libvgagl.a: $(SHAREDDIRS)
(cd $(dir $@); \
$(MAKE) -f $(SRCDIR)/gl/Makefile $(notdir $@) \
SRCDIR="$(SRCDIR)" DLLFLAGS="$(DLLFLAGS)" \
)
sharedlib/libvgagl.so.$(VERSION): $(SHAREDDIRS)
(cd $(dir $@); \
$(MAKE) -f $(SRCDIR)/gl/Makefile $(notdir $@) \
SRCDIR="$(SRCDIR)" DLLFLAGS="$(DLLFLAGS)"; \
ln -fs libvgagl.so.$(VERSION) libvgagl.so; \
)
demoprogs: $(PREDEMO) $(DEMODIRS)
@for dir in $(DEMODIRS); do \
if [ -d $(SRCDIR)/$$dir ]; then \
(cd $$dir; \
$(MAKE) -f $(SRCDIR)/$$dir/Makefile SRCDIR="$(SRCDIR)"); \
fi; \
done
textutils: $(UTILDIRS)
(cd utils; \
$(MAKE) -f $(SRCDIR)/utils/Makefile SRCDIR="$(SRCDIR)")
lrmi:
(cd lrmi-0.6m;\
$(MAKE))
backup: $(BACKUP)
$(BACKUP):
# I tried using a dependency, but make reordered them
# thus I have to do it this way:
$(MAKE) shared
$(MAKE) distclean
sed 's/^TARGET_FORMAT = a.out$$/# TARGET_FORMAT = a.out/' \
$(SRCDIR)/Makefile.cfg | \
sed 's/^#[ ]*TARGET_FORMAT = elf$$/TARGET_FORMAT = elf/' \
> mkcfg ; \
mv mkcfg $(SRCDIR)/Makefile.cfg; \
(cd ..; \
find svgalib-$(VERSION) ! -type d -print | sort | tar -cvf- -T- ) \
| gzip -9 >$(BACKUP)
distclean:
(cd $(SRCDIR)/doc; $(MAKE) clean)
(cd $(SRCDIR)/doc; $(MAKE) ../0-README)
(cd $(SRCDIR)/src; $(MAKE) clean)
(cd $(SRCDIR)/gl; $(MAKE) clean)
(cd $(SRCDIR)/utils; $(MAKE) clean)
(cd $(SRCDIR)/demos; $(MAKE) clean)
(cd $(SRCDIR)/threeDKit; $(MAKE) clean)
(cd $(SRCDIR)/lrmi-0.6m; $(MAKE) clean)
(cd $(SRCDIR)/kernel/svgalib_helper; $(MAKE) clean)
rm -f *.orig
find . \( -name '.depend*' -o -name '*~*' \) -exec rm {} \;
rm -rf sharedlib/[!l]* sharedlib/l[!i]* sharedlib/li[!b]* staticlib
rm -rf sharedlib/*.a core
mkdir -p sharedlib
touch sharedlib/DISTRIBUTION
clean: distclean
rm -rf sharedlib
indent:
find demos gl mach src support -name '*.[ch]' -exec indent -kr {} \;
indent -kr src/*.regs
indent-gnu:
find demos gl mach src support -name '*.[ch]' -exec indent -gnu {} \;
indent -gnu src/*.regs
dkms:
rm -rf /usr/src/svgalib_helper-$(VERSION)
mkdir -p /usr/src/svgalib_helper-$(VERSION)
cp -a kernel/svgalib_helper/* /usr/src/svgalib_helper-$(VERSION)
dkms add -m svgalib_helper -v $(VERSION)
dkms build -m svgalib_helper -v $(VERSION)
dkms install -m svgalib_helper -v $(VERSION)
FORCE:

362
Makefile.cfg Normal file
View file

@ -0,0 +1,362 @@
#----------------------------------------------------------------------
# SVGAlib Compile-time configuration file
#----------------------------------------------------------------------
# If you change ANYTHING in here you MUST 'make clean' and remake what
# you need.
#
# BEWARE! The toggle settings (INCLUDE_*_DRIVER and such) are set when
# the symbols are set. The value is pointless. Even setting a variable
# to n means yes!
MAJOR_VER = 1
MINOR_VER = 9.25
VERSION = $(MAJOR_VER).$(MINOR_VER)
#----------------------------------------------------------------------
# Kernel module Configuration Section
#----------------------------------------------------------------------
# Char major device used by module
SVGALIB_HELPER_MAJOR = 209
# Linux kernel includes
ifeq ($(S_KERNELRELEASE),)
S_KERNELRELEASE = $(shell uname -r)
endif
INCLUDEDIR = /lib/modules/$(S_KERNELRELEASE)/build/include
DIREXIST = $(shell if [ -e $(INCLUDEDIR) ] ; then echo OK ; fi)
ifneq ($(DIREXIST), OK)
INCLUDEDIR = /usr/src/linux/include
endif
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
#----------------------------------------------------------------------
# Configuration Section
#----------------------------------------------------------------------
# Source directory.
#srcdir = /usr/local/src/svgalib-$(VERSION)
SRCDIR = $(shell sh -c pwd)
CONFDIR = $(SRCDIR)/src/config
# Common prefix for installation directories.
# NOTE: This directory must exist when you start the install.
TOPDIR=
prefix = $(TOPDIR)/usr/local
exec_prefix = $(prefix)
# Directory where the shared stubs and static library will be installed.
libdir = $(exec_prefix)/lib
# Directory where the shared library will be installed.
sharedlibdir = $(exec_prefix)/lib
# Directory where the font and textmode utilities will be installed.
bindir = $(exec_prefix)/bin
# Directory where the run-time configuration files will be installed.
datadir = $(TOPDIR)/etc/vga
# Directory where the header files will be installed.
includedir = $(prefix)/include
# Directory where the man files will be installed.
mandir = $(prefix)/share/man
# Target binary format.
TARGET_FORMAT = elf
# Uncomment this to use lrmi-0.9, instead of 0.6
# USE_LRMI_9 = y
# uncomment any of the following line to print some debug messages
# DEBUG = yes
# DEBUG_CONF = yes
# DEBUG_ACCEL = yes
# DEBUG_KEYBOARD = yes
# uncomment this if your compiler fails on compiling the assembler in
# src/vgaconvplanar.c, gl/inlstring.h, gl/line.c or gl/scale.c
# NO_ASM = y
# uncomment if you want to set attribute controller and dac without delay
# This breaks original VGA, but seems to work on new cards.
NO_DELAY = y
# Uncomment this if you want root processes to be able to always get a new
# VC. Alas, some games misuse suid root privs and become root, svgalib cannot
# detect this and will allow Joe blow user to open a new virtual VC. If this
# annoys you, comment out the next line (which is the default already)
ROOT_VC_SHORTCUT = y
# Uncomment thit to use libc's memcpy, instead of simple while loop.
# Use demos/linearspeed to see which is faster to video memory.
LIBC_MEMCPY = y
# Uncomment this if you want to compile and install the static libs.
# INSTALLSTATICLIB = installstaticlib
# Comment this out if you don't want to install the shared libs.
# If you do not install the shared nor the static libs, 'make static'
# first to enforce just building the static lib, then the demos will
# use this local static library!
INSTALLSHAREDLIB = installsharedlib
# Comment this out if you want to keep old shared images. Old header files,
# library stubs and static libraries CANNOT be kept in public locations
# except when you rename them yourself.
# KEEPSHAREDLIBS = keep
# Comment this out if you don't want to compile and install the utilities.
INSTALLUTILS = installutils
# Comment this out if you don't want to install the man pages by default
INSTALLMAN = installman
# Remove the '# ' from one of the next two lines if you want to install the
# man pages compressed (with gzip) or not. If you comment out both lines,
# the Makefiles will try to figure out if your system supports gzipped man
# pages and install them when possible.
# MANFORMAT = compressed
# MANFORMAT = uncompressed
# This is the command to update the man pages whatis database.
# This is a slow command. If you are not very patient, simple
# comment out this line
# MAKEWHATIS = makewhatis # Beware, this will really need a few minutes!
# Comment this out if you use devfs or udev and don't want to make svga nodes
# INSTALLDEV = installdev
# Select which makefile to use to install the module, or comment both out if
# you are going to install the kernel module manually
INSTALLMODULE = installmodule
# INSTALLMODULE = installmodule.alt
#
# Comment out any driver that you don't want included in the library.
# These drivers are obsolete and quite likely broken:
#INCLUDE_ET4000_DRIVER = y
#INCLUDE_OAK_DRIVER = y
#INCLUDE_EGA_DRIVER = y
#INCLUDE_MACH32_DRIVER = y
#INCLUDE_ET3000_DRIVER = y
#INCLUDE_GVGA6400_DRIVER = y
#INCLUDE_ATI_DRIVER = y
# End of obsolete drivers.
INCLUDE_CHIPS_DRIVER = y
INCLUDE_APM_DRIVER = y
INCLUDE_NV3_DRIVER = y
INCLUDE_G400_DRIVER = y
INCLUDE_R128_DRIVER = y
INCLUDE_VESA_DRIVER = y
INCLUDE_MX_DRIVER = y
INCLUDE_RENDITION_DRIVER = y
INCLUDE_RAGE_DRIVER = y
INCLUDE_BANSHEE_DRIVER = y
INCLUDE_SIS_DRIVER = y
INCLUDE_I740_DRIVER = y
INCLUDE_I810_DRIVER = y
INCLUDE_LAGUNA_DRIVER = y
INCLUDE_TRIDENT_DRIVER = y
INCLUDE_SAVAGE_DRIVER = y
INCLUDE_MILLENNIUM_DRIVER = y
##INCLUDE_G450C2_DRIVER = y
INCLUDE_PM2_DRIVER = y
INCLUDE_UNICHROME_DRIVER = y
INCLUDE_NEO_DRIVER = y
INCLUDE_ET6000_DRIVER = y
INCLUDE_FBDEV_DRIVER = y
# These drivers are obsolete, but most likely still work:
INCLUDE_PARADISE_DRIVER = y
INCLUDE_ARK_DRIVER = y
INCLUDE_S3_DRIVER = y
INCLUDE_CIRRUS_DRIVER = y
INCLUDE_TVGA_DRIVER = y
INCLUDE_ALI_DRIVER = y
#
# Comment out any adapter you don't want to autodetect.
#
#INCLUDE_ET4000_DRIVER_TEST = y
INCLUDE_CIRRUS_DRIVER_TEST = y
INCLUDE_TVGA_DRIVER_TEST = y
INCLUDE_OAK_DRIVER_TEST = y
INCLUDE_EGA_DRIVER_TEST = y
INCLUDE_MACH32_DRIVER_TEST = y
INCLUDE_GVGA6400_DRIVER_TEST = y
INCLUDE_S3_DRIVER_TEST = y
INCLUDE_ET3000_DRIVER_TEST = y
INCLUDE_ARK_DRIVER_TEST = y
INCLUDE_ATI_DRIVER_TEST = y
INCLUDE_ALI_DRIVER_TEST = y
INCLUDE_CHIPS_DRIVER_TEST = y
INCLUDE_APM_DRIVER_TEST = y
INCLUDE_NV3_DRIVER_TEST = y
INCLUDE_G400_DRIVER_TEST = y
INCLUDE_R128_DRIVER_TEST = y
INCLUDE_ET6000_DRIVER_TEST = y
INCLUDE_MX_DRIVER_TEST = y
INCLUDE_TRIDENT_DRIVER_TEST = y
INCLUDE_PARADISE_DRIVER_TEST = y
INCLUDE_RAGE_DRIVER_TEST = y
INCLUDE_BANSHEE_DRIVER_TEST = y
INCLUDE_SIS_DRIVER_TEST = y
INCLUDE_I740_DRIVER_TEST = y
INCLUDE_I810_DRIVER_TEST = y
INCLUDE_LAGUNA_DRIVER_TEST = y
INCLUDE_NEO_DRIVER_TEST = y
INCLUDE_SAVAGE_DRIVER_TEST = y
INCLUDE_MILLENNIUM_DRIVER_TEST = y
INCLUDE_RENDITION_DRIVER_TEST = y
INCLUDE_PM2_DRIVER_TEST = y
INCLUDE_UNICHROME_DRIVER_TEST = y
#INCLUDE_FBDEV_DRIVER_TEST = y
#Might be too dangerous:
#INCLUDE_VESA_DRIVER_TEST = y
#
# Comment out any dac support that you don't want included in the library.
#
# you must include SIERRA_DAC, if you include any of SCxxxx DACs.
INCLUDE_NORMAL_DAC = y
INCLUDE_S3_SDAC_DAC = y
INCLUDE_S3_GENDAC_DAC = y
INCLUDE_S3_TRIO64_DAC = y
INCLUDE_SIERRA_DAC = y
INCLUDE_SC15025_DAC = y
INCLUDE_ATT20C490_DAC = y
INCLUDE_ATT20C498_DAC = y
INCLUDE_ICW_DAC = y
INCLUDE_IBMRGB52x_DAC = y
INCLUDE_SC1148X_DAC = y
INCLUDE_ICS_GENDAC_DAC = y
#
# Comment out any dac you don't want to autodetect.
# (not all dacs can be autodetected, at this time)
#
INCLUDE_S3_SDAC_DAC_TEST = y
INCLUDE_S3_GENDAC_DAC_TEST = y
INCLUDE_SC15025_DAC_TEST = y
INCLUDE_ATT20C490_DAC_TEST = y
INCLUDE_IBMRGB52x_DAC_TEST = y
INCLUDE_SC1148X_DAC_TEST = y
INCLUDE_ICS_GENDAC_DAC_TEST = y
# LRMI - disbaled for non i386
LRMI = lrmi
# Location of the svgalib configuration file.
SVGALIB_CONFIG_FILE = $(datadir)/libvga.config
# Defining DYNAMIC enables runtime parsing of the file defined by
# ET4000_REGS (usually /etc/libvga.et4000) for the et4000
# driver. See et4000/README for details. Commenting this out again
# saves binary space.
#
# If you just want to use the et4000.regs in the source directory,
# comment out the definition of DYNAMIC. DYNAMIC allows development of new
# resolutions without recompiling.
DYNAMIC = y
ET4000_REGS = $(datadir)/libvga.et4000
# The EGA driver may load additional modes (SuperEGA cards) like the
# et4000 driver does. Just define the configuration file below.
# [This should be taken with a grain of salt, EGA is untested.]
#EGA_REGS = $(datadir)/libvga.ega
# Defining USE_CLOCKS will cause the ET4000 driver to measure clock
# frequencies (they are not actually used yet).
#USE_CLOCKS = y
# Uncomment to allow mouse type overrides
ALLOW_MOUSE_OVERRIDE = y
#----------------------------------------------------------------------
# Compiler Section
#----------------------------------------------------------------------
# Compiler used.
PC = ppc386
ifndef CC
CC = gcc
endif
ifndef CFLAGS
OPTIMIZE = -fomit-frame-pointer -O2 -fno-strength-reduce -pipe
else
OPTIMIZE := $(CFLAGS)
endif
# You might want to add -m386 here if you have a recently installed
# (486 configured) compiler on a 386. The only real difference is the
# generous alignment padding of function entry-points for the 486.
WARN = -Wall -Wstrict-prototypes
INCLUDES = -I$(srcdir)/include -I.
CFLAGS = $(WARN) $(DLLFLAGS) $(INCLUDES) $(OPTIMIZE) $(DEFINES)
LDFLAGS = -s
# additional flags for shared lib.
DLLFLAGS = -fPIC -DPIC
# Utilites used.
AR = ar
INSTALL_PROGRAM = install -sm755
INSTALL_SCRIPT = install -m755
INSTALL_SHLIB = install -m755
INSTALL_DATA = install -m644
ifneq ($(ARCH),i386)
NO_ASM = y
INCLUDE_VESA_DRIVER=
INCLUDE_CHIPS_DRIVER=
INCLUDE_ET4000_DRIVER=
INCLUDE_MACH32_DRIVER=
INCLUDE_NEO_DRIVER=
INCLUDE_TVGA_DRIVER=
INCLUDE_I810_DRIVER=
LRMI=
endif
ifeq ($(ARCH),ppc)
INCLUDE_S3_DRIVER=
endif
ifneq ($(INCLUDE_S3_DRIVER),y)
INCLUDE_NORMAL_DAC =
INCLUDE_S3_SDAC_DAC =
INCLUDE_S3_GENDAC_DAC =
INCLUDE_S3_TRIO64_DAC =
INCLUDE_SIERRA_DAC =
INCLUDE_SC15025_DAC =
INCLUDE_ATT20C490_DAC =
INCLUDE_ATT20C498_DAC =
INCLUDE_ICW_DAC =
INCLUDE_IBMRGB52x_DAC =
INCLUDE_SC1148X_DAC =
endif
ifeq ($(NO_HELPER),y)
INSTALLDEV =
INSTALLMODULE =
endif

14
README Normal file
View file

@ -0,0 +1,14 @@
This is an _alpha_ release. Don't use it if you are not interested in
svgalib development.
Program using svgalib 1.9.0 or later don't need root provoleges (suid
root). They do need access to /dev/svga, which is a char device
with major 209 and minor 0.
The module svgalib_helper need also be inserted.
To make the devices, and the module (kernel 2.4 or newer), change to directory
kernel/svgalib_helper, and type make install.
There is a compile time option to return to old behaviour, of using root
privileges to access /dev/mem, instead of svgalib helper. To compile for this
select the NO_HELPER option in Makefile.cfg.

75
demos/Makefile Normal file
View file

@ -0,0 +1,75 @@
#----------------------------------------------------------------------
# Makefile for SVGAlib demo programs.
#
# This file is a part of SVGAlib.
#----------------------------------------------------------------------
include ../Makefile.cfg
srcdir = ..
VPATH = $(srcdir)/demos
#----------------------------------------------------------------------
# Compiler Section (overrides Makefile.cfg)
#----------------------------------------------------------------------
CFLAGS = $(WARN) $(OPTIMIZE) -I$(srcdir)/include -I$(srcdir)/gl $(DEBFLAGS)
ifeq (a.out, $(TARGET_FORMAT))
CFLAGS += -DSVGA_AOUT
endif
#----------------------------------------------------------------------
# Rules Section
#----------------------------------------------------------------------
PROGS = fun testgl speedtest mousetest vgatest scrolltest testlinear \
keytest testaccel accel forktest eventtest spin bg_test printftest \
joytest mjoytest bankspeed lineart linearspeed addmodetest \
svidtune linearfork cursor vgatweak buildcsr
# Determine what library (static or shared) we will be linking programs with
ifdef INSTALLSHAREDLIB
LIBS = -lvgagl -lvga
endif
ifndef LIBS
LIBS = ../staticlib/libvgagl.a ../staticlib/libvga.a -lm
LVGADEP = $(LIBS)
endif
all: $(PROGS)
.PHONY: all clean cleanbin dep
$(PROGS): $(LVGADEP)
.c:
$(CC) $(CFLAGS) $(LDFLAGS) -o $* $*.c $(LIBS)
rwpage: rwpage.pp
$(PC) -Rintel rwpage.pp
testaccel: testaccel.c
$(CC) $(CFLAGS) $(LDFLAGS) -o testaccel testaccel.c $(LIBS) -lm
accel: accel.c
$(CC) $(CFLAGS) $(LDFLAGS) -o accel accel.c $(LIBS) -lm
linearspeed: linearspeed.c memset.o
$(CC) $(CFLAGS) $(LDFLAGS) -o linearspeed linearspeed.c memset.o $(LIBS)
buildcsr: mkcur.o
$(CC) -o buildcsr $(LDFLAGS) mkcur.o -lvgagl -lvga
clean: cleanbin
rm -f .depend *.o *~ *.bak core
cleanbin:
rm -f $(PROGS) rwpage
#
# No dependencies required here.
#
dep:
.depend:

1018
demos/accel.c Normal file

File diff suppressed because it is too large Load diff

238
demos/addmodetest.c Normal file
View file

@ -0,0 +1,238 @@
/* From VGAlib, changed for svgalib */
/* partially copyrighted (C) 1993 by Hartmut Schirmer */
#include <stdio.h>
#include <unistd.h> /* for usleep( long ) */
#include <string.h>
#include <stdlib.h>
#include "vga.h"
static unsigned char line[2048 * 3];
static void testmode(int mode)
{
int xmax, ymax, i, x, y, yw, ys, c;
vga_modeinfo *modeinfo;
vga_setmode(mode);
modeinfo = vga_getmodeinfo(mode);
printf("Width: %d Height: %d Colors: %d\n",
modeinfo->width,
modeinfo->height,
modeinfo->colors);
printf("DisplayStartRange: %xh Maxpixels: %d Blit: %s\n",
modeinfo->startaddressrange,
modeinfo->maxpixels,
modeinfo->haveblit ? "YES" : "NO");
printf("Offset: %i Bytes Per Pixel: %d\n",
modeinfo->linewidth,
modeinfo->bytesperpixel);
#ifdef TEST_MODEX
if (modeinfo->colors == 256)
printf("Switching to ModeX ... %s\n",
(vga_setmodeX()? "done" : "failed"));
#endif
vga_screenoff();
xmax = vga_getxdim() - 1;
ymax = vga_getydim() - 1;
vga_setcolor(vga_white());
vga_drawline(0, 0, xmax, 0);
vga_drawline(xmax, 0, xmax, ymax);
vga_drawline(xmax, ymax, 0, ymax);
vga_drawline(0, ymax, 0, 0);
for (i = 0; i <= 15; i++) {
vga_setegacolor(i);
vga_drawline(10 + i * 5, 10, 90 + i * 5, 90);
}
for (i = 0; i <= 15; i++) {
vga_setegacolor(i);
vga_drawline(90 + i * 5, 10, 10 + i * 5, 90);
}
vga_screenon();
ys = 100;
yw = (ymax - 100) / 4;
switch (vga_getcolors()) {
case 256:
for (i = 0; i < 60; ++i) {
c = (i * 64) / 60;
vga_setpalette(i + 16, c, c, c);
vga_setpalette(i + 16 + 60, c, 0, 0);
vga_setpalette(i + 16 + (2 * 60), 0, c, 0);
vga_setpalette(i + 16 + (3 * 60), 0, 0, c);
}
line[0] = line[xmax] = 15;
line[1] = line[xmax - 1] = 0;
for (x = 2; x < xmax - 1; ++x)
line[x] = (((x - 2) * 60) / (xmax - 3)) + 16;
for (y = ys; y < ys + yw; ++y)
vga_drawscanline(y, line);
for (x = 2; x < xmax - 1; ++x)
line[x] += 60;
ys += yw;
for (y = ys; y < ys + yw; ++y)
vga_drawscanline(y, line);
for (x = 2; x < xmax - 1; ++x)
line[x] += 60;
ys += yw;
for (y = ys; y < ys + yw; ++y)
vga_drawscanline(y, line);
for (x = 2; x < xmax - 1; ++x)
line[x] += 60;
ys += yw;
for (y = ys; y < ys + yw; ++y)
vga_drawscanline(y, line);
break;
case 1 << 15:
case 1 << 16:
case 1 << 24:
for (x = 2; x < xmax - 1; ++x) {
c = ((x - 2) * 256) / (xmax - 3);
y = ys;
vga_setrgbcolor(c, c, c);
vga_drawline(x, y, x, y + yw - 1);
y += yw;
vga_setrgbcolor(c, 0, 0);
vga_drawline(x, y, x, y + yw - 1);
y += yw;
vga_setrgbcolor(0, c, 0);
vga_drawline(x, y, x, y + yw - 1);
y += yw;
vga_setrgbcolor(0, 0, c);
vga_drawline(x, y, x, y + yw - 1);
}
for (x = 0; x < 64; x++) {
for (y = 0; y < 64; y++) {
vga_setrgbcolor(x * 4 + 3, y * 4 + 3, 0);
vga_drawpixel(xmax / 2 - 160 + x, y + ymax / 2 - 80);
vga_setrgbcolor(x * 4 + 3, 0, y * 4 + 3);
vga_drawpixel(xmax / 2 - 32 + x, y + ymax / 2 - 80);
vga_setrgbcolor(0, x * 4 + 3, y * 4 + 3);
vga_drawpixel(xmax / 2 + 160 - 64 + x, y + ymax / 2 - 80);
vga_setrgbcolor(x * 4 + 3, y * 4 + 3, 255);
vga_drawpixel(xmax / 2 - 160 + x, y + ymax / 2 + 16);
vga_setrgbcolor(x * 4 + 3, 255, y * 4 + 3);
vga_drawpixel(xmax / 2 - 32 + x, y + ymax / 2 + 16);
vga_setrgbcolor(255, x * 4 + 3, y * 4 + 3);
vga_drawpixel(xmax / 2 + 160 - 64 + x, y + ymax / 2 + 16);
}
}
break;
default:
if (vga_getcolors() == 16) {
for (i = 0; i < xmax - 1; i++)
line[i] = (i + 2) % 16;
line[0] = line[xmax] = 15;
line[1] = line[xmax - 1] = 0;
}
if (vga_getcolors() == 2) {
for (i = 0; i <= xmax; i++)
line[i] = 0x11;
line[0] = 0x91;
}
for (i = 100; i < ymax - 1; i++)
vga_drawscanline(i, line);
break;
}
if (getchar() == 'd')
vga_dumpregs();
vga_setmode(TEXT);
}
int main(int argc, char *argv[])
{
int mode;
int tests=0xffffffff;
if(argc>1)tests=strtol(argv[1],NULL,0);
vga_init(); /* Initialize. */
if(tests&1){
vga_addtiming(45000,720,776,880,936,540,570,576,600,0);
vga_addtiming(36000,720,756,872,950,540,542,547,565,0);
mode=vga_addmode(720,540,1<<24,720*4,4);
printf("Mode=%i\n",mode);
if (vga_hasmode(mode))
testmode(mode);
else printf("Error: Video mode not supported by driver\n");
};
if(tests&2){
vga_addtiming(45000,720,776,880,936,720,750,756,800,0);
vga_addtiming(36000,720,756,872,950,720,723,729,750,0);
mode=vga_addmode(720,720,1<<24,720*4,4);
printf("Mode=%i\n",mode);
if (vga_hasmode(mode))
testmode(mode);
else printf("Error: Video mode not supported by driver\n");
};
if(tests&4){
vga_guesstiming(576,432,0,0);
mode=vga_addmode(576,432,1<<16,576*2,2);
printf("Mode=%i\n",mode);
if (vga_hasmode(mode))
testmode(mode);
else printf("Error: Video mode not supported by driver\n");
};
if(tests&8){
vga_guesstiming(576,431,1,0);
mode=vga_addmode(576,431,1<<16,576*2,2);
printf("Mode=%i\n",mode);
if (vga_hasmode(mode))
testmode(mode);
else printf("Error: Video mode not supported by driver\n");
};
if(tests&16){
vga_guesstiming(360,271,1,0);
mode=vga_addmode(360,271,1<<16,360*2,2);
printf("Mode=%i\n",mode);
if (vga_hasmode(mode))
testmode(mode);
else printf("Error: Video mode not supported by driver\n");
};
if(tests&32){
vga_guesstiming(360,270,1,0);
mode=vga_addmode(360,270,1<<16,360*2,2);
printf("Mode=%i\n",mode);
if (vga_hasmode(mode))
testmode(mode);
else printf("Error: Video mode not supported by driver\n");
};
if(tests&64){
vga_guesstiming(672,800,257,0);
mode=vga_addmode(672,800,1<<16,672*2,2);
printf("Mode=%i\n",mode);
if (vga_hasmode(mode))
testmode(mode);
else printf("Error: Video mode not supported by driver\n");
};
if(tests&128){
vga_guesstiming(712,800,257,0);
mode=vga_addmode(712,800,1<<16,712*2,2);
printf("Mode=%i\n",mode);
if (vga_hasmode(mode))
testmode(mode);
else printf("Error: Video mode not supported by driver\n");
};
return 0;
}

17
demos/arrow.h Normal file
View file

@ -0,0 +1,17 @@
unsigned int arrow[64] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00200000, 0x00700000,
0x00380000, 0x00180000, 0x001c0000, 0x000e0000,
0x00070000, 0x00038000, 0x00018000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0xc0000000, 0xb0000000, 0x4c000000, 0x43000000,
0x20c00000, 0x20300000, 0x10080000, 0x10100000,
0x08300000, 0x08600000, 0x04e00000, 0x05f00000,
0x03380000, 0x00180000, 0x001c0000, 0x000e0000,
0x00070000, 0x00038000, 0x00018000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000};

169
demos/bankspeed.c Normal file
View file

@ -0,0 +1,169 @@
#include <stdlib.h>
#include <stdio.h>
#include <vga.h>
#include <vgagl.h>
#include <time.h>
#include <unistd.h>
/* The logo was drawn by John Remyn. */
/* Feel free to provide a more beautiful/official/thought provoking/cool */
/* logo to replace it. */
#define LOGOWIDTH 201
#define LOGOHEIGHT 85
int VGAMODE;
int VIRTUAL;
GraphicsContext *backscreen;
GraphicsContext *physicalscreen;
void *logobitmap;
void loadbitmap(char *filename, void *buf)
{
FILE *f;
f = fopen(filename, "rb");
if(f==NULL)return;
fread(buf, 1, 17095, f);
fclose(f);
}
void test(void)
{
int i, j;
if (VIRTUAL)
gl_setcontext(backscreen);
gl_clearscreen(0);
for (i = 0; i < 5; i++) {
gl_clearscreen(0);
for (j = 0; j < 100000; j++)
gl_setpixel(random() % WIDTH, random() % HEIGHT,
random() % COLORS);
}
if (VIRTUAL)
gl_copyscreen(physicalscreen);
}
void setcustompalette(void)
{
/* colors 0-31 are an RGB mix (bits 0 and 1 red, 2 green, 3 and 4 blue) */
/* 32-63 black to red */
/* 64-95 black to green */
/* 96-127 black to yellow */
/* 128-159 black to blue */
/* 160-191 black to magenta */
/* 192-223 black to cyan */
/* 224-255 black to white */
Palette pal;
int i;
for (i = 0; i < 256; i++) {
int r, g, b;
r = g = b = 0;
if ((i & 32) > 0)
r = (i & 31) << 1;
if ((i & 64) > 0)
g = (i & 31) << 1;
if ((i & 128) > 0)
b = (i & 31) << 1;
if (i < 32) {
r = (i & 3) << 4; /* 2 bits */
g = (i & 4) << 3; /* 1 bit */
b = (i & 24) << 1; /* 2 bits */
}
pal.color[i].red = r;
pal.color[i].green = g;
pal.color[i].blue = b;
}
gl_setpalette(&pal);
}
void logotest(void)
{
int h;
void *scaled;
/* Set logo palette. */
setcustompalette();
/* Create logo bitmap */
logobitmap = alloca(LOGOWIDTH * LOGOHEIGHT);
loadbitmap("linuxlogo.bitmap", logobitmap);
/* Allocate buffer for scaled bitmap. */
scaled = alloca(WIDTH * HEIGHT);
gl_clearscreen(0);
/* Stretch vertically. */
for (h = 0; h <= LOGOHEIGHT; h++) {
gl_scalebox(LOGOWIDTH, LOGOHEIGHT, logobitmap,
LOGOWIDTH, h, scaled);
gl_putbox(0, 0, LOGOWIDTH, h, scaled);
if (VIRTUAL)
gl_copyscreen(physicalscreen);
}
gl_clearscreen(0);
/* Scale to screen resolution. */
gl_scalebox(LOGOWIDTH, LOGOHEIGHT, logobitmap, WIDTH, HEIGHT, scaled);
gl_putbox(0, 0, WIDTH, HEIGHT, scaled);
gl_copyscreen(physicalscreen);
}
int main(void)
{
clock_t t1, t2;
vga_init();
t1=clock();
VGAMODE = vga_getdefaultmode();
if (VGAMODE == -1)
VGAMODE = G320x200x256; /* Default mode. */
if (!vga_hasmode(VGAMODE)) {
printf("Mode not available.\n");
exit(-1);
}
VIRTUAL = 0; /* No virtual screen. */
if (vga_getmodeinfo(VGAMODE)->colors == 16 ||
(vga_getmodeinfo(VGAMODE)->flags & IS_MODEX))
/* These modes are supported indirectly by vgagl. */
VIRTUAL = 1;
if (VIRTUAL) {
/* Create virtual screen. */
gl_setcontextvgavirtual(VGAMODE);
backscreen = gl_allocatecontext();
gl_getcontext(backscreen);
}
vga_setmode(VGAMODE);
gl_setcontextvga(VGAMODE); /* Physical screen context. */
physicalscreen = gl_allocatecontext();
gl_getcontext(physicalscreen);
if (COLORS == 256)
gl_setrgbpalette();
test();
/* Now do the same with clipping enabled. */
gl_clearscreen(0);
gl_setclippingwindow(WIDTH / 4, HEIGHT / 4, WIDTH - WIDTH / 4 - 1,
HEIGHT - HEIGHT / 4 - 1);
test();
gl_disableclipping();
if (COLORS == 256)
/* Show the logo if using 256 color mode. */
logotest();
if (VIRTUAL)
gl_freecontext(backscreen);
t2=clock();
printf("total:%1.2f sec\n",(1.0*t2-t1)/CLOCKS_PER_SEC);
vga_setmode(TEXT);
exit(0);
}

129
demos/bg_test.c Normal file
View file

@ -0,0 +1,129 @@
/* bg_test.c
Copyright (c) 1997 Michael Friman. All rights reserved.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <strings.h>
#include <vga.h>
#include <vgagl.h>
/*
If you really want to see background runin, add after
vga_setmode vga_runinbackground(1) in fun.
Remember to compile the svgalib with background.
*/
int go = 0;
int linear = 0;
void drawline(int x1, int y1, int x2, int y2)
{
if (linear)
{
gl_line(x1,y1,x2,y2,vga_white());
}
else
{
vga_drawline(x1,y1,x2,y2);
}
}
void set_go(void)
{
go=1;
return;
}
int main(int argc, char *argv[])
{
int x[2];
int y[2];
int counter;
int mode;
if ((argc > 2) || ((argc == 2) && (strcmp(argv[1], "linear") != 0)))
{
fputs("Usage: bg_test [linear]\n", stderr);
exit(2);
}
vga_init();
printf("This is small test for background runin.\n");
if (vga_runinbackground_version()==1 || vga_runinbackground_version()>=3)
{
printf("Background runin enabled. mode %d\n", vga_runinbackground_version());
}
else
{
printf("Svgalib is not background capable.\n");
printf("Test ended.\n");
return(0);
}
printf("Switch to another console when the box appears.\n");
printf("Press enter to continue or CTRL-c to stop.\n");
getchar();
mode = vga_getdefaultmode();
if (mode < 0)
mode = G320x200x256;
if (argc == 2)
{
if (vga_getmodeinfo(mode)->flags & CAPABLE_LINEAR)
{
vga_setlinearaddressing();
fputs("Linear mode set.\n", stderr);
linear = 1;
}
else
{
fputs("Linear mode unavailable.\n", stderr);
}
}
vga_setmode(mode);
if (linear)
gl_setcontextvga(mode);
vga_runinbackground(VGA_GOTOBACK,set_go);
vga_runinbackground(1);
x[0]=0;
y[0]=0;
x[1]=vga_getxdim()-1;
y[1]=vga_getydim()-1;
if (!linear)
vga_setcolor(vga_white());
counter=(y[1]/11)*5+1;
while(counter<=(y[1]/11)*6)
{
drawline((x[1]/11)*5,counter,(x[1]/11)*6,counter);
counter++;
}
/* Program won't go further without console switching. */
while(!go) usleep(1000);
drawline(x[0],y[0],x[1],y[0]);
drawline(x[1],y[0],x[1],y[1]);
drawline(x[1],y[1],x[0],y[1]);
drawline(x[0],y[1],x[0],y[0]);
drawline(x[0],y[0],x[1],y[1]);
drawline(x[1],y[0],x[0],y[1]);
while(!vga_getkey());
vga_setmode(TEXT);
printf("Ok.\n");
return(0);
}

50
demos/clut.xbm Normal file
View file

@ -0,0 +1,50 @@
#define clut_width 18
#define clut_height 233
static char clut_bits[] = {
0xe0,0x07,0x00,0xf8,0x0f,0x00,0xfc,0x1f,0x00,0x3e,0x1c,0x00,0x1e,0x30,0x00,
0x07,0x20,0x00,0x03,0x20,0x00,0x01,0x20,0x00,0x01,0x20,0x00,0x01,0x30,0x00,
0x03,0x10,0x00,0x1e,0x0c,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x00,
0x80,0x1f,0x00,0xc0,0x3f,0x00,0xc0,0x20,0x00,0x20,0x20,0x00,0x20,0x20,0x00,
0x20,0x18,0x00,0xe0,0x1f,0x00,0xc0,0x0f,0x00,0x80,0x07,0x00,0x00,0x00,0x00,
0x00,0x3e,0x00,0xf1,0x3f,0x00,0xff,0x3f,0x00,0xff,0x21,0x00,0x0f,0x10,0x00,
0x00,0x00,0x00,0x00,0x0f,0x00,0x80,0x1f,0x00,0xc0,0x3f,0x00,0xc0,0x20,0x00,
0x20,0x20,0x00,0x20,0x20,0x00,0x20,0x18,0x00,0xe0,0x1f,0x00,0xc0,0x0f,0x00,
0x80,0x07,0x00,0x00,0x00,0x00,0x20,0x3c,0x00,0xe0,0x3f,0x00,0xe0,0x3f,0x00,
0xe0,0x03,0x00,0x80,0x00,0x00,0x40,0x00,0x00,0xe0,0x00,0x00,0xe0,0x00,0x00,
0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x3e,0x00,0xf1,0x3f,0x00,0xff,0x3f,0x00,0xff,0x21,0x00,0x0f,0x10,0x00,
0x00,0x00,0x00,0x00,0x0f,0x00,0x80,0x1f,0x00,0xc0,0x3f,0x00,0xc0,0x20,0x00,
0x20,0x20,0x00,0x20,0x20,0x00,0x20,0x18,0x00,0xe0,0x1f,0x00,0xc0,0x0f,0x00,
0x80,0x07,0x00,0x00,0x00,0x00,0x00,0x0f,0x00,0x80,0x1f,0x00,0xc0,0x3f,0x00,
0xc0,0x20,0x00,0x20,0x20,0x00,0x20,0x20,0x00,0x20,0x18,0x00,0xe0,0x1f,0x00,
0xc0,0x0f,0x00,0x80,0x07,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0xf1,0x3f,0x00,
0xff,0x3f,0x00,0xff,0x03,0x00,0x8f,0x00,0x00,0x40,0x0e,0x00,0x60,0x3e,0x00,
0xe0,0x3d,0x00,0xe0,0x31,0x00,0xc0,0x10,0x00,0x00,0x08,0x00,0x20,0x1e,0x00,
0xe0,0x3f,0x00,0xe0,0x3f,0x00,0xe0,0x31,0x00,0x00,0x10,0x00,0x00,0x08,0x00,
0x00,0x3e,0x00,0xe0,0x3f,0x00,0xe0,0x3f,0x00,0xe0,0x21,0x00,0x00,0x10,0x00,
0x00,0x00,0x02,0x00,0xc0,0x03,0x20,0xfe,0x03,0xe0,0xff,0x03,0xe0,0x3f,0x02,
0xe0,0x21,0x00,0x40,0x20,0x00,0x20,0x20,0x00,0x20,0x18,0x00,0xe0,0x1f,0x00,
0xc0,0x0f,0x00,0x80,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x3e,0x00,0xe0,0x3f,0x00,
0xfc,0x3f,0x00,0xfc,0x21,0x00,0x3c,0x10,0x00,0x20,0x00,0x00,0x20,0x00,0x00,
0x00,0x0f,0x00,0x80,0x1f,0x00,0xc0,0x3f,0x00,0xc0,0x20,0x00,0x20,0x20,0x00,
0x20,0x10,0x00,0x40,0x1c,0x00,0xe0,0x3f,0x00,0xe0,0x3f,0x00,0xe0,0x23,0x00,
0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x0f,0x00,0xf1,0x1f,0x00,0xff,0x3f,0x00,
0xff,0x21,0x00,0x4f,0x20,0x00,0x20,0x20,0x00,0x20,0x18,0x00,0xe0,0x1f,0x00,
0xc0,0x0f,0x00,0x80,0x07,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0xf1,0x3f,0x00,
0xff,0x3f,0x00,0xff,0x21,0x00,0x0f,0x10,0x00,0x00,0x00,0x00,0x00,0x0f,0x00,
0x80,0x1f,0x00,0xc0,0x3f,0x00,0xc0,0x24,0x00,0x20,0x24,0x00,0x20,0x22,0x00,
0x20,0x13,0x00,0xe0,0x13,0x00,0xc0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x0e,0x00,0xe0,0x1f,0x00,
0xe0,0x3f,0x00,0xe0,0x31,0x00,0x00,0x30,0x00,0x00,0x10,0x00,0x00,0x0e,0x00,
0xe0,0x1f,0x00,0xe0,0x3f,0x00,0xe0,0x31,0x00,0x00,0x30,0x00,0x00,0x10,0x00,
0x60,0x18,0x00,0xe0,0x0c,0x00,0xc0,0x03,0x00,0x00,0x00,0x00,0x20,0x3e,0x00,
0xe0,0x3f,0x00,0xe6,0x3f,0x00,0xe6,0x21,0x00,0x06,0x10,0x00,0x00,0x00,0x00,
0x00,0x0f,0x00,0x80,0x1f,0x00,0xc0,0x3f,0x00,0xc0,0x20,0x00,0x20,0x20,0x00,
0x20,0x20,0x00,0x20,0x10,0x00,0x40,0x1e,0x00,0xf1,0x3f,0x00,0xff,0x3f,0x00,
0xff,0x21,0x00,0x0f,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x3e,0x00,
0xe0,0x3f,0x00,0xfc,0x3f,0x00,0xfc,0x21,0x00,0x3c,0x10,0x00,0x20,0x00,0x00,
0x20,0x00,0x00,0x00,0x3e,0x00,0xf1,0x3f,0x00,0xff,0x3f,0x00,0xff,0x01,0x00,
0x8f,0x00,0x00,0x40,0x00,0x00,0x60,0x3c,0x00,0xe0,0x3f,0x00,0xe0,0x3f,0x00,
0xc0,0x23,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0xc0,0x3c,0x00,
0xe0,0x3d,0x00,0xe0,0x19,0x00,0xc0,0x00,0x00};

231
demos/cursor.c Normal file
View file

@ -0,0 +1,231 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <vga.h>
#include <vgamouse.h>
#include <sys/fcntl.h>
#include <stdint.h>
int mode = G1024x768x64K;
uint32_t mag_glass_bits[] = {
0x3f8, 0x60c, 0x9e2, 0x1a13, 0x1401, 0x1401, 0x1001, 0x1001,
0x1001, 0x1003, 0x1802, 0x340c, 0x6ff8, 0xd800, 0xb000, 0xe000,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0x3f8, 0x60c, 0x9e2, 0x1a13, 0x1401, 0x1401, 0x1001, 0x1001,
0x1001, 0x1003, 0x1802, 0x340c, 0x6ff8, 0xd800, 0xb000, 0xe000,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
};
uint32_t mag_glass_filled[] = {
0x3f8, 0x60c, 0x9e2, 0x1a13, 0x1401, 0x1401, 0x1001, 0x1001,
0x1001, 0x1003, 0x1802, 0x340c, 0x6ff8, 0xd800, 0xb000, 0xe000,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0x3f8, 0x7fc, 0xffe, 0x1fff, 0x1fff, 0x1fff, 0x1fff, 0x1fff,
0x1fff, 0x1fff, 0x1ffe, 0x3ffc, 0x7ff8, 0xf800, 0xe000, 0xe000,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
};
uint32_t *c2;
static unsigned char line[2048*4];
static void drawpattern(void)
{
int xmax, ymax, i, x, y, yw, ys, c;
vga_modeinfo *modeinfo;
modeinfo = vga_getmodeinfo(mode);
xmax = vga_getxdim() - 1;
ymax = vga_getydim() - 1;
vga_setcolor(vga_white());
vga_drawline(0, 0, xmax, 0);
vga_drawline(xmax, 0, xmax, ymax);
vga_drawline(xmax, ymax, 0, ymax);
vga_drawline(0, ymax, 0, 0);
for (i = 0; i <= 15; i++) {
vga_setegacolor(i);
vga_drawline(10 + i * 5, 10, 90 + i * 5, 90);
}
for (i = 0; i <= 15; i++) {
vga_setegacolor(i);
vga_drawline(90 + i * 5, 10, 10 + i * 5, 90);
}
vga_screenon();
ys = 100;
yw = (ymax - 100) / 4;
switch (vga_getcolors()) {
case 256:
for (i = 0; i < 60; ++i) {
c = (i * 64) / 60;
vga_setpalette(i + 16, c, c, c);
vga_setpalette(i + 16 + 60, c, 0, 0);
vga_setpalette(i + 16 + (2 * 60), 0, c, 0);
vga_setpalette(i + 16 + (3 * 60), 0, 0, c);
}
line[0] = line[xmax] = 15;
line[1] = line[xmax - 1] = 0;
for (x = 2; x < xmax - 1; ++x)
line[x] = (((x - 2) * 60) / (xmax - 3)) + 16;
for (y = ys; y < ys + yw; ++y) /* gray */
vga_drawscanline(y, line);
for (x = 2; x < xmax - 1; ++x)
line[x] += 60;
ys += yw;
for (y = ys; y < ys + yw; ++y) /* red */
vga_drawscanline(y, line);
for (x = 2; x < xmax - 1; ++x)
line[x] += 60;
ys += yw;
for (y = ys; y < ys + yw; ++y) /* green */
vga_drawscanline(y, line);
for (x = 2; x < xmax - 1; ++x)
line[x] += 60;
ys += yw;
for (y = ys; y < ys + yw; ++y) /* blue */
vga_drawscanline(y, line);
break;
case 1 << 15:
case 1 << 16:
case 1 << 24:
for (x = 2; x < xmax - 1; ++x) {
c = ((x - 2) * 256) / (xmax - 3);
y = ys;
vga_setrgbcolor(c, c, c);
vga_drawline(x, y, x, y + yw - 1);
y += yw;
vga_setrgbcolor(c, 0, 0);
vga_drawline(x, y, x, y + yw - 1);
y += yw;
vga_setrgbcolor(0, c, 0);
vga_drawline(x, y, x, y + yw - 1);
y += yw;
vga_setrgbcolor(0, 0, c);
vga_drawline(x, y, x, y + yw - 1);
}
for (x = 0; x < 64; x++) {
for (y = 0; y < 64; y++) {
vga_setrgbcolor(x * 4 + 3, y * 4 + 3, 0);
vga_drawpixel(xmax / 2 - 160 + x, y + ymax / 2 - 80);
vga_setrgbcolor(x * 4 + 3, 0, y * 4 + 3);
vga_drawpixel(xmax / 2 - 32 + x, y + ymax / 2 - 80);
vga_setrgbcolor(0, x * 4 + 3, y * 4 + 3);
vga_drawpixel(xmax / 2 + 160 - 64 + x, y + ymax / 2 - 80);
vga_setrgbcolor(x * 4 + 3, y * 4 + 3, 255);
vga_drawpixel(xmax / 2 - 160 + x, y + ymax / 2 + 16);
vga_setrgbcolor(x * 4 + 3, 255, y * 4 + 3);
vga_drawpixel(xmax / 2 - 32 + x, y + ymax / 2 + 16);
vga_setrgbcolor(255, x * 4 + 3, y * 4 + 3);
vga_drawpixel(xmax / 2 + 160 - 64 + x, y + ymax / 2 + 16);
}
}
break;
default:
if (vga_getcolors() == 16) {
for (i = 0; i < xmax - 1; i++)
line[i] = (i + 2) % 16;
line[0] = line[xmax] = 15;
line[1] = line[xmax - 1] = 0;
}
if (vga_getcolors() == 2) {
for (i = 0; i <= xmax; i++)
line[i] = 0x11;
line[0] = 0x91;
}
for (i = 100; i < ymax - 1; i++)
vga_drawscanline(i, line);
break;
}
}
int main(int argc, char *argv[]) {
int i,s,j;
unsigned char *g;
vga_init();
vga_setmousesupport(1);
printf("%i\n",vga_initcursor(argc-1));
vga_setmode(mode);
vga_setlinearaddressing();
vga_setcursorposition(100,100);
c2=malloc(256);
j=1;
for(i=0;i<32;i++) {
*(c2+i)=j;
*(c2+32+i)=j;
j<<=1;
}
if(vga_getcolors()==256)
for (i = 0; i < 60; ++i) {
j = (i * 64) / 60;
vga_setpalette(i + 16, j, j, j);
vga_setpalette(i + 16 + 60, j, 0, 0);
vga_setpalette(i + 16 + (2 * 60), 0, j, 0);
vga_setpalette(i + 16 + (3 * 60), 0, 0, j);
}
vga_setcursorimage(0,0,0,0xff0000,(unsigned char *)c2);
vga_setcursorimage(1,0,0,0xffffff,(unsigned char *)mag_glass_bits);
vga_setcursorimage(2,0,0xff1080,0x0f0fff,(unsigned char *)mag_glass_filled);
vga_selectcursor(1);
vga_showcursor(1);
vga_showcursor(2);
g=vga_getgraphmem();
#if 1
drawpattern();
#else
for(j=0;j<256*1024;j++) {
if((j&0x3ff)==0x3ff)usleep(1000);
*(g+2*j)=0x00;
*(g+2*j+1)=(j*83/69)&0xff;
}
for(j=256*1024;j<384*1024;j++) {
if((j&0x3ff)==0x3ff)usleep(1000);
*(g+2*j)=0;
*(g+2*j+1)=0;
}
for(j=384*1024;j<512*1024;j++) {
// if((j&0x3ff)==0x3ff)usleep(1000);
*(g+2*j)=0xff;
*(g+2*j+1)=0x7f;
}
for(j=512*1024;j<2048*1024;j++) {
// if((j&0x3ff)==0x3ff)usleep(1000);
*(g+2*j)=((j>>9)&1)*(((~j)>>4)&0x1f);
*(g+2*j+1)=(1-((j>>9)&1)) * ((j>>2)&0x7c);
}
#endif
i=1;
vga_showcursor(3);
s=3;
while(!(mouse_getbutton()&4)) {
mouse_waitforupdate();
vga_setcursorposition(mouse_getx(),mouse_gety());
if(mouse_getbutton()&1) {
vga_selectcursor(i=(i+1)%3);
}
#if 1
if(mouse_getbutton()&2) {
vga_showcursor(s=(s+1)%4);
}
#else
if(mouse_getbutton()&2) {
vga_dumpregs();
}
#endif
}
vga_setmode(TEXT);
return 0;
}

17
demos/eightbpp.xbm Normal file
View file

@ -0,0 +1,17 @@
#define eightbpp_width 23
#define eightbpp_height 66
static char eightbpp_bits[] = {
0x00,0xf0,0x01,0x00,0xfc,0x01,0x78,0xfc,0x03,0xfe,0x07,0x03,0xfe,0x03,0x02,
0xe3,0x03,0x02,0xc1,0x07,0x02,0x81,0x0f,0x03,0x81,0xff,0x03,0xc3,0xff,0x01,
0x7f,0xfe,0x01,0x7e,0x78,0x00,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x70,0x00,0x01,0xff,0x01,0xf1,0xff,0x01,0xff,0xff,0x03,
0xff,0x03,0x03,0xff,0x00,0x02,0x8f,0x00,0x02,0x40,0x00,0x03,0xc0,0xc0,0x03,
0xc0,0xff,0x01,0x80,0xff,0x01,0x80,0xff,0x00,0x00,0x3e,0x40,0x00,0x00,0x40,
0x00,0x00,0x78,0x40,0x80,0x7f,0x40,0xf8,0x7f,0xc0,0xff,0x7f,0xc0,0xff,0x47,
0xc0,0xff,0x41,0xc0,0x07,0x03,0x80,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x03,
0xc0,0xc0,0x03,0xc0,0xff,0x01,0x80,0xff,0x01,0x80,0xff,0x00,0x00,0x3e,0x40,
0x00,0x00,0x40,0x00,0x00,0x78,0x40,0x80,0x7f,0x40,0xf8,0x7f,0xc0,0xff,0x7f,
0xc0,0xff,0x47,0xc0,0xff,0x41,0xc0,0x07,0x03,0x80,0x00,0x02,0x40,0x00,0x02,
0x40,0x00,0x03,0xc0,0xc0,0x03,0xc0,0xff,0x01,0x80,0xff,0x01,0x80,0xff,0x00,
0x00,0x3e,0x00};

258
demos/eventtest.c Normal file
View file

@ -0,0 +1,258 @@
/* Program to test the vga_waitevent function. */
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <vga.h>
#include <vgagl.h>
#include <vgamouse.h>
#include <vgakeyboard.h>
#define USE_RAWKEYBOARD
static int newcolor(void)
{
if (BYTESPERPIXEL == 1)
return random() % 15 + 1;
return gl_rgbcolor(random() & 255, random() & 255, random() & 255);
}
static void ping(void)
{
putchar('\a');
fflush(stdout);
}
/* read data from fd. Write string if '\n' encountered */
void process_input(int fd)
{
static char textbuf[80], *data = textbuf;
char inbuf[80];
int len, i;
len = read(fd, inbuf, 80);
if (len <= 0)
return;
for (i = 0; i < len; i++) {
if (inbuf[i] == '\n') {
*data = 0;
gl_write(0, 10, textbuf);
ping();
data = textbuf;
} else {
*data++ = inbuf[i];
}
}
}
void child(int fd)
{
time_t last_time = 0, now;
FILE *output;
output = fdopen(fd, "w");
for (;;) { /* when parent dies we get killed by SIGPIPE */
now = time(NULL);
if (now / 5 > last_time) { /* a new minute started */
last_time = now / 5;
fputs(ctime(&now), output);
fputc('\n', output);
fflush(output);
}
sleep(1);
}
}
int main(void)
{
struct timeval timeout;
fd_set inputs;
char bitmap[16 * 16 * 4]; /* big enough for 10x10 bitmap in any mode */
int vgamode, color, pipefd[2], x, y, button, event, cursorsize = 5;
char loop = 1, drawcursor = 1;
#ifdef USE_RAWKEYBOARD
char space_pressed = 0;
#endif
puts("This is a demo showing the abilities of the new vga_waitevent() function\n"
"If something goes wrong it might hang your machine. Thus hit <ctrl>-C now\n"
"to bailout if in doubt.\n"
"Use mouse to move cursor. 1-9,0 to set the cursor size. Space to change the\n"
"cursor color. Left button to draw. Right button or 'Q' to bailout.\n"
"The cursor goes on/off every half second by usage of a timeout passed to\n"
"vga_waitevent. Every 5 secs a string from a child process (the time) arrives\n"
"asynchronously and is displayed by the frontend.");
#ifdef USE_RAWKEYBOARD
puts("\nBEWARE! This has been compiled to use the raw keyboard. A crash might\n"
"render the console unusable. (but shouldn't).");
#endif
fputs("\nHit <Enter> if brave enough, else ^C to bailout: ", stdout);
fflush(stdout);
getchar();
fflush(stdin); /* clear I/O buffer */
pipe(pipefd);
if (fork() == 0) { /* fork off b4 touching graphix to avoid side effects */
close(pipefd[0]); /* Important: close reading side, else it remains */
/* opened by child when parent exits and we don't get */
/* a SIGPIPE! */
child(pipefd[1]);
}
vga_init();
vgamode = vga_getdefaultmode();
if (vgamode == -1)
vgamode = G320x200x256;
if (!vga_hasmode(vgamode)) {
printf("Mode not available.\n");
exit(-1);
}
/* Enable automatic mouse setup at mode set. */
vga_setmousesupport(1);
vga_setmode(vgamode);
/* Disable wrapping (default). */
/* mouse_setwrap(MOUSE_NOWRAP); */
gl_setcontextvga(vgamode);
gl_enableclipping();
/* There might be some scrap data in the serial buffer
from the mouse. It will make vga_waitevent block
because it thinks the mouse wants to send data but
then no mouse packet arrives. */
color = newcolor();
x = 0;
y = 0;
gl_setwritemode(WRITEMODE_OVERWRITE | FONT_COMPRESSED);
gl_setfont(8, 8, gl_font8x8);
gl_setfontcolors(0, newcolor());
#ifdef USE_RAWKEYBOARD
if (keyboard_init()) {
printf("Could not initialize keyboard.\n");
exit(1);
}
#endif
while (loop) {
gl_getbox(x, y, 10, 10, bitmap);
if (drawcursor) {
gl_hline(x, y, x + cursorsize, color);
gl_hline(x, y + cursorsize, x + cursorsize, color);
gl_line(x, y, x, y + cursorsize, color);
gl_line(x + cursorsize, y, x + cursorsize, y + cursorsize, color);
}
FD_ZERO(&inputs);
FD_SET(pipefd[0], &inputs);
timeout.tv_sec = 0;
timeout.tv_usec = 500000; /* 0.5 second time out */
event = vga_waitevent(VGA_MOUSEEVENT | VGA_KEYEVENT,
&inputs, NULL, NULL, &timeout);
gl_putbox(x, y, 10, 10, bitmap);
if (timeout.tv_sec || timeout.tv_usec) {
/* No timeout. An actual event occured. Reset to visible
cursor. Note:
This is actually a bug as the cursor will get visible on time
updates. However, it's better this way for demo/test
purposes. */
drawcursor = 1;
} else {
drawcursor ^= 1;
}
if (FD_ISSET(pipefd[0], &inputs))
process_input(pipefd[0]);
if (event & VGA_MOUSEEVENT) {
x = mouse_getx();
y = mouse_gety();
button = mouse_getbutton();
if (button & MOUSE_LEFTBUTTON)
gl_fillbox(x, y, cursorsize + 1, cursorsize + 1, color);
if (button & MOUSE_RIGHTBUTTON)
loop = 0;
}
if (event & VGA_KEYEVENT) {
#ifdef USE_RAWKEYBOARD
if (keyboard_keypressed(SCANCODE_1))
cursorsize = 0;
if (keyboard_keypressed(SCANCODE_2))
cursorsize = 1;
if (keyboard_keypressed(SCANCODE_3))
cursorsize = 2;
if (keyboard_keypressed(SCANCODE_4))
cursorsize = 3;
if (keyboard_keypressed(SCANCODE_5))
cursorsize = 4;
if (keyboard_keypressed(SCANCODE_6))
cursorsize = 5;
if (keyboard_keypressed(SCANCODE_7))
cursorsize = 6;
if (keyboard_keypressed(SCANCODE_8))
cursorsize = 7;
if (keyboard_keypressed(SCANCODE_9))
cursorsize = 8;
if (keyboard_keypressed(SCANCODE_0))
cursorsize = 9;
if (keyboard_keypressed(SCANCODE_Q))
loop = 0;
if (keyboard_keypressed(SCANCODE_SPACE)) {
if (!space_pressed) {
color = newcolor();
space_pressed = 1;
}
} else {
space_pressed = 0;
}
#else
switch (vga_getch()) {
case '1':
cursorsize = 0;
break;
case '2':
cursorsize = 1;
break;
case '3':
cursorsize = 2;
break;
case '4':
cursorsize = 3;
break;
case '5':
cursorsize = 4;
break;
case '6':
cursorsize = 5;
break;
case '7':
cursorsize = 6;
break;
case '8':
cursorsize = 7;
break;
case '9':
cursorsize = 8;
break;
case '0':
cursorsize = 9;
break;
case ' ':
color = newcolor();
break;
case 'q':
case 'Q':
loop = 0;
break;
default:
ping();
break;
}
#endif
}
}
#ifdef USE_RAWKEYBOARD
keyboard_close(); /* Don't forget this! */
#endif
vga_setmode(TEXT);
exit(0);
}

54
demos/fish_monster.h Normal file
View file

@ -0,0 +1,54 @@
/* Hand edited by M. Weller by from an original XPM file */
#define fish_monster_w 33
#define fish_monster_h 33
/* width height ncolors chars_per_pixel */
static unsigned char fish_monster233[] =
{0x00, 0xf1, 0xf4, 0x07, 0xff, 0xc0};
static unsigned short fish_monster555[] =
{0x0000, 0x125f, 0x431c, 0x7c00, 0x7fff, 0x001f};
static unsigned short fish_monster565[] =
{0x0000, 0x249f, 0x861c, 0xf800, 0xffff, 0x001f};
static unsigned int fish_monster888[] =
{
0x00000000,
0x002900ff,
0x0080e0e0,
0x00ff0000,
0x00ffffff,
0x000000ff};
/* pixels */
static char *fish_monster =
"dddddddddddd```dddddd``ddddddd``d"
"ddddddddddd`eee``dddd`e``ddd``e`d"
"ddddddd``````aaee`ddd`e`e```e`e`d"
"ddddd```bbbbb```ee`dd`aae`e`eab`d"
"dddd`ddd`bb```bb``e`dd``aaeaa``dd"
"ddd`dd```b`dd``bbb``dddd`bbb`dddd"
"dd``dd```b`d```bbbb`ddddd`b`ddddd"
"dd`b````bbb```bbbbbb`dddd`b`ddddd"
"d`bbbbbbbbbbbbbbbbbbb`dd`bb`ddddd"
"d`````bbb````bbbbbbbbb``bbbb`dddd"
"`ccccc```cccc``bbbbbbbbbbbbb`dddd"
"`cccccccccccccc`bbbbbbbbbbbb`dddd"
"d````ccccc````cc`bbbbbbbbbbbb`ddd"
"d`d`d`````d`d``cc`bbbbbbbbbbb`ddd"
"d`d`d`d`d`d`d```c`bbbbb``bbbb`ddd"
"dd`d``d`d```````cc`bbbbba`bbb`ddd"
"dddddd```````````c`bbbb`ae`bb`ddd"
"dddddd```````````c`bbbba`e`bb`ddd"
"ddd`dd```````````c`bbb`ae``b`dddd"
"dd`d`````````````c`b`aa`ee`b`dddd"
"dd`d`d`d`````d``cc`bb`ee``bb`dddd"
"d````d`d`d`d`d`cc`bbbb```bb`ddddd"
"`ccc`````d`d``ccc`bbbbbbbbb`ddddd"
"`cccccccc```cccc`bbbbbbbbbb`ddddd"
"d```ccccccccccc`bbbbbbbbbb`dddddd"
"dd`b````ccccc``bbbbbbbbbbb`dddddd"
"dd`bbbbb`````bbbbbbbbbbbb`ddddddd"
"ddd`bbbbbbbbbbbbbbbbbbbb`dddddddd"
"dddd`bbbbbbbbbbbbbbbbb``ddddddddd"
"ddddd``bbbbbbbbbbbbb``ddddddddddd"
"ddddddd```bbbbbbb```ddddddddddddd"
"dddddddddd```````dddddddddddddddd"
"ddddddddddddddddddddddddddddddddd";

164
demos/forktest.c Normal file
View file

@ -0,0 +1,164 @@
/* Program to test the svgalib keyboard functions. */
/* and stress vga_safety_fork() */
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <string.h>
#include <time.h>
#include <vga.h>
#include <vgagl.h>
#include <vgakeyboard.h>
#define zero_sa_mask(maskptr) memset(maskptr, 0, sizeof(sigset_t))
static char sig2release[] =
{SIGHUP, SIGINT, SIGQUIT, SIGILL,
SIGTRAP, SIGIOT, SIGBUS, SIGFPE,
SIGSEGV, SIGPIPE, SIGALRM, SIGTERM,
SIGXCPU, SIGXFSZ, SIGVTALRM,
SIGPROF, SIGPWR};
static int newcolor(void)
{
if (BYTESPERPIXEL == 1)
return random() % 15 + 1;
return gl_rgbcolor(random() & 255, random() & 255, random() & 255);
}
static void timeout(int sig)
{
keyboard_close();
vga_setmode(TEXT);
puts("Automatic termination after 60 seconds.");
exit(1);
}
void shutdown(void)
{
puts("Shutdown called!");
}
int main(void)
{
struct sigaction siga;
int vgamode, color, leftpressed;
int x, y;
printf("\nWARNING: This program will set the keyboard to RAW mode.\n"
"The keyboard routines in svgalib have not been tested\n"
"very much. There may be no recovery if something goes\n"
"wrong.\n\n"
"Press ctrl-c now to bail out, enter to continue.\n"
"In the test itself, use 'q' or Escape to quit.\n"
"It will also terminate after 60 seconds.\n"
"Use any cursor keys to move, keypad 0 or enter to change color.\n\n"
"\aWARNING, this version of keytest explicitly removes all svgalib\n"
"automatic restore funcs, s.t. when you kill it from the outside\n"
"only vga_safety_fork() can rescue you. Use this svgalib test tool\n"
"with EXTREME! care.\n"
);
getchar();
vga_safety_fork(shutdown); /* Does already enter a videomode */
vga_init();
/* Never do this in your code! */
siga.sa_flags = 0;
zero_sa_mask(&(siga.sa_mask));
for (x = 0; x < sizeof(sig2release); x++) {
siga.sa_handler = SIG_DFL;
sigaction(sig2release[x], &siga, NULL);
}
vgamode = vga_getdefaultmode();
if ((vgamode == -1) || (vga_getmodeinfo(vgamode)->bytesperpixel != 1))
vgamode = G320x200x256;
if (!vga_hasmode(vgamode)) {
printf("Mode not available.\n");
exit(1);
}
vga_setmode(vgamode);
gl_setcontextvga(vgamode);
gl_enableclipping();
signal(SIGALRM, timeout);
/* This installs the default handler, which is good enough for most */
/* purposes. */
if (keyboard_init()) {
printf("Could not initialize keyboard.\n");
exit(1);
}
/* Translate to 4 keypad cursor keys, and unify enter key. */
keyboard_translatekeys(TRANSLATE_CURSORKEYS | TRANSLATE_KEYPADENTER |
TRANSLATE_DIAGONAL);
/* (TRANSLATE_DIAGONAL seems to give problems.) Michael: No doesn't...
but might not do what you expect.. */
alarm(60); /* Terminate after 60 seconds for safety. */
x = WIDTH / 2;
y = HEIGHT / 2;
color = newcolor();
leftpressed = 0;
for (;;) {
/* Draw moving box. */
gl_fillbox(x, y, 5, 5, color);
/* Draw key status bar at top of screen. */
gl_putbox(0, 0, 128, 1, keyboard_getstate());
/* Wait about 1/100th of a second. */
/* Note that use of this function makes things less */
/* smooth because of timer latency. */
usleep(10000);
keyboard_update();
/* Move. */
if (keyboard_keypressed(SCANCODE_CURSORLEFT))
x--;
if (keyboard_keypressed(SCANCODE_CURSORRIGHT))
x++;
if (keyboard_keypressed(SCANCODE_CURSORUP))
y--;
if (keyboard_keypressed(SCANCODE_CURSORDOWN))
y++;
/* Boundary checks. */
if (x < 0)
x = 0;
if (x >= WIDTH)
x = WIDTH - 1;
if (y < 1)
y = 1;
if (y >= HEIGHT)
y = HEIGHT - 1;
/* Check for color change. */
if (keyboard_keypressed(SCANCODE_KEYPAD0) ||
keyboard_keypressed(SCANCODE_ENTER)) {
if (!leftpressed) {
color = newcolor();
leftpressed = 1;
}
} else
leftpressed = 0;
if (keyboard_keypressed(SCANCODE_Q) ||
keyboard_keypressed(SCANCODE_ESCAPE))
break;
}
keyboard_close(); /* Don't forget this! */
vga_setmode(TEXT);
exit(0);
}

533
demos/fun.c Normal file
View file

@ -0,0 +1,533 @@
/* Roaming-blobs-on-mars-collect-some-dust-on-a-tropical-island-and-go-pearl-
diving-before-population-goes-out-of-control. */
/* Each frame, a background virtual screen is copied to a virtual screen; */
/* sprites (well, pixels) are written on that virtual screen; and the */
/* virtual screen is copied to video memory. The background is updated as */
/* appropriate. This simple animation technique works well for 320x200 */
/* because it's so small. */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <vga.h>
#include <vgagl.h>
/* This can be changed into any 256 color mode. */
/* For planar 256 color modes, enable page flipping. */
/* Even 16 color modes work (ugly colors). */
#define VGAMODE G800x600x256
//#define USE_PAGEFLIPPING
/* #define USE_SMALLOC */
/* This is the size of the animated window. */
#define MAPWIDTH 800
#define MAPHEIGHT 560
#define MAXMOVERS 2000
#define MAXCITIES 1000
#define NUMBEROFCITIES 20
#define NUMBEROFMOVERS 1400
#define MOVERTHRESHOLD 1400
#define MOVERLIFETIME 1000
#define COLORTIME 2000
#define randomn( n ) (random() % n)
#define red(x) (32 + x)
#define green(x) (64 + x)
#define yellow(x) (96 + x)
#define blue(x) (128 + x)
#define magenta(x) (160 + x)
#define cyan(x) (192 + x)
#define white(x) (224 + x)
/* Data types */
typedef struct {
int x;
int y;
} Position;
#define STAT_ACTIVE 1
typedef struct {
int stat;
int x;
int y;
int vx;
int vy;
int color;
int time;
} Mover;
typedef struct {
int x;
int y;
int pop;
int hit;
} City;
/* Global variables */
int map[MAPWIDTH][MAPHEIGHT];
/* Map encoding i: */
/* (0 - 0xffff Mover number i) */
/* 0x10000... Part of city (i - 0x10000) */
Mover mover[MAXMOVERS];
int nu_movers = 0;
City city[MAXCITIES];
int nu_cities = 0;
int mytime = 0; /* used to be "time" but collids w/libc function time() */
int pop = 0;
int framerate, framecount, frameclock;
GraphicsContext *physicalscreen;
GraphicsContext *backscreen;
GraphicsContext *background;
void error(char *s)
{
printf("%s\n", s);
vga_setmode(TEXT);
exit(0);
}
void setcustompalette(void)
{
/* colors 0-31 are a RGB mix (bits 0 and 1 red, 2 green, 3 and 4 blue) */
/* 32-63 black to red */
/* 64-95 black to green */
/* 96-127 black to yellow */
/* 128-159 black to blue */
/* 160-191 black to magenta */
/* 192-223 black to cyan */
/* 224-255 black to white */
Palette pal;
int i;
for (i = 0; i < 256; i++) {
int r, g, b;
r = g = b = 0;
if ((i & 32) > 0)
r = (i & 31) << 1;
if ((i & 64) > 0)
g = (i & 31) << 1;
if ((i & 128) > 0)
b = (i & 31) << 1;
if (i < 32) {
r = (i & 3) << 4; /* 2 bits */
g = (i & 4) << 3; /* 1 bit */
b = (i & 24) << 1; /* 2 bits */
}
pal.color[i].red = r;
pal.color[i].green = g;
pal.color[i].blue = b;
}
gl_setpalette(&pal);
}
void initfont(void)
{
void *font;
#ifdef USE_SMALLOC
font = smalloc(256 * 8 * 8 * BYTESPERPIXEL);
#else
font = malloc(256 * 8 * 8 * BYTESPERPIXEL);
#endif
gl_expandfont(8, 8, white(24), gl_font8x8, font);
gl_setfont(8, 8, font);
}
int fsize(FILE * f)
{
int oldpos, size;
oldpos = ftell(f);
fseek(f, 0, SEEK_END);
size = ftell(f);
fseek(f, oldpos, SEEK_SET);
return size;
}
void loadfile(char **buf, char *fname)
{
FILE *f;
int size;
f = fopen(fname, "rb");
size = fsize(f);
*buf = malloc(size);
fread(*buf, 1, size, f);
fclose(f);
}
/* Map */
void clearmap(void)
{
int x, y;
for (y = 0; y < MAPHEIGHT; y++)
for (x = 0; x < MAPWIDTH; x++)
map[x][y] = 0;
}
Position
findfreeposition(void)
{
int x, y;
Position p;
do {
x = randomn(MAPWIDTH);
y = randomn(MAPHEIGHT);
}
while (map[x][y] != 0);
p.x = x;
p.y = y;
return p;
}
/* Movers */
void initmovers(void)
{
int i;
for (i = 0; i < MAXMOVERS; i++)
mover[i].stat = 0;
}
int findfreemoverslot(void)
{
int i;
for (i = 0; i < MAXMOVERS; i++)
if (!(mover[i].stat & STAT_ACTIVE))
return i;
error("Mover table overflow");
return 0;
}
void addrandommover(void)
{
Position p = findfreeposition();
int i = findfreemoverslot();
int c;
mover[i].x = p.x;
mover[i].y = p.y;
do {
mover[i].vx = randomn(3) - 1;
mover[i].vy = randomn(3) - 1;
}
while (mover[i].vx == 0 && mover[i].vy == 0);
mover[i].stat = STAT_ACTIVE;
switch (randomn(4)) {
case 0:
c = blue(20);
break;
case 1:
c = green(20);
break;
case 2:
c = magenta(20);
break;
default:
c = cyan(20);
break;
}
mover[i].time = 0;
mover[i].color = c;
nu_movers++;
}
void killmover(int i)
{
mover[i].stat = 0;
nu_movers--;
}
void drawmover(int i)
{
gl_setpixel(mover[i].x, mover[i].y, mover[i].color);
}
/* Cities */
void initcities(void)
{
nu_cities = 0;
}
void addcity(int x, int y)
{
int i = nu_cities++;
map[x][y] = i + 0x10000;
city[i].x = x;
city[i].y = y;
city[i].pop = 1;
city[i].hit = 0;
}
int cityat(int x, int y)
{
if (map[x][y] >= 0x10000)
return map[x][y] - 0x10000;
else
return -1;
}
int citycolor(void)
{
static int colortable[5] =
{yellow(31), blue(31), white(31), green(31), cyan(31)};
return colortable[(mytime / COLORTIME) % 5]
- (mytime % COLORTIME) * 25 / COLORTIME;
}
void growcity(int cx, int cy, int x, int y, int ct)
{
/* add city unit at (x, y) adjacent to city unit (cx, cy) */
int c;
map[x][y] = ct + 0x10000;
c = citycolor();
gl_setpixel(x, y, c);
city[ct].pop++;
city[ct].hit = 20;
pop++;
}
/* Main components */
void createbackground(void)
{
/* Create fancy dark red background */
int x, y;
for (y = 0; y < MAPHEIGHT; y++)
for (x = 0; x < MAPWIDTH; x++) {
int i = 0;
int n = 0;
int c;
if (x > 0) {
i += gl_getpixel(x - 1, y) - red(0);
n++;
}
if (y > 0) {
i += gl_getpixel(x, y - 1) - red(0);
n++;
}
c = (i + randomn(16)) / (n + 1);
if (c > 9)
c = 9;
gl_setpixel(x, y, red(0) + c);
}
}
void drawbackground(void)
{
/* Build up background from map data */
int x, y;
gl_setcontext(background);
gl_clearscreen(0);
createbackground();
for (y = 0; y < MAPHEIGHT; y++)
for (x = 0; x < MAPWIDTH; x++) {
int c = cityat(x, y);
if (c != -1)
gl_setpixel(x, y, citycolor());
}
}
void createcities(void)
{
int i;
for (i = 0; i < NUMBEROFCITIES; i++) {
Position p = findfreeposition();
addcity(p.x, p.y);
}
}
void writestat(void)
{
char s[41];
int i, x, y;
int maxpopcity, maxpop;
sprintf(s, "Pop %7d Time %7d Rate %5d.%d", pop, mytime,
framerate / 10, framerate % 10);
gl_setwritemode(WRITEMODE_OVERWRITE);
gl_write(0, HEIGHT - 8, s);
maxpop = -1;
maxpopcity = 0;
for (i = 0; i < nu_cities; i++)
if (city[i].pop > maxpop) {
maxpop = city[i].pop;
maxpopcity = i;
}
gl_enableclipping();
gl_circle(city[maxpopcity].x, city[maxpopcity].y, 10,
blue(31));
gl_disableclipping();
gl_setwritemode(WRITEMODE_MASKED);
x = city[maxpopcity].x;
y = city[maxpopcity].y;
sprintf(s, "%d", maxpop);
/* clipping */
if (x + strlen(s) * 8 > MAPWIDTH)
x = MAPWIDTH - strlen(s) * 8;
if (y + 8 > MAPHEIGHT)
y = MAPHEIGHT - 8;
gl_write(x, y, s);
}
void drawscreen(void)
{
int i;
/* Copy background to backscreen. */
gl_setcontext(background);
gl_copyscreen(backscreen);
/* Now draw the objects in backscreen. */
gl_setcontext(backscreen);
for (i = 0; i < MAXMOVERS; i++)
if (mover[i].stat & STAT_ACTIVE) {
drawmover(i);
}
writestat();
/* Copy backscreen to physical screen. */
gl_copyscreen(physicalscreen);
}
void move(void)
{
int i;
gl_setcontext(background);
for (i = 0; i < MAXMOVERS; i++)
if (mover[i].stat & STAT_ACTIVE) {
int nx, ny;
int c;
if (++mover[i].time == MOVERLIFETIME) {
killmover(i);
continue;
}
for (;;) {
nx = mover[i].x + mover[i].vx;
ny = mover[i].y + mover[i].vy;
if (nx < 0 || nx >= MAPWIDTH) {
mover[i].vx = -mover[i].vx;
continue;
}
if (ny < 0 || ny >= MAPHEIGHT) {
mover[i].vy = -mover[i].vy;
continue;
}
break;
}
c = cityat(nx, ny);
if (c != -1) { /* found city */
killmover(i);
growcity(nx, ny, mover[i].x, mover[i].y, c);
continue; /* next mover */
}
mover[i].x = nx;
mover[i].y = ny;
}
if (pop >= MAPWIDTH * MAPHEIGHT * 255 / 256) {
/* start all over again */
printf("fun: new run.\n");
pop = 0;
mytime = 0;
clearmap();
initcities();
createcities();
drawbackground();
}
}
void createmovers(void)
{
int i;
for (i = 0; i < NUMBEROFMOVERS; i++)
addrandommover();
}
int main(void)
{
vga_init();
clearmap();
initmovers();
createcities();
createmovers();
vga_setmode(VGAMODE);
gl_setcontextvga(VGAMODE);
physicalscreen = gl_allocatecontext();
gl_getcontext(physicalscreen);
#ifdef USE_PAGEFLIPPING
/* Try to enable page flipping. */
printf("pf=%i\n", gl_enablepageflipping(physicalscreen));
#endif
setcustompalette();
/* initfont() here caused trouble with planar 256 color modes. */
gl_setcontextvgavirtual(VGAMODE);
backscreen = gl_allocatecontext();
gl_getcontext(backscreen);
#ifdef USE_SMALLOC
free(backscreen->vbuf);
backscreen->vbuf = smalloc(BYTEWIDTH * HEIGHT);
gl_setcontext(backscreen);
#endif
initfont();
gl_setcontextvgavirtual(VGAMODE);
background = gl_allocatecontext();
gl_getcontext(background);
#ifdef USE_SMALLOC
free(background->vbuf);
background->vbuf = smalloc(BYTEWIDTH * HEIGHT);
gl_setcontext(background);
#endif
drawbackground();
framerate = 0;
framecount = 0;
frameclock = clock();
for (;;) {
int i;
drawscreen();
move();
for (i = 0; i < 4; i++)
if (nu_movers < MOVERTHRESHOLD)
addrandommover();
mytime++;
/* Update frame rate every 3 seconds. */
framecount++;
if (clock() - frameclock >= CLOCKS_PER_SEC) {
framerate = framecount * CLOCKS_PER_SEC / (clock() - frameclock);
framecount = 0;
frameclock = clock();
}
}
#ifndef USE_SMALLOC
gl_freecontext(backscreen);
gl_freecontext(background);
#endif
vga_setmode(TEXT);
exit(0);
}

61
demos/joytest.c Normal file
View file

@ -0,0 +1,61 @@
/*
* joytest.c 1.0
* Cpoyright (C) 1998 Daniel Engström <daniel.engstrom@riksnett.no>
*
*/
/*
* This is a simple joystick test program and an example
* how to write programs using the vgajoystick library routines
*/
/*
* usage: joytest <number>
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <vgajoystick.h>
char *axe_name[] = { "X", "Y", "Z", };
int main (int argc, char **argv)
{
int joystick, axes, buttons, i;
if (argc != 2) {
fprintf(stderr, "usage: joytest <number>\n");
exit (1);
}
joystick = atoi(argv[1]);
if (joystick_init(joystick, JOY_CALIB_STDOUT) < 0)
exit(1);
axes = joystick_getnumaxes(joystick);
buttons = joystick_getnumbuttons(joystick);
printf("Joystick %d has %d axes and %d buttons.\n", joystick, axes, buttons);
if (axes > 3)
axes = 3;
printf("Press enter to start testing ... (interrupt to exit)\n");
getchar();
for(;;)
{
while(!joystick_update());
for (i = 0; i < buttons; i++)
printf("B%d: %s ", i, joystick_getbutton(joystick, i) ? "down" : "up ");
for (i = 0; i < axes; i++)
printf("%s: %4d ", axe_name[i], joystick_getaxis(joystick, i));
putchar('\n');
usleep(100);
}
joystick_close(joystick);
return 0;
}

130
demos/keytest.c Normal file
View file

@ -0,0 +1,130 @@
/* Program to test the svgalib keyboard functions. */
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <vga.h>
#include <vgagl.h>
#include <vgakeyboard.h>
static int newcolor(void)
{
if (BYTESPERPIXEL == 1)
return random() % 15 + 1;
return gl_rgbcolor(random() & 255, random() & 255, random() & 255);
}
static void timeout(int sig)
{
keyboard_close();
vga_setmode(TEXT);
puts("Automatic termination after 60 seconds.");
exit(1);
}
int main(void)
{
int vgamode, color, leftpressed;
int x, y;
vga_init();
vgamode = vga_getdefaultmode();
if ((vgamode == -1) || (vga_getmodeinfo(vgamode)->bytesperpixel != 1))
vgamode = G320x200x256;
if (!vga_hasmode(vgamode)) {
printf("Mode not available.\n");
exit(1);
}
printf("\nWARNING: This program will set the keyboard to RAW mode.\n"
"The keyboard routines in svgalib have not been tested\n"
"very much. There may be no recovery if something goes\n"
"wrong.\n\n"
"Press ctrl-c now to bail out, enter to continue.\n"
"In the test itself, use 'q' or Escape to quit.\n"
"It will also terminate after 60 seconds.\n"
"Use any cursor keys to move, keypad 0 or enter to change color.\n");
getchar();
vga_setmode(vgamode);
gl_setcontextvga(vgamode);
gl_enableclipping();
signal(SIGALRM, timeout);
/* This installs the default handler, which is good enough for most */
/* purposes. */
if (keyboard_init()) {
printf("Could not initialize keyboard.\n");
exit(1);
}
/* Translate to 4 keypad cursor keys, and unify enter key. */
keyboard_translatekeys(TRANSLATE_CURSORKEYS | TRANSLATE_KEYPADENTER |
TRANSLATE_DIAGONAL);
/* (TRANSLATE_DIAGONAL seems to give problems.) Michael: No doesn't...
but might not do what you expect.. */
alarm(60); /* Terminate after 60 seconds for safety. */
x = WIDTH / 2;
y = HEIGHT / 2;
color = newcolor();
leftpressed = 0;
for (;;) {
/* Draw moving box. */
gl_fillbox(x, y, 5, 5, color);
/* Draw key status bar at top of screen. */
gl_putbox(0, 0, 128, 1, keyboard_getstate());
/* Wait about 1/100th of a second. */
/* Note that use of this function makes things less */
/* smooth because of timer latency. */
usleep(10000);
keyboard_update();
/* Move. */
if (keyboard_keypressed(SCANCODE_CURSORLEFT))
x--;
if (keyboard_keypressed(SCANCODE_CURSORRIGHT))
x++;
if (keyboard_keypressed(SCANCODE_CURSORUP))
y--;
if (keyboard_keypressed(SCANCODE_CURSORDOWN))
y++;
/* Boundary checks. */
if (x < 0)
x = 0;
if (x >= WIDTH)
x = WIDTH - 1;
if (y < 1)
y = 1;
if (y >= HEIGHT)
y = HEIGHT - 1;
/* Check for color change. */
if (keyboard_keypressed(SCANCODE_KEYPAD0) ||
keyboard_keypressed(SCANCODE_ENTER)) {
if (!leftpressed) {
color = newcolor();
leftpressed = 1;
}
} else
leftpressed = 0;
if (keyboard_keypressed(SCANCODE_Q) ||
keyboard_keypressed(SCANCODE_ESCAPE))
break;
}
keyboard_close(); /* Don't forget this! */
vga_setmode(TEXT);
exit(0);
}

165
demos/linearfork.c Normal file
View file

@ -0,0 +1,165 @@
/* Program to test the svgalib keyboard functions. */
/* and stress vga_safety_fork() */
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <string.h>
#include <time.h>
#include <vga.h>
#include <vgagl.h>
#include <vgakeyboard.h>
#define zero_sa_mask(maskptr) memset(maskptr, 0, sizeof(sigset_t))
static char sig2release[] =
{SIGHUP, SIGINT, SIGQUIT, SIGILL,
SIGTRAP, SIGIOT, SIGBUS, SIGFPE,
SIGSEGV, SIGPIPE, SIGALRM, SIGTERM,
SIGXCPU, SIGXFSZ, SIGVTALRM,
SIGPROF, SIGPWR};
static int newcolor(void)
{
if (BYTESPERPIXEL == 1)
return random() % 15 + 1;
return gl_rgbcolor(random() & 255, random() & 255, random() & 255);
}
static void timeout(int sig)
{
keyboard_close();
vga_setmode(TEXT);
puts("Automatic termination after 60 seconds.");
exit(1);
}
void shutdown(void)
{
puts("Shutdown called!");
}
int main(void)
{
struct sigaction siga;
int vgamode, color, leftpressed;
int x, y;
printf("\nWARNING: This program will set the keyboard to RAW mode.\n"
"The keyboard routines in svgalib have not been tested\n"
"very much. There may be no recovery if something goes\n"
"wrong.\n\n"
"Press ctrl-c now to bail out, enter to continue.\n"
"In the test itself, use 'q' or Escape to quit.\n"
"It will also terminate after 60 seconds.\n"
"Use any cursor keys to move, keypad 0 or enter to change color.\n\n"
"\aWARNING, this version of keytest explicitly removes all svgalib\n"
"automatic restore funcs, s.t. when you kill it from the outside\n"
"only vga_safety_fork() can rescue you. Use this svgalib test tool\n"
"with EXTREME! care.\n"
);
getchar();
vga_safety_fork(shutdown); /* Does already enter a videomode */
vga_init();
/* Never do this in your code! */
siga.sa_flags = 0;
zero_sa_mask(&(siga.sa_mask));
for (x = 0; x < sizeof(sig2release); x++) {
siga.sa_handler = SIG_DFL;
sigaction(sig2release[x], &siga, NULL);
}
vgamode = vga_getdefaultmode();
if ((vgamode == -1) || (vga_getmodeinfo(vgamode)->bytesperpixel != 1))
vgamode = G640x480x256;
if (!vga_hasmode(vgamode)) {
printf("Mode not available.\n");
exit(1);
}
vga_setmode(vgamode);
vga_setlinearaddressing();
gl_setcontextvga(vgamode);
gl_enableclipping();
signal(SIGALRM, timeout);
/* This installs the default handler, which is good enough for most */
/* purposes. */
if (keyboard_init()) {
printf("Could not initialize keyboard.\n");
exit(1);
}
/* Translate to 4 keypad cursor keys, and unify enter key. */
keyboard_translatekeys(TRANSLATE_CURSORKEYS | TRANSLATE_KEYPADENTER |
TRANSLATE_DIAGONAL);
/* (TRANSLATE_DIAGONAL seems to give problems.) Michael: No doesn't...
but might not do what you expect.. */
alarm(60); /* Terminate after 60 seconds for safety. */
x = WIDTH / 2;
y = HEIGHT / 2;
color = newcolor();
leftpressed = 0;
for (;;) {
/* Draw moving box. */
gl_fillbox(x, y, 5, 5, color);
/* Draw key status bar at top of screen. */
gl_putbox(0, 0, 128, 1, keyboard_getstate());
/* Wait about 1/100th of a second. */
/* Note that use of this function makes things less */
/* smooth because of timer latency. */
usleep(10000);
keyboard_update();
/* Move. */
if (keyboard_keypressed(SCANCODE_CURSORLEFT))
x--;
if (keyboard_keypressed(SCANCODE_CURSORRIGHT))
x++;
if (keyboard_keypressed(SCANCODE_CURSORUP))
y--;
if (keyboard_keypressed(SCANCODE_CURSORDOWN))
y++;
/* Boundary checks. */
if (x < 0)
x = 0;
if (x >= WIDTH)
x = WIDTH - 1;
if (y < 1)
y = 1;
if (y >= HEIGHT)
y = HEIGHT - 1;
/* Check for color change. */
if (keyboard_keypressed(SCANCODE_KEYPAD0) ||
keyboard_keypressed(SCANCODE_ENTER)) {
if (!leftpressed) {
color = newcolor();
leftpressed = 1;
}
} else
leftpressed = 0;
if (keyboard_keypressed(SCANCODE_Q) ||
keyboard_keypressed(SCANCODE_ESCAPE))
break;
}
keyboard_close(); /* Don't forget this! */
vga_setmode(TEXT);
exit(0);
}

422
demos/linearspeed.c Normal file
View file

@ -0,0 +1,422 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <vga.h>
#include <vgagl.h>
#include <sys/time.h>
#define LINEAR_ADDRESSING
int VGAMODE, USEGL;
GraphicsContext *physicalscreen;
GraphicsContext *backscreen;
int fast=0;
void screen1(void)
{
int x, y;
for (y = 0; y < HEIGHT; y++)
for (x = 0; x < WIDTH; x++)
/* limited RGB palette in 256-color modes */
/* some color information is not used in */
/* 15-bit color modes */
gl_setpixelrgb(x, y,
x * 256 / WIDTH,
255 - x * 256 / WIDTH,
y * 256 / HEIGHT);
}
void configure(void)
{
int allowed[GLASTMODE + 1];
for (;;) {
int i;
int m;
for (i = G320x200x16; i <= GLASTMODE; i++) {
allowed[i] = 0;
if (vga_hasmode(i)) {
printf("%2d %s\n", i, vga_getmodename(i));
allowed[i] = 1;
}
}
printf("\nWhich mode? ");
scanf("%d", &m);
getchar();
printf("\n");
if (m >= G320x200x16 && m <= GLASTMODE) {
VGAMODE = m;
if (vga_getmodeinfo(m)->bytesperpixel >= 1)
USEGL = 1;
else
USEGL = 0;
break;
}
}
vga_setmode(VGAMODE);
#ifdef LINEAR_ADDRESSING
vga_setlinearaddressing();
#endif
if (USEGL) {
gl_setcontextvga(VGAMODE);
physicalscreen = gl_allocatecontext();
gl_getcontext(physicalscreen);
}
}
void blit(void)
{
gl_clearscreen(0x86);
vga_imageblt(vga_getgraphmem(), 0, WIDTH - 128, HEIGHT - 128,
WIDTH * BYTESPERPIXEL);
/* vga_bitblt(0, 100 * WIDTH * BYTESPERPIXEL, 50, 50, WIDTH * BYTESPERPIXEL);
vga_fillblt(100 * BYTESPERPIXEL, 50, 50, WIDTH * BYTESPERPIXEL, 0x86);
*/
}
#if 0
/* May help on well-designed motherboards. */
/* IT DOES MAKE A DIFFERENCE! REP STOSL IS SLOWER */
/* (CL-GD5434 VLB zero-wait writes -- 2/3 cycles); rep stos takes 4 */
#if 1
static inline void *
__memset(void *s, char c, size_t count)
{
__asm__(
"cld\n\t"
"cmpl $12,%%edx\n\t"
"jl 1f\n\t" /* if (count >= 12) */
"movzbl %%al,%%ax\n\t"
"movl %%eax,%%ecx\n\t"
"shll $8,%%ecx\n\t" /* c |= c << 8 */
"orl %%ecx,%%eax\n\t"
"movl %%eax,%%ecx\n\t"
"shll $16,%%ecx\n\t" /* c |= c << 16 */
"orl %%ecx,%%eax\n\t"
"movl %%edx,%%ecx\n\t"
"negl %%ecx\n\t"
"andl $3,%%ecx\n\t" /* (-s % 4) */
"subl %%ecx,%%edx\n\t" /* count -= (-s % 4) */
"rep ; stosb\n\t" /* align to longword boundary */
"movl %%edx,%%ecx\n\t"
"shrl $2,%%ecx\n\t"
"cmpl $32,%%ecx\n\t" /* do loop unrolling for */
"jl 2f\n\t" /* chunks of 128 bytes */
"jmp 3f\n\t"
".align 4,0x90\n\t"
"3:\n\t"
"movl %%eax,(%%edi)\n\t"
"movl %%eax,4(%%edi)\n\t"
"movl %%eax,8(%%edi)\n\t"
"movl %%eax,12(%%edi)\n\t"
"movl %%eax,16(%%edi)\n\t"
"movl %%eax,20(%%edi)\n\t"
"movl %%eax,24(%%edi)\n\t"
"movl %%eax,28(%%edi)\n\t"
"movl %%eax,32(%%edi)\n\t"
"movl %%eax,36(%%edi)\n\t"
"movl %%eax,40(%%edi)\n\t"
"movl %%eax,44(%%edi)\n\t"
"movl %%eax,48(%%edi)\n\t"
"movl %%eax,52(%%edi)\n\t"
"movl %%eax,56(%%edi)\n\t"
"movl %%eax,60(%%edi)\n\t"
"movl %%eax,64(%%edi)\n\t"
"movl %%eax,68(%%edi)\n\t"
"movl %%eax,72(%%edi)\n\t"
"movl %%eax,76(%%edi)\n\t"
"movl %%eax,80(%%edi)\n\t"
"movl %%eax,84(%%edi)\n\t"
"movl %%eax,88(%%edi)\n\t"
"movl %%eax,92(%%edi)\n\t"
"movl %%eax,96(%%edi)\n\t"
"movl %%eax,100(%%edi)\n\t"
"movl %%eax,104(%%edi)\n\t"
"movl %%eax,108(%%edi)\n\t"
"subl $32,%%ecx\n\t"
"movl %%eax,112(%%edi)\n\t"
"movl %%eax,116(%%edi)\n\t"
"movl %%eax,120(%%edi)\n\t"
"movl %%eax,124(%%edi)\n\t"
"addl $128,%%edi\n\t"
"cmpl $32,%%ecx\n\t"
"jge 3b\n\t"
"2:\n\t"
"rep ; stosl\n\t" /* fill remaining longwords */
"andl $3,%%edx\n" /* fill last few bytes */
"1:\tmovl %%edx,%%ecx\n\t" /* <= 12 entry point */
"rep ; stosb\n\t"
: : "a"(c), "D"(s), "d"(count)
: "ax", "cx", "dx", "di");
return s;
}
#else /* 8-bit writes. */
static inline void *
__memset(void *s, char c, size_t count)
{
__asm__(
"cld\n\t"
"cmpl $12,%%edx\n\t"
"jl 1f\n\t" /* if (count >= 12) */
"movzbl %%al,%%ax\n\t"
"movl %%eax,%%ecx\n\t"
"shll $8,%%ecx\n\t" /* c |= c << 8 */
"orl %%ecx,%%eax\n\t"
"movl %%eax,%%ecx\n\t"
"shll $16,%%ecx\n\t" /* c |= c << 16 */
"orl %%ecx,%%eax\n\t"
"movl %%edx,%%ecx\n\t"
"negl %%ecx\n\t"
"andl $3,%%ecx\n\t" /* (-s % 4) */
"subl %%ecx,%%edx\n\t" /* count -= (-s % 4) */
"rep ; stosb\n\t" /* align to longword boundary */
"movl %%edx,%%ecx\n\t"
"shrl $2,%%ecx\n\t"
"cmpl $32,%%ecx\n\t" /* do loop unrolling for */
"jl 2f\n\t" /* chunks of 128 bytes */
"jmp 3f\n\t"
".align 4,0x90\n\t"
"3:\n\t"
"movb %%al,(%%edi)\n\t"
"movb %%al,1(%%edi)\n\t"
"movb %%al,2(%%edi)\n\t"
"movl %%al,3(%%edi)\n\t"
"movl %%al,4(%%edi)\n\t"
"movl %%al,5(%%edi)\n\t"
"movl %%al,6(%%edi)\n\t"
"movl %%al,7(%%edi)\n\t"
"movl %%al,8(%%edi)\n\t"
"movl %%al,9(%%edi)\n\t"
"movl %%al,10(%%edi)\n\t"
"movl %%al,11(%%edi)\n\t"
"movl %%al,12(%%edi)\n\t"
"movl %%al,13(%%edi)\n\t"
"movl %%al,14(%%edi)\n\t"
"movl %%al,15(%%edi)\n\t"
"movl %%al,16(%%edi)\n\t"
"movl %%al,17(%%edi)\n\t"
"movl %%al,18(%%edi)\n\t"
"movl %%al,19(%%edi)\n\t"
"movl %%al,20(%%edi)\n\t"
"movl %%al,21(%%edi)\n\t"
"movl %%al,22(%%edi)\n\t"
"movl %%al,23(%%edi)\n\t"
"movl %%al,24(%%edi)\n\t"
"movl %%al,25(%%edi)\n\t"
"movl %%al,26(%%edi)\n\t"
"movl %%al,27(%%edi)\n\t"
"movl %%al,28(%%edi)\n\t"
"subl $8,%%ecx\n\t"
"movl %%al,29(%%edi)\n\t"
"movl %%al,30(%%edi)\n\t"
"movl %%al,31(%%edi)\n\t"
"addl $32,%%edi\n\t"
"cmpl $8,%%ecx\n\t"
"jge 3b\n\t"
"2:\n\t"
"rep ; stosl\n\t" /* fill remaining longwords */
"andl $3,%%edx\n" /* fill last few bytes */
"1:\tmovl %%edx,%%ecx\n\t" /* <= 12 entry point */
"rep ; stosb\n\t"
: : "a"(c), "D"(s), "d"(count)
: "ax", "cx", "dx", "di");
return s;
}
#endif
#define memset __memset
#endif
void speed(void)
{
int i;
int start_clock;
int finish_clock;
int diff_clock;
unsigned char *vgabase = vga_getgraphmem()+128*1024;
char *base;
struct timeval tv1, tv2;
#ifndef LINEAR_ADDRESSING
if (VGAMODE >= G640x480x256)
vga_setpage(0);
#endif
base=malloc(655360);
gettimeofday(&tv1, NULL);
for (i = 0; i < 500; i++) {
memset(vgabase, i & 255, 1048576);
}
gettimeofday(&tv2, NULL);
diff_clock = (tv2.tv_sec-tv1.tv_sec)*1000000+(tv2.tv_usec-tv1.tv_usec);
printf("memset video memory timing: %3d.%1ds, %dM/s\n", diff_clock / 1000000,
(diff_clock % 1000000), 500000000 / diff_clock);
if(fast)return;
start_clock = clock();
for (i = 0; i < 500; i++) {
memcpy(vgabase, base, 655360);
}
finish_clock = clock();
diff_clock = (finish_clock - start_clock)*10/CLOCKS_PER_SEC;
printf("memcpy to video memory timing: %3d.%1ds, %dK/s\n", diff_clock / 10,
(diff_clock % 10), 64*5000*10 / diff_clock);
start_clock = clock();
for (i = 0; i < 500; i++) {
memcpy(base, vgabase, 655360);
}
finish_clock = clock();
diff_clock = (finish_clock - start_clock)*10/CLOCKS_PER_SEC;
printf("memcpy from video memory timing: %3d.%1ds, %dK/s\n", diff_clock / 10,
(diff_clock % 10), 64*5000*10 / diff_clock);
start_clock = clock();
for (i = 0; i < 500; i++) {
unsigned char *j;
unsigned char *k;
unsigned char *l;
l=vgabase;
k=base;
j=base;
j+=655360;
while(k<j)*(l++)=*(k++);
}
finish_clock = clock();
diff_clock = (finish_clock - start_clock)*10/CLOCKS_PER_SEC;
printf("byte copy to video memory timing: %3d.%1ds, %dK/s\n", diff_clock / 10,
(diff_clock % 10), 64*5000*10 / diff_clock);
}
void sysmem_speed(void)
{
int i;
int start_clock;
int finish_clock;
int diff_clock;
char *base, *base2;
base=malloc(655360);
base2=malloc(655360);
start_clock = clock();
for (i = 0; i < 500; i++) {
memset(base, i & 255, 655360);
}
finish_clock = clock();
diff_clock = (finish_clock - start_clock)*10/CLOCKS_PER_SEC;
printf("System memory timing: %3d.%1ds, %dK/s\n", diff_clock / 10,
(diff_clock % 10), 64*5000*10 / diff_clock);
start_clock = clock();
for (i = 0; i < 500; i++) {
memcpy(base, base2, 655360);
}
finish_clock = clock();
diff_clock = (finish_clock - start_clock)*10/CLOCKS_PER_SEC;
printf("To System memcpy timing: %3d.%1ds, %dK/s\n", diff_clock / 10,
(diff_clock % 10), 64*5000*10 / diff_clock);
start_clock = clock();
for (i = 0; i < 500; i++) {
unsigned char *j;
unsigned char *k;
unsigned char *l;
l=base2;
k=base;
j=base;
j+=655360;
while(k<j)*(l++)=*(k++);
}
finish_clock = clock();
diff_clock = (finish_clock - start_clock)*10/CLOCKS_PER_SEC;
printf("To System mem copy timing: %3d.%1ds, %dK/s\n", diff_clock / 10,
(diff_clock % 10), 64*5000*10 / diff_clock);
}
int main(int argc, char *argv[])
{
if(argc>1)fast=1;
vga_init();
printf("This is a video memory speed tester. Note that the first "
"screen doesn't test\nanything (nor does the 3 second pause "
"that follows).\n\n");
configure();
if (COLORS == 256)
gl_setrgbpalette(); /* set RGB palette */
if (USEGL)
screen1();
sleep(2);
/* vga_screenoff(); */
speed();
if(!fast)sysmem_speed();
vga_setmode(TEXT);
exit(0);
}

132
demos/lineart.c Normal file
View file

@ -0,0 +1,132 @@
/* A program to test any mode for linear. Default mode is G640x480x256 = 10
** or parameters may be used giving modes as integers.
** linp [mode mode ...]
** Don Secrest Oct. 1998
*/
#include <vga.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
static void screen(int mode)
{
int bpp,bott,endp,linlen,i,j,bii,col,p;
vga_modeinfo *minf;
unsigned char *vbuf;
int mem;
if(mode == 0)
{
printf("Usage:lineart [mode mode ...]\n\nwhere mode is an integer.\n");
return;
}
if(! vga_hasmode(mode)) {
printf("Invalid mode %d\n",mode);
return;
}
vga_setmode(mode);
minf = vga_getmodeinfo(mode);
if(! (minf->flags & CAPABLE_LINEAR)){
vga_setmode(TEXT);
printf("The mode %d is not capable of linear\n",mode);
return;
}
vga_setpage(0);
if(vga_setlinearaddressing() == -1) {
vga_setmode(TEXT);
printf("Could not set linear addressing for mode %d\n",mode);
return;
}
bpp = minf->bytesperpixel;
linlen = minf->width*bpp;
bott = linlen*17; /* pointer 17 pixels wide. */
endp = linlen*minf->height;
mem = minf->linewidth*minf->height;
/* Do random pixels */
vbuf = vga_getgraphmem();
printf("Memory mapped to %08x. Mode = %d.\n",(int) vbuf,mode);
memset(vbuf,0,mem); /* Clear out 2 megabytes of memory, */
for(i = 0;i < 100000;i++)
{
p = rand() % mem-2;
*(vbuf + p) = rand() & 0xff;
if(bpp > 1)
*(vbuf + p + 1) = rand() & 0xff;
if(bpp == 3)
*(vbuf + p + 2) = rand() & 0xff;
}
/* Place marker at top left and bottem right. */
for(i = 0;i < 44;i += bpp) {
*(vbuf + i) = 0x60;
*(vbuf + bott + i) = 0x60;
*(vbuf + endp - i) = 0x60;
bii = endp -1 -bott;
*(vbuf + bii -i) = 0x60;
if(bpp > 1) {
*(vbuf + i + 1) = 0x60;
*(vbuf + i + 1 + bott) = 0x60;
*(vbuf - i - 1 + endp) = 0x60;
*(vbuf - i - 1 + bii) = 0x60;
}
if(bpp == 3) {
*(vbuf + i + 2) = 0x60;
*(vbuf + i + 2 + bott) = 0x60;
*(vbuf - i - 2 + endp) = 0x60;
*(vbuf - i - 2 + bii) = 0x60;
}
col = (i == 0 || i >= 42)? 0x60:0;
for(j = 1;j < 17;j++) {
*(vbuf + i + linlen*j) = col;
*(vbuf - i + endp -1 - linlen*j) = col;
if(bpp > 1) {
*(vbuf + i + 1 + linlen*j) = col;
*(vbuf - i - 2 + endp - linlen*j) = col;
}
if(bpp == 3) {
*(vbuf + i + 2 + linlen*j) = col;
*(vbuf - i - 3 + endp - linlen*j) = col;
}
}
}
for(i = 5;i < 12;i += bpp)
for(j = 4;j < 12;j++) {
*(vbuf + i + linlen*j) = 0x3f;
*(vbuf + endp - i - bpp - linlen*j) = 0x3f;
}
getchar(); /* Wait for a key punch */
}
int
main(int argc,char *argv[])
{
int mode,c;
vga_init();
c=1;
if(argc == 1)
screen(10); /* G640x480x256 */
else
c = 0;
while(argc > 1)
{
argc--;
c++;
if(isdigit(*argv[c]))
mode = atoi(argv[c]);
else if(*argv[c] == 'G')
mode = vga_getmodenumber(argv[c]);
else
{
printf("Unknown mode %s\n",argv[c]);
continue;
}
screen(mode);
}
vga_setmode(TEXT);
return 0;
}

1
demos/linuxlogo.bitmap Normal file

File diff suppressed because one or more lines are too long

91
demos/memset.c Normal file
View file

@ -0,0 +1,91 @@
/* Set a block of memory to some byte value.
For Intel 80x86, x>=3.
Copyright (C) 1991, 1992, 1993, 1997, 1998 Free Software Foundation, Inc.
Contributed by Torbjorn Granlund (tege@sics.se).
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <string.h>
#ifdef __i386__
#if defined(__GNUC__)
#undef memset
#define op_t unsigned int
#define OPSIZ 4
void *
memset (void *dstpp, int c, size_t len)
{
int d0;
unsigned long int dstp = (unsigned long int) dstpp;
/* This explicit register allocation
improves code very much indeed. */
register op_t x asm("ax");
x = (unsigned char) c;
/* Clear the direction flag, so filling will move forward. */
asm volatile("cld");
/* This threshold value is optimal. */
if (len >= 12)
{
/* Fill X with four copies of the char we want to fill with. */
x |= (x << 8);
x |= (x << 16);
/* Adjust LEN for the bytes handled in the first loop. */
len -= (-dstp) % OPSIZ;
/* There are at least some bytes to set.
No need to test for LEN == 0 in this alignment loop. */
/* Fill bytes until DSTP is aligned on a longword boundary. */
asm volatile("rep\n"
"stosb" /* %0, %2, %3 */ :
"=D" (dstp), "=c" (d0) :
"0" (dstp), "1" ((-dstp) % OPSIZ), "a" (x) :
"memory");
/* Fill longwords. */
asm volatile("rep\n"
"stosl" /* %0, %2, %3 */ :
"=D" (dstp), "=c" (d0) :
"0" (dstp), "1" (len / OPSIZ), "a" (x) :
"memory");
len %= OPSIZ;
}
/* Write the last few bytes. */
asm volatile("rep\n"
"stosb" /* %0, %2, %3 */ :
"=D" (dstp), "=c" (d0) :
"0" (dstp), "1" (len), "a" (x) :
"memory");
return dstpp;
}
#else /* __GNUC__ */
#include <sysdeps/generic/memset.c>
#endif
#endif /* __i386__ */

291
demos/mjoytest.c Normal file
View file

@ -0,0 +1,291 @@
/* Program to test the svgalib joystick functions. */
/* Written by M. Weller <eowmob@exp-math.uni-essen.de> */
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <vga.h>
#include <vgagl.h>
#include <vgamouse.h>
#include <vgajoystick.h>
#include <vgakeyboard.h>
extern char *optarg;
extern int optind, opterr, optopt;
#define PENCILSIZE 5
struct {
int wx; /* xoffset to add to scaled joystick position to get cx */
int cx, cy; /* onscreen coords of pencil */
int jx, jy; /* current joystick status */
int tx; /* onscreen xcoord of text for joypos */
char bitmap[PENCILSIZE * PENCILSIZE * 4]; /* big enough in any screen mode */
int ox, oy; /* location of saved patch, ox < 0 for no data saved */
int color; /* drawing color */
int drawing; /* we are drawing (actually shadows button 1 state) */
int newpos; /* cx/cy changed, draw new pencil position */
} joypanel[2];
int wy, sx, sy, ty; /* wy, ty y coords of wx, tx. sx/sy are scale values:
* (jx * sx + 128) / 256 is pencil coords (add wx for screen
* coords). Same for y. */
int newcolor(void)
{
if (BYTESPERPIXEL == 1)
return random() % 15 + 1;
return gl_rgbcolor(random() & 255, random() & 255, random() & 255);
}
void draw_pencil(int i) {
char msg[100];
if (!joypanel[i].newpos)
return;
sprintf(msg, "x = %4d, y = %4d", joypanel[i].jx, joypanel[i].jy);
gl_write(joypanel[i].tx, ty, msg);
if (joypanel[i].ox >= 0)
gl_putbox(joypanel[i].ox, joypanel[i].oy, PENCILSIZE, PENCILSIZE, joypanel[i].bitmap);
/* If not drawing, save destination area */
if (!joypanel[i].drawing)
gl_getbox(joypanel[i].ox = joypanel[i].cx, joypanel[i].oy = joypanel[i].cy,
PENCILSIZE, PENCILSIZE, joypanel[i].bitmap);
else
joypanel[i].ox = -1;
gl_fillbox(joypanel[i].cx, joypanel[i].cy, PENCILSIZE, PENCILSIZE, joypanel[i].color);
joypanel[i].newpos = 0;
}
void init_screen(void) {
int white;
gl_clearscreen(0);
white = vga_white();
gl_line(0, 0, WIDTH - 2, 0, white);
gl_line(0, 0, 0, HEIGHT - 1, white);
gl_line(WIDTH/2, 0, WIDTH/2, HEIGHT - 1, white);
gl_line(WIDTH - 2, 0, WIDTH - 2 , HEIGHT - 1, white);
gl_line(0, 11, WIDTH - 2, 11, white);
gl_line(0, HEIGHT - 1, WIDTH - 2, HEIGHT - 1, white);
ty = 2;
sx = WIDTH / 2 - 3 - PENCILSIZE;
sy = HEIGHT - 6 - PENCILSIZE - 9;
wy = 2 + 8 + 3 + (((sy << 7) + 128) >> 8);
joypanel[0].color = white;
joypanel[0].drawing = 0;
joypanel[0].newpos = 1;
joypanel[0].ox = -1;
joypanel[0].tx = 2;
joypanel[0].jx = 0;
joypanel[0].jy = 0;
joypanel[0].wx = 2 + (((sx << 7) + 128) >> 8);
joypanel[0].cx = joypanel[0].wx;
joypanel[0].cy = wy;
draw_pencil(0);
joypanel[1].color = white;
joypanel[1].drawing = 0;
joypanel[1].newpos = 1;
joypanel[1].ox = -1;
joypanel[1].tx = WIDTH / 2 + 2;
joypanel[1].jx = 0;
joypanel[1].jy = 0;
joypanel[1].wx = joypanel[0].wx + joypanel[1].tx;
joypanel[1].cx = joypanel[0].cx + joypanel[1].tx;
joypanel[1].cy = wy;
draw_pencil(1);
}
void myhandler(int event, int number, char value, int joydev) {
#if 0
printf("%d: %d %d %d\n", joydev, event, number, (int)value);
#endif
switch(event) {
case JOY_EVENTBUTTONUP:
if (!number)
joypanel[joydev].drawing = 0;
else {
joypanel[joydev].color = newcolor();
joypanel[joydev].newpos = 1;
}
break;
case JOY_EVENTBUTTONDOWN:
if (!number)
joypanel[joydev].drawing = 1;
break;
case JOY_EVENTAXIS:
switch(number) {
case 0: /* x */
joypanel[joydev].jx = value;
joypanel[joydev].cx = joypanel[joydev].wx + ((((int)value) * sx + 128) / 256);
joypanel[joydev].newpos = 1;
break;
case 1:
joypanel[joydev].jy = value;
joypanel[joydev].cy = wy + ((((int)value) * sy + 128) / 256);
joypanel[joydev].newpos = 1;
break;
}
}
/* Note that any reserved events are ignored */
}
void usage(void) {
puts("Usage: mjoytest [-j <joystick number>] [svgalib mode]\n"
"\ttest multiple joystick support and joystick sharing.");
exit(1);
}
void mycalout(const char *msg) {
gl_printf(-1, -1, msg);
}
int main(int argc, char *argv[]) {
int vgamode = -1;
int which, joymask = 3;
struct timeval timeout;
while(EOF != (which = getopt(argc, argv, "j:m:"))) {
switch(which) {
case 'j':
if (!strcmp(optarg, "0"))
joymask = 1;
else if (!strcmp(optarg, "1"))
joymask = 1;
else
usage();
break;
case 'm':
vgamode = vga_getmodenumber(optarg);
if (vgamode < 0)
usage();
break;
default:
usage();
}
}
if (optind < argc) {
if (optind != 1 + argc)
usage();
if (vgamode >= 0)
usage();
vgamode = vga_getmodenumber(argv[optind]);
if (vgamode < 0)
usage();
}
vga_init();
if (vgamode < 0)
vgamode = vga_getdefaultmode();
if (vgamode < 0)
vgamode = G320x200x256;
if (!vga_hasmode(vgamode)) {
printf("Mode not available.\n");
exit(-1);
}
puts("In the demo, press\n"
"<1> to calibrate joystick 1.\n"
"<2> to calibrate joystick 2.\n"
"<c> to clear the screen (<1> & <2> do this too).\n"
"<q> to exit (<Ctrl>-C should work too.\n"
"Joystick button 1 enables drawing while pressed.\n"
"Joystick button 2 selects next color.\n"
"\nNow hit <Return> to start the demo.");
getchar();
fflush(stdin);
for (which = 0; which < 2; which++) {
if (!(joymask & (1 << which)))
continue;
errno = 0;
if (joystick_init(which, JOY_CALIB_STDOUT) < 0) {
if (errno)
printf("Unable to initialize joystick %d: %s.\n", which, strerror(errno));
else
printf("Unable to initialize joystick %d.\n", which);
}
}
joystick_sethandler(-1, myhandler);
vga_setmode(vgamode);
gl_setcontextvga(vgamode);
gl_setwritemode(FONT_COMPRESSED | WRITEMODE_OVERWRITE);
gl_setfontcolors(0, vga_white());
gl_setfont(8, 8, gl_font8x8);
init_screen();
for(;;) {
timeout.tv_sec = 0;
timeout.tv_usec = 10000;
which = vga_waitevent(VGA_KEYEVENT, NULL, NULL, NULL, &timeout);
if (which & VGA_KEYEVENT) {
switch(vga_getch()) {
case '1':
gl_printf(2, 2, "");
if (1 & joymask) {
vga_lockvc();
joystick_init(0, mycalout);
/* IMPORTANT, reenable ownhandler! */
joystick_sethandler(0, myhandler);
vga_unlockvc();
}
init_screen();
break;
case '2':
gl_printf(2, 2, "");
if (2 & joymask) {
vga_lockvc();
joystick_init(1, mycalout);
/* IMPORTANT, reenable ownhandler! */
joystick_sethandler(1, myhandler);
vga_unlockvc();
}
init_screen();
break;
case 'c':
case 'C':
init_screen();
break;
case 'q':
case 'Q':
goto leave_loop;
default:
putchar('\a');
fflush(stdout);
break;
}
}
which = joystick_update();
if (which & 1);
draw_pencil(0); /* It makes only sense to check for the newpos flag
* if something happened with the joystick at all */
if (which & 2);
draw_pencil(1);
}
leave_loop:
printf("Shutting down.\n");
vga_setmode(TEXT);
exit(0);
}

223
demos/mkcur.c Normal file
View file

@ -0,0 +1,223 @@
/* Make cursor mkcur.c A program to build a cursor. Started Jan 27, 2001 */
/* Don Secrest */
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <vga.h>
#include <vgagl.h>
#include <vgamouse.h>
#include "arrow.h"
unsigned char *fnt=0;
static int software = 0,psiz;
static unsigned int sprt[64] = {0};
void usage(void)
{
puts("Usage:\n"
"buildcsr -p<sprite> -b<sprite> -m<mode> -s\n"
"\tDraw sprite by holding down the left mouse button.\n"
"\tDraw color 2 type 2 and use left button.\n"
"\tRight mouse button to erase pixels.\n"
"\t-p print out the sprite as a header file to be compiled\n"
"\t-b print out the sprite as a binary file to be read by a program\n"
"\t-m to use any mode. Default is vga_default mode or G640x480x256.\n"
"\t-s to use software cursor. Default is to use hardware cursor if it\n"
"\t exits."
);
exit(2);
};
void setcursor(int *arrow,int cursor, int color0, int color1)
{
static int init = 1;
if(init)
{
init = 0;
if(cursor != 0)
vga_setcursorimage(cursor,0,color0,color1,(void *)arrow);
else
{
vga_setmousesupport(1);
vga_initcursor(software);
}
}
vga_setcursorimage(cursor,0,color0,color1,(void *) arrow);
/* if(vga_selectcursor(0) == -1)
{
vga_setmode(TEXT);
printf("Cursor select failure.\n");
exit(1);
} */
vga_selectcursor(cursor);
mouse_setposition(0,0);
mouse_setxrange(-5,psiz - 1);
mouse_setyrange(0,psiz - 1);
return;
};
int main(int argc,char **argv)
{
int vgamode,opt,vmode=0,color1,color2,xmax,ymax,i,j,px,dx,colnum;
int colors;
char *nameb=0,*namep=0;
FILE *binfile=0,*progfile=0;
while(EOF !=(opt = getopt(argc,argv,"p:b:m:s")))
switch(opt){
case 'p':
namep = optarg;
break;
case 'b':
nameb = optarg;
break;
case 'm':
vmode = atoi(optarg);
break;
case 's':
software = 1;
break;
case ':':
printf("Missingh argument.\n");
usage();
case '?':
printf("Unknown argument, %c\n",optopt);
usage();
}
vga_init();
if(vmode)
vgamode = vmode;
else
vgamode = vga_getdefaultmode();
if(vgamode == -1)
vgamode = G640x480x256;
if(!vga_hasmode(vgamode)){
printf("Mode %d not available\n",vgamode);
exit(1);
}
vga_setmode(vgamode);
gl_setcontextvga(vgamode);
gl_enableclipping();
fnt = gl_font8x8;
gl_setfont(8,8,fnt);
gl_setwritemode(FONT_COMPRESSED + WRITEMODE_OVERWRITE);
gl_setfontcolors(0,vga_white());
colors = color1 = gl_rgbcolor(0,200,0);
color2 = gl_rgbcolor(100,0,100);
xmax = vga_getxdim();
ymax = vga_getydim();
colnum = vga_getcolors();
if(colnum == 256)
vga_setcolor(vga_white());
else
vga_setrgbcolor(255,255,255);
psiz = (xmax < ymax)?xmax:ymax;
i = (psiz -8)/32;
psiz = i*32 - 1;
j = (i*5)/6;
px = j;
dx = i;
setcursor(arrow,0,0xff0000,0x0000ff);
vga_drawline(0,0,psiz+1,0);
vga_drawline(psiz+1,0,psiz+1,psiz);
vga_drawline(psiz+1,psiz,0,psiz);
vga_drawline(0,psiz,0,0);
gl_printf(1,psiz+1,"Type n: new sprite, o: old, q: quit");
gl_fillbox(290,psiz+1,px,px,colors);
do
{
int evt,mx,my,button,key;
evt = vga_waitevent(VGA_MOUSEEVENT | VGA_KEYEVENT,NULL,NULL,NULL,NULL);
if(evt & VGA_KEYEVENT)
{
key = vga_getkey();
if(key == 'q' || key == 'Q')
break;
if(key == 'n')
{
setcursor(sprt,1,0xff0000,0x0000ff);
}
if(key == 'o')
{
setcursor(arrow,0,0xff0000,0x0000ff);
}
if(key == '2')
{
colors = color2;
gl_fillbox(290,psiz+1,px,px,colors);
}
if(key == '1')
{
colors = color1;
gl_fillbox(290,psiz+1,px,px,colors);
}
}
if(evt & VGA_MOUSEEVENT)
{
int x,y,add;
unsigned int loc;
button = 0;
mouse_update();
mx = mouse_getx();
my = mouse_gety();
button = mouse_getbutton();
vga_setcursorposition(mx,my);
vga_showcursor(1);
if(button)
{
vga_showcursor(2);
x = 1 + (mx/dx)*dx;
y = 1 + (my/dx)*dx;
gl_fillbox(x,y,px,px,colors);
add = y/dx +32;
loc = 1 << (31 - x/dx);
if(button & 4)
{
sprt[add] = sprt[add] | loc;
if(colors == color2)
sprt[add - 32] = sprt[add - 32] | loc;
}
else if(button & 1)
{
vga_showcursor(2);
x = 1 + (mx/dx)*dx;
y = 1 + (my/dx)*dx;
gl_fillbox(x,y,px,px,0);
sprt[add] = sprt[add] & (~loc); /* erase it. */
sprt[add - 32] = sprt[add - 32] & (~loc);
}
}
}
}while(1);
vga_setmode(TEXT);
if(namep)
{
if((progfile = fopen(namep,"w")))
{
fprintf(progfile,"unsigned int %s[64] = {\n",namep);
for(i = 0;i < 63;i++)
{
fprintf(progfile,"0x%08x, ",sprt[i]);
if((i+1)%4 == 0)
fprintf(progfile,"\n");
}
fprintf(progfile,"0x%08x};\n",sprt[63]);
}
else
printf("Unable to open file %s.\n",namep);
}
if(nameb)
{
if((binfile = fopen(nameb,"w")))
fwrite(sprt,4,64,binfile);
else
printf("Unable to open file %s.\n",nameb);
}
printf("psiz = %d, px = %d, dx = %d\n",psiz,px,dx);
return(0);
}

140
demos/mousetest.c Normal file
View file

@ -0,0 +1,140 @@
/* Program to test the svgalib mouse functions. */
/* Updated to use middle button and rx axis (for wheel mice)
by Brion Vibber <brion@pobox.com>, 5 July 1998 */
#include <stdlib.h>
#include <stdio.h>
#include <vga.h>
#include <vgagl.h>
#include <vgamouse.h>
#include <vgakeyboard.h>
/* Manually open and close mouse? */
#define MANUALLY_SETUP_MOUSE_NOT
static int newcolor(void)
{
if (BYTESPERPIXEL == 1)
return random() % 15 + 1;
return gl_rgbcolor(random() & 255, random() & 255, random() & 255);
}
int main(void)
{
int vgamode, color, leftpressed, middlepressed;
int x, y, rx, ox, oy, boxsize, button, wheel;
struct MouseCaps caps;
vga_init();
vgamode = vga_getdefaultmode();
if (vgamode == -1)
vgamode = G320x200x256;
if (!vga_hasmode(vgamode)) {
printf("Mode not available.\n");
exit(-1);
}
#ifndef MANUALLY_SETUP_MOUSE
/* Enable automatic mouse setup at mode set. */
vga_setmousesupport(1);
#endif
vga_setmode(vgamode);
/* Disable wrapping (default). */
/* mouse_setwrap(MOUSE_NOWRAP); */
gl_setcontextvga(vgamode);
gl_enableclipping();
#ifdef MANUALLY_SETUP_MOUSE
mouse_init("/dev/mouse", MOUSE_MICROSOFT, MOUSE_DEFAULTSAMPLERATE);
mouse_setxrange(0, WIDTH - 1);
mouse_setyrange(0, HEIGHT - 1);
mouse_setwrap(MOUSE_NOWRAP);
#endif
/* Check the mouse capabilities */
if(mouse_getcaps(&caps)) {
/* Failed! Old library version... Check the mouse type. */
switch(vga_getmousetype() & MOUSE_TYPE_MASK) {
case MOUSE_INTELLIMOUSE:
case MOUSE_IMPS2:
wheel = 1;
break;
default:
wheel = 0;
}
} else {
/* If this is a wheel mouse, interpret rx as a wheel */
wheel = ((caps.info & MOUSE_INFO_WHEEL) != 0);
}
/* To be able to test fake mouse events... */
if (keyboard_init()) {
printf("Could not initialize keyboard.\n");
exit(1);
}
/* Set the range for the wheel */
if(wheel)
mouse_setrange_6d(0,0, 0,0, 0, 0, -180,180, 0,0, 0,0, MOUSE_RXDIM);
color = newcolor();
leftpressed = middlepressed = x = y = rx = ox = oy = 0;
boxsize = 5;
for (;;) {
keyboard_update();
gl_fillbox(x, y, boxsize, boxsize, color);
mouse_update();
/* The RX axis represents the wheel on an wheel mouse */
mouse_getposition_6d(&x, &y, NULL, &rx, NULL, NULL);
if(wheel && rx) {
/* For clarity - wipe the old location out
so we can redraw with the new box size */
gl_fillbox(ox, oy, boxsize, boxsize, 0);
/* Interpret wheel turns; we care only about direction,
not amount, for our purposes */
boxsize += (rx / abs(rx));
(boxsize < 1)?(boxsize = 1):((boxsize > 10)?(boxsize = 10):0);
/* Zero the wheel position */
mouse_setposition_6d(0,0,0, 0,0,0, MOUSE_RXDIM);
}
ox = x; oy = y;
button = mouse_getbutton();
if (button & MOUSE_LEFTBUTTON) {
if (!leftpressed) {
color = newcolor();
leftpressed = 1;
}
} else
leftpressed = 0;
if (button & MOUSE_MIDDLEBUTTON) {
if (!middlepressed) {
/* Move the cursor to a random location */
mouse_setposition_6d(random() % WIDTH, random() % HEIGHT,0,
0,0,0,
MOUSE_2DIM);
middlepressed = 1;
}
} else
middlepressed = 0;
if (button & MOUSE_RIGHTBUTTON)
break;
}
#ifdef MANUALLY_SETUP_MOUSE
mouse_close();
#endif
vga_setmode(TEXT);
exit(0);
}

72
demos/printftest.c Normal file
View file

@ -0,0 +1,72 @@
/* Program to test the svgalib keyboard functions. */
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <vga.h>
#include <vgagl.h>
#include <vgakeyboard.h>
void usage(void)
{
puts("Usage: printftest <x> <y>\n"
"\tread text from keyboard and display it on screen\n"
"\tat position (x, y).\n"
"\t<ctrl>-D for quit\n"
"\t<ctrl>-R for carriage return\n"
"\t<Return> for line feed\n"
"\t<Tab> for tab\n"
"\t<ctrl>-G for bell\n"
"\t<ctrl>-H for backspace (non overwriting)\n"
);
exit(2);
}
int main(int argc, char **argv)
{
int x, y;
char buffer[2];
int vgamode;
int key, retval = 0;
if (argc != 3)
usage();
if (1 != sscanf(argv[1], "%d%c", &x, buffer))
usage();
if (1 != sscanf(argv[2], "%d%c", &y, buffer))
usage();
vga_init();
vgamode = vga_getdefaultmode();
if (vgamode == -1)
vgamode = G320x200x256;
if (!vga_hasmode(vgamode)) {
printf("Mode not available.\n");
exit(1);
}
vga_setmode(vgamode);
gl_setcontextvga(vgamode);
gl_enableclipping();
gl_setfont(8, 8, gl_font8x8);
gl_setwritemode(FONT_COMPRESSED + WRITEMODE_OVERWRITE);
gl_setfontcolors(0, vga_white());
buffer[1] = 0;
for(;;) {
key = vga_getch();
if (key == 4)
break;
if (key == 18)
key = '\r';
buffer[0] = key;
gl_printf(x, y, "%s", buffer);
x = y = -1;
}
vga_setmode(TEXT);
exit(retval);
}

83
demos/rwpage.pp Normal file
View file

@ -0,0 +1,83 @@
PROGRAM ScrollTest;
Uses svgalib;
type
VideoMemType = array[0..65535] of byte;
var
i,mode,StartupMode : longint;
SeparateReadWriteWindows : boolean;
modeinfo : ^vga_modeinfo;
VideoMem : ^VideoMemType;
p : pointer;
Procedure DrawRectangle(x1,y1,x2,y2 : integer);
begin
vga_drawline(x1,y1,x2,y1);
vga_drawline(x1,y2,x2,y2);
vga_drawline(x1,y1,x1,y2);
vga_drawline(x2,y1,x2,y2);
end; {DrawRectangle}
Procedure Scroll;
{ copies first bank of screen to the last bank (for 1024x768x256 mode) }
var i : word;
begin
vga_setreadpage(0);
vga_setwritepage(11);
for i := 65535 downto 0 do VideoMem^[i] := VideoMem^[i];
end; {Scroll}
(*
Procedure Scroll; Assembler;
{ copies first bank of screen to the last bank (for 1024x768x256 mode) }
var popreturn : longint;
asm
mov esi,SegA000
mov edi,esi
mov eax,0
push eax
call vga_setreadpage {set read bank}
pop popreturn {tidy stack}
mov eax,11
push eax
call vga_setwritepage {set write bank}
pop popreturn {tidy stack}
mov ecx,16384
rep movsd {copy all of bank 0 to bank 11}
end; {Scroll}
*)
begin
mode := 12; {1024x768x256}
i := vga_init;
StartupMode := vga_getcurrentmode;
vga_setmode(mode);
gl_setcontextvga(mode);
p := vga_getgraphmem;
VideoMem := p;
modeinfo := vga_getmodeinfo(mode);
SeparateReadWriteWindows := (modeinfo^.flags and HAVE_RWPAGE <> 0);
if SeparateReadWriteWindows <> False then begin
vga_setcolor(14);
gl_fillbox(100,0,823,63,13);
DrawRectangle(100,0,923,63);
vga_setcolor(3);
vga_drawline(0,0,1023,767);
vga_drawline(1023,0,0,767);
for i := 0 to 5000000 do vga_drawpixel(10,10); {delay}
Scroll; {copy first 64 lines down to last 64 lines of screen}
for i := 0 to 5000000 do vga_drawpixel(10,10); {delay}
end;
vga_setmode(StartupMode);
writeln('SeparateReadWriteWindows = ',SeparateReadWriteWindows);
writeln('vgamode = ',mode);
end.

308
demos/scrolltest.c Normal file
View file

@ -0,0 +1,308 @@
/*
Animation/smooth scrolling demo, uses Mode X/page flipping and
linear virtual screen in system memory.
First method copies window to page-flipped Mode X-style video memory
for scrolling.
Linear addressing, and page flipping (no shearing) and triple
buffering, but relatively slow.
Second method uses Mode X-style hardware scrolling.
Limited logical screen size, page flipping if no scrolling, tricky and
slow animation, scrolling fast (page flipping with scrolling is very
tricky).
Third method copies window to linear "Mode 13h" video memory.
Linear addressing, no page flipping (scrolling looks bad), speed
depends on bus (fast on a good ISA card; very fast on VLB).
Some SVGA cards can support page-flipping in linear 320x200x256.
Adding animated objects is trivial with the virtual screen methods (1
and 3).
*/
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <vga.h>
#include <vgagl.h>
/* Virtual screen size. */
/* Limited to 256K by hardware scrolling method (automatically clipped). */
/* Width must be multiple of 8. */
#define VWIDTH 640
#define VHEIGHT 400
/* Scrolling window size for system memory virtual screen demo. */
#define WINWIDTH 320
#define WINHEIGHT 200
/* Define this to use triple-buffering in first method. */
#define TRIPLEBUFFERING
unsigned char *vbuf;
void boxes(void)
{
int x, y;
for (x = 0; x <= VWIDTH - 8; x += 8)
for (y = 0; y <= VHEIGHT - 8; y += 8) {
int r, g, b;
/* Draw red tiles. */
r = rand() & 255;
b = 0;
g = 0;
if ((rand() & 15) == 15) { /* Add occasional */
r = 0; /* blue specks. */
b = rand() & 127;
}
gl_fillbox(x, y, 7, 7, gl_rgbcolor(r, g, b));
}
}
void demo1(void)
{
int x, y;
int targetx, targety;
int pageoffset[3] =
{
0,
320 * 240 / 4,
2 * 320 * 240 / 4
};
int writepage;
int count, startclock;
/* Window coordinate initially at center. */
x = VWIDTH / 2 - WINWIDTH / 2;
y = VHEIGHT / 2 - WINHEIGHT / 2;
targetx = x;
targety = y;
/* Page flipping initialization. */
vga_setdisplaystart(0); /* Display page 0, write to page 1. */
writepage = 1;
count = 0;
startclock = clock();
for (;;) {
/* Copy window to screen. */
vga_copytoplanar256(vbuf + y * WIDTH + x, WIDTH,
pageoffset[writepage], 80, WINWIDTH, WINHEIGHT);
/* Flip pages. */
vga_setdisplaystart(pageoffset[writepage] * 4);
#ifndef TRIPLEBUFFERING
/* Conventional double-buffering (page-flipping). */
vga_waitretrace();
writepage ^= 1;
#else
/* Triple buffering; no need to wait for vertical retrace. */
writepage = (writepage + 1) % 3;
#endif
if (x == targetx && y == targety) {
/* Create new target. */
targetx = rand() % (VWIDTH - WINWIDTH);
targety = rand() % (VHEIGHT - WINHEIGHT);
}
/* Move towards target. */
if (x < targetx)
x++;
if (x > targetx)
x--;
if (y < targety)
y++;
if (y > targety)
y--;
/* Boundary checks. */
if (x < 0)
x = 0;
if (x > VWIDTH - WINWIDTH)
x = VWIDTH - WINWIDTH;
if (y < 0)
y = 0;
if (y > VHEIGHT - WINHEIGHT)
y = VHEIGHT - WINHEIGHT;
if (vga_getkey())
break;
count++;
}
printf("Method 1: frame rate %ld\n", count * CLOCKS_PER_SEC
/ (clock() - startclock));
}
void demo2(void)
{
int x, y;
int targetx, targety;
int vwidth, vheight;
int count, startclock;
/* Make sure window fits in video memory. */
vwidth = VWIDTH;
if (vwidth > 640)
vwidth = 640;
vheight = VHEIGHT;
if (vheight > 400)
vheight = 400;
vga_setlogicalwidth(vwidth);
/* Copy virtual screen to logical screen in video memory. */
vga_copytoplanar256(vbuf, VWIDTH, 0, vwidth / 4,
vwidth, VHEIGHT);
/* Window coordinates initially at center. */
x = vwidth / 2 - WINWIDTH / 2;
y = vheight / 2 - WINHEIGHT / 2;
targetx = x;
targety = y;
count = 0;
startclock = clock();
for (;;) {
/* Set video memory window. */
vga_setdisplaystart((y * vwidth / 4) * 4 + x);
vga_waitretrace();
if (x == targetx && y == targety) {
/* Create new target. */
targetx = rand() % (vwidth - WINWIDTH);
targety = rand() % (vheight - WINHEIGHT);
}
/* Move towards target. */
if (x < targetx)
x++;
if (x > targetx)
x--;
if (y < targety)
y++;
if (y > targety)
y--;
/* Boundary checks. */
if (x < 0)
x = 0;
if (x > vwidth - WINWIDTH)
x = vwidth - WINWIDTH;
if (y < 0)
y = 0;
if (y > vheight - WINHEIGHT)
y = vheight - WINHEIGHT;
if (vga_getkey())
break;
count++;
}
printf("Method 2: frame rate %ld\n", count*CLOCKS_PER_SEC
/(clock() - startclock));
}
void demo3(void)
{
int x, y;
int targetx, targety;
int count, startclock;
GraphicsContext *virtualscreen;
GraphicsContext *physicalscreen;
/* Window coordinate initially at center. */
x = VWIDTH / 2 - WINWIDTH / 2;
y = VHEIGHT / 2 - WINHEIGHT / 2;
targetx = x;
targety = y;
virtualscreen = gl_allocatecontext();
gl_getcontext(virtualscreen);
gl_setcontextvga(G320x200x256);
physicalscreen = gl_allocatecontext();
gl_getcontext(physicalscreen);
gl_setcontext(virtualscreen);
count = 0;
startclock = clock();
for (;;) {
vga_waitretrace();
/* Copy window to screen. */
gl_copyboxtocontext(x, y, WINWIDTH, WINHEIGHT, physicalscreen,
0, 0);
if (x == targetx && y == targety) {
/* Create new target. */
targetx = rand() % (VWIDTH - WINWIDTH);
targety = rand() % (VHEIGHT - WINHEIGHT);
}
/* Move towards target. */
if (x < targetx)
x++;
if (x > targetx)
x--;
if (y < targety)
y++;
if (y > targety)
y--;
/* Boundary checks. */
if (x < 0)
x = 0;
if (x > VWIDTH - WINWIDTH)
x = VWIDTH - WINWIDTH;
if (y < 0)
y = 0;
if (y > VHEIGHT - WINHEIGHT)
y = VHEIGHT - WINHEIGHT;
if (vga_getkey())
break;
count++;
}
printf("Method 3: frame rate %ld\n", count * CLOCKS_PER_SEC
/ (clock() - startclock));
}
int main(void)
{
vga_init();
/* Create virtual screen. */
vbuf = malloc(VWIDTH * VHEIGHT);
gl_setcontextvirtual(VWIDTH, VHEIGHT, 1, 8, vbuf);
/* Set Mode X-style 320x240x256. */
vga_setmode(G320x240x256);
gl_setrgbpalette();
vga_clear();
boxes();
demo1();
demo2();
vga_setmode(G320x200x256); /* Set linear 320x200x256. */
gl_setrgbpalette();
demo3();
vga_setmode(TEXT);
exit(0);
}

17
demos/sixbpp.xbm Normal file
View file

@ -0,0 +1,17 @@
#define sixbpp_width 23
#define sixbpp_height 66
static char sixbpp_bits[] = {
0x80,0x3f,0x00,0xf0,0xff,0x01,0xfc,0xff,0x01,0xfe,0xff,0x03,0x7e,0x02,0x03,
0x0f,0x01,0x02,0x83,0x01,0x02,0x81,0x81,0x03,0x81,0xff,0x01,0x0d,0xff,0x01,
0x1f,0xff,0x00,0x1e,0x3e,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x70,0x00,0x01,0xff,0x01,0xf1,0xff,0x01,0xff,0xff,0x03,
0xff,0x03,0x03,0xff,0x00,0x02,0x8f,0x00,0x02,0x40,0x00,0x03,0xc0,0xc0,0x03,
0xc0,0xff,0x01,0x80,0xff,0x01,0x80,0xff,0x00,0x00,0x3e,0x40,0x00,0x00,0x40,
0x00,0x00,0x78,0x40,0x80,0x7f,0x40,0xf8,0x7f,0xc0,0xff,0x7f,0xc0,0xff,0x47,
0xc0,0xff,0x41,0xc0,0x07,0x03,0x80,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x03,
0xc0,0xc0,0x03,0xc0,0xff,0x01,0x80,0xff,0x01,0x80,0xff,0x00,0x00,0x3e,0x40,
0x00,0x00,0x40,0x00,0x00,0x78,0x40,0x80,0x7f,0x40,0xf8,0x7f,0xc0,0xff,0x7f,
0xc0,0xff,0x47,0xc0,0xff,0x41,0xc0,0x07,0x03,0x80,0x00,0x02,0x40,0x00,0x02,
0x40,0x00,0x03,0xc0,0xc0,0x03,0xc0,0xff,0x01,0x80,0xff,0x01,0x80,0xff,0x00,
0x00,0x3e,0x00};

312
demos/speedtest.c Normal file
View file

@ -0,0 +1,312 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <vga.h>
#include <vgagl.h>
/* #define LINEAR_ADDRESSING */
int VGAMODE, USEGL;
GraphicsContext *physicalscreen;
GraphicsContext *backscreen;
void screen1(void)
{
int x, y;
for (y = 0; y < HEIGHT; y++)
for (x = 0; x < WIDTH; x++)
/* limited RGB palette in 256-color modes */
/* some color information is not used in */
/* 15-bit color modes */
gl_setpixelrgb(x, y,
x * 256 / WIDTH,
255 - x * 256 / WIDTH,
y * 256 / HEIGHT);
}
void configure(void)
{
int allowed[GLASTMODE + 1];
for (;;) {
int i;
int m;
for (i = G320x200x16; i <= GLASTMODE; i++) {
allowed[i] = 0;
if (vga_hasmode(i)) {
printf("%2d %s\n", i, vga_getmodename(i));
allowed[i] = 1;
}
}
printf("\nWhich mode? ");
scanf("%d", &m);
getchar();
printf("\n");
if (m >= G320x200x16 && m <= GLASTMODE) {
VGAMODE = m;
if (vga_getmodeinfo(m)->bytesperpixel >= 1)
USEGL = 1;
else
USEGL = 0;
break;
}
}
vga_setmode(VGAMODE);
#ifdef LINEAR_ADDRESSING
vga_setlinearaddressing();
#endif
if (USEGL) {
gl_setcontextvga(VGAMODE);
physicalscreen = gl_allocatecontext();
gl_getcontext(physicalscreen);
}
}
void blit(void)
{
gl_clearscreen(0x86);
vga_imageblt(vga_getgraphmem(), 0, WIDTH - 128, HEIGHT - 128,
WIDTH * BYTESPERPIXEL);
/* vga_bitblt(0, 100 * WIDTH * BYTESPERPIXEL, 50, 50, WIDTH * BYTESPERPIXEL);
vga_fillblt(100 * BYTESPERPIXEL, 50, 50, WIDTH * BYTESPERPIXEL, 0x86);
*/
}
#if 0
/* May help on well-designed motherboards. */
/* IT DOES MAKE A DIFFERENCE! REP STOSL IS SLOWER */
/* (CL-GD5434 VLB zero-wait writes -- 2/3 cycles); rep stos takes 4 */
#if 1
static inline void *
__memset(void *s, char c, size_t count)
{
__asm__(
"cld\n\t"
"cmpl $12,%%edx\n\t"
"jl 1f\n\t" /* if (count >= 12) */
"movzbl %%al,%%ax\n\t"
"movl %%eax,%%ecx\n\t"
"shll $8,%%ecx\n\t" /* c |= c << 8 */
"orl %%ecx,%%eax\n\t"
"movl %%eax,%%ecx\n\t"
"shll $16,%%ecx\n\t" /* c |= c << 16 */
"orl %%ecx,%%eax\n\t"
"movl %%edx,%%ecx\n\t"
"negl %%ecx\n\t"
"andl $3,%%ecx\n\t" /* (-s % 4) */
"subl %%ecx,%%edx\n\t" /* count -= (-s % 4) */
"rep ; stosb\n\t" /* align to longword boundary */
"movl %%edx,%%ecx\n\t"
"shrl $2,%%ecx\n\t"
"cmpl $32,%%ecx\n\t" /* do loop unrolling for */
"jl 2f\n\t" /* chunks of 128 bytes */
"jmp 3f\n\t"
".align 4,0x90\n\t"
"3:\n\t"
"movl %%eax,(%%edi)\n\t"
"movl %%eax,4(%%edi)\n\t"
"movl %%eax,8(%%edi)\n\t"
"movl %%eax,12(%%edi)\n\t"
"movl %%eax,16(%%edi)\n\t"
"movl %%eax,20(%%edi)\n\t"
"movl %%eax,24(%%edi)\n\t"
"movl %%eax,28(%%edi)\n\t"
"movl %%eax,32(%%edi)\n\t"
"movl %%eax,36(%%edi)\n\t"
"movl %%eax,40(%%edi)\n\t"
"movl %%eax,44(%%edi)\n\t"
"movl %%eax,48(%%edi)\n\t"
"movl %%eax,52(%%edi)\n\t"
"movl %%eax,56(%%edi)\n\t"
"movl %%eax,60(%%edi)\n\t"
"movl %%eax,64(%%edi)\n\t"
"movl %%eax,68(%%edi)\n\t"
"movl %%eax,72(%%edi)\n\t"
"movl %%eax,76(%%edi)\n\t"
"movl %%eax,80(%%edi)\n\t"
"movl %%eax,84(%%edi)\n\t"
"movl %%eax,88(%%edi)\n\t"
"movl %%eax,92(%%edi)\n\t"
"movl %%eax,96(%%edi)\n\t"
"movl %%eax,100(%%edi)\n\t"
"movl %%eax,104(%%edi)\n\t"
"movl %%eax,108(%%edi)\n\t"
"subl $32,%%ecx\n\t"
"movl %%eax,112(%%edi)\n\t"
"movl %%eax,116(%%edi)\n\t"
"movl %%eax,120(%%edi)\n\t"
"movl %%eax,124(%%edi)\n\t"
"addl $128,%%edi\n\t"
"cmpl $32,%%ecx\n\t"
"jge 3b\n\t"
"2:\n\t"
"rep ; stosl\n\t" /* fill remaining longwords */
"andl $3,%%edx\n" /* fill last few bytes */
"1:\tmovl %%edx,%%ecx\n\t" /* <= 12 entry point */
"rep ; stosb\n\t"
: : "a"(c), "D"(s), "d"(count)
: "ax", "cx", "dx", "di");
return s;
}
#else /* 8-bit writes. */
static inline void *
__memset(void *s, char c, size_t count)
{
__asm__(
"cld\n\t"
"cmpl $12,%%edx\n\t"
"jl 1f\n\t" /* if (count >= 12) */
"movzbl %%al,%%ax\n\t"
"movl %%eax,%%ecx\n\t"
"shll $8,%%ecx\n\t" /* c |= c << 8 */
"orl %%ecx,%%eax\n\t"
"movl %%eax,%%ecx\n\t"
"shll $16,%%ecx\n\t" /* c |= c << 16 */
"orl %%ecx,%%eax\n\t"
"movl %%edx,%%ecx\n\t"
"negl %%ecx\n\t"
"andl $3,%%ecx\n\t" /* (-s % 4) */
"subl %%ecx,%%edx\n\t" /* count -= (-s % 4) */
"rep ; stosb\n\t" /* align to longword boundary */
"movl %%edx,%%ecx\n\t"
"shrl $2,%%ecx\n\t"
"cmpl $32,%%ecx\n\t" /* do loop unrolling for */
"jl 2f\n\t" /* chunks of 128 bytes */
"jmp 3f\n\t"
".align 4,0x90\n\t"
"3:\n\t"
"movb %%al,(%%edi)\n\t"
"movb %%al,1(%%edi)\n\t"
"movb %%al,2(%%edi)\n\t"
"movl %%al,3(%%edi)\n\t"
"movl %%al,4(%%edi)\n\t"
"movl %%al,5(%%edi)\n\t"
"movl %%al,6(%%edi)\n\t"
"movl %%al,7(%%edi)\n\t"
"movl %%al,8(%%edi)\n\t"
"movl %%al,9(%%edi)\n\t"
"movl %%al,10(%%edi)\n\t"
"movl %%al,11(%%edi)\n\t"
"movl %%al,12(%%edi)\n\t"
"movl %%al,13(%%edi)\n\t"
"movl %%al,14(%%edi)\n\t"
"movl %%al,15(%%edi)\n\t"
"movl %%al,16(%%edi)\n\t"
"movl %%al,17(%%edi)\n\t"
"movl %%al,18(%%edi)\n\t"
"movl %%al,19(%%edi)\n\t"
"movl %%al,20(%%edi)\n\t"
"movl %%al,21(%%edi)\n\t"
"movl %%al,22(%%edi)\n\t"
"movl %%al,23(%%edi)\n\t"
"movl %%al,24(%%edi)\n\t"
"movl %%al,25(%%edi)\n\t"
"movl %%al,26(%%edi)\n\t"
"movl %%al,27(%%edi)\n\t"
"movl %%al,28(%%edi)\n\t"
"subl $8,%%ecx\n\t"
"movl %%al,29(%%edi)\n\t"
"movl %%al,30(%%edi)\n\t"
"movl %%al,31(%%edi)\n\t"
"addl $32,%%edi\n\t"
"cmpl $8,%%ecx\n\t"
"jge 3b\n\t"
"2:\n\t"
"rep ; stosl\n\t" /* fill remaining longwords */
"andl $3,%%edx\n" /* fill last few bytes */
"1:\tmovl %%edx,%%ecx\n\t" /* <= 12 entry point */
"rep ; stosb\n\t"
: : "a"(c), "D"(s), "d"(count)
: "ax", "cx", "dx", "di");
return s;
}
#endif
#define memset __memset
#endif
void speed(void)
{
int i;
int start_clock;
int finish_clock;
int diff_clock;
unsigned char *vgabase = vga_getgraphmem();
#ifndef LINEAR_ADDRESSING
if (VGAMODE >= G640x480x256)
vga_setpage(0);
#endif
start_clock = clock();
for (i = 0; i < 5000; i++) {
memset(vgabase, i & 255, 65536);
}
finish_clock = clock();
diff_clock = (finish_clock - start_clock)*10/CLOCKS_PER_SEC;
printf("Timing: %3d.%1ds, %dK/s\n", diff_clock / 10,
(diff_clock % 10) , 64*5000*10 / diff_clock);
}
int main(void)
{
vga_init();
printf("This is a video memory speed tester. Note that the first "
"screen doesn't test\nanything (nor does the 3 second pause "
"that follows).\n\n");
configure();
if (COLORS == 256)
gl_setrgbpalette(); /* set RGB palette */
if (USEGL)
screen1();
sleep(2);
/* vga_screenoff(); */
speed();
vga_setmode(TEXT);
exit(0);
}

391
demos/spin.c Normal file
View file

@ -0,0 +1,391 @@
/*
spin.c - A simple (or not quite so) app to test the SpaceOrb by rotating
a shape of a given number of sides.
Copyright (C) 1997 Eric Sharkey, Jason Lyons, Brett Viren
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
---- end copyleft notice ----
This program is FREE!!! However, if you feel that nothing is free and you
refuse to use something someone else made unless paid for, you can send a
donation to me (Jason Lyons). For information on this, E-MAIL me at
jason_l@hotmail.com.
This graphical test program was originally written by Jason Lyons and
later hacked to bits by Eric Sharkey, but this program would not be
possible without Brett's efforts. Be sure to thank him!
The original code for the SpaceOrb in Unix/Linux was written by Brett Viren
(Brett.Viren@sunysb.edu) on his free time (ie, not when on the pay
clock of SUNY@Stony Brook). Do with it what you will, as long as
you abide by the GPL.
I think by now all of Brett's code has been removed from this demo
and incorporated into svgalib itself, but he's still responsible for
starting this whole thing.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vga.h>
#include <vgagl.h>
#include <vgamouse.h>
#include <malloc.h>
#include "spintables.h"
#define DONT_MANUALLY_SETUP_MOUSE
#define NODEBUG
#define GMODE 5
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 200
#define SCREEN_DEPTH 100
#ifndef ROTATION_ONLY
/* Note: 6-D protocol assumes x is left/right, y is in/out, and z is up/down, */
/* which is logical for a three d environment, but for this demo all plotting */
/* is done with x/y only, so we remap y onto z and vice versa here by */
/* defining y as coordinate 2 and z as coordinate 1 */
#define SCR_XCTR t[0]
#define SCR_YCTR t[2]
#define SCR_ZCTR (((float) t[1])/((float) SCREEN_DEPTH))
#else
#define SCR_XCTR (SCREEN_WIDTH/2)
#define SCR_YCTR (SCREEN_HEIGHT/2)
#define SCR_ZCTR 1
#endif
#define SCREEN_SIZE (SCREEN_WIDTH*SCREEN_HEIGHT)
#define LAYERS 6
#define MAX_NUM_SIDES 20
#define MAX_NUM_POINTS MAX_NUM_SIDES*LAYERS
#define HORIZONTAL 0
typedef unsigned short WORD;
typedef unsigned char BYTE;
typedef unsigned int DWORD;
typedef struct {
float x, y, z;
} POINT3D;
int CurrentColor=12;
int Depth[LAYERS] = { -45, -35, -10, +10, +35, +45 };
int Radius[LAYERS] = { 5, 50, 75, 75, 50, 5 };
int InitGraph(int mode);
void InitPoints(POINT3D *Points, int sides);
void SetColor(char c);
char GetColor(void);
void SetPixel(int x, int y, char c);
void line(int x1, int y1, int x2, int y2);
void Update(void);
void Clear(void);
void RotateX(POINT3D *dest, POINT3D src, int a);
void RotateY(POINT3D *dest, POINT3D src, int a);
void RotateZ(POINT3D *dest, POINT3D src, int a);
GraphicsContext *screen;
char *buf;
int main(void)
{
int scale=100, a, b, c;
POINT3D *Points;
int sides;
int NUM_POINTS;
int t[3], r[3], oldbutton=0, button=0;
#ifdef MANUALLY_SETUP_MOUSE
char orbdev[1024] = "/dev/ttyS0";
#endif
printf("\n\n Welcome to SPIN\n\n");
printf(" Spin is a graphical rotation program for Linux which uses the SVGA library.\n");
printf("It's purpose is to demonstrate the new six dimensional mouse driver support.\n");
printf("So far this driver only supports the Spaceball series of controllers including\n");
printf("the Spaceball Avenger and SpaceOrb 360. Spin may be used with any mouse type\n");
printf("but two dimensional mice will only be able to move the image in two dimensions.\n\n");
printf("Spin was originally written by Jason Lyons, based on the SpaceOrb readout code\n");
printf("developed by Brett Viren and others. Eric Sharkey incorporated Brett's code\n");
printf("into svgalib and adapted spin accordingly.\n\n");
printf("Button Functions:\n");
printf(" A - Decrease Sensitivity (Right Mouse Button)\n");
printf(" B - Change color (Middle Mouse Button)\n");
printf(" C - Increase Sensitivity (Left Mouse Button)\n");
printf(" D - Increase Number of Sides\n");
printf(" E - Decrease Number of Sides\n");
printf(" F - Quit (CTRL-C)\n");
printf(" Reset button toggles orientation (default is vertical) \n\n");
printf("Warning: Default sensitivity optimized for spaceball.\n");
printf("Most mice will need to increase this setting.\n");
printf("\nHow many sides to start with (MAX %d) ? ",MAX_NUM_SIDES);
scanf("%d", &c);
if(c == 0) exit(1);
else if(c < 0) printf("\nCannot draw a negative number of sides.\n"), exit(1);
else if(c > MAX_NUM_SIDES) printf("\nCannot draw with more sides than %d.\n",MAX_NUM_SIDES), exit(1);
sides = c;
NUM_POINTS = sides*LAYERS;
Points = (POINT3D *)calloc(MAX_NUM_POINTS, sizeof(POINT3D));
InitPoints(Points,sides);
printf("Initializing mouse\n");
#ifdef MANUALLY_SETUP_MOUSE
if (mouse_init(orbdev,MOUSE_SPACEBALL,MOUSE_DEFAULTSAMPLERATE)) {
printf("mouse_init failed");
return -1;
} else {
printf("mouse_init successful\n");
}
#else
vga_setmousesupport(1);
#endif
if(!InitGraph(GMODE)) return 0;
mouse_setscale(scale);
mouse_setrange_6d(0,SCREEN_WIDTH,1,SCREEN_DEPTH,0,SCREEN_HEIGHT,-2,2,-2,2,-2,2,63);
mouse_setwrap(MOUSE_ROT_INFINITESIMAL);
mouse_setposition_6d(SCREEN_WIDTH/2,SCREEN_DEPTH/2,SCREEN_HEIGHT/2,0,0,0,63);
while(1)
{
mouse_update();
mouse_getposition_6d(&t[0],&t[1],&t[2],&r[0],&r[1],&r[2]);
#ifdef DEBUG
printf("%d %d %d\n",t[0],t[1],t[2]);
#endif
oldbutton = button;
button = mouse_getbutton();
if ((button & MOUSE_RIGHTBUTTON)&&!(oldbutton & MOUSE_RIGHTBUTTON)) {
scale += 5;
mouse_setscale(scale);
}
if ((button & MOUSE_LEFTBUTTON)&&!(oldbutton & MOUSE_LEFTBUTTON)) {
if (scale==1) {
printf("\007");
fflush(stdout);
} else {
if (scale>6)
scale -=5;
else
scale--;
mouse_setscale(scale);
}
}
if ((button & MOUSE_MIDDLEBUTTON)&&!(oldbutton & MOUSE_MIDDLEBUTTON))
CurrentColor = random() % 15 + 1;
if ((button & MOUSE_FOURTHBUTTON)&&!(oldbutton & MOUSE_FOURTHBUTTON)) {
if (sides>1) {
sides--;
NUM_POINTS = sides*LAYERS;
InitPoints(Points,sides);
} else {
printf("\007");
fflush(stdout);
}
}
if ((button & MOUSE_FIFTHBUTTON)&&!(oldbutton & MOUSE_FIFTHBUTTON)) {
if (sides<MAX_NUM_SIDES) {
sides++;
NUM_POINTS = sides*LAYERS;
InitPoints(Points,sides);
} else {
printf("\007");
fflush(stdout);
}
}
if (button & MOUSE_SIXTHBUTTON)
{
vga_setmode(0);
free(buf);
free(Points);
return 0;
}
for(a = 0; a < NUM_POINTS; a++) {
RotateX(&Points[a],Points[a],r[0]);
RotateY(&Points[a],Points[a],r[2]);
RotateZ(&Points[a],Points[a],r[1]);
Points[a].x *= SCR_ZCTR;
Points[a].y *= SCR_ZCTR;
Points[a].z *= SCR_ZCTR;
Points[a].x += SCR_XCTR;
Points[a].y += SCR_YCTR;
}
for(a = 0; a < LAYERS; a++)
{
for(b = 0; b < sides-1; b++)
{
/* Connect the points on each layer */
line(Points[a*sides+(b+1)].x,Points[a*sides+(b+1)].y,
Points[a*sides+b].x,Points[a*sides+b].y);
/* Connect between layers */
if(a < (LAYERS - 1))
{
line(Points[(a+1)*sides+b].x,Points[(a+1)*sides+b].y,
Points[a*sides+b].x,Points[a*sides+b].y);
}
}
line(Points[a*sides+b].x,Points[a*sides+b].y,
Points[a*sides+0].x,Points[a*sides+0].y);
if(a < (LAYERS - 1))
{
line(Points[a*sides+b].x,Points[a*sides+b].y,
Points[(a+1)*sides+b].x,Points[(a+1)*sides+b].y);
}
}
for(a = 0; a < NUM_POINTS; a++) {
Points[a].x -= SCR_XCTR;
Points[a].y -= SCR_YCTR;
Points[a].x /= SCR_ZCTR;
Points[a].y /= SCR_ZCTR;
Points[a].z /= SCR_ZCTR;
}
Update();
Clear();
}
free(buf);
free(Points);
}
void SetColor(char c) { CurrentColor = c; }
char GetColor() { return CurrentColor; }
void SetPixel(int x, int y, char c)
{
if(x >= 0 && x < SCREEN_WIDTH && y >= 0 && y < SCREEN_HEIGHT)
buf[y*SCREEN_WIDTH+x] = c;
}
void Clear() { memset((char *)buf, 0, SCREEN_SIZE); }
void Update()
{
memcpy((char *)screen->vbuf, (char *)buf, SCREEN_SIZE);
}
void InitPoints(POINT3D *Points, int sides)
{
int a, b, c;
for(a = 0; a < LAYERS; a++)
{
for(b = 0; b < sides; b++)
{
c=(b*360)/sides;
Points[a*sides+b].x = cosine[c] * Radius[a];
Points[a*sides+b].y = sine[c] * Radius[a];
Points[a*sides+b].z = Depth[a];
}
}
}
int InitGraph(int mode)
{
buf = (char *)malloc(SCREEN_SIZE);
if(!buf) return 0;
if(!vga_hasmode(mode)) return 0;
vga_setmode(mode);
gl_setcontextvga(mode);
screen = gl_allocatecontext();
gl_getcontext(screen);
gl_setcontextvgavirtual(mode);
gl_setcontext(screen);
return 1;
}
void RotateX(POINT3D *dest, POINT3D src, int a)
{
while (a<0) a+=360;
dest->x = src.x;
dest->y = src.y * cosine[a] + src.z * sine[a];
dest->z = -1 * src.y * sine[a] + src.z * cosine[a];
}
void RotateY(POINT3D *dest, POINT3D src, int a)
{
while (a<0) a+=360;
dest->x = -1 * src.z * sine[a] + src.x * cosine[a];
dest->y = src.y;
dest->z = src.z * cosine[a] + src.x * sine[a];
}
void RotateZ(POINT3D *dest, POINT3D src, int a)
{
while (a<0) a+=360;
dest->x = src.x * cosine[a] + src.y * sine[a];
dest->y = -1 * src.x * sine[a] + src.y * cosine[a];
dest->z = src.z;
}
void line(int x1, int y1, int x2, int y2)
{
int dx, dy;
int sx, sy;
int ax, ay;
int x, y, c=CurrentColor;
dx = x2 - x1;
dy = y2 - y1;
ax = abs(dx) << 1;
ay = abs(dy) << 1;
sx = (dx >= 0) ? 1 : -1;
sy = (dy >= 0) ? 1 : -1;
x = x1;
y = y1;
if (ax > ay)
{
int d = ay - (ax >> 1);
while (x != x2)
{
SetPixel(x, y, c);
if (d > 0 || (d == 0 && sx == 1))
{
y += sy;
d -= ax;
}
x += sx;
d += ay;
}
}
else
{
int sy = (dy >= 0) ? 1 : -1;
int d = ax - (ay >> 1);
while (y != y2)
{
SetPixel(x, y, c);
if (d > 0 || (d == 0 && sy == 1))
{
x += sx;
d -= ay;
}
y += sy;
d += ax;
}
}
SetPixel(x, y, c);
}

724
demos/spintables.h Normal file
View file

@ -0,0 +1,724 @@
float sine[360] = {
0.000000,
0.017449,
0.034893,
0.052326,
0.069743,
0.087139,
0.104509,
0.121846,
0.139147,
0.156405,
0.173616,
0.190773,
0.207873,
0.224909,
0.241877,
0.258771,
0.275587,
0.292318,
0.308961,
0.325509,
0.341958,
0.358303,
0.374539,
0.390661,
0.406664,
0.422544,
0.438294,
0.453911,
0.469390,
0.484726,
0.499914,
0.514951,
0.529830,
0.544548,
0.559100,
0.573482,
0.587689,
0.601718,
0.615563,
0.629221,
0.642687,
0.655957,
0.669028,
0.681895,
0.694554,
0.707002,
0.719235,
0.731248,
0.743039,
0.754604,
0.765939,
0.777040,
0.787905,
0.798530,
0.808912,
0.819048,
0.828934,
0.838568,
0.847947,
0.857067,
0.865927,
0.874522,
0.882852,
0.890912,
0.898702,
0.906217,
0.913457,
0.920419,
0.927100,
0.933499,
0.939614,
0.945442,
0.950983,
0.956234,
0.961195,
0.965862,
0.970235,
0.974313,
0.978094,
0.981578,
0.984762,
0.987647,
0.990230,
0.992513,
0.994493,
0.996170,
0.997544,
0.998614,
0.999381,
0.999843,
1.000000,
0.999853,
0.999401,
0.998645,
0.997586,
0.996222,
0.994555,
0.992585,
0.990313,
0.987739,
0.984865,
0.981691,
0.978217,
0.974446,
0.970379,
0.966015,
0.961358,
0.956408,
0.951166,
0.945635,
0.939816,
0.933711,
0.927322,
0.920650,
0.913698,
0.906468,
0.898961,
0.891181,
0.883130,
0.874810,
0.866223,
0.857372,
0.848261,
0.838891,
0.829266,
0.819388,
0.809261,
0.798887,
0.788270,
0.777413,
0.766320,
0.754992,
0.743436,
0.731652,
0.719646,
0.707421,
0.694980,
0.682328,
0.669468,
0.656404,
0.643141,
0.629681,
0.616030,
0.602191,
0.588169,
0.573967,
0.559591,
0.545045,
0.530332,
0.515459,
0.500428,
0.485244,
0.469913,
0.454439,
0.438827,
0.423081,
0.407206,
0.391207,
0.375089,
0.358857,
0.342515,
0.326069,
0.309524,
0.292885,
0.276156,
0.259344,
0.242452,
0.225487,
0.208453,
0.191355,
0.174199,
0.156991,
0.139734,
0.122435,
0.105098,
0.087730,
0.070335,
0.052918,
0.035485,
0.018042,
0.000593,
-0.016857,
-0.034301,
-0.051734,
-0.069152,
-0.086549,
-0.103919,
-0.121258,
-0.138560,
-0.155820,
-0.173032,
-0.190192,
-0.207293,
-0.224332,
-0.241302,
-0.258199,
-0.275017,
-0.291751,
-0.308397,
-0.324949,
-0.341401,
-0.357750,
-0.373990,
-0.390116,
-0.406123,
-0.422006,
-0.437761,
-0.453383,
-0.468867,
-0.484208,
-0.499401,
-0.514442,
-0.529327,
-0.544051,
-0.558609,
-0.572996,
-0.587210,
-0.601244,
-0.615096,
-0.628760,
-0.642233,
-0.655510,
-0.668587,
-0.681461,
-0.694128,
-0.706583,
-0.718823,
-0.730844,
-0.742642,
-0.754215,
-0.765557,
-0.776667,
-0.787540,
-0.798174,
-0.808564,
-0.818708,
-0.828603,
-0.838245,
-0.847633,
-0.856762,
-0.865630,
-0.874235,
-0.882573,
-0.890643,
-0.898442,
-0.905967,
-0.913216,
-0.920187,
-0.926878,
-0.933286,
-0.939411,
-0.945249,
-0.950800,
-0.956061,
-0.961031,
-0.965708,
-0.970091,
-0.974179,
-0.977971,
-0.981464,
-0.984659,
-0.987554,
-0.990148,
-0.992440,
-0.994431,
-0.996118,
-0.997503,
-0.998583,
-0.999360,
-0.999832,
-1.000000,
-0.999863,
-0.999422,
-0.998676,
-0.997627,
-0.996273,
-0.994616,
-0.992657,
-0.990395,
-0.987832,
-0.984967,
-0.981803,
-0.978340,
-0.974579,
-0.970522,
-0.966168,
-0.961521,
-0.956581,
-0.951349,
-0.945828,
-0.940019,
-0.933923,
-0.927544,
-0.920881,
-0.913939,
-0.906718,
-0.899221,
-0.891450,
-0.883408,
-0.875097,
-0.866519,
-0.857677,
-0.848575,
-0.839213,
-0.829597,
-0.819728,
-0.809609,
-0.799243,
-0.788635,
-0.777786,
-0.766700,
-0.755381,
-0.743832,
-0.732056,
-0.720058,
-0.707840,
-0.695406,
-0.682761,
-0.669908,
-0.656851,
-0.643594,
-0.630141,
-0.616497,
-0.602664,
-0.588648,
-0.574453,
-0.560082,
-0.545542,
-0.530835,
-0.515966,
-0.500941,
-0.485763,
-0.470436,
-0.454967,
-0.439359,
-0.423618,
-0.407747,
-0.391752,
-0.375638,
-0.359410,
-0.343072,
-0.326630,
-0.310088,
-0.293452,
-0.276726,
-0.259916,
-0.243027,
-0.226064,
-0.209032,
-0.191937,
-0.174783,
-0.157576,
-0.140321,
-0.123023,
-0.105688,
-0.088320,
-0.070926,
-0.053510,
-0.036077,
-0.018634,
};
float cosine[360] = {
1.000000,
0.999848,
0.999391,
0.998630,
0.997565,
0.996196,
0.994524,
0.992549,
0.990272,
0.987693,
0.984813,
0.981634,
0.978156,
0.974380,
0.970307,
0.965939,
0.961276,
0.956321,
0.951075,
0.945539,
0.939715,
0.933605,
0.927211,
0.920534,
0.913578,
0.906343,
0.898832,
0.891047,
0.882991,
0.874666,
0.866075,
0.857220,
0.848104,
0.838730,
0.829100,
0.819218,
0.809087,
0.798709,
0.788088,
0.777227,
0.766129,
0.754798,
0.743237,
0.731450,
0.719440,
0.707212,
0.694767,
0.682112,
0.669248,
0.656181,
0.642914,
0.629451,
0.615796,
0.601954,
0.587929,
0.573725,
0.559346,
0.544796,
0.530081,
0.515205,
0.500171,
0.484985,
0.469652,
0.454175,
0.438561,
0.422812,
0.406935,
0.390934,
0.374814,
0.358580,
0.342237,
0.325789,
0.309242,
0.292602,
0.275872,
0.259058,
0.242165,
0.225198,
0.208163,
0.191064,
0.173908,
0.156698,
0.139440,
0.122141,
0.104804,
0.087435,
0.070039,
0.052622,
0.035189,
0.017745,
0.000296,
-0.017153,
-0.034597,
-0.052030,
-0.069448,
-0.086844,
-0.104214,
-0.121552,
-0.138854,
-0.156113,
-0.173324,
-0.190483,
-0.207583,
-0.224621,
-0.241590,
-0.258485,
-0.275302,
-0.292035,
-0.308679,
-0.325229,
-0.341680,
-0.358027,
-0.374265,
-0.390389,
-0.406394,
-0.422275,
-0.438028,
-0.453647,
-0.469128,
-0.484467,
-0.499658,
-0.514697,
-0.529579,
-0.544299,
-0.558854,
-0.573239,
-0.587450,
-0.601481,
-0.615329,
-0.628990,
-0.642460,
-0.655733,
-0.668808,
-0.681678,
-0.694341,
-0.706792,
-0.719029,
-0.731046,
-0.742841,
-0.754409,
-0.765748,
-0.776854,
-0.787723,
-0.798352,
-0.808738,
-0.818878,
-0.828769,
-0.838407,
-0.847790,
-0.856915,
-0.865778,
-0.874379,
-0.882713,
-0.890778,
-0.898572,
-0.906092,
-0.913336,
-0.920303,
-0.926989,
-0.933393,
-0.939512,
-0.945346,
-0.950892,
-0.956148,
-0.961113,
-0.965785,
-0.970163,
-0.974246,
-0.978032,
-0.981521,
-0.984710,
-0.987600,
-0.990189,
-0.992477,
-0.994462,
-0.996144,
-0.997523,
-0.998599,
-0.999370,
-0.999837,
-1.000000,
-0.999858,
-0.999412,
-0.998661,
-0.997606,
-0.996248,
-0.994586,
-0.992621,
-0.990354,
-0.987786,
-0.984916,
-0.981747,
-0.978279,
-0.974513,
-0.970450,
-0.966092,
-0.961439,
-0.956494,
-0.951258,
-0.945732,
-0.939918,
-0.933817,
-0.927433,
-0.920766,
-0.913818,
-0.906593,
-0.899091,
-0.891316,
-0.883269,
-0.874953,
-0.866371,
-0.857525,
-0.848418,
-0.839052,
-0.829431,
-0.819558,
-0.809435,
-0.799065,
-0.788452,
-0.777600,
-0.766510,
-0.755187,
-0.743634,
-0.731854,
-0.719852,
-0.707630,
-0.695193,
-0.682545,
-0.669688,
-0.656628,
-0.643368,
-0.629911,
-0.616263,
-0.602428,
-0.588408,
-0.574210,
-0.559837,
-0.545293,
-0.530584,
-0.515712,
-0.500684,
-0.485503,
-0.470175,
-0.454703,
-0.439093,
-0.423349,
-0.407476,
-0.391480,
-0.375364,
-0.359133,
-0.342794,
-0.326349,
-0.309806,
-0.293168,
-0.276441,
-0.259630,
-0.242740,
-0.225775,
-0.208743,
-0.191646,
-0.174491,
-0.157283,
-0.140027,
-0.122729,
-0.105393,
-0.088025,
-0.070630,
-0.053214,
-0.035781,
-0.018338,
-0.000889,
0.016560,
0.034004,
0.051438,
0.068856,
0.086254,
0.103625,
0.120964,
0.138267,
0.155527,
0.172740,
0.189901,
0.207003,
0.224043,
0.241014,
0.257913,
0.274732,
0.291468,
0.308115,
0.324668,
0.341123,
0.357473,
0.373715,
0.389843,
0.405852,
0.421738,
0.437495,
0.453119,
0.468605,
0.483948,
0.499144,
0.514188,
0.529076,
0.543802,
0.558363,
0.572754,
0.586970,
0.601007,
0.614862,
0.628529,
0.642005,
0.655286,
0.668367,
0.681244,
0.693914,
0.706373,
0.718617,
0.730641,
0.742444,
0.754020,
0.765367,
0.776480,
0.787358,
0.797995,
0.808389,
0.818538,
0.828437,
0.838084,
0.847475,
0.856609,
0.865482,
0.874091,
0.882434,
0.890508,
0.898311,
0.905841,
0.913095,
0.920071,
0.926766,
0.933180,
0.939309,
0.945152,
0.950708,
0.955974,
0.960949,
0.965631,
0.970020,
0.974112,
0.977909,
0.981407,
0.984607,
0.987507,
0.990106,
0.992404,
0.994399,
0.996092,
0.997482,
0.998567,
0.999349,
0.999826,
};

180
demos/svidtune.c Normal file
View file

@ -0,0 +1,180 @@
/* Program to test the svgalib keyboard functions. */
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <vga.h>
#include <vgagl.h>
#include <vgakeyboard.h>
void usage(void)
{
puts("Usage: svidtune [mode]\n"
);
exit(2);
}
int main(int argc, char **argv)
{
int x=-1,xmax,ymax;
char buffer[2];
int vgamode;
int key, retval = 0;
int pixelClock;
int HDisplay;
int HSyncStart;
int HSyncEnd;
int HTotal;
int VDisplay;
int VSyncStart;
int VSyncEnd;
int VTotal;
int flags;
float hsf,vsf;
char flagstring[256];
if (argc > 2)
usage();
if(argc==2){
if(!sscanf(argv[1], "%d", &x))
usage();
};
vga_init();
if(x==-1)vgamode = vga_getdefaultmode(); else vgamode=x;
if (vgamode == -1)
vgamode = G640x480x256;
if (!vga_hasmode(vgamode)) {
printf("Mode not available.\n");
exit(1);
}
vga_setmode(vgamode);
gl_setcontextvga(vgamode);
gl_enableclipping();
gl_setfont(8, 8, gl_font8x8);
gl_setwritemode(FONT_COMPRESSED + WRITEMODE_OVERWRITE);
gl_setfontcolors(0, vga_white());
buffer[1] = 0;
for(;!buffer[1];) {
vga_getcurrenttiming(&pixelClock,
&HDisplay,
&HSyncStart,
&HSyncEnd,
&HTotal,
&VDisplay,
&VSyncStart,
&VSyncEnd,
&VTotal,
&flags);
sprintf(flagstring,"%s%s%s%s%s%s",
flags&1?"+hsync ":"",
flags&2?"-hsync ":"",
flags&4?"+vsync ":"",
flags&8?"-vsync ":"",
flags&16?"interlaced ":"",
flags&32?"doublescan":"");
hsf=pixelClock*1000.0/HTotal;
vsf=hsf/VTotal;
if(flags&32)vsf=vsf/2;
gl_printf(500,500,"îúï æéå-àá");
gl_printf(10,5, "Clock:%i", pixelClock);
gl_printf(10,25, "HDisplay:%i", HDisplay);
gl_printf(10,45, "HSyncStart:%i", HSyncStart);
gl_printf(10,65, "HSyncEnd:%i", HSyncEnd);
gl_printf(10,85, "HTotal:%i", HTotal);
gl_printf(10,105, "VDisplay:%i", VDisplay);
gl_printf(10,125, "VSyncStart:%i", VSyncStart);
gl_printf(10,145, "VSyncEnd:%i", VSyncEnd);
gl_printf(10,165, "VTotal:%i", VTotal);
gl_printf(10,185, "flags:%i = %s", flags,flagstring);
gl_printf(10,205, "Horz freq:%.3f kHz", hsf/1000);
gl_printf(10,215, "Vert freq:%.2f Hz", vsf);
if(VDisplay>270){
gl_printf(10,235, "Up, Down, Left, Right, Wider, Narrower, lOnger, Shorter");
gl_printf(10,258, "'p' - prints current modeline to stdout, 'P' - to config file ");
};
xmax = vga_getxdim() - 1;
ymax = vga_getydim() - 1;
vga_setcolor(vga_white());
vga_drawline(0, 0, xmax, 0);
vga_drawline(xmax, 0, xmax, ymax);
vga_drawline(xmax, ymax, 0, ymax);
vga_drawline(0, ymax, 0, 0);
key = vga_getch();
switch(key) {
case 4:
case 'q':
buffer[1]=1;
break;
case 'l':
vga_changetiming(0,0,8,8,0,0,0,0,0,0);
break;
case 'r':
vga_changetiming(0,0,-8,-8,0,0,0,0,0,0);
break;
case 'u':
vga_changetiming(0,0,0,0,0,0,1,1,0,0);
break;
case 'd':
vga_changetiming(0,0,0,0,0,0,-1,-1,0,0);
break;
case 'w':
vga_changetiming(0,0,-4,-4,-8,0,0,0,0,0);
break;
case 'n':
vga_changetiming(0,0,4,4,8,0,0,0,0,0);
break;
case 's':
vga_changetiming(0,0,0,0,0,0,1,1,2,0);
break;
case 'o':
vga_changetiming(0,0,0,0,0,0,-1,-1,-2,0);
break;
case 'p':
fprintf(stderr,"Modeline %c%ix%i@%.0f%c %.3f %i %i %i %i %i %i %i %i %s\n",'"',xmax+1,ymax+1,vsf,'"',
pixelClock/1000.0,
HDisplay,
HSyncStart,
HSyncEnd,
HTotal,
VDisplay,
VSyncStart,
VSyncEnd,
VTotal,
flagstring);
break;
case 'P':{
FILE *f;
f=fopen("/etc/vga/libvga.config","a");
fprintf(f,"Modeline %c%ix%i@%.0f%c %.3f %i %i %i %i %i %i %i %i %s\n",'"',xmax+1,ymax+1,vsf,'"',
pixelClock/1000.0,
HDisplay,
HSyncStart,
HSyncEnd,
HTotal,
VDisplay,
VSyncStart,
VSyncEnd,
VTotal,
flagstring);
fclose(f);
};
break;
};
}
vga_setmode(TEXT);
exit(retval);
}

758
demos/testaccel.c Normal file
View file

@ -0,0 +1,758 @@
/* Program to test all accelerator functions and the 8 bit
per color color lookup functions. */
/* written by Michael Weller (eowmob@exp-math.uni-essen.de) */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include "vga.h"
#include "clut.xbm"
#include "sixbpp.xbm"
#include "eightbpp.xbm"
#include "fish_monster.h"
#define RED(i) (0)
#define GREEN(i) (0)
#define BLUE(i) (i)
#define LOGO_NAME "linuxlogo.bitmap"
#define LOGO_WIDTH 201
#define LOGO_HEIGHT 85
#undef BITFRAME
typedef struct {
int n;
int pels;
int width;
int offset;
/*
int xmin[n];
int xmax[n]; */
} hlinelst;
/*Adjust hlist for new xcoord */
inline void adj_hlilst(hlinelst * lst, register int x)
{
register int i, *ptr;
i = x;
x -= lst->offset;
lst->offset = i;
i = (lst->n) << 1;
ptr = (int *) (((char *) lst) + sizeof(hlinelst));
while (i--)
*ptr++ += x;
}
inline int sizhlilst(int n)
{
return sizeof(hlinelst) + (sizeof(int) * (n < 1 ? 2 : (n << 1)));
}
inline int isqr(int i)
{
return i * i;
}
int waitmode = 1;
void my_wait(void)
{
if (waitmode)
vga_getch();
else
sleep(1);
}
void setcol(vga_modeinfo * modeinfo)
{
int i;
if (modeinfo->colors == 256)
for (i = 0; i < 256; i++)
vga_setpalette(i, (i & 7) * 0x9, ((i >> 3) & 7) * 0x9, ((i >> 6) & 3) * 0x15);
else if (modeinfo->colors < 256)
for (i = 0; i < 16; i++)
vga_setegacolor(i);
}
int colorcol(int column, int width, int xmax)
{
int color;
color = ((column << 8) - column) / xmax;
if (width != 8)
color &= 0xfc;
return color;
}
void drawtwidth(vga_modeinfo * modeinfo, char *bits, int x, int y, int tw, int th, int width)
{
unsigned char color;
int i, j, k, xmax, offset;
tw = (tw + 7) >> 3;
th <<= 1;
th += x;
xmax = vga_getxdim() - 1;
y *= modeinfo->linewidth;
for (i = x; i < th; i++) {
color = colorcol(xmax - i, width, xmax);
offset = y + i;
if ((i - x) & 1)
bits -= tw;
j = tw;
while (j--) {
k = 1;
do {
if (*bits & k) {
vga_setpage(offset >> 16);
graph_mem[offset & 0xffff] = color;
}
offset += modeinfo->linewidth;
if (*bits & k) {
vga_setpage(offset >> 16);
graph_mem[offset & 0xffff] = color;
}
offset += modeinfo->linewidth;
k <<= 1;
}
while (k & 0xff);
bits++;
}
}
}
void drawwidth(int mode, vga_modeinfo * modeinfo, int line, int height, int width)
{
unsigned char color;
int i, xmax, j, offset;
xmax = vga_getxdim() - 1;
for (i = 0; i < xmax; i++) {
color = colorcol(i, width, xmax);
offset = line * (modeinfo->linewidth) + i;
j = height;
while (j--) {
vga_setpage(offset >> 16);
graph_mem[offset & 0xffff] = color;
offset += modeinfo->linewidth;
}
}
j = clut_width + sixbpp_width;
j = height - j - j;
j /= 3;
drawtwidth(modeinfo, clut_bits, (xmax - 2 * clut_height) >> 1, j + line, clut_width, clut_height, width);
j += j + clut_width;
if (width == 6)
drawtwidth(modeinfo, sixbpp_bits, (xmax - 2 * sixbpp_height) >> 1, j + line, sixbpp_width, sixbpp_height, width);
else
drawtwidth(modeinfo, eightbpp_bits, (xmax - 2 * eightbpp_height) >> 1, j + line, eightbpp_width, eightbpp_height, width);
}
void testwidth(int mode, vga_modeinfo * modeinfo)
{
int ymax, i, old_flags;
ymax = vga_getydim();
if (vga_getxdim() < 640)
puts(" Warning: Resolution too small, displayed text is\n"
" probably scrambled.\n");
if (vga_ext_set(VGA_EXT_AVAILABLE, VGA_AVAIL_FLAGS) & VGA_CLUT8) {
old_flags = vga_ext_set(VGA_EXT_SET, VGA_CLUT8);
for (i = 0; i < 256; i++)
vga_setpalette(i, RED(i), GREEN(i), BLUE(i));
puts(" Has support for CLUT width 8 bit");
drawwidth(mode, modeinfo, 0, ymax >> 1, 6);
drawwidth(mode, modeinfo, ymax >> 1, ymax >> 1, 8);
my_wait();
vga_clear();
vga_ext_set(VGA_EXT_RESET, old_flags);
} else {
for (i = 0; i < 256; i++)
vga_setpalette(i, RED(i) >> 2, GREEN(i) >> 2, BLUE(i) >> 2);
puts(" No support for CLUT width 8 bit");
drawwidth(mode, modeinfo, 0, ymax, 6);
my_wait();
}
}
void testfill(vga_modeinfo * modeinfo)
{
clock_t clk;
unsigned long pels = 0;
int xmax, ymax, lw, i, start, lim, x, y, w, h, mask;
lw = modeinfo->linewidth;
setcol(modeinfo);
vga_clear();
ymax = vga_getydim();
xmax = vga_getxdim();
srand(time(0));
clk = clock();
mask = modeinfo->colors - 1;
lim = ((xmax < ymax) ? xmax : ymax) >> 1;
for (i = 0, start = 0; i < lim; i++, start += lw + modeinfo->bytesperpixel) {
vga_fillblt(start, xmax - (i << 1), ymax - (i << 1), lw, mask & i);
pels += (xmax - (i << 1)) * (ymax - (i << 1));
}
for (i = 0; i < 10000; i++) {
x = rand() % xmax;
y = rand() % ymax;
w = rand() % (xmax - x);
h = rand() % (ymax - y);
switch (modeinfo->bytesperpixel) {
case 2:
x <<= 1;
break;
case 3:
x += (x << 1);
break;
case 4:
x <<= 2;
break;
}
vga_fillblt(x + y * lw, w, h, lw, mask & rand());
pels += w * h;
}
clk = clock() - clk;
printf(" Has FillBlt: %11lu Pixels in %.2f seconds -> %.2f Megapels\n",
pels, ((double) clk) / CLOCKS_PER_SEC, (pels / 1.0e6) / (((double) clk) / CLOCKS_PER_SEC));
my_wait();
}
void getlogo(void *blitimage, vga_modeinfo * modeinfo)
{
int i;
FILE *fd;
fd = fopen(LOGO_NAME, "r");
if (!fd) {
read_err:
perror("Problems reading linuxlogo.bitmap");
exit(2);
}
if (1 != fread(blitimage, LOGO_WIDTH * LOGO_HEIGHT, 1, fd))
goto read_err;
fclose(fd);
switch (modeinfo->bytesperpixel) {
/* Nothing todo for 256 colors! */
case 2:
{
unsigned char *bmp = (void *) blitimage;
unsigned short *bmpsh = (void *) blitimage;
bmp += LOGO_WIDTH * LOGO_HEIGHT;
bmpsh += LOGO_WIDTH * LOGO_HEIGHT;
i = LOGO_WIDTH * LOGO_HEIGHT;
if (modeinfo->colors == 32768) {
while (i--) {
bmp--;
*--bmpsh = ((((unsigned short) *bmp) & 7) << 12) |
((((unsigned short) *bmp) & 0x38) << 4) |
((((unsigned short) *bmp) & 0xc0) >> 3);
}
} else {
while (i--) {
bmp--;
*--bmpsh = ((((unsigned short) *bmp) & 7) << 13) |
((((unsigned short) *bmp) & 0x38) << 5) |
((((unsigned short) *bmp) & 0xc0) >> 3);
}
}
}
break;
case 3:
{
unsigned char *bmp = (void *) blitimage;
unsigned char *bmp3 = (void *) blitimage;
bmp += LOGO_WIDTH * LOGO_HEIGHT;
bmp3 += 3 * LOGO_WIDTH * LOGO_HEIGHT;
i = LOGO_WIDTH * LOGO_HEIGHT;
while (i--) {
bmp--;
*--bmp3 = ((((unsigned int) *bmp) & 7) << 5);
*--bmp3 = ((((unsigned int) *bmp) & 0x38) << 2);
*--bmp3 = ((((unsigned int) *bmp) & 0xc0));
}
}
break;
case 4:
{
unsigned char *bmp = (void *) blitimage;
unsigned int *bmpi = (void *) blitimage;
bmp += LOGO_WIDTH * LOGO_HEIGHT;
bmpi += LOGO_WIDTH * LOGO_HEIGHT;
i = LOGO_WIDTH * LOGO_HEIGHT;
if (modeinfo->flags & RGB_MISORDERED) {
while (i--) {
bmp--;
*--bmpi = ((((unsigned int) *bmp) & 7) << 29) |
((((unsigned int) *bmp) & 0x38) << 18) |
((((unsigned int) *bmp) & 0xc0) << 8);
}
} else {
while (i--) {
bmp--;
*--bmpi = ((((unsigned int) *bmp) & 7) << 21) |
((((unsigned int) *bmp) & 0x38) << 10) |
((((unsigned int) *bmp) & 0xc0));
}
}
}
break;
}
}
void testbit(vga_modeinfo * modeinfo)
{
clock_t clk;
unsigned long pels = 0, *blitimage;
int xmax, ymax, lw, i, x, y, dx, dy, nx, ny;
if ((modeinfo->bytesperpixel != 1) && (modeinfo->bytesperpixel != 2)) {
puts(" Has BitBlt, but no test code for this pixelwidth implemented.");
return;
}
ymax = vga_getydim();
xmax = vga_getxdim();
lw = modeinfo->linewidth;
if ((xmax < 210) || (ymax < 90)) {
puts(" Has BitBlt, but no test code for this small resolution implemented.");
return;
}
setcol(modeinfo);
vga_clear();
pels = 0;
blitimage = alloca(modeinfo->bytesperpixel * LOGO_WIDTH * LOGO_HEIGHT);
getlogo(blitimage, modeinfo);
if (modeinfo->bytesperpixel == 1) {
unsigned char *ptr = (void *) blitimage;
for (y = 1; y <= LOGO_HEIGHT; y++)
for (x = 1; x <= LOGO_WIDTH; x++) {
vga_setcolor((int) *ptr++);
vga_drawpixel(x, y);
}
} else {
unsigned short *ptr = (void *) blitimage;
for (y = 1; y <= LOGO_HEIGHT; y++)
for (x = 1; x <= LOGO_WIDTH; x++) {
vga_setcolor((int) *ptr++);
vga_drawpixel(x, y);
}
}
#ifdef BITFRAME
vga_setcolor(200);
vga_drawline(0, 0, 0, LOGO_HEIGHT + 1);
vga_drawline(0, 0, LOGO_WIDTH + 1, 0);
vga_drawline(LOGO_WIDTH + 1, 0, LOGO_WIDTH + 1, LOGO_HEIGHT + 1);
vga_drawline(0, LOGO_HEIGHT + 1, LOGO_WIDTH + 1, LOGO_HEIGHT + 1);
#endif
x = 0;
y = 0;
dx = 1;
dy = 1;
clk = clock();
for (i = 0; i < 10000; i++) {
nx = x + dx;
ny = y + dy;
if ((nx + LOGO_WIDTH + 2 > xmax) || (nx < 0)) {
dx = -dx;
nx = x + dx;
}
if ((ny + LOGO_HEIGHT + 2 > ymax) || (ny < 0)) {
dy = -dy;
ny = y + dy;
}
if (modeinfo->bytesperpixel == 2) {
vga_bitblt((x + y * (lw >> 1)) << 1,
(nx + ny * (lw >> 1)) << 1,
LOGO_WIDTH + 2, LOGO_HEIGHT + 2, lw);
} else {
vga_bitblt(x + y * lw, nx + ny * lw, LOGO_WIDTH + 2, LOGO_HEIGHT + 2, lw);
}
pels += (LOGO_WIDTH + 2) * (LOGO_HEIGHT + 2);
x = nx;
y = ny;
}
clk = clock() - clk;
printf(" Has BitBlt: %12lu Pixels in %.2f seconds -> %.2f Megapels\n",
pels, ((double) clk) / CLOCKS_PER_SEC, (pels / 1.0e6) / (((double) clk) / CLOCKS_PER_SEC));
my_wait();
}
void testimage(vga_modeinfo * modeinfo)
{
clock_t clk;
unsigned long pels = 0, *blitimage;
int xmax, ymax, lw, i, x, y;
if ((modeinfo->bytesperpixel < 1) || (modeinfo->bytesperpixel > 4)) {
puts(" Has ImageBlt, but no test code for this pixelwidth implemented.");
return;
}
ymax = vga_getydim();
xmax = vga_getxdim();
lw = modeinfo->linewidth;
if ((xmax < 210) || (ymax < 90)) {
puts(" Has ImageBlt, but no test code for this small resolution implemented.");
return;
}
/* Prepare a simple test pattern for testuse: */
switch (modeinfo->bytesperpixel) {
default:
{
/* 8bpp: */
register unsigned char *ptr, *pt_fish = fish_monster;
blitimage = alloca(fish_monster_w * fish_monster_h);
ptr = (unsigned char *) blitimage;
for (i = 0; i < (fish_monster_w * fish_monster_h); i++)
*ptr++ = fish_monster233[(*pt_fish++) - '`'];
}
break;
case 2:
{
register unsigned char *pt_fish = fish_monster;
register unsigned short *ptr, *coltab;
blitimage = alloca(sizeof(unsigned short) * fish_monster_w * fish_monster_h);
ptr = (unsigned short *) blitimage;
if (modeinfo->colors == 32768)
coltab = fish_monster555;
else
coltab = fish_monster565;
for (i = 0; i < (fish_monster_w * fish_monster_h); i++)
*ptr++ = coltab[(*pt_fish++) - '`'];
}
break;
case 3:
{
register unsigned char *pt_fish = fish_monster;
register unsigned char *ptr, *coltab;
blitimage = alloca(3 * fish_monster_w * fish_monster_h);
ptr = (unsigned char *) blitimage;
coltab = (unsigned char *) fish_monster888;
for (i = 0; i < (fish_monster_w * fish_monster_h); i++) {
*ptr++ = coltab[(((*pt_fish) - '`') << 2)];
*ptr++ = coltab[(((*pt_fish) - '`') << 2) + 1];
*ptr++ = coltab[(((*pt_fish++) - '`') << 2) + 2];
}
}
break;
case 4:
{
register unsigned char *pt_fish = fish_monster;
register unsigned int *ptr, *coltab;
blitimage = alloca(sizeof(unsigned int) * fish_monster_w * fish_monster_h);
ptr = (unsigned int *) blitimage;
coltab = fish_monster888;
if (modeinfo->flags & RGB_MISORDERED) {
for (i = 0; i < (fish_monster_w * fish_monster_h); i++)
*ptr++ = (coltab[(*pt_fish++) - '`'] << 8);
} else {
for (i = 0; i < (fish_monster_w * fish_monster_h); i++)
*ptr++ = coltab[(*pt_fish++) - '`'];
}
}
break;
}
setcol(modeinfo);
vga_clear();
srand(time(0));
for (i = 0; i < 10000; i++) {
x = rand() % (xmax - fish_monster_w);
y = rand() % (ymax - fish_monster_h);
if (modeinfo->bytesperpixel > 1)
x *= modeinfo->bytesperpixel;
vga_imageblt(blitimage, x + y * lw, fish_monster_w, fish_monster_h, lw);
pels += fish_monster_w * fish_monster_h;
}
pels = 0;
blitimage = alloca(modeinfo->bytesperpixel * LOGO_WIDTH * LOGO_HEIGHT);
getlogo(blitimage, modeinfo);
clk = clock();
for (i = 0; i < 1000; i++) {
x = rand() % (xmax - LOGO_WIDTH);
y = rand() % (ymax - LOGO_HEIGHT);
if (modeinfo->bytesperpixel > 1)
x *= modeinfo->bytesperpixel;
vga_imageblt(blitimage, x + y * lw, LOGO_WIDTH, LOGO_HEIGHT, lw);
pels += LOGO_WIDTH * LOGO_HEIGHT;
}
clk = clock() - clk;
printf(" Has ImageBlt: %10lu Pixels in %.2f seconds -> %.2f Megapels\n",
pels, ((double) clk) / CLOCKS_PER_SEC, (pels / 1.0e6) / (((double) clk) / CLOCKS_PER_SEC));
my_wait();
}
void hlinesquare(hlinelst * des, register int n)
{
register int *xmin, *xmax;
if (n < 1)
n = 1;
des->n = n;
des->width = n;
des->offset = 0;
des->pels = n * n;
xmin = (int *) ((char *) des + sizeof(hlinelst));
xmax = xmin + n;
while (n--) {
*xmin++ = 0;
*xmax++ = des->width - 1;
}
}
void hlinedisk(hlinelst * des, register int n)
{
register int *xmin, *xmax, radsq, rad, x;
if (!(n & 1))
n--;
if (n < 1)
n = 1;
des->n = n;
des->width = n;
des->offset = 0;
des->pels = n * n;
rad = (n >> 1);
radsq = rad * rad;
xmin = (int *) ((char *) des + sizeof(hlinelst));
xmax = xmin + n;
while (n--) {
x = sqrt(radsq - isqr(n - rad));
*xmin++ = rad - x;
*xmax++ = rad + x;
}
}
void hlinecaro(hlinelst * des, register int n)
{
register int *xmin, *xmax, i, j;
if (!(n & 1))
n--;
if (n < 1)
n = 1;
des->n = n;
des->width = n;
des->offset = 0;
des->pels = (n * n) / 2;
xmin = (int *) ((char *) des + sizeof(hlinelst));
xmax = xmin + n;
i = 1 + (n >> 1);
j = 0;
while (i--) {
*xmin++ = (n >> 1) - j;
*xmax++ = (n >> 1) + j;
j++;
}
i = (n >> 1);
j -= 2;
while (i--) {
*xmin++ = (n >> 1) - j;
*xmax++ = (n >> 1) + j;
j--;
}
}
void testhline(vga_modeinfo * modeinfo)
{
#define SHAPES 9
clock_t clk;
unsigned long pels = 0;
hlinelst *shape[SHAPES], *curs;
int xmax, ymax, lw, i, x, y, mask;
setcol(modeinfo);
vga_clear();
ymax = vga_getydim();
xmax = vga_getxdim();
lw = modeinfo->linewidth;
mask = modeinfo->colors - 1;
srand(time(0));
i = 0;
shape[i] = alloca(sizhlilst(ymax / 2));
hlinesquare(shape[i++], ymax / 2);
shape[i] = alloca(sizhlilst(ymax / 4));
hlinesquare(shape[i++], ymax / 4);
shape[i] = alloca(sizhlilst(ymax / 8));
hlinesquare(shape[i++], ymax / 8);
shape[i] = alloca(sizhlilst(ymax / 2));
hlinecaro(shape[i++], ymax / 2);
shape[i] = alloca(sizhlilst(ymax / 4));
hlinecaro(shape[i++], ymax / 4);
shape[i] = alloca(sizhlilst(ymax / 8));
hlinecaro(shape[i++], ymax / 8);
shape[i] = alloca(sizhlilst(ymax / 2));
hlinedisk(shape[i++], ymax / 2);
shape[i] = alloca(sizhlilst(ymax / 4));
hlinedisk(shape[i++], ymax / 4);
shape[i] = alloca(sizhlilst(ymax / 8));
hlinedisk(shape[i++], ymax / 8);
clk = clock();
for (i = 0; i < 1000; i++) {
curs = shape[rand() % SHAPES];
x = rand() % (xmax - (curs->width));
y = rand() % (ymax - (curs->n));
adj_hlilst(curs, x);
pels += curs->pels;
vga_hlinelistblt(y, curs->n,
(int *) (((char *) curs) + sizeof(hlinelst)),
(int *) (((char *) curs) + sizeof(hlinelst) + (curs->n) * sizeof(int)),
lw, mask & rand());
}
clk = clock() - clk;
clk++;
printf(" Has HlineLst: %10lu Pixels in %.2f seconds -> %.2f Megapels\n",
pels, ((double) clk) / CLOCKS_PER_SEC, (pels / 1.0e6) / (((double) clk) / CLOCKS_PER_SEC));
my_wait();
}
void testmode(int mode)
{
vga_modeinfo *modeinfo;
printf("Testing mode %2d: %s...", mode, vga_getmodename(mode));
if (!vga_hasmode(mode)) {
puts(" not available");
return;
}
puts("");
vga_setmode(mode);
modeinfo = vga_getmodeinfo(mode);
if ((modeinfo->colors == 256) && !(modeinfo->flags & IS_MODEX)) {
testwidth(mode, modeinfo);
} else
puts(" Dacwidth test not applicable.");
if (modeinfo->haveblit & HAVE_BITBLIT)
testbit(modeinfo);
if (modeinfo->haveblit & HAVE_FILLBLIT)
testfill(modeinfo);
if (modeinfo->haveblit & HAVE_IMAGEBLIT)
testimage(modeinfo);
if (modeinfo->haveblit & HAVE_HLINELISTBLIT)
testhline(modeinfo);
vga_setmode(TEXT);
}
void usage(void)
{
puts("Usage: testaccel [-nowait] {all|[mode [mode [mode...]]]}\n"
"\ttests accelerated features and extended options in\n"
"\tall or the given modes.\n"
"\tAll standard svgalib ways of writing modenames are understood.\n"
"\tIf no parameters are given the defaultmode or G640x480x256 is\n"
"\tused.\n"
"\tIf -nowait is given, don't wait for a keypress after each test.");
exit(2);
}
int main(int argc, char *argv[])
{
int mode;
vga_init();
puts(
"Note: Timings include main cpu calculations (random numbers and such\n"
" things). Thus they are esp. for lower resolutions much too slow!");
if ((argc > 1) && !strcmp(argv[1], "-nowait")) {
argc--;
argv++;
waitmode = 0;
}
if ((argc == 2) && !strcmp(argv[1], "all")) {
int flag = 0;
for (mode = 1; mode <= GLASTMODE; mode++)
if (vga_hasmode(mode)) {
flag = 1;
testmode(mode);
}
if (!flag)
puts("testaccel: Not any graphicsmode available!");
} else if (argc > 1) {
for (mode = 1; mode < argc; mode++)
if (vga_getmodenumber(argv[mode]) < 0) {
printf("testaccel: Parameter %s is not a valid graphicsmode.\n", argv[mode]);
usage();
}
for (mode = 1; mode < argc; mode++)
testmode(vga_getmodenumber(argv[mode]));
} else {
mode = vga_getdefaultmode();
if (mode < 0)
mode = G640x480x256;
if (vga_hasmode(mode))
testmode(mode);
else
puts("testaccel: could not set defaultmode or G640x480x256!");
}
return 0;
}

230
demos/testgl.c Normal file
View file

@ -0,0 +1,230 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <vga.h>
#include <vgagl.h>
/* The logo was drawn by John Remyn. */
/* Feel free to provide a more beautiful/official/thought provoking/cool */
/* logo to replace it. */
#define LOGOWIDTH 201
#define LOGOHEIGHT 85
int VGAMODE;
int VIRTUAL;
int timescale=1;
GraphicsContext *backscreen;
GraphicsContext *physicalscreen;
void *logobitmap;
void loadbitmap(char *filename, void *buf)
{
FILE *f;
f = fopen(filename, "rb");
if(f==NULL)return;
fread(buf, 1, 17085, f);
fclose(f);
}
void test(void)
{
int i, j;
unsigned char *bitmap;
GraphicsContext *savedcontext;
if (VIRTUAL)
gl_setcontext(backscreen);
gl_clearscreen(0);
for (i = 0; i < 5; i++) {
gl_clearscreen(0);
for (j = 0; j < 20000*timescale; j++)
gl_setpixel(random() % WIDTH, random() % HEIGHT,
random() % COLORS);
}
if (VIRTUAL)
gl_copyscreen(physicalscreen);
gl_clearscreen(0);
for (i = 0; i < 5000*timescale; i++) {
int x, y;
x = random() % (WIDTH - 1);
y = random() % (HEIGHT - 1);
gl_fillbox(x, y, random() % (WIDTH - x), random()
% (HEIGHT - y), random() % COLORS);
}
if (VIRTUAL)
gl_copyscreen(physicalscreen);
gl_clearscreen(0);
for (i = 0; i < 4000*timescale; i++)
gl_line(random() % WIDTH, random() % HEIGHT,
random() % WIDTH, random() % HEIGHT,
random() % COLORS);
if (VIRTUAL)
gl_copyscreen(physicalscreen);
/* Create bitmap. */
bitmap = malloc(64 * 64 * BYTESPERPIXEL);
/* Create temporary graphics context to create bitmap in. */
savedcontext = gl_allocatecontext();
gl_getcontext(savedcontext);
gl_setcontextvirtual(64, 64, BYTESPERPIXEL, BITSPERPIXEL, bitmap);
/* The rgb functions can be used to create nice bitmaps easily for */
/* hicolor/truecolor modes. The 256 color 'emulated' truecolor */
/* looks less impressive. */
for (i = 0; i < 32; i++)
for (j = 0; j < 32; j++) {
int c;
c = 255 - (i + j) * 4;
gl_setpixelrgb(31 - i, 31 - j, c, 0, 0);
gl_setpixelrgb(32 + i, 31 - j, c, c, 0);
gl_setpixelrgb(31 - i, 32 + j, c, 0, c);
gl_setpixelrgb(32 + i, 32 + j, c, c, c);
}
/* Restore previous context. */
gl_setcontext(savedcontext);
gl_clearscreen(0);
for (i = 0; i < 4000*timescale; i++) {
int x, y;
x = random() % (WIDTH - 64 + 1);
y = random() % (HEIGHT - 64 + 1);
gl_putbox(x, y, 64, 64, bitmap);
}
free(bitmap);
if (VIRTUAL)
gl_copyscreen(physicalscreen);
}
void setcustompalette(void)
{
/* colors 0-31 are an RGB mix (bits 0 and 1 red, 2 green, 3 and 4 blue) */
/* 32-63 black to red */
/* 64-95 black to green */
/* 96-127 black to yellow */
/* 128-159 black to blue */
/* 160-191 black to magenta */
/* 192-223 black to cyan */
/* 224-255 black to white */
Palette pal;
int i;
for (i = 0; i < 256; i++) {
int r, g, b;
r = g = b = 0;
if ((i & 32) > 0)
r = (i & 31) << 1;
if ((i & 64) > 0)
g = (i & 31) << 1;
if ((i & 128) > 0)
b = (i & 31) << 1;
if (i < 32) {
r = (i & 3) << 4; /* 2 bits */
g = (i & 4) << 3; /* 1 bit */
b = (i & 24) << 1; /* 2 bits */
}
pal.color[i].red = r;
pal.color[i].green = g;
pal.color[i].blue = b;
}
gl_setpalette(&pal);
}
void logotest(void)
{
int h;
void *scaled;
/* Set logo palette. */
setcustompalette();
/* Create logo bitmap */
logobitmap = alloca(LOGOWIDTH * LOGOHEIGHT);
loadbitmap("linuxlogo.bitmap", logobitmap);
/* Allocate buffer for scaled bitmap. */
scaled = alloca(WIDTH * HEIGHT);
gl_clearscreen(0);
/* Stretch vertically. */
for (h = 0; h <= LOGOHEIGHT; h++) {
gl_scalebox(LOGOWIDTH, LOGOHEIGHT, logobitmap,
LOGOWIDTH, h, scaled);
gl_putbox(0, 0, LOGOWIDTH, h, scaled);
if (VIRTUAL)
gl_copyscreen(physicalscreen);
usleep(10000);
}
gl_clearscreen(0);
/* Scale to screen resolution. */
gl_scalebox(LOGOWIDTH, LOGOHEIGHT, logobitmap, WIDTH, HEIGHT, scaled);
gl_putbox(0, 0, WIDTH, HEIGHT, scaled);
gl_copyscreen(physicalscreen);
}
int main(int argc, char *argv[])
{
vga_init();
if(argc>=2) {
timescale=atoi(argv[1]);
if(timescale<1)timescale=1;
}
VGAMODE = vga_getdefaultmode();
if (VGAMODE == -1)
VGAMODE = G320x200x256; /* Default mode. */
if (!vga_hasmode(VGAMODE)) {
printf("Mode not available.\n");
exit(-1);
}
VIRTUAL = 0; /* No virtual screen. */
if (vga_getmodeinfo(VGAMODE)->colors == 16 ||
(vga_getmodeinfo(VGAMODE)->flags & IS_MODEX))
/* These modes are supported indirectly by vgagl. */
VIRTUAL = 1;
if (VIRTUAL) {
/* Create virtual screen. */
gl_setcontextvgavirtual(VGAMODE);
backscreen = gl_allocatecontext();
gl_getcontext(backscreen);
}
vga_setmode(VGAMODE);
gl_setcontextvga(VGAMODE); /* Physical screen context. */
physicalscreen = gl_allocatecontext();
gl_getcontext(physicalscreen);
if (COLORS == 256)
gl_setrgbpalette();
if(argc==3)sleep(2);
test();
/* Now do the same with clipping enabled. */
gl_clearscreen(0);
gl_setclippingwindow(WIDTH / 4, HEIGHT / 4, WIDTH - WIDTH / 4 - 1,
HEIGHT - HEIGHT / 4 - 1);
test();
gl_disableclipping();
if (COLORS == 256)
/* Show the logo if using 256 color mode. */
logotest();
getchar();
if (VIRTUAL)
gl_freecontext(backscreen);
vga_setmode(TEXT);
exit(0);
}

124
demos/testlinear.c Normal file
View file

@ -0,0 +1,124 @@
/*
Simple test program for Cirrus linear addressing/color expansion.
vgagl can take advantage of it (linear addressing).
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vga.h>
#include <time.h>
#include "../src/libvga.h"
#define USE_LINEAR_ADDRESSING
/* #define USE_BY16_ADDRESSING */
unsigned char *vbuf;
#if 0
/* This function is Cirrus specific and has nothing to do with linear
* addressing. */
void by8test(void)
{
int i;
int startclock, diffclock;
/* Enable extended write modes and BY8/16 addressing. */
outb(0x3ce, 0x0b);
#ifdef USE_BY16_ADDRESSING
outb(0x3cf, inb(0x3cf) | 0x16);
#else
outb(0x3cf, inb(0x3cf) | 0x06);
#endif
/* Set extended write mode 4. */
outb(0x3ce, 0x05);
outb(0x3cf, (inb(0x3cf) & 0xf8) | 4);
/* Set pixel mask register (coincides with VGA plane mask register). */
outw(0x3c4, 0xff02);
startclock = clock();
for (i = 0; i < 248; i++) {
outw(0x3ce, 0x01 + (i << 8)); /* Set foreground color. */
#ifdef USE_BY16_ADDRESSING
outw(0x3ce, 0x11 + (i << 8)); /* Set high byte. */
memset(vbuf, 0xff, 640 * 480 / 16);
#else
memset(vbuf, 0xff, 640 * 480 / 8);
#endif
}
diffclock = clock() - startclock;
printf("Color expansion framebuffer fill speed: %dK/s\n",
640 * 480 * 248 / diffclock / 10);
}
#endif
int main(int argc, char *argv[])
{
int i,j;
if (!(argc == 2 && strcmp(argv[1], "--force") == 0))
if (!(vga_getmodeinfo(vga_getdefaultmode())->flags & CAPABLE_LINEAR)) {
printf("Linear addressing not supported for this chipset.\n");
exit(1);
}
vga_init();
vga_setmode(vga_getdefaultmode());
vga_setpage(0);
#ifdef USE_LINEAR_ADDRESSING
if (vga_setlinearaddressing() == -1) {
vga_setmode(TEXT);
printf("Could not set linear addressing.\n");
exit(-1);
}
#endif
/* Should not mess with bank register after this. */
vbuf = vga_getgraphmem();
printf("vbuf mapped at %08lx.\n", (unsigned long) vbuf);
getchar();
#ifdef USE_LINEAR_ADDRESSING
memset(vbuf, 0x88, 640 * 480);
sleep(1);
memset(vbuf, 0, 640 * 480);
for (i = 0; i < 100000; i++)
*(vbuf + (rand() & 0xfffff)) = rand();
#endif
#if 0
if (vga_getcurrentchipset() == CIRRUS)
/* Show the bandwidth of the extended write modes of the */
/* Cirrus chip. */
by8test();
#endif
getchar();
for(i = 0;i < 44;i++){
*(vbuf + i) = 0x1c;
*(vbuf + 640*17 + i) = 0x1c;
*(vbuf + 640*480 - i) = 0x1c;
*(vbuf + 640*480 - 1 - 640*17 - i) = 0x1c;
for(j = 1;j < 17;j++){
*(vbuf + 640*j + i) = (i == 0 || i == 43)? 0x1c:0;
*(vbuf + 640*480 - 1 - 640*j - i) = (i == 0 || i == 43)? 0x1c:0;
}
}
for(i = 3;i < 10;i++)
for(j = 4;j < 10;j++){
*(vbuf + i + 640*j) = 0x3f;
*(vbuf + 640*480 -1 -640*j - i) = 0x3f;
}
getchar();
vga_setmode(TEXT);
return 0;
}

294
demos/vgatest.c Normal file
View file

@ -0,0 +1,294 @@
/* From VGAlib, changed for svgalib */
/* partially copyrighted (C) 1993 by Hartmut Schirmer */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> /* for usleep( long ) */
#include <string.h>
#include "vga.h"
static unsigned char line[2048 * 3];
static void
drawSquares(int const xmax, int const ymax)
{
unsigned int const center_x = xmax/2;
/* The column just to the left of the center (assuming
even number of columns)
*/
unsigned int const center_y = ymax/2;
/* The line just above the center (assuming
even number of lines)
*/
int x;
for (x = 0; x < 64; x++) {
int y;
for (y = 0; y < 64; y++) {
/* Top 3 squares */
vga_setrgbcolor(x * 4 + 3, y * 4 + 3, 0);
vga_drawpixel(center_x - 32 - 32 - 64 + x, center_y - 80 + y);
vga_setrgbcolor(x * 4 + 3, 0, y * 4 + 3);
vga_drawpixel(center_x - 32 + x, center_y - 80 + y);
vga_setrgbcolor(0, x * 4 + 3, y * 4 + 3);
vga_drawpixel(center_x + 32 + 32 + x, center_y - 80 + y);
/* Bottom 3 squares */
vga_setrgbcolor(x * 4 + 3, y * 4 + 3, 255);
vga_drawpixel(center_x - 32 - 32 - 64 + x, center_y + 16 + y);
vga_setrgbcolor(x * 4 + 3, 255, y * 4 + 3);
vga_drawpixel(center_x - 32 + x, center_y + 16 + y);
vga_setrgbcolor(255, x * 4 + 3, y * 4 + 3);
vga_drawpixel(center_x + 32 + 32 + x, center_y + 16 + y);
}
}
}
static void testmode(int mode)
{
int xmax, ymax, i, x, y, yw, ys, c;
vga_modeinfo *modeinfo;
vga_setmode(mode);
modeinfo = vga_getmodeinfo(mode);
printf("Width: %d Height: %d Colors: %d\n",
modeinfo->width,
modeinfo->height,
modeinfo->colors);
printf("DisplayStartRange: %xh Maxpixels: %d Blit: %s\n",
modeinfo->startaddressrange,
modeinfo->maxpixels,
modeinfo->haveblit ? "YES" : "NO");
#ifdef TEST_MODEX
if (modeinfo->colors == 256)
printf("Switching to ModeX ... %s\n",
(vga_setmodeX()? "done" : "failed"));
#endif
vga_screenoff();
xmax = vga_getxdim() - 1;
ymax = vga_getydim() - 1;
vga_setcolor(vga_white());
vga_drawline(0, 0, xmax, 0);
vga_drawline(xmax, 0, xmax, ymax);
vga_drawline(xmax, ymax, 0, ymax);
vga_drawline(0, ymax, 0, 0);
/* Draw crosses */
for (i = 0; i <= 15; i++) {
vga_setegacolor(i);
vga_drawline(10 + i * 5, 10, 89 + i * 5, 89);
}
for (i = 0; i <= 15; i++) {
vga_setegacolor(i);
vga_drawline(89 + i * 5, 10, 10 + i * 5, 89);
}
vga_screenon();
ys = 100;
yw = (ymax - 100) / 4;
switch (vga_getcolors()) {
case 256:
/* Draw horizontal color bands using palette */
for (i = 0; i < 60; ++i) {
c = (i * 64) / 60;
vga_setpalette(i + 16, c, c, c);
vga_setpalette(i + 16 + 60, c, 0, 0);
vga_setpalette(i + 16 + (2 * 60), 0, c, 0);
vga_setpalette(i + 16 + (3 * 60), 0, 0, c);
}
line[0] = line[xmax] = 15;
line[1] = line[xmax - 1] = 0;
for (x = 2; x < xmax - 1; ++x)
line[x] = (((x - 2) * 60) / (xmax - 3)) + 16;
for (y = ys; y < ys + yw; ++y) /* gray */
vga_drawscanline(y, line);
for (x = 2; x < xmax - 1; ++x)
line[x] += 60;
ys += yw;
for (y = ys; y < ys + yw; ++y) /* red */
vga_drawscanline(y, line);
for (x = 2; x < xmax - 1; ++x)
line[x] += 60;
ys += yw;
for (y = ys; y < ys + yw; ++y) /* green */
vga_drawscanline(y, line);
for (x = 2; x < xmax - 1; ++x)
line[x] += 60;
ys += yw;
for (y = ys; y < ys + yw; ++y) /* blue */
vga_drawscanline(y, line);
break;
case 1 << 15:
case 1 << 16:
case 1 << 24:
/* Draw horizontal color bands in RGB */
for (x = 2; x < xmax - 1; ++x) {
c = ((x - 2) * 255) / (xmax - 4);
y = ys;
vga_setrgbcolor(c, c, c);
vga_drawline(x, y, x, y + yw - 1);
y += yw;
vga_setrgbcolor(c, 0, 0);
vga_drawline(x, y, x, y + yw - 1);
y += yw;
vga_setrgbcolor(0, c, 0);
vga_drawline(x, y, x, y + yw - 1);
y += yw;
vga_setrgbcolor(0, 0, c);
vga_drawline(x, y, x, y + yw - 1);
}
drawSquares(xmax, ymax);
break;
default:
/* Draw vertical color bars */
if (vga_getcolors() == 16) {
for (i = 0; i < xmax - 1; i++)
line[i] = (i + 2) % 16;
line[0] = line[xmax] = 15;
line[1] = line[xmax - 1] = 0;
}
if (vga_getcolors() == 2) {
for (i = 0; i <= xmax; i++)
line[i] = 0x11;
line[0] = 0x91;
}
for (i = 100; i < ymax - 1; i++)
vga_drawscanline(i, line);
break;
}
if (getchar() == 'd')
vga_dumpregs();
}
int main(int argc, char *argv[])
{
int mode, mode2;
int i, high;
vga_init(); /* Initialize. */
mode = -1;
mode2= -1;
if(argc==2) {
mode = atoi(argv[1]);
} else if(argc==3) {
mode = atoi(argv[1]);
mode2= atoi(argv[2]);
}
if (mode == -1) {
printf("Choose one of the following video modes: \n");
high = 0;
for (i = 1; i <= vga_lastmodenumber(); i++)
if (vga_hasmode(i)) {
vga_modeinfo *info;
char expl[100];
const char *cols = NULL;
*expl = '\0';
info = vga_getmodeinfo(i);
switch (info->colors) {
case 2:
cols = "2";
strcpy(expl, "1 bitplane, monochrome");
break;
case 16:
cols = "16";
strcpy(expl, "4 bitplanes");
break;
case 256:
if (i == G320x200x256)
strcpy(expl, "packed-pixel");
else if (i == G320x240x256
|| i == G320x400x256
|| i == G360x480x256)
strcpy(expl, "Mode X");
else
strcpy(expl,
"packed-pixel, banked");
break;
case 1 << 15:
cols = "32K";
strcpy(expl, "5-5-5 RGB, blue at LSB, banked");
break;
case 1 << 16:
cols = "64K";
strcpy(expl, "5-6-5 RGB, blue at LSB, banked");
break;
case 1 << 24:
cols = "16M";
if (info->bytesperpixel == 3) {
if (info->flags & RGB_MISORDERED)
strcpy(expl, "8-8-8 BGR, red byte first, banked");
else
strcpy(expl, "8-8-8 RGB, blue byte first, banked");
} else if (info->flags & RGB_MISORDERED)
strcpy(expl, "8-8-8 RGBX, 32-bit pixels, X byte first, banked");
else
strcpy(expl, "8-8-8 XRGB, 32-bit pixels, blue byte first, banked");
break;
}
if (info->flags & IS_INTERLACED) {
if (*expl != '\0')
strcat(expl, ", ");
strcat(expl, "interlaced");
}
if (info->flags & IS_DYNAMICMODE) {
if (*expl != '\0')
strcat(expl, ", ");
strcat(expl, "dynamically loaded");
}
high = i;
printf("%5d: %dx%d, ",
i, info->width, info->height);
if (cols == NULL)
printf("%d", info->colors);
else
printf("%s", cols);
printf(" colors ");
if (*expl != '\0')
printf("(%s)", expl);
printf("\n");
}
printf("Enter mode number (1-%d): ", high);
scanf("%d", &mode);
getchar();
printf("\n");
if (mode < 1 || mode > GLASTMODE) {
printf("Error: Mode number out of range \n");
exit(-1);
}
}
if (vga_hasmode(mode)) {
testmode(mode);
if(mode2!=-1 && vga_hasmode(mode2)) {
testmode(mode2);
}
} else {
printf("Error: Video mode not supported by driver\n");
exit(-1);
}
vga_setmode(TEXT);
return 0;
}

131
demos/vgatweak.c Normal file
View file

@ -0,0 +1,131 @@
/* From VGAlib, changed for svgalib */
/* partially copyrighted (C) 1993 by Hartmut Schirmer */
#include <stdio.h>
#include <unistd.h> /* for usleep( long ) */
#include <string.h>
#include "vga.h"
static unsigned char line[2048 * 3];
static void testmode(int mode)
{
int xmax, ymax, i, yw, ys;
unsigned char buf[60];
vga_modeinfo *modeinfo;
vga_setmode(mode);
modeinfo = vga_getmodeinfo(mode);
printf("Width: %d Height: %d Colors: %d\n",
modeinfo->width,
modeinfo->height,
modeinfo->colors);
printf("DisplayStartRange: %xh Maxpixels: %d Blit: %s\n",
modeinfo->startaddressrange,
modeinfo->maxpixels,
modeinfo->haveblit ? "YES" : "NO");
vga_screenoff();
xmax = vga_getxdim() - 1;
ymax = vga_getydim() - 1;
vga_setcolor(vga_white());
vga_drawline(0, 0, xmax, 0);
vga_drawline(xmax, 0, xmax, ymax);
vga_drawline(xmax, ymax, 0, ymax);
vga_drawline(0, ymax, 0, 0);
for (i = 0; i <= 15; i++) {
vga_setegacolor(i);
vga_drawline(10 + i * 5, 10, 90 + i * 5, 90);
}
for (i = 0; i <= 15; i++) {
vga_setegacolor(i);
vga_drawline(90 + i * 5, 10, 10 + i * 5, 90);
}
vga_screenon();
ys = 100;
yw = (ymax - 100) / 4;
for (i = 0; i < xmax - 1; i++)
line[i] = (i + 2) % 16;
line[0] = line[xmax] = 15;
line[1] = line[xmax - 1] = 0;
for (i = 100; i < ymax - 1; i++)
vga_drawscanline(i, line);
if (getchar() == 'd')
vga_dumpregs();
vga_getcrtcregs(buf);
buf[0]=0x4d;
buf[1]=0x3f;
buf[2]=0x3f;
buf[3]=0x80;
buf[4]=0x41;
buf[5]=0x10;
vga_setcrtcregs(buf);
for(i=0;i<20;i++) {
vga_setdisplaystart(i);
usleep(200000);
vga_waitretrace();
}
vga_getch();
vga_setmode(TEXT);
}
int main(void)
{
int mode;
int i, high;
vga_init(); /* Initialize. */
mode = 4;
if (mode == -1) {
printf("Choose one of the following video modes: \n");
high = 0;
for (i = 1; i <= vga_lastmodenumber(); i++)
if (vga_hasmode(i)) {
vga_modeinfo *info;
char expl[100];
char *cols = NULL;
*expl = '\0';
info = vga_getmodeinfo(i);
cols = "16";
strcpy(expl, "4 bitplanes");
high = i;
printf("%5d: %dx%d, ",
i, info->width, info->height);
if (cols == NULL)
printf("%d", info->colors);
else
printf("%s", cols);
printf(" colors ");
if (*expl != '\0')
printf("(%s)", expl);
printf("\n");
}
}
if (vga_hasmode(mode))
testmode(mode);
else {
printf("Error: Video mode not supported by driver\n");
exit(-1);
}
return 0;
}

45
demos/wizard.xbm Normal file
View file

@ -0,0 +1,45 @@
#define wizard_width 67
#define wizard_height 55
static unsigned char wizard_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc0, 0xff, 0x07, 0x00, 0x80, 0x7f, 0x00, 0x00, 0x00, 0xe0,
0xff, 0x07, 0x00, 0x40, 0x80, 0x00, 0x00, 0x00, 0xf0, 0xfd, 0x0f, 0x00,
0xa0, 0x24, 0x01, 0x00, 0x00, 0x78, 0xfc, 0x1f, 0x00, 0xd0, 0xb2, 0x01,
0x00, 0x00, 0x18, 0xf8, 0x3f, 0x00, 0xc8, 0x9a, 0x00, 0x00, 0x00, 0x08,
0xae, 0x3f, 0x00, 0x64, 0xfd, 0x00, 0x00, 0x00, 0x80, 0xff, 0x3f, 0x00,
0xf8, 0xbf, 0x00, 0x00, 0x00, 0x40, 0xff, 0x9f, 0x1f, 0x20, 0xfe, 0x00,
0x00, 0x80, 0xff, 0x00, 0xe0, 0x67, 0x20, 0x9c, 0x00, 0x00, 0xe0, 0xe0,
0xff, 0xff, 0x80, 0x30, 0x4c, 0x00, 0x00, 0xd0, 0x87, 0xff, 0x07, 0x3e,
0x39, 0x44, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x80, 0xff, 0x38, 0x23, 0x00,
0x00, 0xf8, 0xff, 0x00, 0xf0, 0xff, 0x9c, 0x11, 0x00, 0x00, 0xe0, 0xff,
0xff, 0xff, 0x3f, 0xdc, 0x08, 0x00, 0x00, 0x00, 0x3c, 0xdb, 0xe4, 0x0e,
0xde, 0x04, 0x00, 0x00, 0x00, 0x7f, 0x8c, 0x71, 0xfe, 0xdf, 0x0c, 0x00,
0x00, 0xf0, 0xf7, 0x87, 0xbf, 0xfd, 0xee, 0x0c, 0x00, 0x00, 0xf8, 0xfb,
0xcf, 0x3f, 0xfb, 0xee, 0x0e, 0x00, 0x00, 0xff, 0xaf, 0x7b, 0x07, 0x3e,
0xd5, 0x1f, 0x00, 0xe0, 0x80, 0x57, 0xfd, 0x14, 0xae, 0xe7, 0x1e, 0x00,
0x10, 0x0b, 0x3e, 0x74, 0x05, 0x9d, 0xcd, 0x1f, 0x00, 0xc8, 0x00, 0x5c,
0x04, 0x81, 0x1f, 0x87, 0x1e, 0x00, 0x6c, 0x60, 0x18, 0x00, 0x00, 0x6e,
0xf0, 0x1f, 0x00, 0x74, 0x30, 0x72, 0x01, 0x80, 0xbf, 0xec, 0x1e, 0x00,
0x74, 0x00, 0x33, 0x00, 0x10, 0xff, 0xff, 0x1f, 0x00, 0xf6, 0x80, 0xb1,
0x05, 0xa0, 0xff, 0xff, 0x1e, 0x00, 0xf6, 0xf8, 0xf9, 0x80, 0xe8, 0xff,
0xff, 0x0f, 0x00, 0x66, 0x77, 0x7d, 0x13, 0xca, 0xff, 0x7f, 0x0f, 0x00,
0x7e, 0x37, 0xfb, 0xbb, 0xde, 0xff, 0xff, 0x0f, 0x00, 0x76, 0x32, 0xfd,
0xbf, 0xff, 0xff, 0xbd, 0x07, 0x00, 0x46, 0x92, 0xfe, 0xff, 0xff, 0xff,
0xbf, 0x07, 0x00, 0x3e, 0xe4, 0xfb, 0xff, 0xff, 0xff, 0xfd, 0x03, 0x00,
0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0x03, 0x00, 0xfc, 0xef, 0xfb,
0xff, 0xef, 0xff, 0xfb, 0x03, 0x00, 0xfc, 0xef, 0xff, 0xff, 0xff, 0x7f,
0xb7, 0x01, 0x00, 0xf8, 0x6f, 0xff, 0xfd, 0xff, 0xfe, 0x1f, 0x00, 0x00,
0xf8, 0x6f, 0xff, 0xff, 0xef, 0xff, 0x02, 0x00, 0x00, 0xf8, 0xbf, 0xff,
0xfd, 0xff, 0xfb, 0x07, 0x00, 0x00, 0xf0, 0x97, 0xff, 0xff, 0xdf, 0xef,
0x1f, 0x00, 0x00, 0xe0, 0xe3, 0xf7, 0xde, 0xff, 0xff, 0x3f, 0x00, 0x00,
0x00, 0xf8, 0xdf, 0xff, 0xff, 0xdf, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff,
0xff, 0xef, 0xff, 0xff, 0x03, 0x00, 0xe0, 0x1f, 0xf8, 0xdf, 0xff, 0x7d,
0xc0, 0x07, 0x00, 0xf0, 0x4f, 0xf4, 0xef, 0xf7, 0x9b, 0x90, 0x00, 0x00,
0x00, 0x83, 0xef, 0xff, 0xfd, 0xef, 0x0b, 0x01, 0x00, 0x00, 0xd5, 0x80,
0xff, 0xff, 0x00, 0x5e, 0x03, 0x00, 0x80, 0x38, 0x00, 0x78, 0x00, 0x00,
0x70, 0x04, 0x00, 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x04, 0x00,
0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00};

45
demos/wizardmsk.xbm Normal file
View file

@ -0,0 +1,45 @@
#define wizardmsk_width 67
#define wizardmsk_height 55
static unsigned char wizardmsk_bits[] = {
0x00, 0x00, 0xc0, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
0xff, 0x0f, 0x00, 0xc0, 0xff, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x1f, 0x00,
0xe0, 0xff, 0x01, 0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0xf0, 0xff, 0x03,
0x00, 0x00, 0xfc, 0xff, 0x3f, 0x00, 0xf8, 0xff, 0x03, 0x00, 0x00, 0xfe,
0xff, 0x7f, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00,
0xfe, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0x03,
0x00, 0x00, 0xff, 0xff, 0xff, 0xbf, 0xff, 0xff, 0x03, 0x00, 0xc0, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0x03, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03,
0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0xfe, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0x03, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03,
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff,
0xff, 0x7f, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00,
0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0xf8, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x3f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x1f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x07, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0xfc, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x3f, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0xfc, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x3f, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
0xf0, 0xff, 0xc1, 0xff, 0xff, 0x01, 0xff, 0x1f, 0x00, 0xe0, 0x7f, 0x00,
0xfc, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00};

255
doc/0-INSTALL Normal file
View file

@ -0,0 +1,255 @@
Installation of Svgalib v1.2.12 or higher.
Table of contents:
0. Introduction
1. Directories
2. Installation
3. SVGALib port to ALPHA AXP hardware
0. Introduction
This is a low level graphics library for Linux, based on VGAlib 1.2 by
Tommy Frandsen. VGAlib supported a number of standard VGA graphics
modes, as well as Tseng ET4000 high resolution 256-color modes.
Nowadays support for even more hardware is given. For details on
supported chipsets, see the file 0-README which is equal to man 7
svgalib (when svgalib is installed).
It supports transparent virtual console switching, that is, you can
switch consoles to and from text and graphics mode consoles using
alt-[function key]. Also, svgalib corrects most of VGAlib's textmode
corruption behaviour by catching SIGSEGV, SIGFPE and SIGILL, and
ensuring that a program is running in the currently visible virtual
console before setting a graphics mode. Svgalib uses SIGUSR1 and SIGUSR2
internally to do so.
When the library is first used by a program at run-time, the chipset is
detected and the appropriate driver is used. This means that a graphics
program will work on any card that is supported by svgalib, if the mode
it uses is supported by the chipset driver for that card. The library
is upwardly compatible with VGAlib.
The set of drawing functions provided by svgalib itself is limited
(mostly unchanged from VGAlib) and unoptimized; you can however use
vga_setpage and graph_mem (which points to the 64K VGA framebuffer) in
a program or graphics library. A fast external framebuffer graphics
library for linear and banked 1, 2, 3 and 4 bytes per pixel modes is
included (it also indirectly supports planar VGA modes). See 'man 7
vgagl' for details.
One obvious application of the library is a picture viewer. Several are
available, along with animation viewers. See the references at the end
of 0-README.
I have added a simple VGA textmode font restoration utility
(restorefont) which may help if you suffer from XFree86 textmode font
corruption. It can also be used to change the textmode font. It's in
the utils/ directory, along with a README and some other textmode
utilities: restoretextmode (which saves/restores textmode registers),
restorepalette, and the script textmode. If you run the savetextmode
script to save textmode information to /tmp, you'll be able to restore
textmode by running the textmode script.
If you have an ET4000 card, you should read the 0-README in the et4000/
directory. You will probably want to replace the ET4000 registers.
1. Directories
doc/ README's and man pages. See the 0-README in this
directory for info on how to read these man pages
without installing svgalib and how to produce nice
printouts.
demos/ Demo and test programs.
utils/ Textmode/font utilities.
src/ Main library source.
src/mouse/ Source for mouse interface.
src/keyboard/ Source for keyboard interface.
gl/ External framebuffer graphics library sources.
support/ DOS-based utility for dumping VGA registers.
et4000/ Notes, utilities and sample registers for ET4000.
mach32/ Notes and a utility for the ATI mach32 driver.
jump/ Configuration files for building DLL shared library.
sharedlib/ Shared library image and stubs.
threeDKit/ Routines to draw 3-dimensional triangles and
3D demos using these.
lrmi-0.5m/ Linux real mode library (used for VESA driver)
including a utility for restoring text mode
I welcome any questions, comments, suggestions, bug-reports, etc.
The source code is rather a mess, but there's hope. The new XFree86-style
driver interface (used by the Cirrus and S3 drivers) and kernel module
graphics that some are experimenting with should provide some momentum.
Harm Hanemaayer
hhanemaa@cs.ruu.nl
Current maintainer is
Matan Ziv-Av <matan@svgalib.org>
2. Installation
If you are happy with the configuration in 'Makefile.cfg' which means
that you want to install an ELF shared library and probably an a.out
shared library for support of some old binaries (and if the svgalib tar
file you got already contains such an precompiled a.out shared library)
just running
make install
as root should take care of proper installation. After installation,
you MUST edit /etc/vga/libvga.config to set the monitor and mouse type.
Depending on your hardware, other setup might be required. Checkout
'man 7 svgalib' for details after you installed svgalib (or see
doc/0-README)
It is a good idea to read and check the configurable section of
Makefile.cfg nevertheless, even if you don't think you have to. Also,
if your are using GLIBC you have to uncomment the definition of
USEGLIBC in Makefile.cfg as glibc is not completely compatible to the
linux libc (at least at compile time).
Let me rephrase this: YOU MUST COMPILE AND INSTALL AS ROOT.
If you don't nothing bad will happen during compilation, but certain
tools won't be able to become SETUID ROOT which is required for
proper operation.
In case you change anything in 'Makefile.cfg' which does not just control
which parts to install and where, you *MUST* issue a 'make clean' prior to
'make install' to remove any already compiled objects and force complete
recompilation.
Edit Makefile.cfg to change installation paths and to select the parts
that should be installed.
If you have an ET4000 card, read 'man 7 svgalib.et4000' and copy the
appropriate register file to et4000.regs. Remember to set the DAC type.
The default behaviour is the following:
Shared libraries are installed in /lib and /usr/local/lib, header files
in /usr/local/include (any old header files in /usr/include are
removed). In the Slackware distribution the linkable libraries are in
/usr/lib, and the utilities in /usr/bin; these are now removed by 'make
install'. Until now just doing make install with Slackware might have
produced duplicate binaries, but fortunately the newer version in
/usr/local/* would have taken precedence in use.
The et4000 registers (et4000.regs) are installed as
/etc/vga/libvga.et4000, but only if this file does not exit yet. The
same goes for the configuration file, libvga.config.
Textmode utilities are installed in /usr/local/bin. These are
restorefont, runx, restorepalette, dumpreg, restoretextmode, textmode,
savetextmode, fix132x43, and mode3.
If you change Makefile.cfg to install the static libraries, static
libraries are compiled, and installed in /usr/local/lib. Note that you
do not need to do this; the shared library is enough.
If you now run 'make demoprogs', the demo programs are created in the
demos/ and threeDKit/ directory. If you
You can remove previously installed files (not the et4000 registers and
config file and manual pages) with 'make uninstall'.
In 1.28 the makefiles were changed. With minimal effort you can compile
it from a separate (even read-only) source tree. Just make a copy of
Makefile and Makefile.cfg into a writable dir, and change srcdir (or
override from environment) to the directory where the source code is.
This feature, as well as the code for ELF compilation was kindly
contributed by Stephen Lee <sl14@crux1.cit.cornell.edu>.
`make static' compiles a static version of svgalib. It is not
automatically installed by default but you can enable that from
Makefile.cfg. Note though, that if you specify installation of the static
libraries in 'Makefile.cfg' a simple 'make install' will compile the
static library first.
If you do not configure Makefile.cfg to install the shared libs, the
demoprogs and utilities are linked against the new static lib
(regardless of one already installed). However, the static libraries are
not build automatically then. You must issue a 'make static' first.
Building elf or a.out shared libraries can easily be configured in the
Makefile.cfg. Be sure to issue a `make clean' after changing the
TARGET_FORMAT setting.
If you specified elf, `make install' will compile the shared libs as
they don't come pre-built. This is nothing to worry about. Compilation
is easy and will not use any user action.
This is not true for a.out and there is a special hack in the makefiles
for this. As svgalib is distributed there is no attempt to recompile the
a.out sharedlibs. Prebuild images are already included.
If you have the required tools-* installed and if you made patches (or
just feel like recompiling) issue a `make clean' and `make shared' to
enforce recompiling of the a.out sharedlibs (from then on even a make
install will update the shared library if sources changed). Issue `make
distclean' after a `make shared' to fall back to the distribution
behaviour.
However, getting the right tools becomes more and more complicated as
it gets less important to give a.out support. Right now you even have to
hand patch the last tools-* release to make it usuable with current
compilers. In general I discourage trying to compile the a.out libs.
Just use the images that come with svgalib.
3. SVGALib port to ALPHA AXP hardware
David Mosberger-Tang <davidm@azstarnet.com> contributed patches to make
SVGALib run on Linux/Alpha namely APECS-based and low-cost PCI boards.
It is known to run with #9 GXE (but all S3-based graphic cards should
work if they are supported). He wrote a patch to make SVGALib run on
Jensen boards. They own EISA slots instead of PCI slots and can not map
video memory as a continous frame buffer. Use this patch with extreme
care (do sync disks before starting compiled software for the first
time!). He also recommends using SVGATextMode in combination with
SVGALib-based software otherwise the library crunches the font
(although the system should not crash). Here is a list of what is not
supported yet:
- vc-switching (due to lack of some signals supported by current ALPHA
kernels but this could be fixed now [He used a 1.3.28 to test])
- font restoring without SVGATextMode (He still works on it)
- clearing screen in mode 320x200x256
- vgagl (will never be ported by me because he thinks it is too much work
and useless in the end)
He tested his patch with an ELSA Winner 1000 but it should even work on
other cards (He recommends to always sync disks, it saves a lot of time
and sweat :-) ).
If you compile it on a machine where __alpha__ is defined, you should
have configured your kernel correctly once. This is due to the fact
that he saw no other possibility to determine the type of ALPHA AXP
hardware you use. During kernel configuration your are asked which
architecture you want to compile it for.
Also important: you must have the right libc compiled for your board
hardware. This is due to the I/O functions in libc. They need to be
compiled especially for your Alpha board. Have a look at
ftp.azstarnet.com for precompiled libc's (although this is not very
reliable, most of the libc-packages are sources).
Note that he feels __not__ responsible for damage to your hardware when
using this software. If you encounter any problems that refer to
Jensen-type hardware you can send an email to me:
If you encounter any problems that refer to Jensen-type hardware you
can send an email to:
Stephan Kanthak <kanthak@i6.informatik.rwth-aachen.de>
Here are some additional comments Michael Weller wrote on the first
ALPHA patches from David Mosberger-Tang:
No reports of other hardware working or not exist yet. This is REAL
ALPHA software. I don't know any installation details. In theory you
just recompile it out of the box (When you are using Linux/Alpha you
are a hacker and should be able to create a shared lib w/o problems). I
don't know any details, in case of problems please contact David.
From what I saw you might have to use static libs. That's no real
problem, a simple 'make static' will create a static lib.
The background mode is said not to work on Dec-ALPHA, so you better
disable it in Makefile.cfg

1036
doc/CHANGES Normal file

File diff suppressed because it is too large Load diff

86
doc/DESIGN Normal file
View file

@ -0,0 +1,86 @@
This file contains some talk about what is involved with a good
register-level graphics driver interface. This is an old file,
you might also consider reading 'man 7 svgalib.faq'
Section 1: Mode Setting
The following describes what happens during a mode set.
A request is made for a mode with given width, height, and color
resolution. Optionally the request can specify a specific pixel size,
scanline offset (line width), and pixel size (e.g. 3 vs. 4 pixels for
24-bit color modes), otherwise the driver chooses defaults for these
properties. It is the intention that requests for resolutions that don't
match an availabe mode timing can still be honoured by choosing a higher
resolution (for example, 700x500 is requested and 800x600 timing is
programmed). The scanline offset should ensure correct drawing of
graphics.
The user-level driver tries to match the requested mode properties with
either fixed modes defined by the selected kernel module driver, or with a
flexible mode timing if the selected kernel module driver supports mode
timing. In the case of fixed modes, the user-level driver must ask the
kernel driver about the supported fixed modes, and in the case of mode
timings, the user-level driver must ask the kernel driver about physical
limits such as the amount of video memory, maximum pixel clocks for each
pixel size, range and mapping of horizontal timing parameters, and the
available pixel clock frequencies. In both cases, modes/timings that fall
outside of the configured monitor specs (probably stored in a file in
/etc) will not be selected. In the case of flexible mode timings, the
highest refresh timing that is possible will be selected.
Once a mode timing or fixed mode is selected, the kernel module driver is
requested to set the mode on the hardware. A mode state is defined which
is a collection of VGA and driver-specific extended register values (byte
values) that describes the mode that the video card is set to. During the
mode set proper, the following actions are performed:
1. The registers values that make up the state are read from the video
card and stored in a state in system memory (this is the state of
the video card before the mode set).
2. An initialization function modifies the values in the state according
to the requested mode. Nothing is written to the card; only the state
in system memory is changed.
3. The actual mode set on the hardware is performed by writing the values
in the state to the corresponding registers on the video card.
A special case is VGA-compatible textmode state, which would normally be
active at the time of a graphics mode set. This mode cannot be initialized
in the way of (2) above. Instead, the mode is saved using (1), and the
resulting state is restored using (3) when textmode needs to be restored.
Another special case is the setting of a mode for which (1) and (2) have
already been performed, and the resulting state has been saved. In this
case the mode can be set accomplished by just (3), provided that certain
hardware-specific settings on the card have not been changed in the time
between (1) and (3) (this would normally be the case).
When a VT switch away from a graphics modes happens, the current hardware
state should be saved, instead of the initialized mode state, since an
application can have changed it (banking, displaystart, accelerator state
etc.). This is subject to all the extended registers being readable, which
may be a problem with some cards (note that for simple mode setting
followed by textmode restoration, this is not a problem since the mode
initialization overwrites most of the delicate extended registers, and the
saved textmode state is largely VGA registers, and doesn't deal with
delicate extended registers). A possible solution would be to have
functions that save and restore or re-initialize the 'drawing' state,
which would include banking, displaystart and accelerator registers. Upon
VT switching back, the mode initialization function would be used followed
by the restoring of the saved drawing state.
Section 2: What should be in the kernel driver.
A decision that has to be made is whether all chipset specific settings
should be handled within the kernel module driver. There's a fair amount
of information required to select a suitable timing, which the user-level
driver will have to request, and it might have to do additional queries
during its evaluation. The abstractions used for this communication will
include a growing number of properties to accomodate new card/chipset
drivers. It is however desirable that the simple loading of a new module
driver is enough to make full use it, without the requirement of having an
updated user-level driver.
Harm Hanemaayer (hhanemaa@cs.ruu.nl)

View file

@ -0,0 +1,216 @@
Here are some tips on writing a new chipset svgalib driver.
They don't require knowledge of direct vga programming, even though that
helps.
The instructions assume:
1- A super vga card, that is a card which is extended, but also fully
compatible to standard vga. Of the cards available today (in the mass market),
all are, with the possible exception of Permedia chipsets.
2- A PCI (or AGP) connected card. This is useful for detection of the card,
and for finding the linear aperture, as well as knowing it is always there.
3- Knowledge of the extended features of the chipset: Usually either as the
spec, or a source of a driver for the chipset (XFree86).
as a start, get the following:
1- vgadoc4b.zip[1] (or a later version), includes information on the vga
hardware registers, as well as on many chipsets.
2- the latest svgalib[2].
3- If the card is supported by XFree86, either the link kit (Xlkit.tgz[3])
if the card is supported by the XF86_SVGA server, or the XFree86 source
([4]), if it is supported by a special server.
1. in the src subdir of the svgalib distribution, cp skeleton.c to some other
name, chipset.c, where chipset is the name of the chipset you intend to
support.
2. now you have to fill the blanks. The functions that need to be are
sk_setpage
sk_saveregs
sk_setregs
sk_initializemode
sk_unlock
sk_test
sk_setdisplaystart
sk_setlogicalwidth
sk_init
3. When that is done, change all sk_ in the driver to chipset_ (where
chipset is the name of the chipset you write the driver for). Then
the driver needs to be integrated into svgalib. The files that need
to be edited are:
Makefile.cfg
src/Makefile
src/driver.h
src/vga.c
src/vga.h
(It's easy to see what changes are needed in those files, by simply
seeing how its done for another driver).
4. Now is the most interesting time - debugging. Usually (in my experience,
in all cases), the driver won't work right immediately. Here are a few
debugging tips:
Setting modes is made of two things: setting the timings, and setting the
memory organisation. You can usually tell which is the problem, by noticing
if the wrong screen is seen as if some/all pixels are not set to the color
they should (memory organisation), or the display looks "stormy" (timings
problem). If the problem is timing problem, a digital monitor taht displays
horizontal and vertical timings helps. If the horizontal freq is right, but
vertical is wrong, then the problem is in the vertical timing. If both horiz
and vert are wrong, then either the clock frequency, or the horizontal
frequency is wrong.
If the problem is in memory organisation, It might work in linear mode, so try
running testlinear and lineart.
If the driver fails to restore text mode properly, then usually starting X
will work. It won't help restoring text mode, but then you might be able
to see the output of the program (using /dev/vcs?, /dev/vcsa?).
The program mode3 (in lrmi-0.6m subdir) might be able to restore text mode,
corrupted by a bad driver.
The same mode3 might be used for debugging as follows: if a mode, say
800x600x256 does not work properly, but mode3 does work, you might try the
following run vgatest, select 11 (for 800x600x256), and while the wrong mode
is displayed, press d (to recieve a registers dump).
then, try mode3 259 ; utils/dumpreg ; mode3, and compare the register dump
of vesa mode 259 (800x600x256), with the output from your driver. Try finding
out what do the bits that are different mean.
Here are some more details on writing the necessary functions:
examples given are from the banshee.c driver, written according to the spec
available from 3dfx, and the (hypotethical) milleniumII.c driver, written
according to the XFree86 source.
_setpage:
This is a simple function. A mistake in this function is indicated by:
all linear programs work fine, while in paged memory examples, the problem
is that blocks (full width * ??? lines) are moved.
For millenium, from freebe (this part is unavailable in X source,
since X uses only linear mode).
{
outw(0x3de,(page<<8)|4);
};
For Banshee:
{
page<<=1;
outl(banshee_io_base+0x2c,(inl(banshee_io_base+0x2c)&0xfff00000)|(page)|(page<<10));
}
_saveregs, _setregs
This functions should save and restore the state of the svga card, such that
it can be restored to a previous state, no matter what we do. A mistake is
indicated by failure to restore text mode properly.
We should save all registers that we change, or might be changed by other
programs (X, SVGATextMode, etc.), here's the banshee_saveregs:
typedef struct {
unsigned int pllCtrl0, pllCtrl1, dacMode, dacAddr,
vidProcCfg, vidScreenSize, vgaInit0,
vgaInit1, vidDesktopStartAddr,vidDesktopOverlayStride;
} *HWRecPtr;
static int banshee_saveregs(unsigned char regs[])
{
HWRecPtr save;
banshee_unlock();
save=(HWRecPtr)(regs+62);
regs[BANSHEEREG_SAVE(0)]=__svgalib_inCR(0x1a);
regs[BANSHEEREG_SAVE(1)]=__svgalib_inCR(0x1b);
save->pllCtrl0=inl(banshee_io_base+0x40);
save->pllCtrl1=inl(banshee_io_base+0x44);
save->dacMode=inl(banshee_io_base+0x4c);
save->dacAddr=inl(banshee_io_base+0x50);
save->vidProcCfg=inl(banshee_io_base+0x5c);
save->vidScreenSize=inl(banshee_io_base+0x98);
save->vgaInit0=inl(banshee_io_base+0x28);
save->vgaInit1=inl(banshee_io_base+0x2c);
save->vidDesktopStartAddr=inl(banshee_io_base+0xe4);
save->vidDesktopOverlayStride=inl(banshee_io_base+0xe8);
return BANSHEE_TOTAL_REGS - VGA_TOTAL_REGS;
}
If we use the X source, it usually in the functions XXXSave and XXXRestore.
It is only needed to translate from XFree86 notation to svgalib notation,
and to remember that while the X functions need to save the vga state (usually
by calling the vga function to do it, in svgalib the chipset_saveregs/setregs
don't need to do that, but only save extended vga info).
For MilleniumII, the interesting X functions are: MGA3026Save and
MGA3026Restore, here a translation of a part of MGA3026Restore to
mill_setregs:
MGA3026Restore:
for (i = 0; i < 6; i++)
outw(0x3DE, (restore->ExtVga[i] << 8) | i);
/* restore DAC regs */
for (i = 0; i < sizeof(MGADACregs); i++)
outMGA1064(MGADACregs[i], restore->DACreg[i]);
translates to (assuming sizeof(MGADACregs)==32)
for (i = 0; i < 6; i++)
outw(0x3DE, (restore[60+i] << 8) | i);
/* restore DAC regs */
for (i = 0; i < 32; i++){
OUTREG8(RAMDAC_OFFSET + MGA1064_INDEX, MGADACregs[i]);
OUTREG8(RAMDAC_OFFSET + MGA1064_DATA, restore[66+i]);
};
_initializemode - This is the trickiest function. If you use the XFree86
source, try to translate the appropriate function from X to svgalib (in
the milleniumII case, MGA1064Init(mode)). For examples of this translation,
see how its done for nv3.c compared to nv/nv3driver.c from X, or apm.c compared
to apm/apm_driver.c.
If you are working from specs, it usually explained in the spec.
_unlock:
simple function. The skeleton includes the vga unlocking part. If you have
specs, they usually explain how to unlock the extended features, if you use
the X source, its usually in the EnterLeave function.
_test - If you are supporting a single chipset of a single manufacturer,
on a PCI/AGP, the skeleton driver includes a test for this, just make sure to
set VENDOR_ID and CARD_ID properly. Otherwise, either the specs explain
how to recognize that you have the right chipset, or its in the function
XXXProbe of the XFree86 source.
_setdisplaystart, _setlogicalwidth:
vga includes this settings, but with limited range (start<65536,
width<2048 bytes). An svga chipset either defines extra bits, for increasing
the range, or completely new registers for these values.
In the first case, the skeleton driver includes setting the vga part, and
the extra bits are either defined in the specs, or in the XXXAdjust function
in XFree86 (see mx.c for example of this). In the second case, remove the
vga setting part from the functions (see for example rage.c).
Note that none of the demo programs test this functions, so if you want to
check if they work, the only example I know of is seejpeg (try to see an image
larger than the screen)
_init
should not need much changes, except for checking memory size (in the spec, or
in XXXProbe), and maybe setting MMIO (if other functions use it).
1- http://home.worldonline.dk/finth
2- http://www.cs.bgu.ac.il/~zivav/svgalib
3- ftp://ftp.xfree86.org/pub/XFree86/current/binaries/Linux-ix86-libc5/Xlkit.tgz
(or mirrors)
4- ftp://ftp.xfree86.org/pub/XFree86/current/source/X333servonly.tgz
(or mirrors)

94
doc/Makefile Normal file
View file

@ -0,0 +1,94 @@
include ../Makefile.cfg
srcdir = ..
VPATH = $(srcdir)/doc
SVGALIB1=man7/svgalib.7 man5/libvga.config.5 man5/libvga.et4000.5 \
man5/svgalibrc.5 man7/svgalib.chips.7 \
man7/svgalib.et4000.7 man7/svgalib.mach32.7\
man6/mach32info.6 man3/vga_* man3/keyboard_* man3/mouse_* \
man3/joystick_* man3/currentcontext.3 man3/graph_mem.3 \
man1/convfont.1 man1/dumpreg.1 man1/fix132x43.1 man1/restorefont.1 \
man1/restorepalette.1 man1/restoretextmode.1 man1/runx.1 man1/savetextmode.1 \
man1/setmclk.1 man1/textmode.1\
man1/svgakeymap.1 \
man6/joytest.6 man6/mjoytest.6 man6/printftest.6 man6/svidtune.6 \
man6/eventtest.6 man6/forktest.6 man6/fun.6 man6/keytest.6\
man6/mousetest.6 man6/speedtest.6 man6/spin.6\
man6/testaccel.6 man6/threed.6 man6/vgatest.6 man6/accel.6\
man6/bg_test.6 man6/scrolltest.6 man6/testlinear.6\
man7/svgalib.faq.7 man8/mode3.8 man8/vga_reset.8 man6/lineart.6
VGAGL1=man7/vgagl.7 $(shell ls man3/gl_* | grep -v tri ) man6/testgl.6
THREED1=man7/threedkit.7 man3/gl_*tri* man6/plane.6 man6/wrapdemo.6
SVGALIB=$(subst man,$(srcdir)/doc/man,$(SVGALIB1))
VGAGL=$(subst man,$(srcdir)/doc/man,$(VGAGL1))
THREED=$(subst man,$(srcdir)/doc/man,$(THREED1))
COMPMANPAGES=$(shell cd $(srcdir)/doc; find man? -name "*.gz" -type f -print)
.PHONY: clean ascii dvi ps install gunzip gzip
gunzip:
echo gunzipping manpages
for i in $(COMPMANPAGES); do\
gunzip $$i; \
done
gzip:
echo gzipping manpages
for i in $(SVGALIB1) $(VGAGL1) $(THREED1); do\
gzip $$i; \
done
../0-README: man7/svgalib.7
cat man7/svgalib.7 | nroff -man | col -b > ../0-README
ascii:
cat $(SVGALIB) | grep -v '^\.so ' | nroff -man -T$@ \
| col -b > svgalib.$@
cat $(VGAGL) | grep -v '^\.so ' | nroff -man -T$@ \
| col -b > vgagl.$@
cat $(THREED) | grep -v '^\.so ' | nroff -man -T$@ \
| col -b > 3d.$@
lpr:
cat $(SVGALIB) | grep -v '^\.so ' | nroff -man -Tascii > svgalib.lpr
cat $(VGAGL) | grep -v '^\.so ' | nroff -man -Tascii > vgagl.lpr
cat $(THREED) | grep -v '^\.so ' | nroff -man -Tascii > 3d.lpr
ps dvi:
cat $(SVGALIB) | grep -v '^\.so ' | troff -man -T$@ > svgalib.$@
cat $(VGAGL) | grep -v '^\.so ' | troff -man -T$@ > vgagl.$@
cat $(THREED) | grep -v '^\.so ' | troff -man -T$@ > 3d.$@
install: gzip
mkdir -p $(mandir)/man1 $(mandir)/man3 $(mandir)/man5 \
$(mandir)/man6 $(mandir)/man7 $(mandir)/man8
for i in $(COMPMANPAGES); do\
$(INSTALL_DATA) $(srcdir)/doc/$$i $(mandir)/$$i; \
done
make gunzip
ifdef MAKEWHATIS
@echo "Rebuilding the whatis database (this is slow!)"
@echo "You can comment this out in Makefile.cfg!"
$(MAKEWHATIS)
endif
uninstall:
@echo Removing all svgalib man pages.
@for dir in $(mandir) ; do \
if [ -d $$dir ]; then \
cd $$dir; \
rm -f $(COMPMANPAGES) $(UNCOMANPAGES); \
fi; \
done;\
clean:
# -gzip -9 man?/* 2>/dev/null
rm -f man?/*.bak
rm -f svgalib.ascii vgagl.ascii 3d.ascii
rm -f svgalib.dvi vgagl.dvi 3d.dvi
rm -f svgalib.ps vgagl.ps 3d.ps
rm -f svgalib.lpr vgagl.lpr 3d.lpr

83
doc/README.joystick Normal file
View file

@ -0,0 +1,83 @@
Hi!
I wrote a set of SVGAlibish joystick routines while I played with porting
DOSDoom to SVGAlib.
It is compatible with both the older joystick driver for Linux 1.x and 2.0
and the newer joystick driver that is in recent 2.1.x kernels.
Some of the code is ripped from the userland tools joystick-0.6.7 and
joystick-2.0.6 none of wich has any special license attaced to them.
The files are:
joydev.h: my userland version of the kernel joystick.h
vgajoystick.h: library include file analog to vgakeyboard.h and vgamouse.h
joystick.c: the library routines.
joytest.c: a simple test program/example
I dunno how useful these will be, but I could at least use them in doom. (Not
that joystick control in doom adds anything, I just implemented it for
completeness.)
BUGS:
Only one joystick device at any time (but the new 2.1.x driver will let you
map 4 axis and 4 buttons to one logical device).
The routines:
int joystick_init(const char *joydev, int verbose, FILE *file);
This one inits the joystick routines and opens the device. Returna the
filedescriptor of the joystick device if successfull or -1 if not.
Outputs some messages to stdout id verbose is != 0. If file != NULL it will
try to recalibrate the joystick and output the recalibration instructions to
the struct file pointed to by file.
E.g.
if (-1 == joystick_init("/dev/js0, 1, stdout))
{
printf("Joystick init failed\n");
exit(1);
}
void joystick_close(void);
Shuts down the joystick.
int joystick_update(void);
Reads the joystick and calls the joystick handler if anything events are
availible. Should be called every now and then.
void joystick_sethandler(__joystick_handler jh);
Install a user supplied joystick handler.
A user supplied joystick handler would look like this.
void joystick_handler(int event, int number, char value);
int event - event type:
JOY_EVENTAXIS an axis has moved
JOY_EVENTBUTTONDOWN a button has been pushed
JOY_EVENTBUTTONUP a button has been released
int number - the axis or button number for this event 0=x axis or button 1, etc.
char value - value for axis events (-128 .. 0 .. 127)
void joystick_setdefaulthandler(void);
Restore the default joystick handler.
char joystick_getnumaxes(void);
char joystick_getnumbuttons(void);
Retrun the number of axes/buttons on the joystick.
char joystick_getaxis(int a);
char joystick_getbutton(int b);
Querys the jostick state from the default joystick handler if it is used.
The following macros calls joystick_getaxis() or joystick_getbutton().
joystick_getb1() - Gets button 1
joystick_getb2() - Gets button 2
joystick_getb3() - Gets button 3
joystick_getb4() - Gets button 4
joystick_getx() - Returns the X axis
joystick_gety() - Returns the Y axis
joystick_getz() - Returns the Z axis
That all folks,
Daniel Engström
daniel.engstrom@riksnett.no

172
doc/README.keymap Normal file
View file

@ -0,0 +1,172 @@
** Svgalib keyboard scancode remapping: the Readme **
** Introduction
After a poll on Slashdot.org about keyboard layouts, I decided to switch from
QWERTY to the Dvorak simplified keyboard. (Such is the power of Slashdot!) It
was easy to switch the keymaps used by the console and X and even LILO, but
svgalib programs that used raw keyboard weren't affected since they interpret
the keyboard scancodes into characters themselves - often assuming a standard
US keyboard with QWERTY layout.
In order for my machine to present a ``unified front'' with a single consistent
keyboard layout, I added to svgalib the ability to remap scancodes. This is
done in keyboard_getevents(), before the event handler is called, so it will
work whether or not a program provides its own handler. Programs that do not
use raw keyboard are not affected, so by setting both the console and svgalib
itself to use the same keymap a consistent keyboard layout is available to all
svgalib programs.
** Background
When you press or release a key on your keyboard, it sends a byte of data to
your computer. The top bit indicates whether the key was pressed or released,
and the lower seven bits hold the scancode, a number that uniquely identifies
the key. A program on the computer interprets these scancodes as representing
characters (`A', `%', etc) or actions to be taken (`Page Up', `Back Space') or
modifiers that alter the interpretation of other keys (`Shift', `Alt', etc).
Most programs do not perform this interpretation themselves, but leave it up
to some other piece of software: the system BIOS, or the operating system,
or the graphical user interface system.
On Linux this is normally done by the kernel or by the X server for X clients,
but this doesn't meet the needs of some programs (especially games) which
care more about whether a key is up or down than what it means and treat the
modifiers the same way as other keys. These programs open the keyboard in `raw'
mode and deal directly with scancodes.
The problem comes because these programs often do need to interpret the keys
into characters, or it is important for a certain key to be identifiable to
the user as being associated with a certain key. For instance, a game player
might need to type a description of a saved game or be directed to press a
certain key to activate a game feature. Interpretation of keyboard scancodes
can be difficult since there are many different keyboard layouts which do not
have the same associations between scancodes, modifiers, characters, and
commands. So the author of the program must choose between writing a complex
and customizable conversion routine that can handle any layout the user might
have, and a simple routine that is hard-coded to use a single layout. In the
latter case, users of other keyboard layouts will encounter numerous
discrepancies between what he or she tries to type and what the program
interprets.
** How it works
Svgalib's scancode conversion is meant to at least partially fill this gap by
converting the scancodes that the keyboard produces to equivalent, or nearly
equivalent, scancodes for the keyboard layout that the program expects. The
program then (hopefully) interprets the new scancode into the intended
character.
As an example, let us consider a US keyboard with Dvorak layout and the game
Quake, which expects a US keyboard with QWERTY layout. Both layouts have the
same scancodes for each physical key, but different characters are produced.
For intance, the first row of letters produces the scancodes 16 through 27, but
on QWERTY this produces the charaters qwertyuiop[] while Dvorak produces
',.pyfgcrl/=. Thus when the Dvorak letter `p' is pressed, the scancode 19
is interpreted by Quake as the letter `r', which occupies scancode 19 on the
QWERTY layout.
The solution lies in the fact that svgalib acts as an intermediary between the
keyboard and the program and has the opportunity to present a different
scancode to the program than the keyboard produced. In this case we tell Quake
that the scancode was not 19 but rather 25, which is the letter `p' in the
QWERTY layout, so when Quake interprets the scancode the correct character is
produced.
** The keymap files
In order to know what scancodes to convert to what other scancodes, a keymap
file is read which lists scancodes produced by the keyboard and their
equivalents in the layout expected by the program.
A program called svgakeymap is provided to generate these maps from the
keytable files in /usr/lib/kbd/keytables; you must have perl for it to work.
Creating a keymap file with svgakeymap is easy; to make a map to convert
scancodes from a US Dvorak keyboard to a US QWERTY keyboard as for our example
above:
svgakeymap dvorak us > dvorak-us.keymap
The path and .map and .gz suffixes are automatically added if necessary. If
your keytables are stored elsewhere, specify a complete path. If only one
keytable is specified, a keymap is generated that performs no conversions but
contains the correct key names so you can specify scancodes used by fake
keyboard and mouse events by name instead of by number. If none are specified,
this is done for the standard US QWERTY layout.
dvorak-us.keymap and default.keymap (the US QWERTY layout) are provided with
the svgalib distribution and can serve as an example if you wish to make your
own keymap files manually or create an improved generator.
** Configuration
You can specify a keymap to use for all svgalib programs (keeping in mind that
only those that use raw keyboard are affected) by putting a line like this into
libvga.config or ~/.svgalibrc:
kbd_keymap /etc/vga/dvorak-us.keymap
You must specify a complete path to the keymap file. If no keymap is specified,
no conversion is performed.
You can also override the global keymap by setting the environment variable
SVGALIB_KEYMAP to point to the appropriate keymap file. This can be useful if
some programs support alternate keymaps directly but not others, or if
different users use their own keyboard layouts based on preference.
** Security issues
It can be dangerous to let users arbitrarily reassign keyboard scancodes; for
instance all keys could be routed to an unused scancode, making the console
unusable. To prevent this, put the option kbd_only_root_keymaps into
libvga.config; only keymaps owned by root will be accepted, so the available
keymaps can be limited to safe ones.
** Bugs and limitations
There are no known bugs, but there probably are some. If you find any please
let me know at brion@pobox.com.
Limitations however we definitely have. The scancode conversion performed is
very simple, and can only achieve 100% success when the keyboard layouts being
converted between differ _only_ in arrangement of keys while producing the same
characters from each key. Example: the de facto standard Dvorak keyboard has
the left and right brackets (`[' and `]') on separate keys, with the curly
braces (`{' and `}') produced by those keys when shifted. The standard QWERTY
keyboard produces those characters the same way, the only difference is that
the keys are a row higher on Dvorak; switching the scancodes around results in
proper character interpretation. However the official ANSI standard Dvorak
layout has tho two brackets on _the same key_, one regular and one shifted.
The curly braces similarly have their own key. These cannot be properly mapped
by scancode to the QWERTY keyboard since they produce different characters
in conjunction with modifiers, and the wrong character is produced by the
program.
This could be worked around by interpreting the modifiers in svgalib and
simulating the proper modifier/character keypress/release sequences, but it
would be very complex and would do nothing to help the situation where
characters on the physical keyboard layout do not exist on the target layout
(quite likely when dealing with national or language-specific keyboards);
they cannot be converted into any key sequence since they do not exist.
Ultimately it might be better to set up a ``medium-rare'' keyboard mode where
keys are interpreted into characters but ``raw''-style non-interpreted key
press and release events are available.
** Further information
There isn't really any further information right now unless you want to Use The
Source... More to come in the future. If it does you'll find it at:
Brion Vibber's Svgalib Stuff - http://pobox.com/~brion/linux/svgalib.html
-- brion vibber (brion@pobox.com)
3 July 1998

1
doc/README.lrmi Symbolic link
View file

@ -0,0 +1 @@
../lrmi-0.6m/README

88
doc/README.multi-monitor Normal file
View file

@ -0,0 +1,88 @@
multi-monitor support is still very experimental, and not
very easy to setup. Here's a copy of a message I sent to
the mailing list:
First: only nvidia, 3dfx, sis and i740 cards can be secondary cards,
(though the primary can be anything, including vesa).
Second: as far as I can understand, once both cards are enabled, there
ought to be a resource contention (in hardware) between the cards for
the vga regions (IO 0x3c0-0x3df and MEM 0xa0000-0xbffff). I don't know
how it is supposed to be solved, but in practice, if I ignore it in my
system, it just works.
If anybody else has successfully run svgalib on a secondary card, please
tell me, and if you had to do something different from what I did, a
detailed report to the list might help others.
Here's my setup:
I have two vga cards: AGP (1:0.0) nVidia TNT2 and (PCI0:0f.0) Riva128.
The AGP card is the primary (in the BIOS option "initialize AGP card
first" is selected). My boot sequence includes the following code to
initialize the secondary card:
/usr/local/sbin/vbios.x86emu
/usr/local/sbin/vga_reset
/sbin/setpci -s 00:0f.0 COMMAND=2
the vbios.x86emu is the same as distributed in x86emu-0.6 (from ftp.scitechsoft.com)
except that in debug.h the line
#define CONFIG_ACTIVE_DEVICE 1
is replaced by
#define CONFIG_ACTIVE_DEVICE 0
(so that the active device is not initialized by x86emu).
the setpci line enables memory access (of the drivers supporting
secondary card, nv3 and i740 use only memory mapped IO, sis and banshee
need I/O access as well, so you need COMMAND=3). The COMMAND register
might have other bits set, so you might try to see its value first, and
then set the 0,1 bits.
I have two config files in /etc/vga:
libvga.config.0 - for the scondary card:
novccontrol
secondary
include /etc/vga/libvga.config.common
HorizSync 30 54
VertRefresh 40 120
The novccontrol and secondary options are necessary for a secondary
card. The include statement is for a card with common configurations -
mouse, keyboard, etc.
libvga.config.1 - for the primary:
PCIStart 1 0
include /etc/vga/libvga.config.common
HorizSync 30 115
VertRefresh 40 160
The pcistart option is necessary to make sure that svgalib skips the
first card (in PCI order), and so finds the AGP card.
to run a program on the primary card, in the usual way, I do
export SVGALIB_CARD=1
/svgalib/demos/vgatest
to run a program on the secondary card:
export SVGALIB_CARD=0
/svgalib/demos/vgatest
There are a few differences for a program running on secondary card:
- The program is not aware of VC switches, so you can switch to another
console, and the program will still run (and display).
- The program can't event system (mouse or raw keyboard).
- Standard VGA modes and paged memory modes might have problems.
What this limitations mean is that usual svgalib program might not be
useful for a secondary card. I use the secondary display for
watching TV, movies and slideshows. Eye candy programs (such as
synaesthesia) might also work, after a few changes, but interactive
programs (zgv, games) are unusable right now. I intend to add support
for Vojtech Pavlik's input event system to svgalib-2.0, so that
interactive program will be usable as well.

140
doc/README.patching Normal file
View file

@ -0,0 +1,140 @@
Patching svgalib
Contents
0. Introduction
1. Indenting
2. Structure of the chipset drivers
0. Introduction
Here is some info on writing patches and/or adding support for
further chipsets. The info on the chipset drivers is outdated, but
better than nothing and get you started.
As a side note, other than a.out, ELF does not allow to have some
symbols global to svgalib which are not accessible to user
programs.
Because of that, if possible all the symbols and functions in your
program should be static. Those which can not be static should
have a name like: "__svgalib_*" to mark them as internals s.t.
people using them get what they deserve. Please do only add a new
function to the user interface if it is really unavoidable. Better
add some new parameters to an existing function.
Adding a new function would definitly result in loosing a.out
compatibility thus removing the chance to use new cards and such
with old a.out binaries where the source is not available (doom
comes to mind).
A new function should be really important to outweigh this draw
back.
1. Indenting
Due to some request (and I heard it b4) all the sources were now
automatically indentified.
There were some requests for indent -gnu but it looks painful. I
opted for -kr (there were requests for it as well) as it is not
only nicer but also what is done in the linux-kernel and this is
certainly a program only usable for linux.
I dunno if emacs is confused by -kr, but to be honest this is a
big all-in-one egg-giving-wool-milk-sow (as we say in german), and
you won't tell me that this several megs beast is unable to edit
this and I can't use -kr due to some restrictions of emacs. That
would be really ridiculous. If it is the case just make emacs
better.
The OneModeEntry macro is eaten by indent (I would say it is an
indent bug, I might send a bug report to them), please ensure (if
at all possible) that your code can be passed through indent (use
the INDENT-OFF comments as shown in some sources for
OneModeEntry).
You can use `make indent-gnu' (if you have a recent enough (I use
1.9.1) indent) to switch to your favorite style. But please ensure
your patches fit into this now declared as "official style"
sources. (Use `make indent' to reformat).
Do not use it too often though as most indent's tend to add empty
lines at certain places in the source.
2. Structure of the chipset drivers
The chipset specific registers saving function (saveregs) is only
used directly to save the textmode registers at initialization.
The chipset specific registers restoring function (setregs) is only
used directly to return to textmode, and when setting a VGA mode
after an SVGA mode.
The registers for each mode are stored like the ET4000 modes in
VGAlib 1.2, i.e. the extended registers at the end. The following
functions must be provided in a driver:
saveregs( unsigned char regs[] )
Saves the chipset-specific registers in regs, starting at
array index EXT (after the VGA registers).
setregs( unsigned char regs[] )
Sets the chipset-specific registers stored in regs from
index EXT.
modeavailable( int mode )
Returns nonzero if mode is available (should check video
memory).
getmodeinfo( vga_modeinfo *modeinfo )
Fills in chipset specific field of mode information
structure: maxlogicalwidth, startaddressrange (mask of
significant bits), and maxpixels (video memory divided by
the number of bytes per pixel). haveblit indicates whether
bitblt functions are available.
Note: providing extended info and an aperture with size
>= memory and setting bits 4 and 6 in flags will
automatically enable linear addressing support.
setmode( int mode, int previous_mode )
Sets all registers for a mode; returns nonzero if mode not
available. __vga_setregs can be called to set the VGA
registers.
unlock()
Unlocks chipset-specific registers.
lock()
Lock (protect) chipset-specific registers. Currently not
called.
test()
Identify chipset; initialize (check memory and type) and
return nonzero if detected.
setpage( int page )
Set 64K page number to be mapped at 0xa0000.
init( int force, int par1, ... )
Initialize memory and type; called by test. If force is 1,
the chiptype or the amount of memory can be forced (this
is pretty useless).
The following functions provide for things like page flipping
and hardware scrolling virtual desktops.
setdisplaystart( int address )
Sets the display start address in video memory in pixels.
setlogicalwidth( int width )
Sets the logical scanline length in bytes. Usually a
multiple of 8.
The function getchipset() in vga.c must call the test routine for
the chipset. The chipsetfunctionslist must be have a pointer
to the chipsetfunctions table for the chipset (which is the only
global symbol in a chipset driver). Also, vga.h contains a magic
number for each chipset. Also driver_names[] in vga.c has to
contain a name for each driver at the correct position.

60
doc/README.vesa Normal file
View file

@ -0,0 +1,60 @@
Notes for the VESA driver:
The driver's autodetection is disabled by default, so in order to use it,
the line
chipset VESA
must be added to the config file (usually /etc/vga/libvga.config).
The error:
Int 0x10 is not in rom (xxxx:xxxx)
is usually caused by running linux using loadlin, after loading a dos tsr
that changes the int 10 vector, or after windows 95, that does the same
thing. The solution, is either to use lilo, or run loadlin after a clean
dos boot.
There is a new config file option that affects the vesa driver:
VesaText
If this option is used, the driver sets 80x25 text mode (using vesa bios)
before setting any standard vga mode.
This option was added in order to enable standard vga modes with the vesa
driver on Matrox Millenium, but now it has the following effect:
(read in a fixed width font)
chipset with VesaText without VesaText
CL-GD5446 works leaves a messy font when
returning to text mode
Riva 128 does not restore works
previous used text
font, but reverts to
ROM font.
Matrox
Millenium works does not set standard vga
modes properly.
A list of cards known to work with the VESA driver is:
* Riva128 (both on a STBV128 and a Viper330)
* RivaTNT
* Matrox Millenium 2
* Matrox Mystique
* Matrox Productiva G100
* Matrox Millenium G200
* Neomagic Magicgraph 128XD (in a Dell Inspiron laptop)
* S3 375 Virge/DX ( A "Trident Video Excel 3D Accelerator" )
* S3 Trio3D
* Cirrus Logic GD5446
* Rendition V1000 - Only modes up to 800x600 seem to work
* ATI Expression+ PC2TV 2MB (RageII chipset) - tested only modes up
to 800x600 resolution
* i740 (Diamond Stealth G460)
* Voodoo Banshee
* Alliance Technology AT24
Please note that some of this cards have also failed to work in some
cases, so it is _very_ configuration dependent.
For Matrox cards, the advice is to upgrade to the latest bios from Matrox.

40
doc/TODO Normal file
View file

@ -0,0 +1,40 @@
Be sure to read the svgalib.FAQ man 7 svgalib.faq
Have to decide what exactly is G320x200x256 (VGA Mode 13h or SVGA
packed-pixel). A separate Mode X would be nice too.
A set of functions to handle page-flipping would be nice. (e.g. a
vga_setvideopage() that returns the new video start address)
Support for more chipsets?
Clean up keyword parsing code.
Kernel support for page-flipping.
automatic console restore on device close.
really reliable vc switching.
There are races in the mouse code when the mouse device is closed in the
signal handler on a vc switch. Again, probably kernel support is due.
start marking functions that will become obsolete.
Move away from hard-coded mode numbers:
Think what would happen if a program is compiled to call
vga_setmode(G1280x1024x256) and we change the mode number to
something else... This has happened before. The solution is either
to provide a getmodenum(xres, yres, colordepth, layout) function, or
a setmode(xres, yres, colordepth, layout) function or vow not to
change the definitions of the mode numbers (i.e. new modes can only
be added to the end of the list).
More RamDAC support. The S3 code should have no problem with 868, Trio and
9xx chips except that boards that uses those chips usually uses
newer/unsupported RamDACs as well.
Multiple-adaptor support.
IBM RGB52x >8bpp support.

6
doc/add_driver Normal file
View file

@ -0,0 +1,6 @@
Makefile.cfg DRIVER, DRIVER_TEST
src/Makefile
src/vga.c driverspecs, config names, test
src/vga.h
src/driver.h

111
doc/dual-head-howto Normal file
View file

@ -0,0 +1,111 @@
There is a new config option - "device". After you insert the module, you
see output such as (those lines are available with the command dmesg, or
in the file /var/log/messages, depending on your syslog setup):
svgalib_helper: Initializing, version 1.9.18
svgalib_helper: device1: vendor:1002 id:4c49
device1: region0, base=dd000000 len=16777216 type=0
device1: region1, base=0000d000 len=256 type=1
device1: region2, base=e4000000 len=4096 type=0
svgalib_helper: device2: vendor:12d2 id:0018
device2: region0, base=df000000 len=16777216 type=0
device2: region1, base=e0000000 len=16777216 type=8
svgalib_helper: device3: vendor:102b id:051a
device3: region0, base=e1000000 len=16384 type=0
device3: region1, base=e2000000 len=8388608 type=8
device3: region2, base=e3000000 len=8388608 type=0
svgalib_helper: device4: vendor:102b id:0525
device4: region0, base=d8000000 len=33554432 type=8
device4: region1, base=da000000 len=16384 type=0
device4: region2, base=db000000 len=8388608 type=0
(Of course, the number of cards, and their types will be different).
From which you can see which number each card is assigned. Then you
create a different libvga.config for each card, which contains the
device keyword.
For example In my system I have
/etc/vga/libvga.config.rage:
novccontrol
secondary
device 1
BiosParams 3 29500
include /etc/vga/libvga.config.common
mouse none
HorizSync 30 38
VertRefresh 40 90
/etc/vga/libvga.config.nv3:
helper /dev/svga_helper/2
novccontrol
secondary
include /etc/vga/libvga.config.common
Modeline "6" 14.16 640 776 840 904 240 332 337 625 -hsync -vsync tvmode tvpal
newmode 640 240 65536 1280 2
HorizSync 24 60
VertRefresh 55 75
/etc/vga/libvga.config.mystique:
helper /dev/svga3
novccontrol
secondary
chipset g400
include /etc/vga/libvga.config.common
Modeline "6" 14.16 640 776 840 904 240 332 337 625 -hsync -vsync tvmode
tvpal
newmode 640 240 65536 1280 2
HorizSync 30 37
VertRefresh 30 90
/etc/vga/libvga.config.mga:
Device 4
OverRideEnable
include /etc/vga/libvga.config.common
HorizSync 30 115
VertRefresh 40 160
Some explanations:
When the environment variable SVGALIB_CARD is set, svgalib opens the
config file /etc/vga/libvga.config.$SVGALIB_CARD, instead of the usual
/etc/vga/libvga.config. So, if I want to run zgv on the nv3 card, I do
export SVGALIB_CARD=nv3 ; zgv
The helper keyword can be used similar to the device keyword, to tell
svgalib which device to open.
All cards except for the primary need to use the secondary and
novccontrol keywords. Secondary tells svgalib not to try to use the
standard VGA ports when accessing this card (since only one card can be
accessed with those, and that is the primary). NoVCControl tells svgalib
not to check or try to control the VC, so you can run an svgalib program
on a secondary card, while working normally on the main head, including
switching virtual consoles.
You should use "mouse none", or "mdev" options to make sure no two
programs open the mouse at the same time. (Though it is possible with
most mice, and can give some funny results).
XFree86 likes to disable all PCI video cards that it does not use,
whenever it is started, or switched to, so if you switch in and out of X
on your main card, you need to patch your X server to prevent this
behavior. If you only run X on the main card, and don't return to
text mode, there is no need to patch X.
There are no limitations on the primary card. As you can see, I currently
use nvidia, mystique and rage (mach64) cards as secondaries. Also known to
work are sis, r128 (including radeon), laguna, trident and s3 (trio and up)
cards.
The main issue with secondary cards is initializing them. If your BIOS
initializes them, that's the best (I heard rumors of such BIOSes, but
never something concrete). The next option is x86emu, this almost always
works (on x86 systems). It also works on some other arches, if you use PC
video cards. If even that fails, then C code is available to initialize some
mach64 cards, and old matrox cards (before G100).

80
doc/man1/convfont.1 Normal file
View file

@ -0,0 +1,80 @@
.TH convfont 1 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
convfont \- convert font files for svgalib
.SH SYNOPSIS
.BI convfont " fontfile fontheight vgafontfile"
.SH DESCRIPTION
convert the standard format binary fontfile name
.I fontfile
to the codepage format required by
.BR restorefont (1).
The converted font is written to
.IR vgafontfile .
A binary font file of any number of characters up to 256 can be used, although
at least defining the first 128 characters is a good idea. The
.I fontheight
must be in the range
.BR 1 " - " 32 .
The
.I fontfile
file consist of
.I fontheight
bytes stored sequentially (top to bottom) for each character in your
font, starting with the character with code 0.
The format of
.I vgafontfile
is that required by
.BR restorefont (1)
and described there.
This utility is part of svgalib and can be found in the
.I utils/
subdirectory of the original svgalib distribution. However, it is not installed
by default, s.t. it is unclear where you can find it if your svgalib was install
linux distribution.
In case of any such problem, simply get an svgalib distribution from the net. You
don't need to install it. Just
.B make
in the
.I utils/
subdirecty. As of this writing,
.I svgalib-1.2.12.tar.gz
is the latest version and can be retrieved by ftp from
.IR "sunsite.unc.edu" " at " "/pub/Linux/libs/graphics"
and
.IR "tsx-11.mit.edu" " at " "/pub/linux/sources/libs"
which will most probably be mirrored by a site close to you.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR libvga.config (5),
.BR dumpreg (1),
.BR fix132x43 (1),
.BR restorefont (1),
.BR restorepalette (1),
.BR restoretextmode (1),
.BR runx (1),
.BR savetextmode (1),
.BR setmclk (1),
.BR textmode (1).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced utility as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

54
doc/man1/dumpreg.1 Normal file
View file

@ -0,0 +1,54 @@
.TH dumpreg 1 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
dumpreg \- dump the state of the card as the svgalib chipset driver sees it.
.SH SYNOPSIS
.BI dumpreg
.br
.BI "dumpreg < /dev/tty" N
.SH DESCRIPTION
The chipset drivers of svgalib inquire the mode of the graphic card when the application
is started and restore it when the svgalib application quits.
.B dumpreg
prints this information to stdout.
This is useful for debugging or adding modes to a device driver. For example you can
use Xfree86 to setup a given mode timing, then run
.B dumpreg
and use it's stdout to make your chipset driver use exactly this timing.
However, the recent change of svgalib to hunt an own free virtual console does not allow
this, because it will make Xfree86 return to textmode first. You can avoid this by using
the second form where
.I N
is the number of the virtual console on which Xfree86 runs (usually 7) as root.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR libvga.config (5),
.BR vga_dumpregs (3),
.BR convfont (1),
.BR fix132x43 (1),
.BR restorefont (1),
.BR restorepalette (1),
.BR restoretextmode (1),
.BR runx (1),
.BR savetextmode (1),
.BR setmclk (1),
.BR textmode (1).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced utility as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

91
doc/man1/fix132x43.1 Normal file
View file

@ -0,0 +1,91 @@
.TH fix132x43 1 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
fix132x43 \- fix problems with certain (132 column) graphics modes
dump the state of the card as the svgalib chipset driver sees it.
.SH SYNOPSIS
.BI fix132x43 " options"
.SH DESCRIPTION
This program tries to fix problems with extended textmodes on some cards. The problem is that for
132x43 textmode, some BIOS's set the vertical display end register to 349 (350), instead of 343
(344 = 3 * 8 scanlines). Because in Linux textmode video memory is usually filled with old text
that has already scrolled away (this includes the area below the 43rd textmode line, which changes
when the console scrolls), the top half of a constantly changing irrelevant text line is visible
at the bottom of the screen, which is very annoying.
This program sets the VGA Vertical Display End register to the proper value.
This problem is at least present in the BIOS of most Cirrus Logic 542x based cards, and
some WD90C03x based cards.
The
.B LINES
environment variable is used to detect 43 or 44 line consoles.
.SH OPTIONS
You have to specify exactly one of the following options:
.TP
.B -f
Fix problem of annoying changing line of text at bottom of screen.
.TP
.B -v
Switch to 9 line characters (400 line frame, 70 Hz).
.TP
.B -w
Switch to 11 line characters (480 line frame, 60 Hz).
.B fix132x43
does not usually provide this option but it can be enabled in the source of
.BR fix132x43.
.TP
.B -r
Switch to 8 line characters again (350 line frame, 70 Hz).
.PP
This utility is part of svgalib and can be found in the
.I utils/
subdirectory of the original svgalib distribution. However, it is not installed
by default, s.t. it is unclear where you can find it if your svgalib was install
linux distribution.
In case of any such problem, simply get an svgalib distribution from the net. You
don't need to install it. Just
.B make
in the
.I utils/
subdirecty. As of this writing,
.I svgalib-1.2.12.tar.gz
is the latest version and can be retrieved by ftp from
.IR "sunsite.unc.edu" " at " "/pub/Linux/libs/graphics"
and
.IR "tsx-11.mit.edu" " at " "/pub/linux/sources/libs"
which will most probably be mirrored by a site close to you.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR libvga.config (5),
.BR convfont (1),
.BR dumpreg (1),
.BR restorefont (1),
.BR restorepalette (1),
.BR restoretextmode (1),
.BR runx (1),
.BR savetextmode (1),
.BR setmclk (1),
.BR textmode (1).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced utility as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

125
doc/man1/restorefont.1 Normal file
View file

@ -0,0 +1,125 @@
.TH restorefont 1 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
restorefont \- save or restore the SVGA font for textmode.
.SH SYNOPSIS
.BI "restorefont {-r|-w} " filename
.SH DESCRIPTION
The font used by SVGA when in textmode is written to or restored from
.IR filename
using the
.BR vga_gettextfont "(3) and "
.BR vga_puttextfont (3)
functions.
.SH FILE FORMAT
The VGA font file
.I filename
has the following format:
.RS
.BR Offset:
.br
.BR " 0 - 31 " "Character 0"
.br
.BR " ... " " ..."
.br
.BR "8164 - 8195 " "Character 255"
.RE
Each row of a character bitmap is stored as a byte (8 pixels).
The space that is left from the 32-byte buffer for each character
is ignored, e.g. a 16 line font uses only offsets 0 - 15 of each character.
Linux textmode screen resolutions:
.BR 80x25 " 16 line font 400 scanlines"
.br
.BR 80x28 " 14 line font 400 scanlines"
.br
.BR 80x50 " 8 line font 400 scanlines"
The font sizes and resolutions of extended textmodes depend on the
video card type and BIOS:
.BR 132x25 " 14 line font 350 scanlines (ugly)"
.br
.BR 132x25 " 16 line font 400 scanlines"
.br
.BR 132x43 " 8 line font 350 scanlines (use fix132x43 to fix/improve)"
.br
.BR 132x50 " 8 line font 400 scanlines"
.br
Using a font that has less lines per character than the textmode works, but
the characters are smaller. Using a font that is bigger than the textmode
font results in the bottom part of characters being cut off.
The svgalib distribution contains sample fonts with 8, 14 and 16 line characters
in the files
.IR utils/font8 ", " utils/font14 ", and " utils/font16 .
The
.BR convfont
(1) program can be used to convert fonts straightforwardly stored
character-after-character (i.e. each character only uses 8/14/whatever
bytes), to the 32-byte per character format that
.B restorefont
requires.
The purpose of this program is usually to recover from a crashed console due to an
svgalib, Xfree or other program bug. First save the state of the SVGA card when on a
text console. After the crash restore this state. The
.BR savetextmode (1)
and
.BR textmode (1)
script makes this procedure very easy.
The national/fontpak packages, which include kernel patches, allow different
textmode fonts to be used in different virtual consoles. These have been
superseded by the kbd package (in the kernel since ages). See the
.BR setfont (8)
utility of the kbd package as a starting point.
Recent kernels support up to 2 fonts with 512 chars each. Recent versions
of svgalib take this into account and extend the size of the datafile accordingly.
.SH OPTIONS
.TP
.BI "-w " filename
write the font to the file
.IR filename .
.TP
.BI "-r " filename
restore the font from the file
.IR filename .
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR libvga.config (5),
.BR setfont (8),
.BR vga_gettextfont (3),
.BR vga_puttextfont (3),
.BR dumpreg (1),
.BR convfont (1),
.BR fix132x43 (1),
.BR restoretextmode (1),
.BR restorepalette (1),
.BR runx (1),
.BR savetextmode (1),
.BR setmclk (1),
.BR textmode (1).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced utility as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

107
doc/man1/restorepalette.1 Normal file
View file

@ -0,0 +1,107 @@
.TH restorepalette 1 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
restorepalette \- set the color palette for textmode.
.SH SYNOPSIS
.BI "restorepalette [" filename ]
.SH DESCRIPTION
.B restorepalette
without arguments sets the standard VGA palette. This can be useful
if it is somehow messed up.
With a
.I filename
argument a custom palette can be loaded (feature added by Charles Blake
<chuckb@alice.wonderland.caltech.edu>).
This allow a user to set up a file that looks like this one
(These color map definitions are the same as the default VGA ones.
Alter to suite personal tastes). The first column contains the number of
the color to set, then follow three integers in range 0 - 63 (lowest to
highest intensity) for red, green, blue.
.RS
.B " 0 0 0 0 # black"
.br
.B " 1 0 0 42 # blue"
.br
.B " 2 0 42 0 # green"
.br
.B " 3 0 42 42 # cyan"
.br
.B " 4 42 0 0 # red"
.br
.B " 5 42 0 42 # magenta"
.br
.B " 6 42 21 0 # brown"
.br
.B " 7 42 42 42 # white"
.br
.B " 8 21 21 21 # bright black"
.br
.B " 9 21 21 63 # bright blue"
.br
.B "10 21 63 21 # bright green"
.br
.B "11 21 63 63 # bright cyan"
.br
.B "12 63 21 21 # bright red"
.br
.B "13 63 21 63 # bright magenta"
.br
.B "14 63 63 21 # bright brown"
.br
.B "15 63 63 63 # bright white"
.RE
The inline comments are the
only kind of allowed, as I use a little
.BR fscanf (3)
trick to get them. Blank lines
are ok, but not pure comment lines. See the comments in my code, also.
This allows people to set up custom palettes for use in virtual console text
modes. I use it all the time. When combined with a color-syntax editor like
jed-0.97+ or color-ls, etc., being able to choose your own text-mode palette is
quite a bonus. I set mine up via
.B restorepalette /etc/palette
in my
.IR /etc/rc .
If the program is given the correct permissions, then individual users can
have
.B restorepalette ~/.palette
or some such thing in their shell startup
files.
Of course, it shouldn't be done when starting remote shells or when
under X, so some kind of test that
.B TERM
is a virtual console is needed for that case.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR libvga.config (5),
.BR vga_setpalvec (3),
.BR dumpreg (1),
.BR convfont (1),
.BR fix132x43 (1),
.BR restorefont (1),
.BR restoretextmode (1),
.BR runx (1),
.BR savetextmode (1),
.BR setmclk (1),
.BR textmode (1).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced utility as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

View file

@ -0,0 +1,66 @@
.TH restoretextmode 1 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
restoretextmode \- save or restore the SVGA registers for textmode.
.SH SYNOPSIS
.BI "restoretextmode {-r|-w} " filename
.SH DESCRIPTION
The state of the SVGA is written to or restored from
.IR filename
using the
.BR vga_gettextmoderegs "(3) and "
.BR vga_settextmoderegs (3)
functions.
As of this writing this file is 385 bytes long but this might change with future versions.
Please do not fiddle with the contents of the file except when you know what you do. It
might even result in hardware damage. Because of that, you should think twice to make
this command available to all users on your system.
The purpose of this program is usually to recover from a crashed console due to an
svgalib, Xfree or other program bug. First save the state of the SVGA card when on a
text console. After the crash restore this state. The
.BR savetextmode (1)
and
.BR textmode (1)
script makes this procedure very easy.
.SH OPTIONS
.TP
.BI "-w " filename
write the SVGA state to the file
.IR filename .
.TP
.BI "-r " filename
restore the SVGA state from the file
.IR filename .
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR libvga.config (5),
.BR vga_gettextmoderegs (3),
.BR vga_settextmoderegs (3),
.BR dumpreg (1),
.BR convfont (1),
.BR fix132x43 (1),
.BR restorefont (1),
.BR restorepalette (1),
.BR runx (1),
.BR savetextmode (1),
.BR setmclk (1),
.BR textmode (1).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced utility as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

104
doc/man1/runx.1 Normal file
View file

@ -0,0 +1,104 @@
.TH runx 1 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
runx \- try to overcome problems of Xfree96 restoring textmode using svgalib.
.SH SYNOPSIS
.BI runx
.SH DESCRIPTION
If XFree86 corrupts your textmode font, try putting
.BR restorefont (1)
in your path and use the shell script
.B runx
to run X.
.B runx
saves the VGA font data in
.IR /tmp/fontdata ,
and restores it when you exit X.
The
.B runx
script actually is:
.RS
.B #!/bin/sh
.br
.B echo Saving font in /tmp/fontdata
.br
.B restorefont -w /tmp/fontdata
.br
.B startx
.br
.B echo Restoring font from /tmp/fontdata
.br
.B restorefont -r /tmp/fontdata
.RE
Note that this doesn't help with syncing problems.
A more rigorous alternative is to run the
.BR savetextmode (1)
script before running X, and
.BR textmode (1)
after. This will restore the textmode registers and the VGA palette in addition to the VGA font.
Assuming that
.BR savetextmode (1)
and
.BR textmode (1)
are in your
.BR PATH
the
.B runx
script would then look like:
.RS
.B #!/bin/sh
.br
.B echo Saving SVGA state
.br
.B savetextmode
.br
.B startx
.br
.B echo restoring SVGA state
.br
.B textmode
.RE
.PP
This utility is part of svgalib and can be found in the
.I utils/
subdirectory of the original svgalib distribution. However, it is not installed
by default, s.t. it is unclear where you can find it if your svgalib was install
by a linux distribution.
However, this is no big deal as it was printed out above already ;-).
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR libvga.config (5),
.BR convfont (1),
.BR dumpreg (1),
.BR restorefont (1),
.BR restorepalette (1),
.BR restoretextmode (1),
.BR fix132x43 (1),
.BR savetextmode (1),
.BR setmclk (1),
.BR textmode (1).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced utility as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

71
doc/man1/savetextmode.1 Normal file
View file

@ -0,0 +1,71 @@
.TH savetextmode 1 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
savetextmode, textmode \- save or restore the complete SVGA status for textmode.
.SH SYNOPSIS
.B savetextmode
.br
.B textmode
.SH DESCRIPTION
These are simple scripts to save the SVGA register state when in textmode to the
files
.IR /tmp/fontdata " and " /tmp/textregs
or to restore it from these files.
The actual utilities used are
.BR restorefont (1),
.BR restoretextmode "(1), and "
.BR restorepalette (1).
The purpose of these scripts program is usually to recover from a crashed console due to an
svgalib, Xfree or other program bug.
You do this by being a smart guy and running
.B savetextmode
right after booting of your machine,
.B prior
to any problems. Then, in case the SVGA state is hosed and you sit in front of a blank or
useless console, change VC (maybe login) to get to a shell. Or exist the currently running
program with
.BR <Ctrl>-C ", "
.BR <Ctrl>-<Alt>-<Backspace> ,
or whatever applies. Once you got a shell, run
.B textmode
and it will hopefully render your console useable again.
To make it clear: You do all this while not seeing anything on your console screen, you
enter this information blindly or after logging in from a network. Also, if the keyboard is
left in raw mode, nothing can really help you as you cannot enter anything which a shell
will understand.
.SH FILES
.I /tmp/fontdata
.br
.I /tmp/textregs
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR libvga.config (5),
.BR dumpreg (1),
.BR convfont (1),
.BR fix132x43 (1),
.BR restorefont (1),
.BR restoretextmode (1),
.BR restorepalette (1),
.BR runx (1),
.BR setmclk (1),
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced utility as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

90
doc/man1/setmclk.1 Normal file
View file

@ -0,0 +1,90 @@
.TH setmclk 1 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
setmclk \- adjust the memory timing of certain Cirrus cards.
.SH SYNOPSIS
.BI setmclk
.SH DESCRIPTION
This program sets the
.B memory clock
of Cirrus 5424/26/28 cards.
The first three values could be set by utility programs that
came with my card (AVGA3), but somewhat higher values seem to work (on my
card at least). It may be that better and more recent Cirrus cards use a
higher value as boot-up default. It should depend on DRAM speed, but it
seems to be more dependant on the card logic.
I have the impression that many Cirrus 542x cards suffer from horrible
BIOS version/DRAM timing misconfigurations. Perhaps even some versions of
MS-Windows drivers change the MCLK register. In any case, the boot-up BIOS
default (0x1c) may be inappropriately low for the type of DRAM timing most
cards use.
Using a higher memory clock gives a very significant performance improvement;
with high dot clock modes (like 640x480x16M or 1150x900x256) performance can
be more than twice that of the standard 50 MHz clock. This goes for both
(VLB) framebuffer access and accelerated features (bitblt). This also helps
XFree86 server performance, but only if the XFree86 Cirrus driver doesn't
set the memory clock register (it should work for XFree86 1.3 and 2.0).
Use at your own risk!
Note that the
.B dot clock
is something entirely different. There does not
seem to be much correlation between the two (i.e. if a high dot clock gives
screen problems, using a high memory clock is not likely to fix it, other
than improving speed).
The actual
.B memory clock
is hard compiled into the program. It defaults to 0x1c. You can change this value
and some suggestiong come in th source of the utility.
This utility is part of svgalib and can be found in the
.I utils/
subdirectory of the original svgalib distribution. However, it is not installed
by default, s.t. it is unclear where you can find it if your svgalib was install
linux distribution.
In case of any such problem, simply get an svgalib distribution from the net. You
don't need to install it. Just
.B make
in the
.I utils/
subdirecty. As of this writing,
.I svgalib-1.2.12.tar.gz
is the latest version and can be retrieved by ftp from
.IR "sunsite.unc.edu" " at " "/pub/Linux/libs/graphics"
and
.IR "tsx-11.mit.edu" " at " "/pub/linux/sources/libs"
which will most probably be mirrored by a site close to you.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR libvga.config (5),
.BR convfont (1),
.BR dumpreg (1),
.BR restorefont (1),
.BR restorepalette (1),
.BR restoretextmode (1),
.BR runx (1),
.BR savetextmode (1),
.BR fix132x43 (1),
.BR textmode (1).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced utility as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

41
doc/man1/svgakeymap.1 Normal file
View file

@ -0,0 +1,41 @@
.TH svgakeymap 1 "3 July 1998" "Svgalib 1.3.0" "Svgalib User Manual"
.SH NAME
svgakeymap \- generates keymaps for svgalib
.SH SYNOPSIS
.BI "svgakeymap [" "physical_table" " [" program_table "]] > " output.keymap
.SH DESCRIPTION
Generates a keymap conversion file for
.BR svgalib (7)
from two keytable definitions. Keytables are searched for in
.I /usr/lib/kbd/keytables
and are automatically filtered through
.BR gzip (1)
if necessary.
If only one keytable is specified, a keymap is generated that performs no
conversion but contains the proper key names for that layout. If no keytables
are specified, the standard US QWERTY keyboard is used.
The generated keymap is sent to the standard output and may be redirected
or piped in any creative manner you wish.
.SH FILES
.I /usr/lib/kbd/keytables/*.map[.gz]
.RS
The system keytable files used by
.BR loadkeys "(1)."
.RE
.SH BUGS
Can get confused if there is more than one key with a given name or if names
do not match properly between keytables. Keymaps may require manual editing.
.SH AUTHOR
Brion Vibber <brion@pobox.com>
.SH SEE ALSO
.BR libvga.config (5)
.IR README.keymap " from the svgalib distribution"

1
doc/man1/textmode.1 Normal file
View file

@ -0,0 +1 @@
.so man1/savetextmode.1

View file

@ -0,0 +1 @@
.so man3/gl_getcontext.3

View file

@ -0,0 +1,48 @@
.TH gl_allocatecontext 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_allocatecontext \- allocate a graphics context
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "GraphicsContext *gl_allocatecontext(void);"
.SH DESCRIPTION
Allocate a graphics context. This is preferred to
hardcoding a context variable in a program since the
latter is incompatible with a future vgagl version that
have additional context fields.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR plane (1),
.BR wrapdemo (1),
.BR currentcontext (3),
.BR gl_allocatecontext (3),
.BR gl_copyboxfromcontext (3),
.BR gl_copyboxtocontext (3),
.BR gl_getcontext (3),
.BR gl_setcontext (3),
.BR gl_setcontextheight (3),
.BR gl_setcontextvga (3),
.BR gl_setcontextvgavirtual (3),
.BR gl_setcontextvirtual (3),
.BR gl_setcontextwidth (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

66
doc/man3/gl_bcircle.3 Normal file
View file

@ -0,0 +1,66 @@
.TH gl_bcircle 3 "4 Dec 1999" "Svgalib (>= 1.4.1)" "Svgalib User Manual"
.SH NAME
gl_bcircle \- draw a filled or unfilled Bresenham circle
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_bcircle(int " x ", int " y ", int " r ", int " c ", int " fill ");"
.SH DESCRIPTION
Draw a Bresenham circle of radius
.I r
in color
.I c ,
centered at
.I ( x ", " y ).
.I Fill
should be 0 for a hollow circle, or any other value for a solid color.
This function differs from gl_circle (3) and gl_fillcircle (3) in that it
looks good in 320 x 200 screen modes. The modified algorithm was provided
by Chris Atenasio <chris@svgalib.org>, and is based upon Bresenham's
formula.
Note that the "circle" is technically an ellipse, and is actually wider
than it is tall. Therefore,
.I r
is equal to the circle's height, but is less than its width. This
distortion is necessary to accomodate the 8:5 aspect ratio (e.g., 320 x
200).
I don't recommend using this function in standard 4:3 screen modes (e.g.,
640 x 480 and higher). Furthermore, care must be taken so that a circle
drawn with this function isn't copied to a screen with a different aspect
ratio. Otherwise, the result may be undesirable.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR plane (1),
.BR wrapdemo (1),
.BR gl_circle (3),
.BR gl_clearscreen (3),
.BR gl_colorfont (3),
.BR gl_disableclipping (3),
.BR gl_enableclipping (3),
.BR gl_fillbox (3),
.BR gl_fillcircle (3),
.BR gl_hline (3),
.BR gl_line (3),
.BR gl_setclippingwindow (3),
.BR gl_setpalette (3),
.BR gl_setpalettecolor (3),
.BR gl_setpalettecolors (3),
.BR gl_setpixel (3),
.BR gl_setpixelrgb (3),
.BR gl_setrgbpalette (3),
.BR gl_setwritemode (3).
.SH AUTHOR
This manual page was written by Jay Link <jlink@svgalib.org>.

53
doc/man3/gl_circle.3 Normal file
View file

@ -0,0 +1,53 @@
.TH gl_circle 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_circle \- draw a circle
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_circle(int " x ", int " y ", int " r ", int " c );
.SH DESCRIPTION
Draw a circle of radius
.I r
in color
.IR c ,
centered at
.RI ( x ", " y ).
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR plane (1),
.BR wrapdemo (1),
.BR gl_clearscreen (3),
.BR gl_colorfont (3),
.BR gl_disableclipping (3),
.BR gl_enableclipping (3),
.BR gl_fillbox (3),
.BR gl_hline (3),
.BR gl_line (3),
.BR gl_setclippingwindow (3),
.BR gl_setpalette (3),
.BR gl_setpalettecolor (3),
.BR gl_setpalettecolors (3),
.BR gl_setpixel (3),
.BR gl_setpixelrgb (3),
.BR gl_setrgbpalette (3),
.BR gl_setwritemode (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

39
doc/man3/gl_clearscreen.3 Normal file
View file

@ -0,0 +1,39 @@
.TH gl_clearscreen 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_clearscreen \- clear the screen
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_clearscreen(int " c );
.SH DESCRIPTION
Fill the entire screen with color
.IR c .
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR plane (1),
.BR wrapdemo (1),
.BR currentcontext (3),
.BR gl_circle (3),
.BR gl_fillbox (3),
.BR gl_hline (3),
.BR gl_line (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

45
doc/man3/gl_colorfont.3 Normal file
View file

@ -0,0 +1,45 @@
.TH gl_colorfont 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_colorfont \- change the color of a font
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_colorfont(int " fw ", int " fh ", int " c ", void *" fp );
.SH DESCRIPTION
Set all nonzero pixels in the expanded font
.I fp
with 256 characters of size
.IR fw " and " fh
each to color
.IR c .
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR plane (1),
.BR wrapdemo (1),
.BR gl_colorfont (3),
.BR gl_expandfont (3),
.BR gl_font8x8 (3),
.BR gl_setfontcolors (3),
.BR gl_write (3),
.BR gl_writen (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

View file

@ -0,0 +1,52 @@
.TH gl_compileboxmask 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_compileboxmask \- compress a masked bitmap
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_compileboxmask(int " w ", int " h ", void *" sdp ", void *" ddp );
.SH DESCRIPTION
Convert the rectangular masked bitmap of size
.RI ( w ", " h ") at " sdp
to a compressed format that allows faster drawing, which is
stored at
.IR ddp .
Allocating
.IR w " * " h
bytes for the compiled
version is usually enough; an upper limit should be
.RI ( w " + 2) * " h .
Compiled bitmaps are only supported in linear 256 color modes.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR plane (1),
.BR wrapdemo (1),
.BR gl_compileboxmask (3),
.BR gl_compiledboxmasksize (3),
.BR gl_getbox (3),
.BR gl_putbox (3),
.BR gl_putboxpart (3),
.BR gl_putboxmask (3),
.BR gl_putboxmaskcompiled (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

View file

@ -0,0 +1,46 @@
.TH gl_compiledboxmasksize 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_compiledboxmasksize \- compute the size of a compiled masked box
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "int gl_compiledboxmasksize(int " w ", int " h ", void *" sdp );
.SH DESCRIPTION
Returns the size of the compiled version of the masked
bitmap of size
.RI ( w ", " h )
at
.I sdp
that would be generated by
.BR compileboxmask(3).
Compiled bitmaps are only supported in linear 256 color modes.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR plane (1),
.BR wrapdemo (1),
.BR gl_compileboxmask (3),
.BR gl_putbox (3),
.BR gl_putboxmask (3),
.BR gl_putboxmaskcompiled (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

51
doc/man3/gl_copybox.3 Normal file
View file

@ -0,0 +1,51 @@
.TH gl_copybox 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_copybox \- copy a rectangular screen area
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_copybox(int " x1 ", int " y1 ", int " w ", int " h
.BI ", int "x2 ", int " y2 );
.SH DESCRIPTION
Copy the rectangular area at
.BR (x1 ", " y1 )
of size
.BR (w ", " h ),
to
.BR (x2 ", " y2 )
(screencopy).
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR plane (1),
.BR wrapdemo (1),
.BR gl_copyboxfromcontext (3),
.BR gl_copyboxtocontext (3),
.BR gl_copyscreen (3),
.BR gl_fillbox (3),
.BR gl_getbox (3),
.BR gl_putbox (3),
.BR gl_putboxmask (3),
.BR gl_putboxmaskcompiled (3),
.BR gl_putboxpart (3),
.BR gl_scalebox (3),
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

View file

@ -0,0 +1,57 @@
.TH gl_copyboxfromcontext 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_copyboxfromcontext \- copy rectangular area from another context
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_copyboxfromcontext(GraphicsContext *" gc ", int " x1 ", int "
.IB y1 ", int " w ", int " h ", int " x2 ", int " y2 );
.SH DESCRIPTION
Copy the rectangular area at
.RI ( x1 ", " y1 )
in the context
.IR gc
of size
.RI ( w ", " h )
to position
.RI ( x2 ", " y2 )
in the current context.
This is more efficient than
.BR copyboxtocontext (3).
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR plane (1),
.BR wrapdemo (1),
.BR gl_copybox (3),
.BR gl_copyboxtocontext (3),
.BR gl_copyscreen (3),
.BR gl_fillbox (3),
.BR gl_getbox (3),
.BR gl_getcontext (3),
.BR gl_putbox (3),
.BR gl_putboxmask (3),
.BR gl_putboxmaskcompiled (3),
.BR gl_putboxpart (3),
.BR gl_rgbcolor (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

View file

@ -0,0 +1,52 @@
.TH gl_copyboxtocontext 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_copyboxtocontext \- copy a rectangular area to another context
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_copyboxtocontext(int " x1 ", int " y1 ", int " w ", int " h
.BI ", GraphicsContext *" gc ", int " x2 ", int " y2 );
.SH DESCRIPTION
Copy the rectangular area at
.RI ( x1 ", " y1 )
of size
.RI ( w ", " h )
to position
.RI ( x2 ", " y2 )
in the context
.IR gc .
If possible use
.BR copyboxfromcontext (3).
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR plane (1),
.BR wrapdemo (1),
.BR gl_copybox (3),
.BR gl_copyboxfromcontext (3),
.BR gl_copyscreen (3),
.BR gl_getbox (3),
.BR gl_putbox (3),
.BR gl_putboxmask (3),
.BR gl_putboxmaskcompiled (3),
.BR gl_putboxpart (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

45
doc/man3/gl_copyscreen.3 Normal file
View file

@ -0,0 +1,45 @@
.TH gl_copyscreen 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_copyscreen \- copy the screen contents of contexts
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_copyscreen(GraphicsContext *" gc );
.SH DESCRIPTION
Copy the current graphics context contents (screen data) to
the specified graphics context (the physical screen, for
example). Contexts are assumed to be identical in size.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR plane (1),
.BR wrapdemo (1),
.BR currentcontext (3),
.BR gl_allocatecontext (3),
.BR gl_clearscreen (3),
.BR gl_copybox (3),
.BR gl_copyboxfromcontext (3),
.BR gl_copyboxtocontext (3),
.BR gl_fillbox (3),
.BR gl_getbox (3),
.BR gl_putbox (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

View file

@ -0,0 +1,36 @@
.TH gl_disableclipping 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_disableclipping \- disables clipping
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_disableclipping(void);"
.SH DESCRIPTION
Disable clipping. This is the default.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR plane (1),
.BR wrapdemo (1),
.BR gl_enableclipping (3),
.BR gl_setclippingwindow (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

View file

@ -0,0 +1,41 @@
.TH gl_enableclipping 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_enableclipping \- enables clipping
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_enableclipping(void);"
.SH DESCRIPTION
Enable automatic clipping in most functions. No, I don't know
which ones. However, it works for most.
.BR gl_copybox (3)
is report to do no clipping.
Go figure.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR plane (1),
.BR wrapdemo (1),
.BR gl_disableclipping (3),
.BR gl_setclippingwindow (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

View file

@ -0,0 +1,71 @@
.TH gl_enablepageflipping 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_enablepageflipping \- enables automatic page flipping
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "int gl_enablepageflipping(GraphicsContext *" gc );
.SH DESCRIPTION
Enable page flipping or triple buffering in
.BR gl_copyscreen (3)
if the physical context
.I gc
can do it.
Returns 3 if triple
buffering will be used, 2 for page flipping, 0 if page
flipping is not possible (due to video memory/mode
limitations).
When pageflipping is enabled, the
.BR gl_screenoffset (3)
is ignored in
.BR gl_copyscreen (3).
The idea is that you draw your picture in
.I gc
and copy it to the screen by consecutive
.BR gl_copyscreen (3)
calls. Each of these will choose a free buffer in the screen and
adjust the display start accourdingly.
The current context must by the VGA when
.BR gl_copyscreen (3)
is called in this situation.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR plane (1),
.BR wrapdemo (1),
.BR gl_copybox (3),
.BR gl_copyboxfromcontext (3),
.BR gl_copyboxtocontext (3),
.BR gl_copyscreen (3),
.BR gl_getbox (3),
.BR gl_putbox (3),
.BR gl_setcontext (3),
.BR gl_setcontextheight (3),
.BR gl_setcontextvga (3),
.BR gl_setcontextvgavirtual (3),
.BR gl_setcontextvirtual (3),
.BR gl_setcontextwidth (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

53
doc/man3/gl_expandfont.3 Normal file
View file

@ -0,0 +1,53 @@
.TH gl_expandfont 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_expandfont \- expand a packed pixel font
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_expandfont(int " fw ", int " fh ", int " c ", void *" sfp ", void *" dfp );
.SH DESCRIPTION
Convert a bit-per-pixel font at
.IR sfp
with 256 characters of size
.RI ( fw ", " fh )
to an expanded font of character pixmaps, stored at
.I dfp
(size will be 256 *
.IR fw " * " fw
.RB " * " BYTESPERPIXEL ).
All non-zero pixels are set to color
.IR c .
It is possible to use non expanded fonts (but it is slower) when
the
.BR "FONT_COMPRESSED gl_setwritemode" (3)
flag is set.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR testgl (1),
.BR gl_colorfont (3),
.BR gl_font8x8 (3),
.BR gl_setfont (3),
.BR gl_setfontcolors (3),
.BR gl_setwritemode (3),
.BR gl_write (3),
.BR gl_writen (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

44
doc/man3/gl_fillbox.3 Normal file
View file

@ -0,0 +1,44 @@
.TH gl_fillbox 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_fillbox \- fill a rectangular area
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_fillbox(int " x ", int " y ", int " w ", int " h ", int " c );
.SH DESCRIPTION
Fill a rectangular area at position
.RI ( x ", " y )
with size
.RI ( w ", " h )
of the screen with a single color
.IR c .
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR testgl (1),
.BR currentcontext (3),
.BR gl_clearscreen (3),
.BR gl_getbox (3),
.BR gl_putbox (3),
.BR gl_putboxmask (3),
.BR gl_putboxmaskcompiled (3),
.BR gl_putboxpart (3),
.BR gl_scalebox (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

46
doc/man3/gl_fillcircle.3 Normal file
View file

@ -0,0 +1,46 @@
.TH gl_fillcircle 3 "4 Dec 1999" "Svgalib (>= 1.4.1)" "Svgalib User Manual"
.SH NAME
gl_fillcircle \- draw a filled circle
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_fillcircle(int " x ", int " y ", int " r ", int " c );
.SH DESCRIPTION
Draw a filled circle of radius
.I r
in color
.I c ,
centered at
.I ( x ", " y ).
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR plane (1),
.BR wrapdemo (1),
.BR gl_circle (3),
.BR gl_clearscreen (3),
.BR gl_colorfont (3),
.BR gl_disableclipping (3),
.BR gl_enableclipping (3),
.BR gl_fillbox (3),
.BR gl_hline (3),
.BR gl_line (3),
.BR gl_setclippingwindow (3),
.BR gl_setpalette (3),
.BR gl_setpalettecolor (3),
.BR gl_setpalettecolors (3),
.BR gl_setpixel (3),
.BR gl_setpixelrgb (3),
.BR gl_setrgbpalette (3),
.BR gl_setwritemode (3).
.SH AUTHOR
This manual page was written by Jay Link <jlink@svgalib.org>. The function
itself is based upon the original gl_circle (3).

49
doc/man3/gl_font8x8.3 Normal file
View file

@ -0,0 +1,49 @@
.TH gl_font8x8 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_font8x8 \- a packed 8x8 pixel font
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "extern unsigned char *" gl_font8x8 ;
.SH DESCRIPTION
.I gl_font8x8
contains a packed pixel font with 8x8 pixels per character which you can
use in your
.B vgagl
programs. Before you can use it, you might need to expand it with
.BR gl_expandfont (3),
though.
It is possible to use non expanded fonts (but it is slower) when
the
.BR "FONT_COMPRESSED gl_setwritemode" (3)
flag is set.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR testgl (1),
.BR gl_colorfont (3),
.BR gl_expandfont (3),
.BR gl_setfont (3),
.BR gl_setfontcolors (3),
.BR gl_setwritemode (3),
.BR gl_write (3),
.BR gl_writen (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

45
doc/man3/gl_freecontext.3 Normal file
View file

@ -0,0 +1,45 @@
.TH gl_freecontext 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_freecontext \- free a virtual screen
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_freecontext(GraphicsContext *" gc );
.SH DESCRIPTION
Free the space allocated for the virtual screen in the
given context
.I gc
which should better be a virtual context.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR currentcontext (3),
.BR gl_allocatecontext (3),
.BR gl_copyscreen (3),
.BR gl_getcontext (3),
.BR gl_setcontext (3),
.BR gl_setcontextheight (3),
.BR gl_setcontextvga (3),
.BR gl_setcontextvgavirtual (3),
.BR gl_setcontextvirtual (3),
.BR gl_setcontextwidth (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

51
doc/man3/gl_getbox.3 Normal file
View file

@ -0,0 +1,51 @@
.TH gl_getbox 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_getbox \- copy a rectangular pixmap from the screen to a buffer
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_getbox(int " x ", int " y ", int " w ", int " h ", void *" dp );
.SH DESCRIPTION
Copy a rectangular bitmap at position
.RI ( x ", " y )
with size
.RI ( w ", " h )
from the screen to a buffer
.IR dp .
Pixmaps are in row-major order. The destination pixmap has the size
.IR w " * " h " * "
.BR BYTESPERPIXEL .
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR gl_compileboxmask (3),
.BR gl_compiledboxmasksize (3),
.BR gl_copybox (3),
.BR gl_copyboxfromcontext (3),
.BR gl_copyboxtocontext (3),
.BR gl_putbox (3),
.BR gl_putboxmask (3),
.BR gl_putboxmaskcompiled (3),
.BR gl_putboxpart (3),
.BR gl_scalebox (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

69
doc/man3/gl_getcontext.3 Normal file
View file

@ -0,0 +1,69 @@
.TH gl_getcontext 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_getcontext, currentcontext \- get the current graphics contents.
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_getcontext(GraphicsContext *" gc );
.BI "extern GraphicsContext " currentcontext ;
/* this is already in vgagl.h */
.SH DESCRIPTION
Save the current context in the structure variable
.IR gc .
You can also get the current context from the global
variable
.IR currentcontext ;
However, simply access single elements in this structure
with the macros given in
.BR vgagl (7)
but do not copy
.I currentcontext
in another structure. This is because the size of the structure
might change and your program does not know it when it will be
linked dynamically to future svgalib versions.
Instead use
.BR gl_allocatecontext (3)
to allocate such a structure, fill it with
.B gl_getcontext
and release it with
.BR free (3)
after usage.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR plane (1),
.BR wrapdemo (1),
.BR gl_allocatecontext (3),
.BR gl_copyboxfromcontext (3),
.BR gl_copyboxtocontext (3),
.BR gl_freecontext (3),
.BR gl_setcontext (3),
.BR gl_setcontextheight (3),
.BR gl_setcontextvga (3),
.BR gl_setcontextvgavirtual (3),
.BR gl_setcontextvirtual (3),
.BR gl_setcontextwidth (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

1
doc/man3/gl_getpalette.3 Normal file
View file

@ -0,0 +1 @@
.so man3/gl_getpalettecolor.3

View file

@ -0,0 +1,62 @@
.TH gl_getpalettecolor 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_getpalettecolor, gl_getpalettecolors, gl_getpalette \- read the color palette
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_getpalettecolor(int " c ", int *" r ", int *" g ", int *" b );
.br
.BI "void gl_getpalettecolors(int " s ", int " n ", void *" dp );
.br
.BI "void gl_getpalette(void *" dp );
.SH DESCRIPTION
.B gl_getpalettecolor
gets red, green and blue values (in the range 0 - 63) of
color
.I c
from the color-lookup-table, and stores
them as integers in the memory locations pointed to by
.IR r ", " g " and " b .
.B gl_getpalettecolors
gets RGB values of
.I n
colors starting at
.IR s ,
which are stored
as a table of groups of three bytes each at
.IR dp .
.B gl_getpalette
is equivalent to
.BR "getpalettecolors(0, 256, " dp ).
.BR vga_ext_set (3)
might change the range of the colors returned to 0 - 255.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR vga_ext_set (3),
.BR gl_setpalette (3),
.BR gl_setpalettecolor (3),
.BR gl_setpalettecolors (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

View file

@ -0,0 +1 @@
.so man3/gl_getpalettecolor.3

47
doc/man3/gl_getpixel.3 Normal file
View file

@ -0,0 +1,47 @@
.TH gl_getpixel 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_getpixel \- return the color of a pixel
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "int gl_getpixel(int " x ", int " y );
.SH DESCRIPTION
Returns the color of pixel at position
.RI ( x ", " y )
in the format used in the screen memory.
The color -1 is returned for points outside the clipping window.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR gl_getbox (3),
.BR gl_getpalette (3),
.BR gl_getpalettecolor (3),
.BR gl_getpalettecolors (3),
.BR gl_getpixelrgb (3),
.BR gl_rgbcolor (3),
.BR gl_setpalette (3),
.BR gl_setpalettecolor (3),
.BR gl_setpalettecolors (3),
.BR gl_setpixel (3),
.BR gl_setpixelrgb (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

41
doc/man3/gl_getpixelrgb.3 Normal file
View file

@ -0,0 +1,41 @@
.TH gl_getpixelrgb 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_getpixelrgb \- store color components of a pixel
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_getpixelrgb(int " x ", int " y ", int *" r ", int *" g ", int *" b );
.SH DESCRIPTION
Store color components from pixel at
.RI ( x ", " y )
ranging from 0 to 255 into integers pointed to by
.IR r ", " g " and " b .
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR plane (1),
.BR wrapdemo (1),
.BR gl_getpixel (3),
.BR gl_rgbcolor (3),
.BR gl_setpixel (3),
.BR gl_setpixelrgb (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

47
doc/man3/gl_hline.3 Normal file
View file

@ -0,0 +1,47 @@
.TH gl_hline 3 "9 Feb 2000" "Svgalib (>= 1.4.2)" "Svgalib User Manual"
.SH NAME
gl_hline \- draw a horizontal line
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_hline(int " x1 ", int " y ", int " x2 ", int " c );
.SH DESCRIPTION
Draw a horizontal line from point
.RI ( x1 ", " y )
to
.RI ( x2 ", " y )
in color
.IR c .
x1 must not be larger than x2. If x2<x1 the function does nothing.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR plane (1),
.BR wrapdemo (1),
.BR gl_circle (3),
.BR gl_clearscreen (3),
.BR gl_fillbox (3),
.BR gl_line (3),
.BR gl_setpixel (3),
.BR gl_setpixelrgb (3),
.BR gl_setwritemode (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

56
doc/man3/gl_line.3 Normal file
View file

@ -0,0 +1,56 @@
.TH gl_line 3 "21 Aug 1999" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_line \- draw a line
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_line(int " x1 ", int " y1 ", int " x2 ", int " y2 ", int " c );
.SH DESCRIPTION
Draw a line from point
.RI ( x1 ", " y1 )
to
.RI ( x2 ", " y2 )
inclusively in color
.IR c .
You should not assume that the same drawing trajectory is used when you exchange start and
end points.
To use this program one first sets up a mode with a regular
vga_setmode call and vga_setpage(0), with possibly a
vga_setlinearaddressing
call. Then a call to gl_setcontextvga(mode) is made. This makes the
information about the mode available to gl_line.
The pixels are placed directly into video memory using inline coded
commands.
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR plane (1),
.BR wrapdemo (1),
.BR gl_circle (3),
.BR gl_clearscreen (3),
.BR gl_hline (3),
.BR gl_setpixel (3),
.BR gl_setpixelrgb (3),
.BR gl_setcontextvga (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown. This page was modified by Don Secrest <secrest@uiuc.edu>.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

70
doc/man3/gl_printf.3 Normal file
View file

@ -0,0 +1,70 @@
.TH gl_printf 3 "22 Feb 1997" "Svgalib 1.3.0" "Svgalib User Manual"
.SH NAME
gl_printf \- write formatted output in graphic mode
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "int gl_printf(int " x ", int " y ", const char *" fmt ", ...);"
.SH DESCRIPTION
.B gl_printf
writes, like
.B printf(3)
a formatted string to position
.RI ( x ", " y )
using the currently selected font. If one or both of
.IR x " and " y
is negative, the text printing continues at the last position. The
special characters
.BR \eb ", " \er ", "
.BR \en ", " \ea ", "
.BR \et " and " \ev
have the usual effects.
Printing wraps at the screen borders. Nevertheless, behaviour is undefined
if not a single characters fits on the screen or if the initial position
is outside the screen.
The kind of text draw operation is set with
.BR gl_setwritemode (3).
.B BEWARE!
Prior to the of use of
.BR gl_printf (3)
you must set a font.
A good default initialization sequence is:
.B gl_setfont(8, 8, gl_font8x8);
.br
.B gl_setwritemode(FONT_COMPRESSED + WRITEMODE_OVERWRITE);
.br
.B gl_setfontcolors(0, vga_white());
.br
.SH RETURN VALUE
The number of characters printed.
.SH BUGS
For compatibility reasons this function is not contained in a.out
libraries.
.SH SEE ALSO
.BR printf (3),
.BR svgalib (7),
.BR vgagl (7),
.BR gl_colorfont (3),
.BR gl_expandfont (3),
.BR gl_font8x8 (3),
.BR gl_setfont (3),
.BR gl_setfontcolors (3),
.BR gl_setwritemode (3),
.BR gl_write (3),
.BR gl_writechar (3),
.BR printftest (6).
.SH AUTHOR
This function and manual page was written by Trek <trek00@freenet.hut.fi>
<trek@mediaservice.net>.

52
doc/man3/gl_putbox.3 Normal file
View file

@ -0,0 +1,52 @@
.TH gl_putbox 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_putbox \- copy a pixmap to a rectangular area
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_putbox(int " x ", int " y ", int " w ", int " h ", void *" dp );
.SH DESCRIPTION
Copy the contents of a memory buffer
.I dp
to a rectangular bitmap at position
.RI ( x ", " y )
with size
.RI ( w ", " h ).
Pixmaps are in row-major order. The source pixmap memory has the size
.IR w " * " h " * "
.BR BYTESPERPIXEL .
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR gl_compileboxmask (3),
.BR gl_compiledboxmasksize (3),
.BR gl_copybox (3),
.BR gl_copyboxfromcontext (3),
.BR gl_copyboxtocontext (3),
.BR gl_fillbox (3),
.BR gl_getbox (3),
.BR gl_putboxmask (3),
.BR gl_putboxmaskcompiled (3),
.BR gl_putboxpart (3),
.BR gl_scalebox (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

58
doc/man3/gl_putboxmask.3 Normal file
View file

@ -0,0 +1,58 @@
.TH gl_putboxmask 3 "2 Aug 1997" "Svgalib (>= 1.2.11)" "Svgalib User Manual"
.SH NAME
gl_putboxmask \- copy a masked pixmap to a rectangular area
.SH SYNOPSIS
.B #include <vgagl.h>
.BI "void gl_putboxmask(int " x ", int " y ", int " w ", int " h ", void *" dp );
.SH DESCRIPTION
Copy the contents of a memory buffer
.I dp
to a rectangular bitmap at position
.RI ( x ", " y )
with size
.RI ( w ", " h ).
This function works like
.BR gl_putbox ,
but does not write pixmap pixels of color zero. If the same pixmap is used often
you should consider using the faster
.BR gl_putboxmaskcompiled (3).
Pixmaps are in row-major order. The source pixmap memory has the size
.IR w " * " h " * "
.BR BYTESPERPIXEL .
.SH SEE ALSO
.BR svgalib (7),
.BR vgagl (7),
.BR svgalib.conf (5),
.BR threedkit (7),
.BR testgl (1),
.BR gl_compileboxmask (3),
.BR gl_compiledboxmasksize (3),
.BR gl_copybox (3),
.BR gl_copyboxfromcontext (3),
.BR gl_copyboxtocontext (3),
.BR gl_fillbox (3),
.BR gl_getbox (3),
.BR gl_putbox (3),
.BR gl_putboxmaskcompiled (3),
.BR gl_putboxpart (3),
.BR gl_scalebox (3).
.SH AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The
exact source of the referenced demo as well as of the original documentation is
unknown.
It is very likely that both are at least to some extent are due to
Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby
asked to be excused by the original author and will happily accept any additions or corrections
to this first version of the svgalib manual.

Some files were not shown because too many files have changed in this diff Show more