~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to mess/src/mame/video/pk8000.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Jordi Mallach, Emmanuel Kasper
  • Date: 2011-12-19 22:56:27 UTC
  • mfrom: (0.1.2)
  • Revision ID: package-import@ubuntu.com-20111219225627-ub5oga1oys4ogqzm
Tags: 0.144-1
[ Jordi Mallach ]
* Fix syntax errors in DEP5 copyright file (lintian).
* Use a versioned copyright Format specification field.
* Update Vcs-* URLs.
* Move transitional packages to the new metapackages section, and make
  them priority extra.
* Remove references to GNU/Linux and MESS sources from copyright.
* Add build variables for s390x.
* Use .xz tarballs as it cuts 4MB for the upstream sources.
* Add nplayers.ini as a patch. Update copyright file to add CC-BY-SA-3.0.

[ Emmanuel Kasper ]
* New upstream release. Closes: #651538.
* Add Free Desktop compliant png icons of various sizes taken from
  the hydroxygen iconset
* Mess is now built from a new source package, to avoid possible source
  incompatibilities between mame and the mess overlay.
* Mame-tools are not built from the mame source package anymore, but
  from the mess source package

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "emu.h"
2
 
#include "includes/pk8000.h"
3
 
 
4
 
static UINT8 pk8000_text_start;
5
 
static UINT8 pk8000_chargen_start;
6
 
static UINT8 pk8000_video_start;
7
 
static UINT8 pk8000_color_start;
8
 
 
9
 
UINT8 pk8000_video_mode;
10
 
static UINT8 pk8000_video_color;
11
 
static UINT8 pk8000_color[32];
12
 
UINT8 pk8000_video_enable;
13
 
 
14
 
READ8_HANDLER(pk8000_video_color_r)
15
 
{
16
 
        return pk8000_video_color;
17
 
}
18
 
 
19
 
WRITE8_HANDLER(pk8000_video_color_w)
20
 
{
21
 
        pk8000_video_color = data;
22
 
}
23
 
 
24
 
READ8_HANDLER(pk8000_text_start_r)
25
 
{
26
 
        return pk8000_text_start;
27
 
}
28
 
 
29
 
WRITE8_HANDLER(pk8000_text_start_w)
30
 
{
31
 
        pk8000_text_start = data;
32
 
}
33
 
 
34
 
READ8_HANDLER(pk8000_chargen_start_r)
35
 
{
36
 
        return pk8000_chargen_start;
37
 
}
38
 
 
39
 
WRITE8_HANDLER(pk8000_chargen_start_w)
40
 
{
41
 
        pk8000_chargen_start = data;
42
 
}
43
 
 
44
 
READ8_HANDLER(pk8000_video_start_r)
45
 
{
46
 
        return pk8000_video_start;
47
 
}
48
 
 
49
 
WRITE8_HANDLER(pk8000_video_start_w)
50
 
{
51
 
        pk8000_video_start = data;
52
 
}
53
 
 
54
 
READ8_HANDLER(pk8000_color_start_r)
55
 
{
56
 
        return pk8000_color_start;
57
 
}
58
 
 
59
 
WRITE8_HANDLER(pk8000_color_start_w)
60
 
{
61
 
        pk8000_color_start = data;
62
 
}
63
 
 
64
 
READ8_HANDLER(pk8000_color_r)
65
 
{
66
 
        return pk8000_color[offset];
67
 
}
68
 
 
69
 
WRITE8_HANDLER(pk8000_color_w)
70
 
{
71
 
        pk8000_color[offset] = data;
72
 
}
73
 
 
74
 
static const rgb_t pk8000_palette[16] = {
75
 
        MAKE_RGB(0x00, 0x00, 0x00), // 0
76
 
        MAKE_RGB(0x00, 0x00, 0x00), // 1
77
 
        MAKE_RGB(0x00, 0xc0, 0x00), // 2
78
 
        MAKE_RGB(0x00, 0xff, 0x00), // 3
79
 
        MAKE_RGB(0x00, 0x00, 0xc0), // 4
80
 
        MAKE_RGB(0x00, 0x00, 0xff), // 5
81
 
        MAKE_RGB(0x00, 0xc0, 0xc0), // 6
82
 
        MAKE_RGB(0x00, 0xff, 0xff), // 7
83
 
        MAKE_RGB(0xc0, 0x00, 0x00), // 8
84
 
        MAKE_RGB(0xff, 0x00, 0x00), // 9
85
 
        MAKE_RGB(0xc0, 0xc0, 0x00), // A
86
 
        MAKE_RGB(0xff, 0xff, 0x00), // B
87
 
        MAKE_RGB(0xc0, 0x00, 0xc0), // C
88
 
        MAKE_RGB(0xff, 0x00, 0xff), // D
89
 
        MAKE_RGB(0xc0, 0xc0, 0xc0), // E
90
 
        MAKE_RGB(0xff, 0xff, 0xff),     // F
91
 
};
92
 
 
93
 
PALETTE_INIT( pk8000 )
94
 
{
95
 
        palette_set_colors(machine, 0, pk8000_palette, ARRAY_LENGTH(pk8000_palette));
96
 
}
97
 
 
98
 
UINT32 pk8000_video_update(device_t *screen, bitmap_t *bitmap, const rectangle *cliprect, UINT8 *videomem)
99
 
{
100
 
        int x,y,j,b;
101
 
        UINT16 offset = (pk8000_video_mode & 0xc0) << 8;
102
 
        rectangle my_rect;
103
 
        my_rect.min_x = 0;
104
 
        my_rect.max_x = 256+32-1;
105
 
        my_rect.min_y = 0;
106
 
        my_rect.max_y = 192+32-1;
107
 
 
108
 
        if (pk8000_video_enable) {
109
 
                bitmap_fill(bitmap, &my_rect, (pk8000_video_color >> 4) & 0x0f);
110
 
 
111
 
                if (BIT(pk8000_video_mode,4)==0){
112
 
                        // Text mode
113
 
                        if (BIT(pk8000_video_mode,5)==0){
114
 
                                // 32 columns
115
 
                                for (y = 0; y < 24; y++)
116
 
                                {
117
 
                                        for (x = 0; x < 32; x++)
118
 
                                        {
119
 
                                                UINT8 chr  = videomem[x +(y*32) + ((pk8000_text_start & 0x0f) << 10)+offset] ;
120
 
                                                UINT8 color= pk8000_color[chr>>3];
121
 
                                                for (j = 0; j < 8; j++) {
122
 
                                                        UINT8 code = videomem[((chr<<3) + j) + ((pk8000_chargen_start & 0x0e) << 10)+offset];
123
 
 
124
 
                                                        for (b = 0; b < 8; b++)
125
 
                                                        {
126
 
                                                                UINT8 col = (code >> b) & 0x01 ? (color & 0x0f) : ((color>>4) & 0x0f);
127
 
                                                                *BITMAP_ADDR16(bitmap, (y*8)+j+16, x*8+(7-b)+16) =  col;
128
 
                                                        }
129
 
                                                }
130
 
                                        }
131
 
                                }
132
 
                        } else {
133
 
                                // 40 columns
134
 
                                for (y = 0; y < 24; y++)
135
 
                                {
136
 
                                        for (x = 0; x < 42; x++)
137
 
                                        {
138
 
                                                UINT8 chr = videomem[x +(y*64) + ((pk8000_text_start & 0x0e) << 10)+offset] ;
139
 
                                                for (j = 0; j < 8; j++) {
140
 
                                                        UINT8 code = videomem[((chr<<3) + j) + ((pk8000_chargen_start  & 0x0e) << 10)+offset];
141
 
                                                        for (b = 2; b < 8; b++)
142
 
                                                        {
143
 
                                                                UINT8 col = ((code >> b) & 0x01) ? (pk8000_video_color) & 0x0f : (pk8000_video_color>>4) & 0x0f;
144
 
                                                                *BITMAP_ADDR16(bitmap, (y*8)+j+16, x*6+(7-b)+16+8) =  col;
145
 
                                                        }
146
 
                                                }
147
 
                                        }
148
 
                                }
149
 
                        }
150
 
                } else {
151
 
                        //Graphics
152
 
                        for (y = 0; y < 24; y++)
153
 
                        {
154
 
                                UINT16 off_color = (((~pk8000_color_start) & 0x08) << 10)+offset + ((y>>3)<<11);
155
 
                                UINT16 off_code  = (((~pk8000_video_start) & 0x08) << 10)+offset + ((y>>3)<<11);
156
 
                                for (x = 0; x < 32; x++)
157
 
                                {
158
 
                                        UINT8 chr  = videomem[x +(y*32) + ((pk8000_chargen_start & 0x0e) << 10)+offset] ;
159
 
                                        for (j = 0; j < 8; j++) {
160
 
                                                UINT8 color= videomem[((chr<<3) + j)+off_color];
161
 
                                                UINT8 code = videomem[((chr<<3) + j)+off_code];
162
 
 
163
 
                                                for (b = 0; b < 8; b++)
164
 
                                                {
165
 
                                                        UINT8 col = (code >> b) & 0x01 ? (color & 0x0f) : ((color>>4) & 0x0f);
166
 
                                                        *BITMAP_ADDR16(bitmap, (y*8)+j+16, x*8+(7-b)+16) =  col;
167
 
                                                }
168
 
                                        }
169
 
                                }
170
 
                        }
171
 
                }
172
 
        } else {
173
 
                // Disabled video
174
 
                bitmap_fill(bitmap, &my_rect, 0);
175
 
        }
176
 
    return 0;
177
 
}