1 // license:BSD-3-Clause
2 // copyright-holders:Manuel Abadia
3 #include "emu.h"
4 #include "includes/bladestl.h"
5 
6 
bladestl_palette(palette_device & palette) const7 void bladestl_state::bladestl_palette(palette_device &palette) const
8 {
9 	uint8_t const *const color_prom = memregion("proms")->base();
10 
11 	// characters use pens 0x00-0x1f, no look-up table
12 	for (int i = 0; i < 0x20; i++)
13 		palette.set_pen_indirect(i, i);
14 
15 	// sprites use pens 0x20-0x2f
16 	for (int i = 0x20; i < 0x120; i++)
17 	{
18 		uint8_t const ctabentry = (color_prom[i - 0x20] & 0x0f) | 0x20;
19 		palette.set_pen_indirect(i, ctabentry);
20 	}
21 }
22 
23 
24 
25 /***************************************************************************
26 
27   Callback for the K007342
28 
29 ***************************************************************************/
30 
K007342_CALLBACK_MEMBER(bladestl_state::bladestl_tile_callback)31 K007342_CALLBACK_MEMBER(bladestl_state::bladestl_tile_callback)
32 {
33 	*code |= ((*color & 0x0f) << 8) | ((*color & 0x40) << 6);
34 	*color = layer;
35 }
36 
37 /***************************************************************************
38 
39   Callback for the K007420
40 
41 ***************************************************************************/
42 
K007420_CALLBACK_MEMBER(bladestl_state::bladestl_sprite_callback)43 K007420_CALLBACK_MEMBER(bladestl_state::bladestl_sprite_callback)
44 {
45 	*code |= ((*color & 0xc0) << 2) + m_spritebank;
46 	*code = (*code << 2) | ((*color & 0x30) >> 4);
47 	*color = 0 + (*color & 0x0f);
48 }
49 
50 
51 /***************************************************************************
52 
53   Screen Refresh
54 
55 ***************************************************************************/
56 
screen_update_bladestl(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)57 uint32_t bladestl_state::screen_update_bladestl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
58 {
59 	m_k007342->tilemap_update();
60 
61 	m_k007342->tilemap_draw(screen, bitmap, cliprect, 1, TILEMAP_DRAW_OPAQUE ,0);
62 	m_k007420->sprites_draw(bitmap, cliprect, m_gfxdecode->gfx(1));
63 	m_k007342->tilemap_draw(screen, bitmap, cliprect, 1, 1 | TILEMAP_DRAW_OPAQUE ,0);
64 	m_k007342->tilemap_draw(screen, bitmap, cliprect, 0, 0 ,0);
65 	m_k007342->tilemap_draw(screen, bitmap, cliprect, 0, 1 ,0);
66 	return 0;
67 }
68