1 /***************************************************************************
2
3 vidhrdw.c
4
5 Functions to emulate the video hardware of the machine.
6
7
8 ***************************************************************************/
9
10 #include "driver.h"
11 extern int portrait_scrollx_hi, portrait_scrollx_lo;
12 data8_t *portrait_bgvideoram, *portrait_fgvideoram, *portrait_spriteram;
13 static struct tilemap *foreground, *background;
14
WRITE_HANDLER(portrait_bgvideo_write)15 WRITE_HANDLER( portrait_bgvideo_write )
16 {
17 if (portrait_bgvideoram[offset] != data)
18 {
19 tilemap_mark_tile_dirty(background,offset/2);
20 portrait_bgvideoram[offset] = data;
21 }
22 }
23
WRITE_HANDLER(portrait_fgvideo_write)24 WRITE_HANDLER( portrait_fgvideo_write )
25 {
26 if (portrait_fgvideoram[offset] != data)
27 {
28 tilemap_mark_tile_dirty(foreground,offset/2);
29 portrait_fgvideoram[offset] = data;
30 }
31 }
32
get_tile_info(const data8_t * source,int tile_index)33 static void get_tile_info( const data8_t *source, int tile_index )
34 {
35 int attr = source[tile_index*2+0];
36 int tilenum = source[tile_index*2+1];
37 int flags = 0;
38 int color = 0;
39
40 if( attr & 0x20 ) flags |= TILE_FLIPY;
41
42 attr &= 0x07;
43 if(attr == 1) tilenum+=0x200; /* 001*/
44 if(attr == 3) tilenum+=0x300; /* 011*/
45 if(attr == 5) tilenum+=0x100; /* 101*/
46
47 SET_TILE_INFO( 0, tilenum, color, flags )
48 }
49
get_bg_tile_info(int tile_index)50 static void get_bg_tile_info(int tile_index)
51 {
52 get_tile_info( portrait_bgvideoram, tile_index );
53 }
54
get_fg_tile_info(int tile_index)55 static void get_fg_tile_info(int tile_index)
56 {
57 get_tile_info( portrait_fgvideoram, tile_index );
58 }
59
VIDEO_START(portrait)60 VIDEO_START( portrait )
61 {
62 background = tilemap_create( get_bg_tile_info, tilemap_scan_rows, TILEMAP_OPAQUE, 16, 16, 32, 32 );
63 foreground = tilemap_create( get_fg_tile_info, tilemap_scan_rows, TILEMAP_TRANSPARENT, 16, 16, 32, 32 );
64 if( background && foreground )
65 {
66 tilemap_set_transparent_pen( foreground, 0 );
67 return 0;
68 }
69 return -1;
70 }
71
72
PALETTE_INIT(portrait)73 PALETTE_INIT( portrait )
74 {
75 }
76
draw_sprites(struct mame_bitmap * bitmap)77 static void draw_sprites( struct mame_bitmap *bitmap )
78 {
79 const data8_t *source = portrait_spriteram;
80 const data8_t *finish = source + 0x200;
81 while( source<finish )
82 {
83 int sy = source[0];
84 int sx = source[1];
85 int attr = source[2];
86 /* xx------
87 * --x----- flip
88 * ----x--- msb source[0]
89 * -----x-- msb source[1]
90 */
91 int tilenum = source[3];
92 int color = 0;
93 int flip = attr&0x20;
94 if( attr&0x04 ) sx |= 0x100;
95 if( attr&0x08 ) sy |= 0x100;
96
97 sx += (source-portrait_spriteram)-8;
98 sx &= 0x1ff;
99
100 sy = (512-64)-sy;
101 /*sy += portrait_scrollx_hi;*/
102
103 drawgfx(bitmap,Machine->gfx[0],
104 tilenum,color,
105 0,flip,
106 sx,sy,
107 NULL,TRANSPARENCY_PEN,0 );
108
109 source+=0x10;
110 }
111 }
112
VIDEO_UPDATE(portrait)113 VIDEO_UPDATE( portrait )
114 {
115 tilemap_set_scrolly( background, 0, portrait_scrollx_hi );
116 tilemap_set_scrolly( foreground, 0, portrait_scrollx_hi );
117
118 tilemap_draw( bitmap, cliprect, background, 0, 0 );
119 draw_sprites(bitmap);
120 tilemap_draw( bitmap, cliprect, foreground, 0, 0 );
121 }
122