1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 #include "emu.h"
4 #include "kan_pand.h"
5 #include "includes/galpanic.h"
6
7
video_start()8 void galpanic_state::video_start()
9 {
10 m_screen->register_screen_bitmap(m_bitmap);
11
12 save_item(NAME(m_bitmap));
13 }
14
galpanic_palette(palette_device & palette) const15 void galpanic_state::galpanic_palette(palette_device &palette) const
16 {
17 // first 1024 colors are dynamic
18
19 // initialize 555 GRB lookup
20 for (int i = 0; i < 32768; i++)
21 palette.set_pen_color(i + 1024, pal5bit(i >> 5), pal5bit(i >> 10), pal5bit(i >> 0));
22 }
23
bgvideoram_w(offs_t offset,uint16_t data,uint16_t mem_mask)24 void galpanic_state::bgvideoram_w(offs_t offset, uint16_t data, uint16_t mem_mask)
25 {
26 data = COMBINE_DATA(&m_bgvideoram[offset]);
27
28 int sy = offset / 256;
29 int sx = offset % 256;
30
31 m_bitmap.pix(sy, sx) = 1024 + (data >> 1);
32 }
33
draw_fgbitmap(bitmap_ind16 & bitmap,const rectangle & cliprect)34 void galpanic_state::draw_fgbitmap(bitmap_ind16 &bitmap, const rectangle &cliprect)
35 {
36 for (int offs = 0;offs < m_fgvideoram.bytes()/2;offs++)
37 {
38 int const sx = offs % 256;
39 int const sy = offs / 256;
40 int const color = m_fgvideoram[offs];
41 if (color)
42 bitmap.pix(sy, sx) = color;
43 }
44 }
45
screen_update(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)46 uint32_t galpanic_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
47 {
48 /* copy the temporary bitmap to the screen */
49 copybitmap(bitmap,m_bitmap,0,0,0,0,cliprect);
50
51 draw_fgbitmap(bitmap, cliprect);
52
53 m_pandora->update(bitmap, cliprect);
54
55 return 0;
56 }
57