Previous 15994 Revisions Next

r12079 Monday 27th June, 2011 at 07:49:49 UTC by Miodrag Milanović
[intv] Proper rendering of overscan borders and native resolution, along with various updates and cleanups [H@P]
* Converted intv driver to use native Intellivision resolution of 159x192. Scaled intvkbd driver so carts look correct.
* Added overscan borders. Approximate, but at least measured on an actual Intellivision.
* Added a STIC header file, defining various object sizes, and register and bit names.
* Cleaned up render_color_stack_mode() and render_fg_bg_mode() loops, eliminating the ugly fix-ups at the end of each row.
* Updated the code found in UNUSED_FUNCTION, but neither compiled nor tested it.
[src/mess/audio]intv.c
[src/mess/drivers]intv.c
[src/mess/includes]intv.h stic.h*
[src/mess/machine]intv.c
[src/mess/video]intv.c stic.c

src/mess/audio/intv.c
r12078r12079
11#include "emu.h"
2#include "includes/stic.h"
23#include "includes/intv.h"
34#include "sound/ay8910.h"
45
src/mess/machine/intv.c
r12078r12079
11#include "emu.h"
2#include "includes/stic.h"
23#include "includes/intv.h"
34#include "cpu/cp1610/cp1610.h"
45#include "image.h"
src/mess/includes/stic.h
r0r12079
1/*****************************************************************************
2 *
3 * includes/stic.h
4 *
5 ****************************************************************************/
6
7#ifndef STIC_H_
8#define STIC_H_
9
10// GROM/GRAM cards are 8x8
11#define STIC_CARD_WIDTH            8
12#define STIC_CARD_HEIGHT         8
13
14// Intellivision resolution is 20x12 BACKTAB CARDs, minus the rightmost column,
15// for an effective resolution of (19 * 8 + 1 * 7) x (12 * 8) == 159x96.
16//
17// MOB scanline height can be half of a card scanline height, so y-coordinates
18// are scaled by 2.
19#define STIC_X_SCALE            1
20#define STIC_Y_SCALE            2
21
22// the Intellivision emulation scales to match the output format at the last
23// step. The Intellivision keyboard component appears to be 320x96, but can
24// also run Intellivision carts, so x-coordinates are conditionally scaled
25// by 2.
26#define INTV_X_SCALE            1
27#define INTV_Y_SCALE            1
28#define INTVKBD_X_SCALE            2
29#define INTVKBD_Y_SCALE            INTV_Y_SCALE
30
31// overscan sizes in intv pixels
32// these values are approximate.
33#define STIC_OVERSCAN_LEFT_WIDTH   13
34#define STIC_OVERSCAN_RIGHT_WIDTH   17
35#define STIC_OVERSCAN_TOP_HEIGHT   12
36#define STIC_OVERSCAN_BOTTOM_HEIGHT   12
37
38/*** STIC registers *********************************************************/
39
40// number of STIC registers
41#define STIC_REGISTERS            0x33
42
43// STIC MOBs (Moveable OBjects)
44enum
45{
46   STIC_MOB0,
47   STIC_MOB1,
48   STIC_MOB2,
49   STIC_MOB3,
50   STIC_MOB4,
51   STIC_MOB5,
52   STIC_MOB6,
53   STIC_MOB7,
54
55   STIC_MOBS
56};
57
58// STIC Color Stack
59enum
60{
61   STIC_CSR0,
62   STIC_CSR1,
63   STIC_CSR2,
64   STIC_CSR3,
65
66   STIC_CSRS
67};
68
69/****************************************************************************
70 *                                                         *
71 * MXR      0000[..0007]   MOB X REGISTER               RW            *
72 *                                                         *
73 * (MSB)                              (LSB)                  *
74 * +-+-+-+-+-+-----+---+---+--+--+--+--+--+--+--+--+                  *
75 * | | | | | |XSIZE|VIS|COL|X7|X6|X5|X4|X3|X2|X1|X0|                  *
76 * +-+-+-+-+-+-----+---+---+--+--+--+--+--+--+--+--+                  *
77 *                                                         *
78 * Xn      x-position                  [0..255]                  *
79 * COL      collision detection            [1=enable]                  *
80 * VIS      visibility                  [1=visible]                  *
81 * XSIZE   double width               [1=double]                  *
82 *                                                         *
83 ****************************************************************************
84 *                                                         *
85 *   NOTES                                                   *
86 *                                                         *
87 *   1. If X=0, the sprite is not visible and does not register collisions.   *
88 *   2. The horizontal handle is 8 pixels from the left of the sprite,      *
89 *      regardless of width.                                       *
90 *                                                         *
91 ****************************************************************************/
92#define STIC_MXR               0x0000
93
94#define STIC_MXR_XSIZE            0x0400
95#define STIC_MXR_VIS            0x0200
96#define STIC_MXR_COL            0x0100
97#define STIC_MXR_X               0x00FF
98
99/****************************************************************************
100 *                                                         *
101 * MYR      0008[..000F]   MOB Y REGISTER               RW            *
102 *                                                         *
103 * (MSB)                                     (LSB)            *
104 * +-+-+-+-+-----+-----+-----+-----+----+--+--+--+--+--+--+--+            *
105 * | | | | |YFLIP|XFLIP|YSIZE|YFULL|YRES|Y6|Y5|Y4|Y3|Y2|Y1|Y0|            *
106 * +-+-+-+-+-----+-----+-----+-----+----+--+--+--+--+--+--+--+            *
107 *                                                         *
108 * Yn      y-position                  [0..127]                  *
109 * YRES      y-resolution               [0=8 scanlines,1=16 scanlines]   *
110 * YFULL   double scanline height         [1=double]                  *
111 * YSIZE   quadruple scanline height      [1=quadruple]               *
112 * XFLIP   horizontally flip image         [1=flip]                  *
113 * YFLIP   vertically flip image         [1=flip]                  *
114 *                                                         *
115 ****************************************************************************
116 *                                                         *
117 *   NOTES                                                   *
118 *                                                         *
119 *   1. A sprite with YRES=1 will display two cards.                     *
120 *   2. A sprite with YFULL=0 and YSIZE=0 will have scanlines half the      *
121 *      height of a background card.                                 *
122 *   3, The minimum size of a sprite is 8x8 (XSIZE=YRES=YSIZE=YFULL=0).      *
123 *   4. The maximum size of a sprite is 16x128 (XSIZE=YRES=YSIZE=YFULL=1).   *
124 *   5. The Y-position is measured in double height scanlines.            *
125 *   6. The vertical handle is 8 double height scanlines from the top of the   *
126 *      sprite, regardless of height.                              *
127 *                                                         *
128 ****************************************************************************/
129#define STIC_MYR               0x0008
130
131#define STIC_MYR_YFLIP            0x0800
132#define STIC_MYR_XFLIP            0x0400
133#define STIC_MYR_YSIZE            0x0200
134#define STIC_MYR_YFULL            0x0100
135#define STIC_MYR_YRES            0x0080
136#define STIC_MYR_Y               0x007F
137
138/****************************************************************************
139 *                                                         *
140 * SAR      0010[..0017]   MOB ATTRIBUTE REGISTER         RW            *
141 *                                                         *
142 * (MSB)                               (LSB)                  *
143 * +-+-+---+---+---+-+-+--+--+--+--+--+--+---+---+---+                  *
144 * | | |PRI|FG3|SEL| | |C5|C4|C3|C2|C1|C0|FG2|FG1|FG0|                  *
145 * +-+-+---+---+---+-+-+--+--+--+--+--+--+---+---+---+                  *
146 *                                                         *
147 * FGn      foreground color            [0..15]                     *
148 * Cn      card #                     [0..63]                     *
149 * SEL      card memory   select            [0=GROM, 1=GRAM]            *
150 * PRI      sprite priority               [1=behind set background bit]   *
151 *                                                         *
152 ****************************************************************************/
153#define STIC_MAR               0x0010
154
155#define STIC_MAR_PRI            0x2000
156#define STIC_MAR_FG3            0x1000
157#define STIC_MAR_SEL            0x0800
158#define STIC_MAR_C               0x07F8
159#define STIC_MAR_FG20            0x0007
160
161/****************************************************************************
162 *                                                         *
163 * SCR      0018[..001F]   MOB COLLISION REGISTER         RW            *
164 *                                                         *
165 * (MSB)                                        (LSB)         *
166 * +-+-+-+-+-+-+----+----+----+----+----+----+----+----+----+----+         *
167 * | | | | | | |BRDR|BKGD|SPR7|SPR6|SPR5|SPR4|SPR3|SPR2|SPR1|SPR0|         *
168 * +-+-+-+-+-+-+----+----+----+----+----+----+----+----+----+----+         *
169 *                                                         *
170 * SPRn         1=collision with sprite #n                           *
171 * BKGD         1=collsion with set background bit                     *
172 * BRDR         1=collision with screen border                        *
173 *                                                         *
174 ****************************************************************************
175 *                                                         *
176 *   NOTES                                                   *
177 *                                                         *
178 *   1. All collisions are latched.  Successive reads read from the latch.   *
179 *      A write will reset the latch.                              *
180 *   2. Sprites with VIS=0 register collisions.                        *
181 *   3. Sprites with X=0 do not register collisions.                     *
182 *   4. Two overlapping sprites with different priorities, one completely   *
183 *      hidden behind the background, still register a collision.         *
184 *                                                         *
185 ****************************************************************************/
186#define STIC_MCR               0x0018
187
188#define STIC_MCR_BRDR            0x0200
189#define STIC_MCR_BKGD            0x0100
190#define STIC_MCR_SPR7            0x0080
191#define STIC_MCR_SPR6            0x0040
192#define STIC_MCR_SPR5            0x0020
193#define STIC_MCR_SPR4            0x0010
194#define STIC_MCR_SPR3            0x0008
195#define STIC_MCR_SPR2            0x0004
196#define STIC_MCR_SPR1            0x0002
197#define STIC_MCR_SPR0            0x0001
198
199/****************************************************************************
200 *                                                         *
201 * DER      0021         DISPLAY ENABLE REGISTER         W            *
202 *                                                         *
203 * (MSB)                  (LSB)                              *
204 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                              *
205 * | | | | | | | | | | | | | | | | |                              *
206 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                              *
207 *                                                         *
208 ****************************************************************************
209 *                                                         *
210 *   NOTES                                                   *
211 *                                                         *
212 *   1. Any write during VBLANK enables STIC output.                     *
213 *                                                         *
214 ****************************************************************************/
215#define STIC_DER               0x0020
216
217/****************************************************************************
218 *                                                         *
219 * GMR      0021         GRAPHICS MODE REGISTER         RW            *
220 *                                                         *
221 * (MSB)                  (LSB)                              *
222 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                              *
223 * | | | | | | | | | | | | | | | | |                              *
224 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                              *
225 *                                                         *
226 ****************************************************************************
227 *                                                         *
228 *   NOTES                                                   *
229 *                                                         *
230 *   1. Any write during VBLANK enables FOREGROUND/BACKGROUND mode.         *
231 *   2. Any read during VBLANK enables COLOR STACK/COLORED SQUARES mode.      *
232 *                                                         *
233 ****************************************************************************/
234#define STIC_GMR               0x0021
235
236/****************************************************************************
237 *                                                         *
238 * CSR      0028         COLOR STACK REGISTER         RW            *
239 *                                                         *
240 * (MSB)                        (LSB)                        *
241 * +-+-+-+-+-+-+-+-+-+-+-+-+---+---+---+---+                        *
242 * | | | | | | | | | | | | |BG3|BG2|BG1|BG0|                        *
243 * +-+-+-+-+-+-+-+-+-+-+-+-+---+---+---+---+                        *
244 *                                                         *
245 * BGn      background color            [0..15]                     *
246 *                                                         *
247 ****************************************************************************/
248#define STIC_CSR               0x0028
249
250#define STIC_CSR_BG               0x000F
251
252/****************************************************************************
253 *                                                         *
254 * BCR      002C         BORDER COLOR REGISTER         RW            *
255 *                                                         *
256 * (MSB)                        (LSB)                        *
257 * +-+-+-+-+-+-+-+-+-+-+-+-+---+---+---+---+                        *
258 * | | | | | | | | | | | | |BC3|BC2|BC1|BC0|                        *
259 * +-+-+-+-+-+-+-+-+-+-+-+-+---+---+---+---+                        *
260 *                                                         *
261 * BCn      border color               [0..15]                     *
262 *                                                         *
263 ****************************************************************************
264 *                                                         *
265 *   NOTES                                                   *
266 *                                                         *
267 *   1. Affects overscan, and column and row blockouts.                  *
268 *                                                         *
269 ****************************************************************************/
270#define STIC_BCR               0x002C
271
272#define STIC_BCR_BC               0x000F
273
274/****************************************************************************
275 *                                                         *
276 * HDR      0030         HORIZONTAL DELAY REGISTER      RW            *
277 *                                                         *
278 * (MSB)                        (LSB)                        *
279 * +-+-+-+-+-+-+-+-+-+-+-+-+-+----+----+----+                        *
280 * | | | | | | | | | | | | | |DEL2|DEL1|DEL0|                        *
281 * +-+-+-+-+-+-+-+-+-+-+-+-+-+----+----+----+                        *
282 *                                                         *
283 * DELn      horizontal delay            [0..7]                     *
284 *                                                         *
285 ****************************************************************************
286 *                                                         *
287 *   NOTES                                                   *
288 *                                                         *
289 *   1. Affects both BACKTAB and MOBs.                              *
290 *                                                         *
291 ****************************************************************************/
292#define STIC_HDR               0x0030
293
294#define STIC_HDR_DEL            0x0007
295
296/****************************************************************************
297 *                                                         *
298 * STIC_VDR      0030         VERTICAL DELAY REGISTER         RW         *
299 *                                                         *
300 * (MSB)                        (LSB)                        *
301 * +-+-+-+-+-+-+-+-+-+-+-+-+-+----+----+----+                        *
302 * | | | | | | | | | | | | | |DEL2|DEL1|DEL0|                        *
303 * +-+-+-+-+-+-+-+-+-+-+-+-+-+----+----+----+                        *
304 *                                                         *
305 * DELn      vertical delay               [0..7]                     *
306 *                                                         *
307 ****************************************************************************
308 *                                                         *
309 *   NOTES                                                   *
310 *                                                         *
311 *   1. Affects both BACKTAB and MOBs.                              *
312 *                                                         *
313 ****************************************************************************/
314#define STIC_VDR               0x0031
315
316#define STIC_VDR_DEL            0x0007
317
318/****************************************************************************
319 *                                                         *
320 * STIC_CBR      0032         CARD BLOCKOUT REGISTER         RW         *
321 *                                                         *
322 * (MSB)                     (LSB)                           *
323 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+---+---+                           *
324 * | | | | | | | | | | | | | | |ROW|COL|                           *
325 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+---+---+                           *
326 *                                                         *
327 * COL      blockout first card column      [1=blockout]               *
328 * ROW      blockout first card row         [1=blockout]               *
329 *                                                         *
330 ****************************************************************************
331 *                                                         *
332 *   NOTES                                                   *
333 *                                                         *
334 *   1. Generally used in conjunction with HDR and VDR registers, to achieve   *
335 *      smooth scrolling.                                       *
336 *                                                         *
337 ****************************************************************************/
338#define STIC_CBR               0x0032
339
340#define STIC_CBR_ROW            0x0002
341#define STIC_CBR_COL            0x0001
342
343/*** BACKTAB ****************************************************************/
344
345// BACKTAB is made up of 20x12 cards
346// (the first 19 columns are 8x8, the 20th column is 7x8)
347#define STIC_BACKTAB_WIDTH         20
348#define STIC_BACKTAB_HEIGHT         12
349
350/****************************************************************************
351 *                                                         *
352 * FOREGROUND/BACKGROUND MODE                                    *
353 *                                                         *
354 * (MSB)                                  (LSB)               *
355 * +-+-+---+---+---+---+---+--+--+--+--+--+--+---+---+---+               *
356 * | | |BG2|BG3|SEL|BG1|BG0|C5|C4|C3|C2|C1|C0|FG2|FG1|FG0|               *
357 * +-+-+---+---+---+---+---+--+--+--+--+--+--+---+---+---+               *
358 *                                                         *
359 * FGn      foreground color            [0..7]                     *
360 * Cn      card #                     [0..63]                     *
361 * SEL      card memory   select            [0=GROM, 1=GRAM]            *
362 * BGn      background color            [0..15]                     *
363 *                                                         *
364 ****************************************************************************/
365#define STIC_FBM_BG2            0x2000
366#define STIC_FBM_BG310            0x1600
367#define STIC_FBM_SEL            0x0800
368#define STIC_FBM_C               0x01F8
369#define STIC_FBM_FG               0x0007
370
371/****************************************************************************
372 *                                                         *
373 * COLOR STACK MODE                                             *
374 *                                                         *
375 * (MSB)                                 (LSB)               *
376 * +-+-+---+---+---+--+--+--+--+--+--+--+--+---+---+---+               *
377 * | | |ADV|FG3|SEL|C7|C6|C5|C4|C3|C2|C1|C0|FG2|FG1|FG0|               *
378 * +-+-+---+---+---+--+--+--+--+--+--+--+--+---+---+---+               *
379 *                                                         *
380 * FGn      foreground color            [0..15]                     *
381 * Cn      card #                     [GROM=0..212, GRAM=0..63]      *
382 * SEL      card memory   select            [0=GROM, 1=GRAM]            *
383 * ADV      advance color stack index      [1=advance]                  *
384 *                                                         *
385 ****************************************************************************
386 *                                                         *
387 * NOTES:                                                   *
388 *                                                         *
389 * 1. When FG3=1 and SEL=0, COLORED SQUARES MODE is enabled.            *
390 * 2. When SEL=1, C7 and C6 can be used as user-defined flags.            *
391 *                                                         *
392 ****************************************************************************/
393#define STIC_CSTM_ADV            0x2000
394#define STIC_CSTM_FG3            0x1000
395#define STIC_CSTM_SEL            0x0800
396#define STIC_CSTM_C7            0x0400
397#define STIC_CSTM_C6            0x0200
398#define STIC_CSTM_C50            0x01F8
399#define STIC_CSTM_FG20            0x0007
400
401#define STIC_CSTM_C               (STIC_CSTM_C7|STIC_CSTM_C6|STIC_CSTM_C50)
402
403/****************************************************************************
404 *                                                         *
405 * COLORED SQUARES MODE                                          *
406 *                                                         *
407 * (MSB)                           (LSB)                     *
408 * +-+-+--+-+-+--+--+--+--+--+--+--+--+--+--+--+                     *
409 * | | |D2|1|0|D1|D0|C2|C1|C0|B2|B1|B0|A2|A1|A0|                     *
410 * +-+-+--+-+-+--+--+--+--+--+--+--+--+--+--+--+                     *
411 *                                                         *
412 * An      color a                     [0..7]                     *
413 * Bn      color b                     [0..7]                     *
414 * Cn      color c                     [0..7]                     *
415 * Dn      color d                     [0..7]                     *
416 *                                                         *
417 ****************************************************************************
418 *                                                         *
419 * NOTES:                                                   *
420 *                                                         *
421 * 1. Each color corresponds to one of the following 4 x 4 squares:         *
422 *                                                         *
423 *      +---+---+                                             *
424 *      | a | b |                                             *
425 *      +---+---+                                             *
426 *      | c | d |                                             *
427 *      +---+---+                                             *
428 *                                                         *
429 * 2. When color 7 is specified, the color is taken from the color stack.   *
430 *                                                         *
431 ****************************************************************************/
432#define STIC_CSQM_D2            0x2000
433#define STIC_CSQM_D10            0x0600
434#define STIC_CSQM_C               0x01C0
435#define STIC_CSQM_B               0x0038
436#define STIC_CSQM_A               0x0007
437
438#define STIC_CSQM_WIDTH            (STIC_CARD_WIDTH / 2)
439#define STIC_CSQM_HEIGHT         (STIC_CARD_HEIGHT / 2)
440
441#endif /* STIC_H_ */
442
src/mess/includes/intv.h
r12078r12079
3434      : driver_device(mconfig, type, tag) { }
3535
3636   UINT8 *m_videoram;
37   intv_sprite_type m_sprite[8];
38   UINT8 m_sprite_buffers[8][16][128];
37   intv_sprite_type m_sprite[STIC_MOBS];
38   UINT8 m_sprite_buffers[STIC_MOBS][STIC_CARD_WIDTH*2][STIC_CARD_HEIGHT*4*2*2];
3939   int m_color_stack_mode;
40   UINT16 m_x_registers[8];
41   UINT16 m_y_registers[8];
42   UINT16 m_a_registers[8];
43   int m_collision_registers[8];
40   int m_stic_registers[STIC_REGISTERS];
4441   int m_color_stack_offset;
45   int m_color_stack[4];
4642   int m_stic_handshake;
4743   int m_border_color;
4844   int m_col_delay;
r12078r12079
5349   UINT8 m_gram[512];
5450   UINT8 m_gramdirtybytes[512];
5551   UINT16 m_ram16[0x160];
52   int m_x_scale;
53   int m_y_scale;
5654   int m_intvkbd_text_blanked;
5755   UINT16 *m_intvkbd_dualport_ram;
5856   int m_intvkbd_keyboard_col;
src/mess/video/stic.c
r12078r12079
11#include "emu.h"
2#include "includes/stic.h"
23#include "includes/intv.h"
34
4
55/* STIC variables */
66
77READ16_HANDLER( intv_stic_r )
r12078r12079
1010   //logerror("%x = stic_r(%x)\n",0,offset);
1111   switch (offset)
1212   {
13      case 0x00:
14      case 0x01:
15      case 0x02:
16      case 0x03:
17      case 0x04:
18      case 0x05:
19      case 0x06:
20      case 0x07:
21         return 0x3800 | state->m_x_registers[offset & 0x07];
22      case 0x08:
23      case 0x09:
24      case 0x0a:
25      case 0x0b:
26      case 0x0c:
27      case 0x0d:
28      case 0x0e:
29      case 0x0f:
30         return 0x3000 | state->m_y_registers[offset & 0x07];
31      case 0x10:
32      case 0x11:
33      case 0x12:
34      case 0x13:
35      case 0x14:
36      case 0x15:
37      case 0x16:
38      case 0x17:
39         return state->m_a_registers[offset & 0x07];
40      case 0x18:
41      case 0x19:
42      case 0x1a:
43      case 0x1b:
44      case 0x1c:
45      case 0x1d:
46      case 0x1e:
47      case 0x1f:
48            return 0x3C00 | state->m_collision_registers[offset & 0x07];
49      case 0x20:
50         return 0;
51      case 0x21:
13      case STIC_MXR + STIC_MOB0:
14      case STIC_MXR + STIC_MOB1:
15      case STIC_MXR + STIC_MOB2:
16      case STIC_MXR + STIC_MOB3:
17      case STIC_MXR + STIC_MOB4:
18      case STIC_MXR + STIC_MOB5:
19      case STIC_MXR + STIC_MOB6:
20      case STIC_MXR + STIC_MOB7:
21         return 0x3800 | (state->m_stic_registers[offset] & 0x07FF);
22      case STIC_MYR + STIC_MOB0:
23      case STIC_MYR + STIC_MOB1:
24      case STIC_MYR + STIC_MOB2:
25      case STIC_MYR + STIC_MOB3:
26      case STIC_MYR + STIC_MOB4:
27      case STIC_MYR + STIC_MOB5:
28      case STIC_MYR + STIC_MOB6:
29      case STIC_MYR + STIC_MOB7:
30         return 0x3000 | (state->m_stic_registers[offset] & 0x0FFF);
31      case STIC_MAR + STIC_MOB0:
32      case STIC_MAR + STIC_MOB1:
33      case STIC_MAR + STIC_MOB2:
34      case STIC_MAR + STIC_MOB3:
35      case STIC_MAR + STIC_MOB4:
36      case STIC_MAR + STIC_MOB5:
37      case STIC_MAR + STIC_MOB6:
38      case STIC_MAR + STIC_MOB7:
39         return state->m_stic_registers[offset] & 0x3FFF;
40      case STIC_MCR + STIC_MOB0:
41      case STIC_MCR + STIC_MOB1:
42      case STIC_MCR + STIC_MOB2:
43      case STIC_MCR + STIC_MOB3:
44      case STIC_MCR + STIC_MOB4:
45      case STIC_MCR + STIC_MOB5:
46      case STIC_MCR + STIC_MOB6:
47      case STIC_MCR + STIC_MOB7:
48         return 0x3C00 | (state->m_stic_registers[offset] & 0x03FF);
49      case STIC_GMR:
5250         state->m_color_stack_mode = 1;
5351         //logerror("Setting color stack mode\n");
52         /*** fall through ***/
53      case STIC_DER:
54         return 0x3FFF;
5455         break;
55      case 0x28:
56      case 0x29:
57      case 0x2A:
58      case 0x2B:
59         return 0x3FF0 | state->m_color_stack[offset&0x3];
60      case 0x2C:
61         return 0x3FF0 | state->m_border_color;
62      case 0x30:
63         return 0x3FF8 | state->m_col_delay;
64      case 0x31:
65         return 0x3FF8 | state->m_row_delay;
66      case 0x32:
67         return 0x3FFC | state->m_top_edge_inhibit<<1 | state->m_left_edge_inhibit;
56      case STIC_CSR + STIC_CSR0:
57      case STIC_CSR + STIC_CSR1:
58      case STIC_CSR + STIC_CSR2:
59      case STIC_CSR + STIC_CSR3:
60      case STIC_BCR:
61         return 0x3FF0 | (state->m_stic_registers[offset] & 0x000F);
62      case STIC_HDR:
63      case STIC_VDR:
64         return 0x3FF8 | (state->m_stic_registers[offset] & 0x0007);
65      case STIC_CBR:
66         return 0x3FFC | (state->m_stic_registers[offset] & 0x0003);
67      default:
68         //logerror("unmapped read from STIC register %02X\n", offset);
69         return 0x3FFF;
6870   }
69   return 0;
7071}
7172
7273WRITE16_HANDLER( intv_stic_w )
r12078r12079
7879   switch (offset)
7980   {
8081      /* X Positions */
81      case 0x00:
82      case 0x01:
83      case 0x02:
84      case 0x03:
85      case 0x04:
86      case 0x05:
87      case 0x06:
88      case 0x07:
89         s =  &state->m_sprite[offset & 0x07];
90         s->doublex = !!(data & 0x0400);
91         s->visible = !!(data & 0x0200);
92         s->coll = !!(data & 0x0100);
93         s->xpos = (data & 0xFF);
94         state->m_x_registers[offset & 0x07] = data & 0x07FF;
82      case STIC_MXR + STIC_MOB0:
83      case STIC_MXR + STIC_MOB1:
84      case STIC_MXR + STIC_MOB2:
85      case STIC_MXR + STIC_MOB3:
86      case STIC_MXR + STIC_MOB4:
87      case STIC_MXR + STIC_MOB5:
88      case STIC_MXR + STIC_MOB6:
89      case STIC_MXR + STIC_MOB7:
90         s =  &state->m_sprite[offset & (STIC_MOBS - 1)];
91         s->doublex = !!(data & STIC_MXR_XSIZE);
92         s->visible = !!(data & STIC_MXR_VIS);
93         s->coll = !!(data & STIC_MXR_COL);
94         s->xpos = (data & STIC_MXR_X);
9595         break;
9696      /* Y Positions */
97      case 0x08:
98      case 0x09:
99      case 0x0a:
100      case 0x0b:
101      case 0x0c:
102      case 0x0d:
103      case 0x0e:
104      case 0x0f:
105         s =  &state->m_sprite[offset & 0x07];
106         s->yflip = !!(data & 0x0800);
107         s->xflip = !!(data & 0x0400);
108         s->quady = !!(data & 0x0200);
109         s->doubley = !!(data & 0x0100);
110         s->doubleyres = !!(data & 0x0080);
111         s->ypos = (data & 0x7F);
112         state->m_y_registers[offset & 0x07] = data & 0x0FFF;
97      case STIC_MYR + STIC_MOB0:
98      case STIC_MYR + STIC_MOB1:
99      case STIC_MYR + STIC_MOB2:
100      case STIC_MYR + STIC_MOB3:
101      case STIC_MYR + STIC_MOB4:
102      case STIC_MYR + STIC_MOB5:
103      case STIC_MYR + STIC_MOB6:
104      case STIC_MYR + STIC_MOB7:
105         s =  &state->m_sprite[offset & (STIC_MOBS - 1)];
106         s->yflip = !!(data & STIC_MYR_YFLIP);
107         s->xflip = !!(data & STIC_MYR_XFLIP);
108         s->quady = !!(data & STIC_MYR_YSIZE);
109         s->doubley = !!(data & STIC_MYR_YFULL);
110         s->doubleyres = !!(data & STIC_MYR_YRES);
111         s->ypos = (data & STIC_MYR_Y);
113112         break;
114113      /* Attributes */
115      case 0x10:
116      case 0x11:
117      case 0x12:
118      case 0x13:
119      case 0x14:
120      case 0x15:
121      case 0x16:
122      case 0x17:
123         s =  &state->m_sprite[offset & 0x07];
124            s->behind_foreground = !!(data & 0x2000);
125            s->grom = !(data & 0x0800);
126         s->card = ((data >> 3) & 0xFF);
127         s->color = ((data >> 9) & 0x08) | (data & 0x7);
128         state->m_a_registers[offset & 0x07] = data&0x3FFF;
114      case STIC_MAR + STIC_MOB0:
115      case STIC_MAR + STIC_MOB1:
116      case STIC_MAR + STIC_MOB2:
117      case STIC_MAR + STIC_MOB3:
118      case STIC_MAR + STIC_MOB4:
119      case STIC_MAR + STIC_MOB5:
120      case STIC_MAR + STIC_MOB6:
121      case STIC_MAR + STIC_MOB7:
122         s =  &state->m_sprite[offset & (STIC_MOBS - 1)];
123         s->behind_foreground = !!(data & STIC_MAR_PRI);
124         s->grom = !(data & STIC_MAR_SEL);
125         s->card = ((data & STIC_MAR_C) >> 3);
126         s->color = ((data & STIC_MAR_FG3) >> 9) | (data & STIC_MAR_FG20);
129127         break;
130128      /* Collision Detection - TBD */
131      case 0x18:
132      case 0x19:
133      case 0x1a:
134      case 0x1b:
135      case 0x1c:
136      case 0x1d:
137      case 0x1e:
138      case 0x1f:
139            //a MOB's own collision bit is *always* zero, even if a
140            //one is poked into it
141            data &= (~(1 << (offset & 0x07))) & 0x03FF;
142            state->m_collision_registers[offset & 0x07] = data;
129      case STIC_MCR + STIC_MOB0:
130      case STIC_MCR + STIC_MOB1:
131      case STIC_MCR + STIC_MOB2:
132      case STIC_MCR + STIC_MOB3:
133      case STIC_MCR + STIC_MOB4:
134      case STIC_MCR + STIC_MOB5:
135      case STIC_MCR + STIC_MOB6:
136      case STIC_MCR + STIC_MOB7:
137         // a MOB's own collision bit is *always* zero, even if a
138         // one is poked into it
139         data &= ~(1 << (offset & (STIC_MOBS - 1)));
143140         break;
144141      /* Display enable */
145      case 0x20:
142      case STIC_DER:
146143         //logerror("***Writing a %x to the STIC handshake\n",data);
147144         state->m_stic_handshake = 1;
148145         break;
149146      /* Graphics Mode */
150      case 0x21:
147      case STIC_GMR:
151148         state->m_color_stack_mode = 0;
152149         break;
153150      /* Color Stack */
154      case 0x28:
155      case 0x29:
156      case 0x2a:
157      case 0x2b:
158         logerror("Setting color_stack[%x] = %x (%x)\n",offset&0x3,data&0xf,cpu_get_pc(&space->device()));
159         state->m_color_stack[offset&0x3] = data&0xf;
151      case STIC_CSR + STIC_CSR0:
152      case STIC_CSR + STIC_CSR1:
153      case STIC_CSR + STIC_CSR2:
154      case STIC_CSR + STIC_CSR3:
155         logerror("Setting color_stack[%x] = %x (%x)\n", offset & (STIC_CSRS - 1),data & STIC_CSR_BG, cpu_get_pc(&space->device()));
160156         break;
161157      /* Border Color */
162      case 0x2c:
158      case STIC_BCR:
163159         //logerror("***Writing a %x to the border color\n",data);
164         state->m_border_color = data & 0xf;
160         state->m_border_color = data & STIC_BCR_BC;
165161         break;
166162      /* Framing */
167      case 0x30:
168         state->m_col_delay = data & 0x7;
163      case STIC_HDR:
164         state->m_col_delay = data & STIC_HDR_DEL;
169165         break;
170      case 0x31:
171         state->m_row_delay = data & 0x7;
166      case STIC_VDR:
167         state->m_row_delay = data & STIC_VDR_DEL;
172168         break;
173      case 0x32:
174         state->m_left_edge_inhibit = (data & 0x01);
175         state->m_top_edge_inhibit = (data & 0x02)>>1;
169      case STIC_CBR:
170         state->m_left_edge_inhibit = (data & STIC_CBR_COL);
171         state->m_top_edge_inhibit = (data & STIC_CBR_ROW) >> 1;
176172         break;
173      default:
174         //logerror("unmapped write to STIC register %02X: %04X\n", offset, data);
175         break;
177176   }
177
178   if (offset < sizeof(state->m_stic_registers) / sizeof(state->m_stic_registers[0]))
179      state->m_stic_registers[offset] = data;
178180}
src/mess/video/intv.c
r12078r12079
11#include "emu.h"
2#include "includes/stic.h"
23#include "includes/intv.h"
34
45#define FOREGROUND_BIT 0x0010
56
7// conversion from Intellivision color to internal representation
8#define SET_COLOR(c)   ((c * 2) + 1)
9#define GET_COLOR(c)   ((c - 1) / 2)
10
611/* initialized to non-zero, because we divide by it */
712
8INLINE void intv_plot_pixel(bitmap_t *bitmap, int x, int y, UINT32 color)
13INLINE void intv_set_pixel(intv_state *state, bitmap_t *bitmap, int x, int y, UINT32 color)
914{
10   *BITMAP_ADDR16(bitmap, y, x) = (color<<1)+1;
15   int w, h;
16
17   // output scaling
18   x *= state->m_x_scale;
19   y *= state->m_y_scale;
20   color = SET_COLOR(color);
21
22   for (h = 0; h < state->m_y_scale; h++)
23      for (w = 0; w < state->m_x_scale; w++)
24         *BITMAP_ADDR16(bitmap, y + h, x + w) = color;
1125}
1226
27INLINE UINT32 intv_get_pixel(intv_state *state, bitmap_t *bitmap, int x, int y)
28{
29   return GET_COLOR(*BITMAP_ADDR16(bitmap, y * state->m_y_scale, x * state->m_x_scale));
30}
31
32INLINE void intv_plot_box(intv_state *state, bitmap_t *bm, int x, int y, int w, int h, int color)
33{
34   plot_box(bm, x * state->m_x_scale, y * state->m_y_scale, w * state->m_x_scale, h * state->m_y_scale, SET_COLOR(color));
35}
36
1337VIDEO_START( intv )
1438{
1539   intv_state *state = machine.driver_data<intv_state>();
r12078r12079
1943   VIDEO_START_CALL(generic_bitmapped);
2044
2145#if 0
22    for (i = 0; i < 8; i++) {
23        intv_sprite_type* s = &state->m_sprite[i];
24        s->visible = 0;
25        s->xpos = 0;
26        s->ypos = 0;
27        s->coll = 0;
28        s->collision = 0;
29        s->doublex = 0;
30        s->doubley = 0;
31        s->quady = 0;
32        s->xflip = 0;
33        s->yflip = 0;
34        s->behind_foreground = 0;
35        s->grom = 0;
36        s->card = 0;
37        s->color = 0;
38        s->doubleyres = 0;
39        s->dirty = 1;
40        for (j = 0; j < 16; j++) {
41            for (k = 0; k < 128; k++) {
42                state->m_sprite_buffers[i][j][k] = 0;
43            }
44        }
45        state->m_collision_registers[i] = 0;
46    }
47    for(i = 0; i < 4; i++) {
48        state->m_color_stack[i] = 0;
49    }
50    state->m_color_stack_mode = 0;
51    state->m_color_stack_offset = 0;
52    state->m_stic_handshake = 0;
53    state->m_border_color = 0;
54    state->m_col_delay = 0;
55    state->m_row_delay = 0;
56    state->m_left_edge_inhibit = 0;
57    state->m_top_edge_inhibit = 0;
46   for (i = 0; i < STIC_MOBS; i++)
47   {
48      intv_sprite_type* s = &state->m_sprite[i];
49      s->visible = 0;
50      s->xpos = 0;
51      s->ypos = 0;
52      s->coll = 0;
53      s->collision = 0;
54      s->doublex = 0;
55      s->doubley = 0;
56      s->quady = 0;
57      s->xflip = 0;
58      s->yflip = 0;
59      s->behind_foreground = 0;
60      s->grom = 0;
61      s->card = 0;
62      s->color = 0;
63      s->doubleyres = 0;
64      s->dirty = 1;
65      for (j = 0; j < 16; j++)
66      {
67         for (k = 0; k < 128; k++)
68         {
69            state->m_sprite_buffers[i][j][k] = 0;
70         }
71      }
72   }
73   for(i = 0; i < STIC_REGISTERS; i++)
74   {
75      state->m_stic_registers[i] = 0;
76   }
77   state->m_color_stack_mode = 0;
78   state->m_color_stack_offset = 0;
79   state->m_stic_handshake = 0;
80   state->m_border_color = 0;
81   state->m_col_delay = 0;
82   state->m_row_delay = 0;
83   state->m_left_edge_inhibit = 0;
84   state->m_top_edge_inhibit = 0;
5885
59    state->m_gramdirty = 1;
60    for(i=0;i<64;i++) {
61        state->m_gram[i] = 0;
62        state->m_gramdirtybytes[i] = 1;
63    }
86   state->m_gramdirty = 1;
87   for(i=0;i<64;i++)
88   {
89      state->m_gram[i] = 0;
90      state->m_gramdirtybytes[i] = 1;
91   }
6492#endif
6593}
6694
6795
68static int sprites_collide(intv_state *state, int spriteNum0, int spriteNum1) {
69    INT16 x1, x2, y1, y2, w1, w2, h1, h2, x0, y0, r0y, r1y,
70          width, height, x, y, x_offset,y_offset;
96static int sprites_collide(intv_state *state, int spriteNum1, int spriteNum2)
97{
98   INT16 x0, y0, w0, h0, x1, y1, w1, h1, x2, y2, w2, h2;
7199
72    intv_sprite_type* s1 = &state->m_sprite[spriteNum0];
73    intv_sprite_type* s2 = &state->m_sprite[spriteNum1];
100   intv_sprite_type* s1 = &state->m_sprite[spriteNum1];
101   intv_sprite_type* s2 = &state->m_sprite[spriteNum2];
74102
75    x_offset = state->m_col_delay - 8;
76    y_offset = state->m_row_delay - 8;
77    x1 = s1->xpos+x_offset; x2 = s2->xpos+x_offset;
78    y1 = (s1->ypos+y_offset)<<1; y2 = (s2->ypos+y_offset)<<1;
79    w1 = (s1->doublex ? 2 : 1)<<3;
80    w2 = (s2->doublex ? 2 : 1)<<3;
81    h1 = (s1->quady ? 4 : 1) * (s1->doubley ? 2 : 1) * (s1->doubleyres ? 2 : 1)<<3;
82    h2 = (s2->quady ? 4 : 1) * (s2->doubley ? 2 : 1) * (s2->doubleyres ? 2 : 1)<<3;
103   x0 = STIC_OVERSCAN_LEFT_WIDTH + state->m_col_delay - STIC_CARD_WIDTH;
104   y0 = STIC_OVERSCAN_TOP_HEIGHT + state->m_row_delay - STIC_CARD_HEIGHT;
105   x1 = (s1->xpos + x0) * STIC_X_SCALE; y1 = (s1->ypos + y0) * STIC_Y_SCALE;
106   x2 = (s2->xpos + x0) * STIC_X_SCALE; y2 = (s2->ypos + y0) * STIC_Y_SCALE;
107   w1 = (s1->doublex ? 2 : 1) * STIC_CARD_WIDTH;
108   w2 = (s2->doublex ? 2 : 1) * STIC_CARD_WIDTH;
109   h1 = (s1->quady ? 4 : 1) * (s1->doubley ? 2 : 1) * (s1->doubleyres ? 2 : 1) * STIC_CARD_HEIGHT;
110   h2 = (s2->quady ? 4 : 1) * (s2->doubley ? 2 : 1) * (s2->doubleyres ? 2 : 1) * STIC_CARD_HEIGHT;
83111
84    if ((x1 + w1 <= x2) || (y1 + h1 <= y2) ||
85            (x1 >= x2 + w2) || (y1 >= y2 + h2))
86        return FALSE;
112   if ((x1 >= x2 + w2) || (y1 >= y2 + h2) ||
113      (x2 >= x1 + w1) || (y2 >= y1 + h1))
114      return FALSE;
87115
88    //iterate over the intersecting bits to see if any touch
89    x0 = MAX(x1, x2);
90    y0 = MAX(y1, y2);
91    r0y = y0-y1;
92    r1y = y0-y2;
93    width = MIN(x1+w1, x2+w2) - x0;
94    height = MIN(y1+h1, y2+h2) - y0;
95    for (x = 0; x < width; x++) {
96        for (y = 0; y < height; y++) {
97            if (state->m_sprite_buffers[spriteNum0][x0-x1+x][r0y+y] &&
98                    state->m_sprite_buffers[spriteNum1][x0-x2+x][r1y+y])
99                return TRUE;
100        }
101    }
116   // iterate over the intersecting bits to see if any touch
117   x0 = MAX(x1, x2);
118   y0 = MAX(y1, y2);
119   w0 = MIN(x1 + w1, x2 + w2) - x0;
120   h0 = MIN(y1 + h1, y2 + h2) - y0;
121   x1 = x0 - x1;
122   y1 = y0 - y1;
123   x2 = x0 - x2;
124   y2 = y0 - y2;
125   for (x0 = 0; x0 < w0; x0++)
126   {
127      for (y0 = 0; y0 < h0; y0++)
128      {
129         if (state->m_sprite_buffers[spriteNum1][x0 + x1][y0 + y1] &&
130            state->m_sprite_buffers[spriteNum2][x0 + x2][y0 + y2])
131            return TRUE;
132      }
133   }
102134
103    return FALSE;
135   return FALSE;
104136}
105137
106138static void determine_sprite_collisions(intv_state *state)
107139{
108    //check sprite to sprite collisions
109    int i, j;
110    for (i = 0; i < 7; i++) {
111        intv_sprite_type* s1 = &state->m_sprite[i];
112        if (s1->xpos == 0 || !s1->coll)
113            continue;
140   // check sprite to sprite collisions
141   int i, j;
142   for (i = 0; i < STIC_MOBS - 1; i++)
143   {
144      intv_sprite_type* s1 = &state->m_sprite[i];
145      if (s1->xpos == 0 || !s1->coll)
146         continue;
114147
115        for (j = i+1; j < 8; j++) {
116            intv_sprite_type* s2 = &state->m_sprite[j];
117            if (s2->xpos == 0 || !s2->coll)
118                continue;
148      for (j = i + 1; j < STIC_MOBS; j++)
149      {
150         intv_sprite_type* s2 = &state->m_sprite[j];
151         if (s2->xpos == 0 || !s2->coll)
152            continue;
119153
120            if (sprites_collide(state, i, j)) {
121                s1->collision |= (1 << j);
122                s2->collision |= (1 << i);
123            }
124        }
125    }
154         if (sprites_collide(state, i, j))
155         {
156            s1->collision |= (1 << j);
157            s2->collision |= (1 << i);
158         }
159      }
160   }
126161}
127162
128163static void render_sprites(running_machine &machine)
129164{
130165   intv_state *state = machine.driver_data<intv_state>();
131    INT32 cardMemoryLocation, pixelSize;
132    INT32 spritePixelHeight;
133    INT32 nextMemoryLocation;
134    INT32 nextData;
135    INT32 nextX;
136    INT32 nextY;
137    INT32 xInc;
138    INT32 i, j, k;
166   INT32 cardMemoryLocation, pixelSize;
167   INT32 spritePixelHeight;
168   INT32 nextMemoryLocation;
169   INT32 nextData;
170   INT32 nextX;
171   INT32 nextY;
172   INT32 xInc;
173   INT32 i, j, k;
139174
140    UINT8* memory = machine.region("maincpu")->base();
175   UINT8* memory = machine.region("maincpu")->base();
141176
142    for (i = 0; i < 8; i++) {
177   for (i = 0; i < STIC_MOBS; i++)
178   {
143179      intv_sprite_type* s = &state->m_sprite[i];
144180
145        if (s->grom)
146            cardMemoryLocation = (s->card << 3);
147        else
148            cardMemoryLocation = ((s->card & 0x003F) << 3);
181      if (s->grom)
182         cardMemoryLocation = (s->card * STIC_CARD_HEIGHT);
183      else
184         cardMemoryLocation = ((s->card & 0x003F) * STIC_CARD_HEIGHT);
149185
150        pixelSize = (s->quady ? 4 : 1) * (s->doubley ? 2 : 1);
151        spritePixelHeight = 8 * pixelSize * (s->doubleyres ? 2 : 1);
186      pixelSize = (s->quady ? 4 : 1) * (s->doubley ? 2 : 1);
187      spritePixelHeight = pixelSize * (s->doubleyres ? 2 : 1) * STIC_CARD_HEIGHT;
152188
153        for (j = 0; j < spritePixelHeight; j++) {
154            nextMemoryLocation = (cardMemoryLocation + (j/pixelSize));
155            if (s->grom)
156                nextData = memory[(0x3000+nextMemoryLocation)<<1];
157            else if (nextMemoryLocation < 0x200)
158                nextData = state->m_gram[nextMemoryLocation];
159            else
160                nextData = 0xFFFF;
161            nextX = (s->xflip ? (s->doublex ? 15 : 7) : 0);
162            nextY = (s->yflip ? (spritePixelHeight - j - 1) : j);
163            xInc = (s->xflip ? -1: 1);
164           
165            for (k=0;k < 8*(1+s->doublex);k++)
166            {
167               state->m_sprite_buffers[i][nextX + k*xInc][nextY] = (nextData & (1<<(7 - k/(1 + s->doublex)))) != 0;
168            }
169        }
189      for (j = 0; j < spritePixelHeight; j++)
190      {
191         nextMemoryLocation = (cardMemoryLocation + (j/pixelSize));
192         if (s->grom)
193            nextData = memory[(0x3000+nextMemoryLocation)<<1];
194         else if (nextMemoryLocation < 0x200)
195            nextData = state->m_gram[nextMemoryLocation];
196         else
197            nextData = 0xFFFF;
198         nextX = (s->xflip ? ((s->doublex ? 2 : 1) * STIC_CARD_WIDTH - 1) : 0);
199         nextY = (s->yflip ? (spritePixelHeight - j - 1) : j);
200         xInc = (s->xflip ? -1: 1);
170201
171    }
202         for (k = 0; k < STIC_CARD_WIDTH * (1 + s->doublex); k++)
203         {
204            state->m_sprite_buffers[i][nextX + k * xInc][nextY] = (nextData & (1 << ((STIC_CARD_WIDTH - 1) - k / (1 + s->doublex)))) != 0;
205         }
206      }
207   }
172208}
173209
174210static void render_line(running_machine &machine, bitmap_t *bitmap,
175211   UINT8 nextByte, UINT16 x, UINT16 y, UINT8 fgcolor, UINT8 bgcolor)
176212{
177    UINT32 color;
178    UINT8 i;
179    for (i=0; i<8; i++)
180    {
181       color = (nextByte & (1<<(7-i)) ? fgcolor : bgcolor);
182       intv_plot_pixel(bitmap, x+2*i, y, color);
183       intv_plot_pixel(bitmap, x+2*i+1, y, color);
184       intv_plot_pixel(bitmap, x+2*i, y+1, color);
185       intv_plot_pixel(bitmap, x+2*i+1, y+1, color);
186    }
213   intv_state *state = machine.driver_data<intv_state>();
214   UINT32 color;
215   UINT8 i;
216
217   for (i = 0; i < STIC_CARD_WIDTH; i++)
218   {
219      color = (nextByte & (1 << ((STIC_CARD_WIDTH - 1) - i)) ? fgcolor : bgcolor);
220      intv_set_pixel(state, bitmap, x+i, y, color);
221      intv_set_pixel(state, bitmap, x+i, y+1, color);
222   }
187223}
188224
189225static void render_colored_squares(running_machine &machine, bitmap_t *bitmap,
190226   UINT16 x, UINT16 y, UINT8 color0, UINT8 color1, UINT8 color2, UINT8 color3)
191227{
192    plot_box(bitmap, x, y, 8, 8, (color0<<1)+1);
193    plot_box(bitmap, x+8, y, 8, 8, (color1<<1)+1);
194    plot_box(bitmap, x, y+8, 8, 8, (color2<<1)+1);
195    plot_box(bitmap, x+8, y+8, 8, 8, (color3<<1)+1);
228   intv_state *state = machine.driver_data<intv_state>();
229
230   intv_plot_box(state, bitmap, x, y, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, color0);
231   intv_plot_box(state, bitmap, x + STIC_CSQM_WIDTH * STIC_X_SCALE, y, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, color1);
232   intv_plot_box(state, bitmap, x, y + STIC_CSQM_HEIGHT * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, color2);
233   intv_plot_box(state, bitmap, x + STIC_CSQM_WIDTH * STIC_X_SCALE, y + STIC_CSQM_HEIGHT * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, color3);
196234}
197235
198236static void render_color_stack_mode(running_machine &machine, bitmap_t *bitmap)
199237{
200238   intv_state *state = machine.driver_data<intv_state>();
201    UINT8 h, csPtr = 0, nexty = 2*state->m_row_delay;
202    UINT16 nextCard, nextx = 2*state->m_col_delay;
203    UINT8 *ram = machine.region("maincpu")->base();
239   INT16 w, h, nextx, nexty;
240   UINT8 csPtr = 0;
241   UINT16 nextCard;
242   UINT8 *ram = machine.region("maincpu")->base();
204243
205    for (h = 0; h < 240; h++) {
206        nextCard = state->m_ram16[h];
244   for (h = 0, nexty = (STIC_OVERSCAN_TOP_HEIGHT + state->m_row_delay) * STIC_Y_SCALE;
245       h < STIC_BACKTAB_HEIGHT;
246       h++, nexty += STIC_CARD_HEIGHT * STIC_Y_SCALE)
247   {
248      for (w = 0, nextx = (STIC_OVERSCAN_LEFT_WIDTH + state->m_col_delay) * STIC_X_SCALE;
249          w < STIC_BACKTAB_WIDTH;
250          w++, nextx += STIC_CARD_WIDTH * STIC_X_SCALE)
251      {
252         nextCard = state->m_ram16[w + h * STIC_BACKTAB_WIDTH];
207253
208        //colored squares mode
209        if ((nextCard & 0x1800) == 0x1000) {
210            UINT8 csColor = state->m_color_stack[csPtr];
211            UINT8 color0 = nextCard & 0x0007;
212            UINT8 color1 = (nextCard & 0x0038) >> 3;
213            UINT8 color2 = (nextCard & 0x01C0) >> 6;
214            UINT8 color3 = ((nextCard & 0x2000) >> 11) |
215                    ((nextCard & 0x0600) >> 9);
216            render_colored_squares(machine, bitmap, nextx, nexty,
217                    (color0 == 7 ? csColor : (color0 | FOREGROUND_BIT)),
218                    (color1 == 7 ? csColor : (color1 | FOREGROUND_BIT)),
219                    (color2 == 7 ? csColor : (color2 | FOREGROUND_BIT)),
220                    (color3 == 7 ? csColor : (color3 | FOREGROUND_BIT)));
221        }
222        //color stack mode
223        else {
224            UINT8 isGrom, j;
225            UINT16 memoryLocation, fgcolor, bgcolor;
226            UINT8* memory;
254         // colored squares mode
255         if ((nextCard & (STIC_CSTM_FG3|STIC_CSTM_SEL)) == STIC_CSTM_FG3)
256         {
257            UINT8 csColor = state->m_stic_registers[STIC_CSR + csPtr];
258            UINT8 color0 = nextCard & STIC_CSQM_A;
259            UINT8 color1 = (nextCard & STIC_CSQM_B) >> 3;
260            UINT8 color2 = (nextCard & STIC_CSQM_C) >> 6;
261            UINT8 color3 = ((nextCard & STIC_CSQM_D2) >> 11) |
262                  ((nextCard & (STIC_CSQM_D10)) >> 9);
263            render_colored_squares(machine, bitmap, nextx, nexty,
264                  (color0 == 7 ? csColor : (color0 | FOREGROUND_BIT)),
265                  (color1 == 7 ? csColor : (color1 | FOREGROUND_BIT)),
266                  (color2 == 7 ? csColor : (color2 | FOREGROUND_BIT)),
267                  (color3 == 7 ? csColor : (color3 | FOREGROUND_BIT)));
268         }
269         //color stack mode
270         else
271         {
272            UINT8 isGrom, j;
273            UINT16 memoryLocation, fgcolor, bgcolor;
274            UINT8* memory;
227275
228            //advance the color pointer, if necessary
229            if (nextCard & 0x2000)
230                csPtr = (csPtr+1) & 0x03;
276            //advance the color pointer, if necessary
277            if (nextCard & STIC_CSTM_ADV)
278               csPtr = (csPtr+1) & (STIC_CSRS - 1);
231279
232            fgcolor = ((nextCard & 0x1000) >> 9) |
233                    (nextCard & 0x0007) | FOREGROUND_BIT;
234            bgcolor = state->m_color_stack[csPtr] & 0x0F;
280            fgcolor = ((nextCard & STIC_CSTM_FG3) >> 9) |
281                  (nextCard & (STIC_CSTM_FG20)) | FOREGROUND_BIT;
282            bgcolor = state->m_stic_registers[STIC_CSR + csPtr] & STIC_CSR_BG;
235283
236            isGrom = !(nextCard & 0x0800);
237            if (isGrom) {
238                memoryLocation = 0x3000 + (nextCard & 0x07F8);
239                memory = ram;
240                for (j = 0; j < 16; j+=2)
241                    render_line(machine, bitmap, memory[(memoryLocation<<1)+j],
242                            nextx, nexty+j, fgcolor, bgcolor);
243            }
244            else {
245                memoryLocation = (nextCard & 0x01F8);
246                memory = state->m_gram;
247                for (j = 0; j < 16; j+=2)
248                    render_line(machine, bitmap, memory[memoryLocation+(j>>1)],
249                            nextx, nexty+j, fgcolor, bgcolor);
250            }
251        }
252        nextx += 16;
253        if (nextx >= 320) {
254            nextx = 2*state->m_col_delay;
255            nexty += 16;
256        }
257    }
284            isGrom = !(nextCard & STIC_CSTM_SEL);
285            if (isGrom)
286            {
287               memoryLocation = 0x3000 + (nextCard & STIC_CSTM_C);
288               memory = ram;
289               for (j = 0; j < STIC_CARD_HEIGHT; j++)
290                  render_line(machine, bitmap, memory[(memoryLocation + j) * 2],
291                     nextx, nexty + j * STIC_Y_SCALE, fgcolor, bgcolor);
292            }
293            else
294            {
295               memoryLocation = (nextCard & STIC_CSTM_C50);
296               memory = state->m_gram;
297               for (j = 0; j < STIC_CARD_HEIGHT; j++)
298                  render_line(machine, bitmap, memory[memoryLocation + j],
299                        nextx, nexty + j * STIC_Y_SCALE, fgcolor, bgcolor);
300            }
301         }
302      }
303   }
258304}
259305
260306static void render_fg_bg_mode(running_machine &machine, bitmap_t *bitmap)
261307{
262308   intv_state *state = machine.driver_data<intv_state>();
263    UINT8 i, j, isGrom, fgcolor, bgcolor, nexty = 2*state->m_row_delay;
264    UINT16 nextCard, memoryLocation, nextx = 2*state->m_col_delay;
265    UINT8* memory;
266    UINT8* ram = machine.region("maincpu")->base();
309   INT16 w, h, nextx, nexty;
310   UINT8 j, isGrom, fgcolor, bgcolor;
311   UINT16 nextCard, memoryLocation;
312   UINT8* memory;
313   UINT8* ram = machine.region("maincpu")->base();
267314
268    for (i = 0; i < 240; i++) {
269        nextCard = state->m_ram16[i];
270        fgcolor = (nextCard & 0x0007) | FOREGROUND_BIT;
271        bgcolor = ((nextCard & 0x2000) >> 11) |
272                ((nextCard & 0x1600) >> 9);
315   for (h = 0, nexty = (STIC_OVERSCAN_TOP_HEIGHT + state->m_row_delay) * STIC_Y_SCALE;
316       h < STIC_BACKTAB_HEIGHT;
317       h++, nexty += STIC_CARD_HEIGHT * STIC_Y_SCALE)
318   {
319      for (w = 0, nextx = (STIC_OVERSCAN_LEFT_WIDTH + state->m_col_delay) * STIC_X_SCALE;
320          w < STIC_BACKTAB_WIDTH;
321          w++, nextx += STIC_CARD_WIDTH * STIC_X_SCALE)
322      {
323         nextCard = state->m_ram16[w + h * STIC_BACKTAB_WIDTH];
324         fgcolor = (nextCard & STIC_FBM_FG) | FOREGROUND_BIT;
325         bgcolor = ((nextCard & STIC_FBM_BG2) >> 11) |
326               ((nextCard & STIC_FBM_BG310) >> 9);
273327
274        isGrom = !(nextCard & 0x0800);
275        if (isGrom) {
276            memoryLocation = 0x3000 + (nextCard & 0x01F8);
277            memory = ram;
278            for (j = 0; j < 16; j+=2)
279                render_line(machine, bitmap, memory[(memoryLocation<<1)+j],
280                        nextx, nexty+j, fgcolor, bgcolor);
281        }
282        else {
283            memoryLocation = (nextCard & 0x01F8);
284            memory = state->m_gram;
285            for (j = 0; j < 16; j+=2)
286                render_line(machine, bitmap, memory[memoryLocation+(j>>1)],
287                        nextx, nexty+j, fgcolor, bgcolor);
288        }
289
290        nextx += 16;
291        if (nextx >= 320) {
292            nextx = 2*state->m_col_delay;
293            nexty += 16;
294        }
295    }
328         isGrom = !(nextCard & STIC_FBM_SEL);
329         if (isGrom)
330         {
331            memoryLocation = 0x3000 + (nextCard & STIC_FBM_C);
332            memory = ram;
333            for (j = 0; j < STIC_CARD_HEIGHT; j++)
334               render_line(machine, bitmap, memory[(memoryLocation + j) * 2],
335                     nextx, nexty + j * STIC_Y_SCALE, fgcolor, bgcolor);
336         }
337         else
338         {
339            memoryLocation = (nextCard & STIC_FBM_C);
340            memory = state->m_gram;
341            for (j = 0; j < STIC_CARD_HEIGHT; j++)
342               render_line(machine, bitmap, memory[memoryLocation + j],
343                     nextx, nexty + j * STIC_Y_SCALE, fgcolor, bgcolor);
344         }
345      }
346   }
296347}
297348
298349static void copy_sprites_to_background(running_machine &machine, bitmap_t *bitmap)
299350{
300351   intv_state *state = machine.driver_data<intv_state>();
301    UINT8 width, currentPixel;
302    UINT8 borderCollision, foregroundCollision;
303    UINT8 spritePixelHeight, x, y;
304    INT16 leftX, nextY, i;
305    INT32 nextX;
352   UINT8 width, currentPixel;
353   UINT8 borderCollision, foregroundCollision;
354   UINT8 spritePixelHeight, x, y;
355   INT16 leftX, nextY, i;
356   INT16 leftBorder, rightBorder, topBorder, bottomBorder;
357   INT32 nextX;
306358
307    for (i = 7; i >= 0; i--) {
359   for (i = STIC_MOBS - 1; i >= 0; i--)
360   {
308361      intv_sprite_type *s = &state->m_sprite[i];
309        if (s->xpos == 0 ||
310                (!s->coll && !s->visible))
311            continue;
362      if (s->xpos == 0 || (!s->coll && !s->visible))
363         continue;
312364
313        borderCollision = FALSE;
314        foregroundCollision = FALSE;
365      borderCollision = FALSE;
366      foregroundCollision = FALSE;
315367
316        spritePixelHeight = (s->quady ? 4 : 1) *
317                (s->doubley ? 2 : 1) * (s->doubleyres ? 2 : 1)<<3;
318        width = (s->doublex ? 2 : 1)<<3;
368      spritePixelHeight = (s->quady ? 4 : 1) * (s->doubley ? 2 : 1) * (s->doubleyres ? 2 : 1) * STIC_CARD_HEIGHT;
369      width = (s->doublex ? 2 : 1) * STIC_CARD_WIDTH;
319370
320        leftX = (s->xpos-8+state->m_col_delay)<<1;
321        nextY = (s->ypos-8+state->m_row_delay)<<1;
371      leftX = (s->xpos - STIC_CARD_WIDTH + STIC_OVERSCAN_LEFT_WIDTH + state->m_col_delay) * STIC_X_SCALE;
372      nextY = (s->ypos - STIC_CARD_HEIGHT + STIC_OVERSCAN_TOP_HEIGHT + state->m_row_delay) * STIC_Y_SCALE;
322373
323        for (y = 0; y < spritePixelHeight; y++) {
324            for (x = 0; x < width; x++) {
325                //if this sprite pixel is not on, then don't paint it
326                if (!state->m_sprite_buffers[i][x][y])
327                    continue;
374      leftBorder =  (STIC_OVERSCAN_LEFT_WIDTH + (state->m_left_edge_inhibit ? STIC_CARD_WIDTH : 0)) * STIC_X_SCALE;
375      rightBorder = (STIC_OVERSCAN_LEFT_WIDTH + STIC_BACKTAB_WIDTH * STIC_CARD_WIDTH - 1 - 1) * STIC_X_SCALE;
376      topBorder = (STIC_OVERSCAN_TOP_HEIGHT + (state->m_top_edge_inhibit ? STIC_CARD_HEIGHT : 0)) * STIC_Y_SCALE;
377      bottomBorder = (STIC_OVERSCAN_TOP_HEIGHT + STIC_BACKTAB_HEIGHT * STIC_CARD_HEIGHT) * STIC_Y_SCALE - 1;
328378
329                nextX = leftX + (x<<1);
330                //if the next pixel location is on the border, then we
331                //have a border collision and we can ignore painting it
332                if (nextX < (state->m_left_edge_inhibit ? 16 : 0) || nextX > 317 ||
333                       nextY < (state->m_top_edge_inhibit ? 16: 0) || nextY > 191)
334                {
335                    borderCollision = TRUE;
336                    continue;
337                }
379      for (y = 0; y < spritePixelHeight; y++)
380      {
381         for (x = 0; x < width; x++)
382         {
383            //if this sprite pixel is not on, then don't paint it
384            if (!state->m_sprite_buffers[i][x][y])
385               continue;
338386
339                currentPixel = (*BITMAP_ADDR16(bitmap, nextY, nextX) -1) >> 1;
387            nextX = leftX + x;
388            //if the next pixel location is on the border, then we
389            //have a border collision and we can ignore painting it
390            if ((nextX < leftBorder) || (nextX > rightBorder) ||
391               (nextY < topBorder) || (nextY > bottomBorder))
392            {
393               borderCollision = TRUE;
394               continue;
395            }
340396
341                //check for foreground collision
342                if (currentPixel & FOREGROUND_BIT) {
343                    foregroundCollision = TRUE;
344                    if (s->behind_foreground)
345                        continue;
346                }
397            currentPixel = intv_get_pixel(state, bitmap, nextX, nextY);
347398
348                if (s->visible) {
349                    intv_plot_pixel(bitmap, nextX, nextY, s->color | (currentPixel & FOREGROUND_BIT));
350                    intv_plot_pixel(bitmap, nextX+1, nextY, s->color | (currentPixel & FOREGROUND_BIT));
351                }
352            }
353            nextY++;
354        }
399            //check for foreground collision
400            if (currentPixel & FOREGROUND_BIT)
401            {
402               foregroundCollision = TRUE;
403               if (s->behind_foreground)
404                  continue;
405            }
355406
356        //update the collision bits
357        if (s->coll) {
358            if (foregroundCollision)
359                s->collision |= 0x0100;
360            if (borderCollision)
361                s->collision |= 0x0200;
362        }
363    }
407            if (s->visible)
408            {
409               intv_set_pixel(state, bitmap, nextX, nextY, s->color | (currentPixel & FOREGROUND_BIT));
410            }
411         }
412         nextY++;
413      }
414
415      //update the collision bits
416      if (s->coll)
417      {
418         if (foregroundCollision)
419            s->collision |= STIC_MCR_BKGD;
420         if (borderCollision)
421            s->collision |= STIC_MCR_BRDR;
422      }
423   }
364424}
365425
366426static void render_background(running_machine &machine, bitmap_t *bitmap)
367427{
368428   intv_state *state = machine.driver_data<intv_state>();
369429   if (state->m_color_stack_mode)
370        render_color_stack_mode(machine, bitmap);
371    else
372        render_fg_bg_mode(machine, bitmap);
430      render_color_stack_mode(machine, bitmap);
431   else
432      render_fg_bg_mode(machine, bitmap);
373433}
374434
375435#ifdef UNUSED_CODE
r12078r12079
391451
392452   int j;
393453
454   int x0 = STIC_OVERSCAN_LEFT_WIDTH + state->m_col_delay;
455   int y0 = STIC_OVERSCAN_TOP_HEIGHT + state->m_row_delay;
456
394457   if (state->m_color_stack_mode == 1)
395458   {
396459      state->m_color_stack_offset = 0;
397      for(row = 0; row < 12; row++)
460      for(row = 0; row < STIC_BACKTAB_HEIGHT; row++)
398461      {
399         for(col = 0; col < 20; col++)
462         for(col = 0; col < STIC_BACKTAB_WIDTH; col++)
400463         {
401464            value = state->m_ram16[offs];
402465
403            n_bit = value & 0x2000;
404            p_bit = value & 0x1000;
405            g_bit = value & 0x0800;
466            n_bit = value & STIC_CSTM_ADV;
467            p_bit = value & STIC_CSTM_FG3;
468            g_bit = value & STIC_CSTM_SEL;
406469
407470            if (p_bit && (!g_bit)) // colored squares mode
408471            {
409               colora = value&0x7;
410               colorb = (value>>3)&0x7;
411               colorc = (value>>6)&0x7;
412               colord = ((n_bit>>11)&0x4) + ((value>>9)&0x3);
472               colora = value & STIC_CSQM_A;
473               colorb = (value & STIC_CSQM_B) >> 3;
474               colorc = (value & STIC_CSQM_C) >> 6;
475               colord = ((n_bit & STIC_CSQM_D2) >> 11) + ((value & STIC_CSQM_D10) >> 9);
413476               // color 7 if the top of the color stack in this mode
414               if (colora == 7) colora = state->m_color_stack[3];
415               if (colorb == 7) colorb = state->m_color_stack[3];
416               if (colorc == 7) colorc = state->m_color_stack[3];
417               if (colord == 7) colord = state->m_color_stack[3];
418               plot_box(bitmap,col*16,row*16,8,8,(colora<<1)+1);
419               plot_box(bitmap,col*16+8,row*16,8,8,(colorb<<1)+1);
420               plot_box(bitmap,col*16,row*16+8,8,8,(colorc<<1)+1);
421               plot_box(bitmap,col*16+8,row*16+8,8,8,(colord<<1)+1);
477               if (colora == 7) colora = state->m_stic_registers[STIC_CSR + STIC_CSR3];
478               if (colorb == 7) colorb = state->m_stic_registers[STIC_CSR + STIC_CSR3];
479               if (colorc == 7) colorc = state->m_stic_registers[STIC_CSR + STIC_CSR3];
480               if (colord == 7) colord = state->m_stic_registers[STIC_CSR + STIC_CSR3];
481               intv_plot_box(state, bitmap, (x0 + col * STIC_CARD_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT) * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, colora);
482               intv_plot_box(state, bitmap, (x0 + col * STIC_CARD_WIDTH + STIC_CSQM_WIDTH)) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT) * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, colorb);
483               intv_plot_box(state, bitmap, (x0 + col * STIC_CARD_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT + STIC_CSQM_HEIGHT) * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, colorc);
484               intv_plot_box(state, bitmap, (x0 + col * STIC_CARD_WIDTH + STIC_CSQM_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT + STIC_CSQM_HEIGHT) * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, colord);
422485            }
423486            else // normal color stack mode
424487            {
425488               if (n_bit) // next color
426489               {
427490                  state->m_color_stack_offset += 1;
428                  state->m_color_stack_offset &= 3;
491                  state->m_color_stack_offset &= (STIC_CSRS - 1);
429492               }
430493
431494               if (p_bit) // pastel color set
432                  fgcolor = (value&0x7) + 8;
495                  fgcolor = (value & STIC_CSTM_FG20) + 8;
433496               else
434                  fgcolor = value&0x7;
497                  fgcolor = value & STIC_CSTM_FG20;
435498
436               bgcolor = state->m_color_stack[state->m_color_stack_offset];
437               code = (value>>3)&0xff;
499               bgcolor = state->m_stic_registers[STIC_CSR + state->m_color_stack_offset];
500               code = (value & STIC_CSTM_C)>>3;
438501
439502               if (g_bit) // read from gram
440503               {
441                  code %= 64;  // keep from going outside the array
504                  code &= (STIC_CSTM_C50 >> 3);  // keep from going outside the array
442505                  //if (state->m_gramdirtybytes[code] == 1)
443506                  {
444507                     decodechar(machine.gfx[1],
445                           code,
446                           state->m_gram,
447                           machine.config()->gfxdecodeinfo[1].gfxlayout);
508                        code,
509                        state->m_gram,
510                        machine.config()->gfxdecodeinfo[1].gfxlayout);
448511                     state->m_gramdirtybytes[code] = 0;
449512                  }
450513                  // Draw GRAM char
451514                  drawgfx(bitmap,machine.gfx[1],
452515                     code,
453516                     bgcolor*16+fgcolor,
454                     0,0,col*16,row*16,
517                     0,0, (x0 + col * STIC_CARD_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT) * STIC_Y_SCALE,
455518                     0,transparency,bgcolor);
456519
457520                  for(j=0;j<8;j++)
458521                  {
459                     //intv_plot_pixel(bitmap, col*16+j*2, row*16+7*2+1, 1);
460                     //intv_plot_pixel(bitmap, col*16+j*2+1, row*16+7*2+1, 1);
522                     //intv_set_pixel(state, bitmap, (x0 + col * STIC_CARD_WIDTH + j) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT + 7) * STIC_Y_SCALE + 1, 1);
461523                  }
462524
463525               }
r12078r12079
466528                  drawgfx(bitmap,machine.gfx[0],
467529                     code,
468530                     bgcolor*16+fgcolor,
469                     0,0,col*16,row*16,
531                     0,0, (x0 + col * STIC_CARD_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT) * STIC_Y_SCALE,
470532                     0,transparency,bgcolor);
471533
472534                  for(j=0;j<8;j++)
473535                  {
474                     //intv_plot_pixel(bitmap, col*16+j*2, row*16+7*2+1, 2);
475                     //intv_plot_pixel(bitmap, col*16+j*2+1, row*16+7*2+1, 2);
536                     //intv_set_pixel(state, bitmap, (x0 + col * STIC_CARD_WIDTH + j) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT + 7) * STIC_Y_SCALE + 1, 2);
476537                  }
477538               }
478539            }
r12078r12079
483544   else
484545   {
485546      // fg/bg mode goes here
486      for(row = 0; row < 12; row++)
547      for(row = 0; row < STIC_BACKTAB_HEIGHT; row++)
487548      {
488         for(col = 0; col < 20; col++)
549         for(col = 0; col < STIC_BACKTAB_WIDTH; col++)
489550         {
490551            value = state->m_ram16[offs];
491            fgcolor = value & 0x07;
492            bgcolor = ((value & 0x2000)>>11)+((value & 0x1600)>>9);
493            code = (value & 0x01f8)>>3;
552            fgcolor = value & STIC_FBM_FG;
553            bgcolor = ((value & STIC_FBM_BG2) >> 11) + ((value & STIC_FBM_BG310) >> 9);
554            code = (value & STIC_FBM_C) >> 3;
494555
495            if (value & 0x0800) // read for GRAM
556            if (value & STIC_FBM_SEL) // read for GRAM
496557            {
497558               //if (state->m_gramdirtybytes[code] == 1)
498559               {
499560                  decodechar(machine.gfx[1],
500                        code,
501                        state->m_gram,
502                        machine.config()->gfxdecodeinfo[1].gfxlayout);
561                     code,
562                     state->m_gram,
563                     machine.config()->gfxdecodeinfo[1].gfxlayout);
503564                  state->m_gramdirtybytes[code] = 0;
504565               }
505566               // Draw GRAM char
506567               drawgfx(bitmap,machine.gfx[1],
507568                  code,
508569                  bgcolor*16+fgcolor,
509                  0,0,col*16,row*16,
570                  0,0, (x0 + col * STIC_CARD_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT) * STIC_Y_SCALE,
510571                  0,transparency,bgcolor);
511572            }
512573            else // read from GROM
r12078r12079
514575               drawgfx(bitmap,machine.gfx[0],
515576                  code,
516577                  bgcolor*16+fgcolor,
517                  0,0,col*16,row*16,
578                  0,0, (x0 + col * STIC_CARD_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT) * STIC_Y_SCALE,
518579                  0,transparency,bgcolor);
519580            }
520581            offs++;
r12078r12079
529590static void draw_sprites(running_machine &machine, bitmap_t *bitmap, int behind_foreground)
530591{
531592   intv_state *state = machine.driver_data<intv_state>();
532    int i;
533    int code;
593   int i;
594   int code;
595   int x0 = STIC_OVERSCAN_LEFT_WIDTH + state->m_col_delay - STIC_CARD_WIDTH;
596   int y0 = STIC_OVERSCAN_TOP_HEIGHT + state->m_row_delay - STIC_CARD_HEIGHT;
534597
535    for(i=7;i>=0;--i)
536    {
537        intv_sprite_type *s = &state->m_sprite[i];
538        if (s->visible && (s->behind_foreground == behind_foreground))
539        {
540            code = s->card;
541            if (!s->grom)
542            {
543                code %= 64;  // keep from going outside the array
544                if (s->yres == 1)
545                {
546                    //if (state->m_gramdirtybytes[code] == 1)
547                    {
548                        decodechar(machine.gfx[1],
549                           code,
550                           state->m_gram,
551                           machine.config()->gfxdecodeinfo[1].gfxlayout);
552                        state->m_gramdirtybytes[code] = 0;
553                    }
554                    // Draw GRAM char
555                    drawgfxzoom_transpen(bitmap,&machine.screen[0].visarea,machine.gfx[1],
556                        code,
557                        s->color,
558                        s->xflip,s->yflip,
559                        s->xpos*2-16,s->ypos*2-16,
560                        0x8000*s->xsize, 0x8000*s->ysize,0);
561                }
562                else
563                {
564                    //if ((state->m_gramdirtybytes[code] == 1) || (state->m_gramdirtybytes[code+1] == 1))
565                    {
566                        decodechar(machine.gfx[1],
567                           code,
568                           state->m_gram,
569                           machine.config()->gfxdecodeinfo[1].gfxlayout);
570                        decodechar(machine.gfx[1],
571                           code+1,
572                           state->m_gram,
573                           machine.config()->gfxdecodeinfo[1].gfxlayout);
574                        state->m_gramdirtybytes[code] = 0;
575                        state->m_gramdirtybytes[code+1] = 0;
576                    }
577                    // Draw GRAM char
578                    drawgfxzoom_transpen(bitmap,&machine.screen[0].visarea,machine.gfx[1],
579                        code,
580                        s->color,
581                        s->xflip,s->yflip,
582                        s->xpos*2-16,s->ypos*2-16+(s->yflip)*s->ysize*8,
583                        0x8000*s->xsize, 0x8000*s->ysize,0);
584                    drawgfxzoom_transpen(bitmap,&machine.screen[0].visarea,machine.gfx[1],
585                        code+1,
586                        s->color,
587                        s->xflip,s->yflip,
588                        s->xpos*2-16,s->ypos*2-16+(1-s->yflip)*s->ysize*8,
589                        0x8000*s->xsize, 0x8000*s->ysize,0);
590                }
591            }
592            else
593            {
594                if (s->yres == 1)
595                {
596                    // Draw GROM char
597                    drawgfxzoom_transpen(bitmap,&machine.screen[0].visarea,machine.gfx[0],
598                        code,
599                        s->color,
600                        s->xflip,s->yflip,
601                        s->xpos*2-16,s->ypos*2-16,
602                        0x8000*s->xsize, 0x8000*s->ysize,0);
603                }
604                else
605                {
606                    drawgfxzoom_transpen(bitmap,&machine.screen[0].visarea,machine.gfx[0],
607                        code,
608                        s->color,
609                        s->xflip,s->yflip,
610                        s->xpos*2-16,s->ypos*2-16+(s->yflip)*s->ysize*8,
611                        0x8000*s->xsize, 0x8000*s->ysize,0);
612                    drawgfxzoom_transpen(bitmap,&machine.screen[0].visarea,machine.gfx[0],
613                        code+1,
614                        s->color,
615                        s->xflip,s->yflip,
616                        s->xpos*2-16,s->ypos*2-16+(1-s->yflip)*s->ysize*8,
617                        0x8000*s->xsize, 0x8000*s->ysize,0);
618                }
619            }
620        }
621    }
598   for(i = STIC_MOBS - 1; i >= 0; --i)
599   {
600      intv_sprite_type *s = &state->m_sprite[i];
601      if (s->visible && (s->behind_foreground == behind_foreground))
602      {
603         code = s->card;
604         if (!s->grom)
605         {
606            code %= 64;  // keep from going outside the array
607            if (s->yres == 1)
608            {
609               //if (state->m_gramdirtybytes[code] == 1)
610               {
611                  decodechar(machine.gfx[1],
612                     code,
613                     state->m_gram,
614                     machine.config()->gfxdecodeinfo[1].gfxlayout);
615                  state->m_gramdirtybytes[code] = 0;
616               }
617               // Draw GRAM char
618               drawgfxzoom_transpen(bitmap,&machine.screen[0].visarea,machine.gfx[1],
619                  code,
620                  s->color,
621                  s->xflip,s->yflip,
622                  (s->xpos + x0) * STIC_X_SCALE, (s->ypos + y0) * STIC_Y_SCALE,
623                  0x8000 * s->xsize, 0x8000 * s->ysize,0);
624            }
625            else
626            {
627               //if ((state->m_gramdirtybytes[code] == 1) || (state->m_gramdirtybytes[code+1] == 1))
628               {
629                  decodechar(machine.gfx[1],
630                     code,
631                     state->m_gram,
632                     machine.config()->gfxdecodeinfo[1].gfxlayout);
633                  decodechar(machine.gfx[1],
634                     code+1,
635                     state->m_gram,
636                     machine.config()->gfxdecodeinfo[1].gfxlayout);
637                  state->m_gramdirtybytes[code] = 0;
638                  state->m_gramdirtybytes[code+1] = 0;
639               }
640               // Draw GRAM char
641               drawgfxzoom_transpen(bitmap,&machine.screen[0].visarea,machine.gfx[1],
642                  code,
643                  s->color,
644                  s->xflip,s->yflip,
645                  (s->xpos + x0) * STIC_X_SCALE, (s->ypos + y0) * STIC_Y_SCALE + s->yflip * s->ysize * STIC_CARD_HEIGHT,
646                  0x8000*s->xsize, 0x8000*s->ysize,0);
647               drawgfxzoom_transpen(bitmap,&machine.screen[0].visarea,machine.gfx[1],
648                  code+1,
649                  s->color,
650                  s->xflip,s->yflip,
651                  (s->xpos + x0) * STIC_X_SCALE, (s->ypos + y0) * STIC_Y_SCALE + (1 - s->yflip) * s->ysize * STIC_CARD_HEIGHT,
652                  0x8000*s->xsize, 0x8000*s->ysize,0);
653            }
654         }
655         else
656         {
657            if (s->yres == 1)
658            {
659               // Draw GROM char
660               drawgfxzoom_transpen(bitmap,&machine.screen[0].visarea,machine.gfx[0],
661                  code,
662                  s->color,
663                  s->xflip,s->yflip,
664                  (s->xpos + x0) * STIC_X_SCALE, (s->ypos + y0) * STIC_Y_SCALE,
665                  0x8000*s->xsize, 0x8000*s->ysize,0);
666            }
667            else
668            {
669               drawgfxzoom_transpen(bitmap,&machine.screen[0].visarea,machine.gfx[0],
670                  code,
671                  s->color,
672                  s->xflip,s->yflip,
673                  (s->xpos + x0) * STIC_X_SCALE, (s->ypos + y0) * STIC_Y_SCALE + s->yflip * s->ysize * STIC_CARD_HEIGHT,
674                  0x8000*s->xsize, 0x8000*s->ysize,0);
675               drawgfxzoom_transpen(bitmap,&machine.screen[0].visarea,machine.gfx[0],
676                  code+1,
677                  s->color,
678                  s->xflip,s->yflip,
679                  (s->xpos + x0) * STIC_X_SCALE, (s->ypos + y0) * STIC_Y_SCALE + (1 - s->yflip) * s->ysize * STIC_CARD_HEIGHT,
680                  0x8000*s->xsize, 0x8000*s->ysize,0);
681            }
682         }
683      }
684   }
622685}
623686#endif
624687
625688static void draw_borders(running_machine &machine, bitmap_t *bm)
626689{
627690   intv_state *state = machine.driver_data<intv_state>();
628   if (state->m_left_edge_inhibit)
629      plot_box(bm, 0, 0, 16, 16*12, (state->m_border_color<<1)+1);
630   else if (state->m_col_delay)
631      plot_box(bm, 0, 0, state->m_col_delay*2, 16*12, (state->m_border_color<<1)+1);
632691
633   if (state->m_top_edge_inhibit)
634      plot_box(bm, 0, 0, 16*20, 16, (state->m_border_color<<1)+1);
635   else if (state->m_row_delay)
636      plot_box(bm, 0, 0, 16*20, state->m_row_delay*2, (state->m_border_color<<1)+1);
692   intv_plot_box(state, bm, 0, 0, (STIC_OVERSCAN_LEFT_WIDTH + (state->m_left_edge_inhibit ? STIC_CARD_WIDTH : state->m_col_delay)) * STIC_X_SCALE, (STIC_OVERSCAN_TOP_HEIGHT + STIC_BACKTAB_HEIGHT * STIC_CARD_HEIGHT + STIC_OVERSCAN_BOTTOM_HEIGHT) * STIC_Y_SCALE, state->m_border_color);
693   intv_plot_box(state, bm, (STIC_OVERSCAN_LEFT_WIDTH + STIC_BACKTAB_WIDTH * STIC_CARD_WIDTH - 1) * STIC_X_SCALE, 0, STIC_OVERSCAN_RIGHT_WIDTH, (STIC_OVERSCAN_TOP_HEIGHT + STIC_BACKTAB_HEIGHT * STIC_CARD_HEIGHT + STIC_OVERSCAN_BOTTOM_HEIGHT) * STIC_Y_SCALE, state->m_border_color);
694
695   intv_plot_box(state, bm, 0, 0, (STIC_OVERSCAN_LEFT_WIDTH + STIC_BACKTAB_WIDTH * STIC_CARD_WIDTH - 1 + STIC_OVERSCAN_RIGHT_WIDTH) * STIC_X_SCALE, (STIC_OVERSCAN_TOP_HEIGHT + (state->m_top_edge_inhibit ? STIC_CARD_HEIGHT : state->m_row_delay)) * STIC_Y_SCALE, state->m_border_color);
696   intv_plot_box(state, bm, 0, (STIC_OVERSCAN_TOP_HEIGHT + STIC_BACKTAB_HEIGHT * STIC_CARD_HEIGHT) * STIC_Y_SCALE, (STIC_OVERSCAN_LEFT_WIDTH + STIC_BACKTAB_WIDTH * STIC_CARD_WIDTH - 1 + STIC_OVERSCAN_RIGHT_WIDTH) * STIC_X_SCALE, STIC_OVERSCAN_BOTTOM_HEIGHT * STIC_Y_SCALE, state->m_border_color);
637697}
638698
639699void intv_stic_screenrefresh(running_machine &machine)
r12078r12079
648708      render_background(machine, machine.generic.tmpbitmap);
649709      // Render the sprites into their buffers
650710      render_sprites(machine);
651      for (i = 0; i < 8; i++) state->m_sprite[i].collision = 0;
711      for (i = 0; i < STIC_MOBS; i++) state->m_sprite[i].collision = 0;
652712      // Copy the sprites to the background
653713      copy_sprites_to_background(machine, machine.generic.tmpbitmap);
654714      determine_sprite_collisions(state);
655      for (i = 0; i < 8; i++) state->m_collision_registers[i] |= state->m_sprite[i].collision;
715      for (i = 0; i < STIC_MOBS; i++) state->m_stic_registers[STIC_MCR + i] |= state->m_sprite[i].collision;
656716      /* draw the screen borders if enabled */
657717      draw_borders(machine, machine.generic.tmpbitmap);
658718   }
659719   else
660720   {
661721      /* STIC disabled, just fill with border color */
662      bitmap_fill(machine.generic.tmpbitmap, NULL, (state->m_border_color<<1)+1);
722      bitmap_fill(machine.generic.tmpbitmap, NULL, SET_COLOR(state->m_border_color));
663723   }
664724}
665725
r12078r12079
720780   UINT8 *videoram = state->m_videoram;
721781   int x,y,offs;
722782   int current_row;
723//  char c;
783//   char c;
724784
725785   /* Draw the underlying INTV screen first */
726786   SCREEN_UPDATE_CALL(generic_bitmapped);
src/mess/drivers/intv.c
r12078r12079
3434#include "emu.h"
3535#include "cpu/m6502/m6502.h"
3636#include "cpu/cp1610/cp1610.h"
37#include "includes/stic.h"
3738#include "includes/intv.h"
3839#include "imagedev/cartslot.h"
3940#include "sound/ay8910.h"
r12078r12079
445446   MCFG_SCREEN_REFRESH_RATE(59.92)
446447   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
447448   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
448   MCFG_SCREEN_SIZE(41*8, 25*8)
449   MCFG_SCREEN_VISIBLE_AREA(0, 40*8-1, 0, 24*8-1)
449   MCFG_SCREEN_SIZE((STIC_OVERSCAN_LEFT_WIDTH+STIC_BACKTAB_WIDTH*STIC_CARD_WIDTH-1+STIC_OVERSCAN_RIGHT_WIDTH)*STIC_X_SCALE*INTV_X_SCALE, (STIC_OVERSCAN_TOP_HEIGHT+STIC_BACKTAB_HEIGHT*STIC_CARD_HEIGHT+STIC_OVERSCAN_BOTTOM_HEIGHT)*STIC_Y_SCALE*INTV_Y_SCALE)
450   MCFG_SCREEN_VISIBLE_AREA(0, (STIC_OVERSCAN_LEFT_WIDTH+STIC_BACKTAB_WIDTH*STIC_CARD_WIDTH-1+STIC_OVERSCAN_RIGHT_WIDTH)*STIC_X_SCALE*INTV_X_SCALE-1, 0, (STIC_OVERSCAN_TOP_HEIGHT+STIC_BACKTAB_HEIGHT*STIC_CARD_HEIGHT+STIC_OVERSCAN_BOTTOM_HEIGHT)*STIC_Y_SCALE*INTV_Y_SCALE-1)
450451   MCFG_SCREEN_UPDATE( generic_bitmapped )
451452
452453   MCFG_GFXDECODE( intv )
r12078r12079
481482   /* video hardware */
482483   MCFG_GFXDECODE(intvkbd)
483484   MCFG_SCREEN_MODIFY("screen")
485   MCFG_SCREEN_SIZE((STIC_OVERSCAN_LEFT_WIDTH+STIC_BACKTAB_WIDTH*STIC_CARD_WIDTH-1+STIC_OVERSCAN_RIGHT_WIDTH)*STIC_X_SCALE*INTVKBD_X_SCALE, (STIC_OVERSCAN_TOP_HEIGHT+STIC_BACKTAB_HEIGHT*STIC_CARD_HEIGHT+STIC_OVERSCAN_BOTTOM_HEIGHT)*STIC_Y_SCALE*INTVKBD_Y_SCALE)
486   MCFG_SCREEN_VISIBLE_AREA(0, (STIC_OVERSCAN_LEFT_WIDTH+STIC_BACKTAB_WIDTH*STIC_CARD_WIDTH-1+STIC_OVERSCAN_RIGHT_WIDTH)*STIC_X_SCALE*INTVKBD_X_SCALE-1, 0, (STIC_OVERSCAN_TOP_HEIGHT+STIC_BACKTAB_HEIGHT*STIC_CARD_HEIGHT+STIC_OVERSCAN_BOTTOM_HEIGHT)*STIC_Y_SCALE*INTVKBD_Y_SCALE-1)
484487   MCFG_SCREEN_UPDATE(intvkbd)
485488
486489   /* cartridge */
r12078r12079
546549}
547550#endif
548551
552static DRIVER_INIT( intv )
553{
554   intv_state *state = machine.driver_data<intv_state>();
549555
556   state->m_x_scale = INTV_X_SCALE;
557   state->m_y_scale = INTV_Y_SCALE;
558}
559
560static DRIVER_INIT( intvkbd )
561{
562   intv_state *state = machine.driver_data<intv_state>();
563
564   state->m_x_scale = INTVKBD_X_SCALE;
565   state->m_y_scale = INTVKBD_Y_SCALE;
566}
567
550568/***************************************************************************
551569
552570  Game driver(s)
553571
554572***************************************************************************/
555573
556/*    YEAR  NAME  PARENT  COMPAT  MACHINE  INPUT   INIT     COMPANY      FULLNAME */
557CONS( 1979, intv,   0,   0,   intv,     intv,    0,         "Mattel",    "Intellivision", 0 )
558CONS( 1981, intvsrs,   intv,   0,   intv,     intv,    0,   "Mattel",    "Intellivision (Sears)", 0 )
559COMP( 1981, intvkbd,   intv,   0,   intvkbd,  intvkbd,   0,   "Mattel",    "Intellivision Keyboard Component (Unreleased)", GAME_NOT_WORKING)
574/*    YEAR  NAME        PARENT  COMPAT  MACHINE     INPUT       INIT        COMPANY     FULLNAME */
575CONS( 1979,   intv,      0,      0,      intv,      intv,      intv,      "Mattel",   "Intellivision", 0 )
576CONS( 1981,   intvsrs,   intv,   0,      intv,      intv,      intv,      "Mattel",   "Intellivision (Sears)", 0 )
577COMP( 1981,   intvkbd,   intv,   0,      intvkbd,   intvkbd,   intvkbd,   "Mattel",   "Intellivision Keyboard Component (Unreleased)", GAME_NOT_WORKING)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team