1 /***************************************************************************
2
3 vidhrdw.c
4
5 Functions to emulate the video hardware of the machine.
6
7 ***************************************************************************/
8 #include "driver.h"
9 #include "vidhrdw/generic.h"
10 static int tilebank=0;
11
12 static struct tilemap *tilemap;
13 static int palette_bank,gfxctrl;
14
15 UINT8 *ladyfrog_scrlram;
16
17 UINT8 *ladyfrog_spriteram;
18 extern UINT8 *ladyfrog_sharedram;
19
WRITE_HANDLER(ladyfrog_spriteram_w)20 WRITE_HANDLER(ladyfrog_spriteram_w)
21 {
22 ladyfrog_spriteram[offset]=data;
23 }
24
READ_HANDLER(ladyfrog_spriteram_r)25 READ_HANDLER(ladyfrog_spriteram_r)
26 {
27 return ladyfrog_spriteram[offset];
28 }
29
get_tile_info(int tile_index)30 static void get_tile_info(int tile_index)
31 {
32 int pal,tile;
33 pal=videoram[tile_index*2+1]&0x0f;
34 tile=videoram[tile_index*2] + ((videoram[tile_index*2+1] & 0xc0) << 2)+ ((videoram[tile_index*2+1] & 0x30) <<6 );
35 SET_TILE_INFO(
36 0,
37 tile +0x1000 * tilebank,
38 pal,TILE_FLIPY;
39 )
40 }
41
WRITE_HANDLER(ladyfrog_videoram_w)42 WRITE_HANDLER( ladyfrog_videoram_w )
43 {
44 videoram[offset] = data;
45 tilemap_mark_tile_dirty(tilemap,offset>>1);
46 }
47
READ_HANDLER(ladyfrog_videoram_r)48 READ_HANDLER( ladyfrog_videoram_r )
49 {
50 return videoram[offset];
51 }
52
WRITE_HANDLER(ladyfrog_palette_w)53 WRITE_HANDLER( ladyfrog_palette_w )
54 {
55 if (offset & 0x100)
56 paletteram_xxxxBBBBGGGGRRRR_split2_w((offset & 0xff) + (palette_bank << 8),data);
57 else
58 paletteram_xxxxBBBBGGGGRRRR_split1_w((offset & 0xff) + (palette_bank << 8),data);
59 }
60
READ_HANDLER(ladyfrog_palette_r)61 READ_HANDLER( ladyfrog_palette_r )
62 {
63 if (offset & 0x100)
64 return paletteram_2[ (offset & 0xff) + (palette_bank << 8) ];
65 else
66 return paletteram [ (offset & 0xff) + (palette_bank << 8) ];
67 }
68
WRITE_HANDLER(ladyfrog_gfxctrl_w)69 WRITE_HANDLER( ladyfrog_gfxctrl_w )
70 {
71 palette_bank = (data & 0x20) >> 5;
72
73 }
74
WRITE_HANDLER(ladyfrog_gfxctrl2_w)75 WRITE_HANDLER( ladyfrog_gfxctrl2_w )
76 {
77 tilebank=((data & 0x18) >> 3)^3;
78 tilemap_mark_all_tiles_dirty( tilemap );
79 }
80
81
READ_HANDLER(ladyfrog_gfxctrl_r)82 READ_HANDLER( ladyfrog_gfxctrl_r )
83 {
84 return gfxctrl;
85 }
86
READ_HANDLER(ladyfrog_scrlram_r)87 READ_HANDLER( ladyfrog_scrlram_r )
88 {
89 return ladyfrog_scrlram[offset];
90 }
91
WRITE_HANDLER(ladyfrog_scrlram_w)92 WRITE_HANDLER( ladyfrog_scrlram_w )
93 {
94 ladyfrog_scrlram[offset] = data;
95 tilemap_set_scrolly(tilemap, offset, data );
96 }
97
ladyfrog_draw_sprites(struct mame_bitmap * bitmap,const struct rectangle * cliprect)98 void ladyfrog_draw_sprites(struct mame_bitmap *bitmap, const struct rectangle *cliprect)
99 {
100 int i;
101 for (i=0;i<0x20;i++)
102 {
103 int pr = ladyfrog_spriteram[0x9f-i];
104 int offs = (pr & 0x1f) * 4;
105 {
106 int code,sx,sy,flipx,flipy,pal;
107 code = ladyfrog_spriteram[offs+2] + ((ladyfrog_spriteram[offs+1] & 0x10) << 4)+0x800;
108 pal=ladyfrog_spriteram[offs+1] & 0x0f;
109 sx = ladyfrog_spriteram[offs+3];
110 sy = 240-ladyfrog_spriteram[offs+0];
111 flipx = ((ladyfrog_spriteram[offs+1]&0x40)>>6);
112 flipy = ((ladyfrog_spriteram[offs+1]&0x80)>>7);
113 drawgfx(bitmap,Machine->gfx[1],
114 code,
115 pal,
116 flipx,flipy,
117 sx,sy,
118 cliprect,TRANSPARENCY_PEN,15);
119
120 if(ladyfrog_spriteram[offs+3]>240)
121 {
122 sx = (ladyfrog_spriteram[offs+3]-256);
123 drawgfx(bitmap,Machine->gfx[1],
124 code,
125 pal,
126 flipx,flipy,
127 sx,sy,
128 cliprect,TRANSPARENCY_PEN,15);
129 }
130 }
131 }
132
133 }
134
VIDEO_START(ladyfrog)135 VIDEO_START( ladyfrog )
136 {
137 ladyfrog_spriteram = auto_malloc (160);
138 tilemap = tilemap_create( get_tile_info,tilemap_scan_rows,TILEMAP_OPAQUE,8,8,32,32 );
139
140 paletteram = auto_malloc(0x200);
141 paletteram_2 = auto_malloc(0x200);
142 tilemap_set_scroll_cols(tilemap,32);
143 tilemap_set_scrolldy( tilemap, 15, 15 );
144 return 0;
145
146 }
147
148
VIDEO_UPDATE(ladyfrog)149 VIDEO_UPDATE( ladyfrog )
150 {
151 tilemap_draw(bitmap,cliprect,tilemap,0,0);
152 ladyfrog_draw_sprites(bitmap,cliprect);
153 }
154
155