Subversion Repositories SvarDOS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1661 mateusz.vi 1
/*
2
 * video library - provides a few functions for mode 4 and 13h programming.
3
 *
4
 * This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
5
 * Published under the terms of the MIT License, as stated below.
6
 *
7
 * Copyright (C) 2014-2023 Mateusz Viste
8
 *
9
 * Permission is hereby granted, free of charge, to any person obtaining a copy
10
 * of this software and associated documentation files (the "Software"), to
11
 * deal in the Software without restriction, including without limitation the
12
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
13
 * sell copies of the Software, and to permit persons to whom the Software is
14
 * furnished to do so, subject to the following conditions:
15
 *
16
 * The above copyright notice and this permission notice shall be included in
17
 * all copies or substantial portions of the Software.
18
 *
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25
 * IN THE SOFTWARE.
26
 */
27
 
28
#ifndef MDR_VIDEO_H
29
 
30
  #define MDR_VIDEO_H
31
 
32
  #define VIDEO_DBUF 1
33
 
34
  struct video_handler {
35
    unsigned char far *dbuf;
36
    int flags;
37
    int mode;
38
    unsigned char lastmode;
39
  };
40
 
41
  /* returns 0 if no VGA has been detected, non-zero otherwise */
42
  int video_detectvga(void);
43
 
44
  /* returns 0 if no EGA has been detected, non-zero otherwise */
45
  int video_detectega(void);
46
 
47
  /* init video mode. either 0x04 for CGA or 0x13 for VGA */
48
  struct video_handler *video_open(int mode, int flags);
49
 
50
  /* reads a screen dump from file and puts it to the screen buffer */
51
  void video_file2screen(struct video_handler *handler, char *file);
52
 
53
  /* load count colors of palette from array of rgb triplets */
54
  void video_loadpal(const unsigned char *pal, int count, int offset);
55
 
56
  /* Wait until VBLANK */
57
  void video_waitvblank(void);
58
 
59
  void video_flip(struct video_handler *handler);
60
 
61
  /* copies line ysrc over ydst in CGA mode memory */
62
  void video_cgalinecopy(struct video_handler *handler, int ydst, int ysrc);
63
 
64
  /* clear screen using color */
65
  void video_cls(struct video_handler *handler, unsigned char color);
66
 
67
  /* renders a sprite of width and height dimensions onscreen, starting at specified x/y location
68
     coloffset is an offset to add to color indexes, while transp is the index of the transparent color (set to -1 if none) */
69
  void video_putsprite(struct video_handler *handler, unsigned char *sprite, int x, int y, int width, int height, int coloffset, int transp, int maxcol);
70
 
71
  /* same as video_putsprite(), but reads the sprite from a file */
72
  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);
73
 
74
  void video_close(struct video_handler *handler);
75
 
76
  void video_rputpixel(struct video_handler *handler, int x, int y, unsigned char col, int repeat);
77
 
78
  /* render a horizontal line of length len starting at x/y */
79
  void video_hline(struct video_handler *handler, int x, int y, int len, unsigned char color);
80
 
81
  /* render a vertical line of length len starting at x/y */
82
  void video_vline(struct video_handler *handler, int x, int y, int len, unsigned char color);
83
 
84
  void video_line(struct video_handler *handler, int x1, int y1, int x2, int y2, unsigned char color);
85
 
86
  void video_rect(struct video_handler *handler, int x, int y, int width, int height, unsigned char color);
87
 
88
  /* renders a rectangle on screen, at position x/y, filled with color */
89
  void video_rectfill(struct video_handler *handler, int x, int y, int width, int height, unsigned char color);
90
 
91
  void video_setpalette(unsigned char index, unsigned char r, unsigned char g, unsigned char b);
92
 
93
  void video_getpalette(unsigned char index, unsigned char *r, unsigned char *g, unsigned char *b);
94
#endif