Subversion Repositories SvarDOS

Compare Revisions

Ignore whitespace Rev 1359 → Rev 1360

/sved/trunk/mdr/inc/mdr/bios.h
0,0 → 1,35
/*
* BIOS functions
*
* This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
* Published under the terms of the MIT License, as stated below.
*
* Copyright (C) 2014-2023 Mateusz Viste
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
 
#ifndef MDR_BIOS_H
#define MDR_BIOS_H
 
/* waits for ticks time (1 tick is roughly 55ms, an hour has 65543 ticks)
* works on IBM PC, XT, AT - ie. it's always safe */
void mdr_bios_tickswait(unsigned short ticks);
 
#endif
/sved/trunk/mdr/inc/mdr/cout.h
0,0 → 1,71
/*
* Console output
*
* This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
* Published under the terms of the MIT License, as stated below.
*
* Copyright (C) 2014-2023 Mateusz Viste
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
 
#ifndef MDR_COUT
#define MDR_COUT
 
/* inits the subsystem, fills arguments with:
* w = screen width
* h = screen height
* Any of these arguments may be passed as NULL
* Returns a color flag (0=mono, non-zero=color) */
unsigned char mdr_cout_init(unsigned char *w, unsigned char *h);
 
/* get current attribute value under cursor and returns it */
int mdr_cout_getcurattr(void);
 
void mdr_cout_close(void);
void mdr_cout_cursor_hide(void);
void mdr_cout_cursor_show(void);
 
/* gets cursor's position on screen (row, column) and shape */
void mdr_cursor_getinfo(unsigned char *column, unsigned char *row, unsigned short *shape);
 
void mdr_cout_locate(unsigned char row, unsigned char column);
 
/* print a single character on screen */
void mdr_cout_char(unsigned char y, unsigned char x, char c, unsigned char attr);
 
/* print a single character on screen, repeated count times */
void mdr_cout_char_rep(unsigned char y, unsigned char x, char c, unsigned char attr, unsigned char count);
 
/* print a nul-terminated string on screen, up to maxlen characters
* returns the number of characters actually displayed */
unsigned char mdr_cout_str(unsigned char y, unsigned char x, const char *s, unsigned char attr, unsigned char maxlen);
 
/* clears screen, filling it with a single color attribute */
void mdr_cout_cls(unsigned char colattr);
 
void mdr_cout_getconprops(unsigned char *termwidth, unsigned char *termheight, unsigned char *colorflag);
 
/* functions below do not need mdr_cout_init() initialization, they may be
* used to display characters or nul-terminated strings to console right away
* as they use DOS services */
void mdr_coutraw_char(char c);
void mdr_coutraw_puts(const char *s);
 
#endif
/sved/trunk/mdr/inc/mdr/dos.h
0,0 → 1,69
/*
* Functions interacting with DOS
*
* This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
* Published under the terms of the MIT License, as stated below.
*
* Copyright (C) 2014-2022 Mateusz Viste
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
 
#ifndef MDR_DOS_H
#define MDR_DOS_H
 
#include <time.h> /* time_t */
 
/* returns a far pointer to the current process PSP structure */
void far *mdr_dos_psp(void);
 
/* returns a far pointer to the environment block of the current process */
char far *mdr_dos_env(void);
 
/* looks for varname in the DOS environment and fills result with its value if
* found. returns NULL if not found or if value is too big to fit in result
* (reslimit exceeded). returns result on success.
* NOTE: this function performs case-sensitive matches */
char *mdr_dos_getenv(char *result, const char *varname, unsigned short reslimit);
 
/* fetches directory where the program was loaded from and return its length.
* path string is never longer than 128 (incl. the null terminator) and it is
* always terminated with a backslash separator, unless it is an empty string */
unsigned char mdr_dos_exepath(char *path);
 
/* converts a "DOS format" 16-bit packed date into a standard (time_t)
* unix timestamp. A DOS date is a 16-bit value:
* YYYYYYYM MMMDDDDD
*
* day of month is always within 1-31 range;
* month is always within 1-12 range;
* year starts at 1980 and continues for 127 years */
time_t mdr_dos_date2unix(unsigned short d);
 
/* converts a "DOS format" 16-bit packed time into hours, minutes and seconds
*
* A DOS time is a 16-bit value:
* HHHHHMMM MMMSSSSS
*
* HHHHH = hours, always within 0-23 range
* MMMMMM = minutes, always within 0-59 range
* SSSSS = seconds/2 (always within 0-29 range) */
void mdr_dos_time2hms(unsigned char *h, unsigned char *m, unsigned char *s, unsigned short t);
 
#endif
/sved/trunk/mdr/inc/mdr/keyb.h
0,0 → 1,41
/*
* Keyboard routines
*
* This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
* Published under the terms of the MIT License, as stated below.
*
* Copyright (C) 2014-2023 Mateusz Viste
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
 
#ifndef KEYB_MDR_H
#define KEYB_MDR_H
 
/* waits for a keypress and return it. Extended keys are returned ORed with
* 0x100 (example: PGUP is 0x149). */
int keyb_getkey(void);
 
/* poll the keyboard, and return the next input key if any, or -1 */
int keyb_getkey_ifany(void);
 
/* flush the keyboard buffer */
void keyb_flush(void);
 
#endif
/sved/trunk/mdr/inc/mdr/mouse.h
0,0 → 1,48
/*
* Mouse routines
*
* This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
* Published under the terms of the MIT License, as stated below.
*
* Copyright (C) 2014-2022 Mateusz Viste
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
 
#ifndef MDR_MOUSE_H
#define MDR_MOUSE_H
 
/* init the mouse driver (and checks for presence of mouse support at same time)
* returns 0 if no mouse is present, and the number of buttons otherwise */
int mouse_init(void);
 
/* shows the mouse pointer */
void mouse_show(void);
 
/* hides the mouse pointer */
void mouse_hide(void);
 
/* get x/y coordinates of the mouse, and returns a bitfield with state of buttons */
int mouse_getstate(int *x, int *y);
 
/* get x/y coordinates of the mouse when the last button release occured since last check.
returns the id of the button pressed (1 or 2), or 0 if no event occured. */
int mouse_fetchrelease(int *x, int *y);
 
#endif
/sved/trunk/mdr/inc/mdr/pcx.h
0,0 → 1,50
/*
* PCX-loading routines
*
* This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
* Published under the terms of the MIT License, as stated below.
*
* Copyright (C) 2022 Mateusz Viste
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
 
#ifndef MDR_PCX_H
#define MDR_PCX_H
 
struct pcx_hdr {
unsigned char rle;
unsigned char bpp;
unsigned short max_x;
unsigned short max_y;
unsigned short bytes_per_scanline;
struct {
unsigned char r;
unsigned char g;
unsigned char b;
} pal[256];
};
 
int pcx_anal(struct pcx_hdr *h, FILE *fd, unsigned long offset, unsigned short len);
int pcx_load(void *ptr, size_t ptrsz, const struct pcx_hdr *h, FILE *fd, unsigned long offset);
 
/* convert img to 8bpp if needed (ie unpack 2 and 4bpp data to 8bpp) */
int pcx_convto8bpp(void *img, const struct pcx_hdr *h);
 
#endif
/sved/trunk/mdr/inc/mdr/rs232.h
0,0 → 1,47
/*
* Reading from and writing to an RS-232 port
*
* This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
* Published under the terms of the MIT License, as stated below.
*
* Copyright (C) 2015-2022 Mateusz Viste
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
 
#ifndef MDR_RS232_H
#define MDR_RS232_H
 
/* get the I/O port for COMx (1..4) */
unsigned short rs232_getport(int x);
 
/* check if the COM port is ready for write. loops for some time waiting.
* returns 0 if port seems ready eventually, non-zero otherwise. can be used
* to verify the rs232 presence */
int rs232_check(unsigned short port);
 
/* write a byte to the COM port at 'port'. this function will block if the
* UART is not ready to transmit yet. */
void rs232_write(unsigned short port, int data);
 
/* read a byte from COM port at 'port'. returns the read byte, or -1 if
* nothing was available to read. */
int rs232_read(unsigned short port);
 
#endif
/sved/trunk/mdr/inc/mdr/sbdigi.h
0,0 → 1,57
/*
* SoundBlaster routines for DSP driving
*
* Copyright (C) 2022 Mateusz Viste
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
 
#ifndef MDR_SBDIGI_H
#define MDR_SBDIGI_H
 
struct sbdigi_ctx;
 
/* initializes the SoundBlaster DSP chip
* blaster must point to a BLASTER environment string (like "A220 I5 D1")
* returns a pointer to a context, NULL on error
* NOTE: DSP's state after initialization may or may not be muted, depending
* on the exact hardware revision. use sbdigi_spkoff() to make sure it is
* unmuted */
struct sbdigi_ctx *sbdigi_init(const char *blaster);
 
/* unmutes the SoundBlaster DSP */
void sbdigi_spkon(struct sbdigi_ctx *ctx);
 
/* mutes the SoundBlaster DSP */
void sbdigi_spkoff(struct sbdigi_ctx *ctx);
 
/* plays a short sample
* ctx - DSP context, as returned by sbdigi_init()
* buf - pointer to sample data (must be PCM, 8000 Hz, mono, 8-bit unsigned
* len - length of the sample, in bytes
* NOTES: this routine uses DMA to transfer memory. This has two implications:
* 1. the routine will return almost immediately, while the sound is playing
* 2. sample data must be contained in a buffer that does NOT cross a 64K page
* because DMA transfers are unable to cross 64K boundaries */
void sbdigi_playsample(struct sbdigi_ctx *ctx, void *buf, unsigned short len);
 
/* shuts down the DSP and frees context memory */
void sbdigi_quit(struct sbdigi_ctx *ctx);
 
#endif
/sved/trunk/mdr/inc/mdr/timer.h
0,0 → 1,52
/*
* High-resolution timing routines (PIT reprogramming)
*
* This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
* Published under the terms of the MIT License, as stated below.
*
* Copyright (C) 2014-2022 Mateusz Viste
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
 
#ifndef MDR_TIMER_H
#define MDR_TIMER_H
 
/* reset the timer value, this can be used by the application to make sure
* no timer wrap occurs during critical parts of the code flow */
void timer_reset(void);
 
/* This routine will stop the fast clock if it is going. It has void return
* value so that it can be an exit procedure. */
void timer_stop(void);
 
/* This routine will start the fast clock rate by installing the
* handle_clock routine as the interrupt service routine for the clock
* interrupt and then setting the interrupt rate up to its higher speed
* by programming the 8253 timer chip.
* This routine does nothing if the clock rate is already set to
* its higher rate, but then it returns -1 to indicate the error. */
void timer_init(void);
 
/* This routine will return the present value of the time, which is
* read from the nowtime structure. Interrupts are disabled during this
* time to prevent the clock from changing while it is being read. */
void timer_read(unsigned long *res);
 
#endif
/sved/trunk/mdr/inc/mdr/trigint.h
0,0 → 1,46
/*
* Routines for computation of basic transcendental functions sin and cos.
* These routines use only integers, hence they do not require an FPU nor any
* kind of FPU emulation. Works reasonably fast even on an 8086 CPU.
*
* The results are computed using polynomial approximations. Their precision
* is not expected to be ideal, but "good enough" for common usage.
*
* This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
* Published under the terms of the MIT License, as stated below.
*
* Copyright (C) 2022 Mateusz Viste
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
 
#ifndef MDR_TRIGINT_H
#define MDR_TRIGINT_H
 
/* Computes the cosine value for the given radian.
* The radian argument must be provided multiplied by 1000.
* Returns the cosine value multiplied by 1000. */
short trigint_cos(short rad1000);
 
/* Computes the sine value for the given radian angle.
* The radian argument must be provided multiplied by 1000.
* Returns the cosine value multiplied by 1000. */
short trigint_sin(short rad1000);
 
#endif
/sved/trunk/mdr/inc/mdr/unzip.h
0,0 → 1,58
/*
* Function to iterate through files in a ZIP archive.
*
* This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
* Published under the terms of the MIT License, as stated below.
*
* Copyright (C) 2012-2022 Mateusz Viste
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
 
#ifndef MDR_UNZIP
#define MDR_UNZIP
 
#include <stdio.h> /* FILE * */
 
#define ZIP_FLAG_ISADIR 1
#define ZIP_FLAG_ENCRYPTED 2
 
#define ZIP_METH_STORE 0
#define ZIP_METH_DEFLATE 8
 
struct mdr_zip_item {
unsigned long filelen;
unsigned long compressedfilelen;
unsigned long crc32;
unsigned long dataoffset; /* offset in the file where compressed data starts */
unsigned long nextidxoffset; /* offset in the file of the next zip record, used by mdr_zip_iter() */
unsigned short dosdate; /* datestamp of the file (DOS packed format) */
unsigned short dostime; /* timestamp of the file (DOS packed format) */
unsigned short compmethod; /* compression method (ZIP_METH_xxx) */
unsigned char flags; /* see ZIP_FLAG_xxx above */
char fname[256]; /* filename */
};
 
/* returns next item found in zip file. this is supposed to be called
* iteratively, passing the previous mdr_zipitem struct each time (z must be
* all zeroed out on first call).
* returns 0 on success, neg on error, 1 on end of archive */
int mdr_zip_iter(struct mdr_zip_item *z, FILE *fd);
 
#endif
/sved/trunk/mdr/inc/mdr/ver.h
0,0 → 1,33
/*
* MDR version
*
* This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
* Published under the terms of the MIT License, as stated below.
*
* Copyright (C) 2014-2023 Mateusz Viste
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
 
#ifndef MDR_VER_H
 
#define MDR_VER_MAJOR 2023
#define MDR_VER_MINOR 0
 
#endif
/sved/trunk/mdr/inc/mdr/vid12.h
0,0 → 1,72
/*
* a few functions for mode 12h programming (640x480 4bpp)
*
* This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
* Published under the terms of the MIT License, as stated below.
*
* Copyright (C) 2022 Mateusz Viste
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
 
#ifndef MDR_VID12_H
 
#define MDR_VID12_H
 
/* init video mode 12h (640x480x16c) */
void vid12_init(void);
 
/* Wait until VBLANK */
void vid12_waitvblank(void);
 
/* clear screen using color
* this function is fastest when color is 0 or 15 */
void vid12_cls(unsigned char color);
 
/* clear a single scanline (0..479) with a solid color (0..15)
* this function is fastest when color is 0 or 15 */
void vid12_clrline(unsigned short line, unsigned char color);
 
/* fill lines from linefirst to linelast with an 8 pixels pattern
* linelast must be equal to or greater than linelast
* pattern must be 8 bytes long */
void vid12_linepat(unsigned short linefirst, unsigned short linelast, const unsigned char *pattern);
 
void vid12_close(void);
 
void vid12_putpixel(unsigned short x, unsigned short y, unsigned char col);
 
/* draws a horizonatal line from [x1,y] to [x2,y] */
void vid12_hline(unsigned short y, unsigned short x1, unsigned short x2, unsigned char color);
 
void vid12_putscanline(unsigned short scanline, const unsigned char *pixels);
 
/* prepares VGA for a VRAM-to-VRAM copy operation */
void vid12_vramcpy_prep(void);
 
/* fast (VRAM-to-VRAM) copy of a scanline (0..479) to another scanline.
* vid12_vramcpy_prep() must be called before and vid12_vramcpy_done must be
* called after one or more vid12_vramcpy_scanline() calls. */
void vid12_vramcpy_scanline(unsigned short dst, unsigned short src);
 
/* sets VGA back to its normal state after VRAM-to-VRAM operations */
void vid12_vramcpy_done(void);
 
void vid12_setpalette(unsigned char index, unsigned char r, unsigned char g, unsigned char b);
#endif
/sved/trunk/mdr/inc/mdr/video.h
0,0 → 1,94
/*
* video library - provides a few functions for mode 4 and 13h programming.
*
* This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
* Published under the terms of the MIT License, as stated below.
*
* Copyright (C) 2014-2023 Mateusz Viste
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
 
#ifndef MDR_VIDEO_H
 
#define MDR_VIDEO_H
 
#define VIDEO_DBUF 1
 
struct video_handler {
unsigned char far *dbuf;
int flags;
int mode;
unsigned char lastmode;
};
 
/* returns 0 if no VGA has been detected, non-zero otherwise */
int video_detectvga(void);
 
/* returns 0 if no EGA has been detected, non-zero otherwise */
int video_detectega(void);
 
/* init video mode. either 0x04 for CGA or 0x13 for VGA */
struct video_handler *video_open(int mode, int flags);
 
/* reads a screen dump from file and puts it to the screen buffer */
void video_file2screen(struct video_handler *handler, char *file);
 
/* load count colors of palette from array of rgb triplets */
void video_loadpal(const unsigned char *pal, int count, int offset);
 
/* Wait until VBLANK */
void video_waitvblank(void);
 
void video_flip(struct video_handler *handler);
 
/* copies line ysrc over ydst in CGA mode memory */
void video_cgalinecopy(struct video_handler *handler, int ydst, int ysrc);
 
/* clear screen using color */
void video_cls(struct video_handler *handler, unsigned char color);
 
/* renders a sprite of width and height dimensions onscreen, starting at specified x/y location
coloffset is an offset to add to color indexes, while transp is the index of the transparent color (set to -1 if none) */
void video_putsprite(struct video_handler *handler, unsigned char *sprite, int x, int y, int width, int height, int coloffset, int transp, int maxcol);
 
/* same as video_putsprite(), but reads the sprite from a file */
void video_putspritefromfile(struct video_handler *handler, char *file, long foffset, int x, int y, int width, int height, int coloffset, int transp, int maxcol);
 
void video_close(struct video_handler *handler);
 
void video_rputpixel(struct video_handler *handler, int x, int y, unsigned char col, int repeat);
 
/* render a horizontal line of length len starting at x/y */
void video_hline(struct video_handler *handler, int x, int y, int len, unsigned char color);
 
/* render a vertical line of length len starting at x/y */
void video_vline(struct video_handler *handler, int x, int y, int len, unsigned char color);
 
void video_line(struct video_handler *handler, int x1, int y1, int x2, int y2, unsigned char color);
 
void video_rect(struct video_handler *handler, int x, int y, int width, int height, unsigned char color);
 
/* renders a rectangle on screen, at position x/y, filled with color */
void video_rectfill(struct video_handler *handler, int x, int y, int width, int height, unsigned char color);
 
void video_setpalette(unsigned char index, unsigned char r, unsigned char g, unsigned char b);
 
void video_getpalette(unsigned char index, unsigned char *r, unsigned char *g, unsigned char *b);
#endif
/sved/trunk/mdr/inc/mdr/wave.h
0,0 → 1,42
/*
* WAVE-loading routines
*
* Copyright (C) 2022 Mateusz Viste
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
 
#ifndef MDR_WAVE_H
#define MDR_WAVE_H
 
struct wave_t {
unsigned short format;
unsigned short channels;
unsigned short rate;
unsigned short bitdepth;
unsigned long dataoffset;
unsigned long len;
};
 
/* looks at an open WAVE file and fills the wav structure with related
* information (format, number of channels, bit depth, data rate, etc)
* returns 0 on success */
int wave_anal(struct wave_t *wav, FILE *fd);
 
#endif
/sved/trunk/mdr/inc/mdr/xms.h
0,0 → 1,51
/*
* XMS driver
*
* This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
* Published under the terms of the MIT License, as stated below.
*
* Copyright (C) 2014-2022 Mateusz Viste
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
 
#ifndef MDR_XMS_H
#define MDR_XMS_H
 
struct xms_struct {
unsigned int handle;
long memsize; /* allocated memory size, in bytes */
};
 
/* checks if a XMS driver is installed, inits it and allocates a memory block of memsize K-bytes.
* if memsize is 0, then the maximum possible block will be allocated.
* returns the amount of allocated memory (in K-bytes) on success, 0 otherwise. */
unsigned int xms_init(struct xms_struct *xms, unsigned int memsize);
 
/* free XMS memory */
void xms_close(struct xms_struct *xms);
 
/* copies a chunk of memory from conventional memory into the XMS block.
returns 0 on sucess, non-zero otherwise. */
int xms_push(struct xms_struct *xms, void far *src, unsigned int len, long xmsoffset);
 
/* copies a chunk of memory from the XMS block into conventional memory */
int xms_pull(struct xms_struct *xms, long xmsoffset, void far *dst, unsigned int len);
 
#endif