summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/gunpey.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/drivers/gunpey.cpp')
-rw-r--r--src/mame/drivers/gunpey.cpp964
1 files changed, 335 insertions, 629 deletions
diff --git a/src/mame/drivers/gunpey.cpp b/src/mame/drivers/gunpey.cpp
index d17bef7bf78..3104f460e37 100644
--- a/src/mame/drivers/gunpey.cpp
+++ b/src/mame/drivers/gunpey.cpp
@@ -1,12 +1,10 @@
// license:LGPL-2.1+
-// copyright-holders:Angelo Salese, Tomasz Slanina, David Haywood, Luca Elia
+// copyright-holders:Angelo Salese, Tomasz Slanina, David Haywood, Luca Elia, Morten Shearman Kirkegaard
/********************************************************************************************
Gunpey (c) 2000 Banpresto
TODO:
- - Implement correct Axell video chip decompression scheme, currently using decompressed
- data extracted from the PCB (for reference)
- Framebuffer is actually in the same DRAM as the blitter data gets copied to, not a
separate RAM. It (and the double buffered copy) appear near the top right of the
framebuffer, so there are likely registers to control this that need finding.
@@ -211,11 +209,25 @@ public:
m_maincpu(*this, "maincpu"),
m_oki(*this, "oki"),
m_wram(*this, "wram"),
- m_palette(*this, "palette"),
- m_pre_index(*this, "pre_index"),
- m_pre_data(*this, "pre_data")
+ m_palette(*this, "palette")
{ }
+ // TODO: make these non-static and private
+ static void set_o(struct state_s *s, unsigned char v);
+ static unsigned char get_o(struct state_s *s, int x, int y);
+ static void hn_bytes_new_colour(struct state_s *s, unsigned char v, int n);
+ static void hn_bytes_prev_colour(struct state_s *s, unsigned char v, int n);
+ static void hn_copy_directly(struct state_s *s, unsigned char v, int n);
+ static void hn_copy_plus_one(struct state_s *s, unsigned char v, int n);
+ static void hn_copy_minus_one(struct state_s *s, unsigned char v, int n);
+
+ void gunpey(machine_config &config);
+ void io_map(address_map &map);
+ void mem_map(address_map &map);
+
+ DECLARE_DRIVER_INIT(gunpey);
+private:
+
DECLARE_WRITE8_MEMBER(status_w);
DECLARE_READ8_MEMBER(status_r);
DECLARE_READ8_MEMBER(inputs_r);
@@ -225,25 +237,17 @@ public:
DECLARE_WRITE8_MEMBER(output_w);
DECLARE_WRITE16_MEMBER(vram_bank_w);
DECLARE_WRITE16_MEMBER(vregs_addr_w);
- DECLARE_DRIVER_INIT(gunpey);
virtual void video_start() override;
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
TIMER_DEVICE_CALLBACK_MEMBER(scanline);
TIMER_CALLBACK_MEMBER(blitter_end);
- void gunpey(machine_config &config);
- void io_map(address_map &map);
- void mem_map(address_map &map);
-private:
-
void irq_check(uint8_t irq_type);
uint8_t draw_gfx(bitmap_ind16 &bitmap, const rectangle &cliprect, int count, uint8_t scene_gradient);
uint16_t m_vram_bank;
uint16_t m_vreg_addr;
uint8_t* m_blit_rom;
- uint8_t* m_blit_rom2;
-
uint8_t* m_vram;
emu_timer *m_blitter_end_timer;
@@ -262,40 +266,28 @@ private:
int m_dstxbase;
int m_dstxcount;
int m_dstycount;
- bool m_out_of_data;
-
- int m_latched_bits_left;
- uint8_t m_latched_byte;
- int m_zero_bit_count;
-
- void get_stream_next_byte(void);
- int get_stream_bit(void);
- uint32_t get_stream_bits(int bits);
+ uint16_t m_blit_ram[0x10];
+ uint8_t get_vrom_byte(int x, int y);
int write_dest_byte(uint8_t usedata);
- //uint16_t main_m_vram[0x800][0x800];
+ int decompress_sprite(unsigned char *buf, int ix, int iy, int ow, int oh, int dx, int dy);
+ int next_node(struct huffman_node_s **res, struct state_s *s);
+ int get_next_bit(struct state_s *s);
+
- uint16_t m_blit_ram[0x10];
uint8_t m_irq_cause, m_irq_mask;
std::unique_ptr<uint16_t[]> m_blit_buffer;
-
required_device<cpu_device> m_maincpu;
required_device<okim6295_device> m_oki;
required_shared_ptr<uint16_t> m_wram;
required_device<palette_device> m_palette;
-
- // compression workaround
- void replace_decompressed_sprite(void);
- required_region_ptr<uint8_t> m_pre_index;
- required_region_ptr<uint8_t> m_pre_data;
};
void gunpey_state::video_start()
{
m_blit_buffer = std::make_unique<uint16_t[]>(512*512);
-
m_blitter_end_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gunpey_state::blitter_end), this));
}
@@ -356,20 +348,20 @@ uint8_t gunpey_state::draw_gfx(bitmap_ind16 &bitmap,const rectangle &cliprect,in
if (zoomheight) heightstep = sourceheight / zoomheight;
uint16_t unused;
- if (debug) printf("sprite %04x %04x %04x %04x %04x %04x %04x %04x\n", m_wram[count+0], m_wram[count+1], m_wram[count+2], m_wram[count+3], m_wram[count+4], m_wram[count+5], m_wram[count+6], m_wram[count+7]);
+ if (debug) logerror("sprite %04x %04x %04x %04x %04x %04x %04x %04x\n", m_wram[count+0], m_wram[count+1], m_wram[count+2], m_wram[count+3], m_wram[count+4], m_wram[count+5], m_wram[count+6], m_wram[count+7]);
- unused = m_wram[count+0]&~0xff98; if (unused) printf("unused bits set in word 0 - %04x\n", unused);
- unused = m_wram[count+1]&~0xf89f; if (unused) printf("unused bits set in word 1 - %04x\n", unused);
- unused = m_wram[count+2]&~0xfc3f; if (unused) printf("unused bits set in word 2 - %04x\n", unused);
- unused = m_wram[count+3]&~0xff1f; if (unused) printf("unused bits set in word 3 - %04x\n", unused);
- unused = m_wram[count+4]&~0xff77; if (unused) printf("unused bits set in word 4 - %04x\n", unused);
- unused = m_wram[count+5]&~0xffff; if (unused) printf("unused bits set in word 5 - %04x\n", unused);
- unused = m_wram[count+6]&~0x00ff; if (unused) printf("unused bits set in word 6 - %04x\n", unused);
- unused = m_wram[count+7]&~0xff00; if (unused) printf("unused bits set in word 7 - %04x\n", unused);
+ unused = m_wram[count+0]&~0xff98; if (unused) logerror("unused bits set in word 0 - %04x\n", unused);
+ unused = m_wram[count+1]&~0xf89f; if (unused) logerror("unused bits set in word 1 - %04x\n", unused);
+ unused = m_wram[count+2]&~0xfc3f; if (unused) logerror("unused bits set in word 2 - %04x\n", unused);
+ unused = m_wram[count+3]&~0xff1f; if (unused) logerror("unused bits set in word 3 - %04x\n", unused);
+ unused = m_wram[count+4]&~0xff77; if (unused) logerror("unused bits set in word 4 - %04x\n", unused);
+ unused = m_wram[count+5]&~0xffff; if (unused) logerror("unused bits set in word 5 - %04x\n", unused);
+ unused = m_wram[count+6]&~0x00ff; if (unused) logerror("unused bits set in word 6 - %04x\n", unused);
+ unused = m_wram[count+7]&~0xff00; if (unused) logerror("unused bits set in word 7 - %04x\n", unused);
if (((zoomwidth<<ZOOM_SHIFT) != sourcewidth) || ((zoomheight<<ZOOM_SHIFT) != sourceheight))
{
- // printf("sw %08x zw %08x sh %08x zh %08x heightstep %08x widthstep %08x \n", sourcewidth, zoomwidth<<ZOOM_SHIFT, sourceheight, zoomheight<<ZOOM_SHIFT, heightstep, widthstep );
+ // logerror("sw %08x zw %08x sh %08x zh %08x heightstep %08x widthstep %08x \n", sourcewidth, zoomwidth<<ZOOM_SHIFT, sourceheight, zoomheight<<ZOOM_SHIFT, heightstep, widthstep );
}
if(bpp_sel == 0x00) // 4bpp
@@ -453,7 +445,7 @@ uint8_t gunpey_state::draw_gfx(bitmap_ind16 &bitmap,const rectangle &cliprect,in
else if(bpp_sel == 0x08) // 6bpp
{
// not used by Gunpey?
- printf("6bpp\n");
+ logerror("6bpp\n");
}
else if(bpp_sel == 0x10) // 8bpp
{
@@ -527,7 +519,7 @@ uint8_t gunpey_state::draw_gfx(bitmap_ind16 &bitmap,const rectangle &cliprect,in
else if(bpp_sel == 0x18) // RGB32k
{
// not used by Gunpey?
- printf("32k\n");
+ logerror("32k\n");
// ...
}
}
@@ -563,7 +555,7 @@ uint32_t gunpey_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap
scene_enabled = m_wram[scene_index+0] & 0x01;
scene_gradient = m_wram[scene_index+1] & 0xff;
-// printf("%08x: %08x %08x %08x %08x | %08x %08x %08x %08x\n",scene_index,m_wram[scene_index+0],m_wram[scene_index+1],m_wram[scene_index+2],m_wram[scene_index+3],
+// logerror("%08x: %08x %08x %08x %08x | %08x %08x %08x %08x\n",scene_index,m_wram[scene_index+0],m_wram[scene_index+1],m_wram[scene_index+2],m_wram[scene_index+3],
// m_wram[scene_index+4],m_wram[scene_index+5],m_wram[scene_index+6],m_wram[scene_index+7]);
if(scene_enabled)
@@ -636,508 +628,372 @@ TIMER_CALLBACK_MEMBER(gunpey_state::blitter_end)
irq_check(4);
}
-void gunpey_state::get_stream_next_byte(void)
+
+int gunpey_state::write_dest_byte(uint8_t usedata)
{
- // check if we need to move on to the next row of the source bitmap
- // to get the data requested
+ // write the byte we and to destination and increase our counters
+ m_vram[(((m_dsty)&0x7ff)*0x800)+((m_dstx)&0x7ff)] = usedata;
- if (m_scrxcount==m_sourcewide)
+ // increase destination counter and check if we've filled our destination rectangle
+ m_dstx++; m_dstxcount++;
+ if (m_dstxcount==m_xsize)
{
- m_scrxcount = 0;
- m_srcx = m_srcxbase;
- m_srcy++; m_srcycount++;
+ m_dstxcount = 0;
+ m_dstx = m_dstxbase;
+ m_dsty++; m_dstycount++;
+ if (m_dstycount==m_ysize)
+ {
+ return -1;
+ }
}
- m_latched_byte = m_blit_rom[(((m_srcy)&0x7ff)*0x800)+((m_srcx)&0x7ff)];
- if (!m_out_of_data) m_blit_rom2[(((m_srcy)&0x7ff)*0x800)+((m_srcx)&0x7ff)] = 0x77; // debug
+ return 1;
+}
- m_latched_bits_left = 8;
- // increase counters
- m_srcx++; m_scrxcount++;
+inline uint8_t gunpey_state::get_vrom_byte(int x, int y)
+{
+ return m_blit_rom[(x)+2048 * (y)];
}
-int gunpey_state::get_stream_bit(void)
+struct state_s
+{
+ unsigned char *buf;
+ unsigned char bits;
+ int num_bits;
+ unsigned char colour[16];
+ int basex;
+ int ix, iy, iw;
+ int dx, dy;
+ int ow, oh;
+ int ox, oy;
+};
+
+inline int gunpey_state::get_next_bit(struct state_s *s)
{
- if (m_latched_bits_left==0)
+ if (s->num_bits == 0)
{
- get_stream_next_byte();
+ if (s->ix >= s->basex + s->iw)
+ {
+ s->ix = s->basex;
+ s->iy++;
+ }
+ s->bits = get_vrom_byte(s->ix, s->iy);
+ s->ix++;
+ s->num_bits = 8;
}
- m_latched_bits_left--;
+ int res = 1 & s->bits;
- int bit = (m_latched_byte >> (7-m_latched_bits_left))&1;
+ s->bits >>= 1;
+ s->num_bits--;
- if (bit==0) m_zero_bit_count++;
- else m_zero_bit_count=0;
-
- return bit;
+ return res;
}
-uint32_t gunpey_state::get_stream_bits(int bits)
+
+void gunpey_state::set_o(struct state_s *s, unsigned char v)
{
- uint32_t output = 0;
- for (int i=0;i<bits;i++)
+ assert(s->ox >= 0);
+ assert(s->ox < s->ow);
+ assert(s->ox < 256);
+ assert(s->oy >= 0);
+ assert(s->oy < s->oh);
+ assert(s->oy < 256);
+
+ unsigned char a = v;
+ for (int i = 0; i < sizeof(s->colour) / sizeof(*s->colour); i++)
{
- output = output<<1;
- output |= get_stream_bit();
+ unsigned char b = s->colour[i];
+ s->colour[i] = a;
+ a = b;
+ if (a == v)
+ break;
}
- return output;
+ s->buf[((s->dx + s->ox++) & 0x7ff) + (((s->dy + s->oy) & 0x7ff) * 0x800)] = v;
}
-int gunpey_state::write_dest_byte(uint8_t usedata)
+
+unsigned char gunpey_state::get_o(struct state_s *s, int x, int y)
{
- // write the byte we and to destination and increase our counters
- m_vram[(((m_dsty)&0x7ff)*0x800)+((m_dstx)&0x7ff)] = usedata;
+ assert(x >= 0);
+ assert(x < s->ow);
+ assert(x < 256);
+ assert(y >= 0);
+ assert(y < s->oh);
+ assert(y < 256);
+
+ return s->buf[((s->dx + x) & 0x7ff) + (((s->dy + y) & 0x7ff) * 0x800)];
+}
- // increase destination counter and check if we've filled our destination rectangle
- m_dstx++; m_dstxcount++;
- if (m_dstxcount==m_xsize)
+
+void gunpey_state::hn_bytes_new_colour(struct state_s *s, unsigned char v, int n)
+{
+ for (int i = 0; i < n; i++)
{
- m_dstxcount = 0;
- m_dstx = m_dstxbase;
- m_dsty++; m_dstycount++;
- if (m_dstycount==m_ysize)
- {
- return -1;
- }
+ set_o(s, v);
}
-
- return 1;
}
-/*
-the very first transfer, which might be 100% blank data looks like this.. are the 239 repeats significant (our screen height is 240.. 239 is 16x15 - 1)
- and this same data block occurs 6 times in the transfer. Maximum draw size is 256x256.. (but I'm not sure this gets drawn)
- the value that repeats (110010110) is quite common in other blocks of more noisy data too.
-
-this is sprite 959 in test mode, as you can see below the sprite size is 27 ef (== 0x50 0xf0)
-
-
-02 08 00 8c|6c 06 73 06|80 03 00 00|27 00 ef 00
-data:
- 000101010 001011011 1111111
-
- (this is 239 (0xef) repeats)
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101
-
- 101001 1001 0000
-
- (this is 239 repeats)
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101
-
-
- 101001 1001 0000
-
- (this is 239 repeats)
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-
- 101001 1001 0000
-
- (this is 239 repeats)
- 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-
- 101001 1001 0000
-
- (this is 239 repeats)
- 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-
- 101001 1001 0000
-
- (this is 239 repeats)
-
- 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-
- (then what happens?! is this part of the same sprite or just running past the end of the compressed source block?)
- (this is also a repeat of 239 values, but this time 11 bit ones)
-
- 101001110000000
-
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100 10101000100
- 10101000100 10101000100 10101000100 10101000100 10101000100
-
-
-
- 219 in char test
-
-02 08 00 8c|8a 03 78 00|90 01 e0 02|17 00 27 00
-data: 000101 010 001011 010 000011
-
-(40 (0x28) 'repeat' values, last one is different)
- 1101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 10110010
- 1101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 10110010
- 1101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 10110010
- 1101100101 101100101 101100101 101100101 101100101 101100101
-
- 10100110010000
-
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101
-
- 101001 1001 0000 << this string again before repeating data..
- (39 (0x27) repeat)
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101
-
- 101001 1001 0000 << this string again before repeating data..
- (39 (0x27) 'repeat' values, last one is different)
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101
-
- 000000 000000
-
-
- 378 - might be interesting, is text, not pasting here.
-
-
- 703 - another (mostly) blank?
-
- 02 08 00 8c|1a 00 3f 03|90 01 e0 02|23 00 67 00
-data: 000101 001100 10000
-
-(0x67 repeats...)
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-
- 101001 1001 0000 << this.. again
-
- (0x67 repeats...)
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-
- 101001 1001 0000
-
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-
- 1010011001 0000
-
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101
-
- 10100111111111000000101000110000110010100010100111110100010110100100101101101010101100000101111100110010101110001010100011001000110010101011
- 101100101
- 10101000111001100101010111010011111001001001000011001010001010011111010001011010010010 110110100 110010000
-
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 10100110010000
+void gunpey_state::hn_bytes_prev_colour(struct state_s *s, unsigned char v, int n)
+{
+ int c = s->colour[v];
- 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101
+ for (int i = 0; i < n; i++)
+ {
+ set_o(s, c);
+ }
+}
- 101001 1001 0000
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 101100101 101100101 101100101 101100101 101100101 101100101 101100101
- 000000 000000
+void gunpey_state::hn_copy_directly(struct state_s *s, unsigned char v, int n)
+{
+ for (int i = 0; i < n; i++)
+ {
+ if ((s->ox / 12) & 1)
+ {
+ set_o(s, get_o(s, s->ox, s->oy + 1));
+ }
+ else
+ {
+ set_o(s, get_o(s, s->ox, s->oy - 1));
+ }
+ }
+}
- thoughts:
+void gunpey_state::hn_copy_plus_one(struct state_s *s, unsigned char v, int n)
+{
+ for (int i = 0; i < n; i++)
+ {
+ if ((s->ox / 12) & 1)
+ {
+ set_o(s, get_o(s, s->ox + 1, s->oy + 1));
+ }
+ else
+ {
+ set_o(s, get_o(s, s->ox + 1, s->oy - 1));
+ }
+ }
+}
- where there are repeating values of 101100101 they tend to be in blocks the same (or a very similar) size to the HEIGHT (y-size) of the object with a different (often
- common '101001100 10000') value between them.. which can throw out the stream alignment.. this separator CAN vary in both content and length..
- not all data is 9-bit, some blocks are made of 11-bit repeating values, see first example.
+void gunpey_state::hn_copy_minus_one(struct state_s *s, unsigned char v, int n)
+{
+ for (int i = 0; i < n; i++)
+ {
+ if ((s->ox / 12) & 1)
+ {
+ set_o(s, get_o(s, s->ox - 1, s->oy + 1));
+ }
+ else
+ {
+ set_o(s, get_o(s, s->ox - 1, s->oy - 1));
+ }
+ }
+}
-
-02 08 00 8c|90 03 78 00|90 01 e0 02|17 00 27 00
-data:
-00010101 00010110 10000 0111
-101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-101100101 101100101 101100101 101100101 101100101 101100101 101100101
-101001100 10000
-101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-101100101 101100101 101100101 101100101 101100101 101100101 101100101
-101001100 10000
-101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-101100101 101100101 101100101 101100101 101100101 101100101 101100101
-101001100 10000
-101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-101100101 101100101 101100101 101100101 101100101 101100101 101100101 101100101
-101100101 101100101 101100101 101100101 101100101 101100101 101100101
-00000000000000
+static struct huffman_node_s
+{
+ const char *bits;
+ void (*func)(struct state_s *, unsigned char, int);
+ int arg0_bits;
+ int arg1_val;
+} hn[] = {
+ { "11", gunpey_state::hn_bytes_new_colour, 8, 1 },
+ { "10111", gunpey_state::hn_bytes_new_colour, 8, 2 },
+ { "10110011", gunpey_state::hn_bytes_new_colour, 8, 3 },
+ { "1010011000", gunpey_state::hn_bytes_new_colour, 8, 4 },
+ { "1010101010000", gunpey_state::hn_bytes_new_colour, 8, 5 },
+ { "101010001011110", gunpey_state::hn_bytes_new_colour, 8, 6 },
+ { "101010010101110", gunpey_state::hn_bytes_new_colour, 8, 7 },
+ { "101010010101111", gunpey_state::hn_bytes_new_colour, 8, 8 },
+ { "101010010101100", gunpey_state::hn_bytes_new_colour, 8, 9 },
+ { "10101000101100", gunpey_state::hn_bytes_new_colour, 8, 10 },
+ { "101010010101101", gunpey_state::hn_bytes_new_colour, 8, 11 },
+ { "10101000101101", gunpey_state::hn_bytes_new_colour, 8, 12 },
+ { "0", gunpey_state::hn_bytes_prev_colour, 4, 1 },
+ { "100", gunpey_state::hn_bytes_prev_colour, 4, 2 },
+ { "101011", gunpey_state::hn_bytes_prev_colour, 4, 3 },
+ { "1010010", gunpey_state::hn_bytes_prev_colour, 4, 4 },
+ { "101010100", gunpey_state::hn_bytes_prev_colour, 4, 5 },
+ { "1010100100", gunpey_state::hn_bytes_prev_colour, 4, 6 },
+ { "10101010110", gunpey_state::hn_bytes_prev_colour, 4, 7 },
+ { "10100111000", gunpey_state::hn_bytes_prev_colour, 4, 8 },
+ { "101010101001", gunpey_state::hn_bytes_prev_colour, 4, 9 },
+ { "101001111000", gunpey_state::hn_bytes_prev_colour, 4, 10 },
+ { "101010010100", gunpey_state::hn_bytes_prev_colour, 4, 11 },
+ { "1010011001", gunpey_state::hn_bytes_prev_colour, 4, 12 },
+ { "101101", gunpey_state::hn_copy_directly, 0, 2 },
+ { "10101011", gunpey_state::hn_copy_directly, 0, 3 },
+ { "101010011", gunpey_state::hn_copy_directly, 0, 4 },
+ { "101001101", gunpey_state::hn_copy_directly, 0, 5 },
+ { "1010011111", gunpey_state::hn_copy_directly, 0, 6 },
+ { "1010100011", gunpey_state::hn_copy_directly, 0, 7 },
+ { "10101000100", gunpey_state::hn_copy_directly, 0, 8 },
+ { "101010101111", gunpey_state::hn_copy_directly, 0, 9 },
+ { "101001110010", gunpey_state::hn_copy_directly, 0, 10 },
+ { "1010011100111", gunpey_state::hn_copy_directly, 0, 11 },
+ { "101100101", gunpey_state::hn_copy_directly, 0, 12 },
+ { "1011000", gunpey_state::hn_copy_plus_one, 0, 2 },
+ { "101010000", gunpey_state::hn_copy_plus_one, 0, 3 },
+ { "10101001011", gunpey_state::hn_copy_plus_one, 0, 4 },
+ { "101010001010", gunpey_state::hn_copy_plus_one, 0, 5 },
+ { "1010101011101", gunpey_state::hn_copy_plus_one, 0, 6 },
+ { "1010101011100", gunpey_state::hn_copy_plus_one, 0, 7 },
+ { "1010011110010", gunpey_state::hn_copy_plus_one, 0, 8 },
+ { "10101000101110", gunpey_state::hn_copy_plus_one, 0, 9 },
+ { "101010001011111", gunpey_state::hn_copy_plus_one, 0, 10 },
+ { "1010011110011", gunpey_state::hn_copy_plus_one, 0, 11 },
+ { "101000", gunpey_state::hn_copy_minus_one, 0, 2 },
+ { "101100100", gunpey_state::hn_copy_minus_one, 0, 3 },
+ { "1010011101", gunpey_state::hn_copy_minus_one, 0, 4 },
+ { "10101010101", gunpey_state::hn_copy_minus_one, 0, 5 },
+ { "101001111011", gunpey_state::hn_copy_minus_one, 0, 6 },
+ { "101001111010", gunpey_state::hn_copy_minus_one, 0, 7 },
+ { "1010101010001", gunpey_state::hn_copy_minus_one, 0, 8 },
+ { "1010011100110", gunpey_state::hn_copy_minus_one, 0, 9 },
+ { "10101001010101", gunpey_state::hn_copy_minus_one, 0, 10 },
+ { "10101001010100", gunpey_state::hn_copy_minus_one, 0, 11 },
+ { NULL },
+};
-02 08 00 8c|18 04 f0 00|90 01 e0 02|17 00 27 00
-data:
-00010101 00010110 10111 1011
-(then same as above)
-
-
-
-02 08 00 8c|a2 03 d0 04|90 01 e0 02|03 00 07 00
-data:
+int gunpey_state::next_node(struct huffman_node_s **res, struct state_s *s)
+{
+ char bits[128];
-000101010 010101110 101101001 101001100 010001011 111110100 101110000 110001000
-101101101 101010001 101011100 110111110 011111100 101101011 010110111 011000110
-000011110 101100110 000011011 101100011 100100001 111111000 111111001 101001011
-111101101 011100001 100001011 000110011 101010110 010001011 101001100 110111001
-011100011 101100000 001101000 111001011 001111110 011110011 111110101 110110110
-111111111 011010000 010101101 110010101 111100001 110101000 110111100 001100011
-001101111 001001000 000000000
-ooutcount was 51
+ memset(bits, 0, sizeof(bits));
+ for (int i = 0; i < sizeof(bits) - 1; i++)
+ {
+ bits[i] = '0' + get_next_bit(s);
- */
+ for (int j = 0;; j++)
+ {
+ if (!hn[j].bits) return -1;
+ if (strncmp(bits, hn[j].bits, i + 1) == 0)
+ {
+ if (!hn[j].bits[i + 1])
+ {
+ *res = &hn[j];
+ return 0;
+ }
+ break;
+ }
+ }
+ }
-//#define SHOW_COMPRESSED_DATA_DEBUG
+ return -1;
+}
-void gunpey_state::replace_decompressed_sprite(void)
+int gunpey_state::decompress_sprite(unsigned char *buf, int ix, int iy, int ow, int oh, int dx, int dy)
{
- m_srcx = m_blit_ram[0x04] + (m_blit_ram[0x05] << 8);
- m_srcy = m_blit_ram[0x06] + (m_blit_ram[0x07] << 8);
- m_dstx = m_blit_ram[0x08] + (m_blit_ram[0x09] << 8);
- m_dsty = m_blit_ram[0x0a] + (m_blit_ram[0x0b] << 8);
- m_xsize = m_blit_ram[0x0c] + 1;
- m_ysize = m_blit_ram[0x0e] + 1;
+ struct huffman_node_s *n;
+ struct state_s s;
+ unsigned char v;
+ int eol;
- m_dstx <<= 1;
- m_xsize <<= 1;
+ s.buf = buf;
+ s.num_bits = 0;
- int i = 0;
+ memset(s.colour, 0, sizeof(s.colour));
- for (;;)
- {
- uint16_t lookupx, lookupy;
- uint32_t lookupoffset;
+ s.basex = ix;
+
+ s.ix = ix;
+ s.iy = iy;
+ s.iw = get_vrom_byte(s.ix++, s.iy) + 1;
+ s.dx = dx;
+ s.dy = dy;
- lookupx = (m_pre_index[i + 0] << 8) | (m_pre_index[i + 1] << 0);
- lookupy = (m_pre_index[i + 2] << 8) | (m_pre_index[i + 3] << 0);
- lookupoffset = (m_pre_index[i + 4] << 24) | (m_pre_index[i + 5] << 16) | (m_pre_index[i + 6] << 8) | (m_pre_index[i + 7] << 0);
+ s.ow = ow;
+ s.oh = oh;
+ s.ox = 0;
+ s.oy = 0;
+
+ int temp;
+ temp = get_next_bit(&s);
+ temp |= get_next_bit(&s) << 1;
+ temp |= get_next_bit(&s) << 2;
+ assert(temp == 0);
+
+ while (s.ox < s.ow)
+ {
+ if (next_node(&n, &s))
+ return -1;
- // reached end up list without finding anything (shouldn't happen)
- if ((lookupx == 0xffff) && (lookupy == 0xffff) && (lookupoffset == 0xffffffff))
+ v = 0;
+ for (int i = 0; i < n->arg0_bits; i++)
{
- //fatalerror("sprite replacement not found");
- break;
+ v |= get_next_bit(&s) << i;
}
- if ((lookupx == m_srcx) && (lookupy == m_srcy))
+ n->func(&s, v, n->arg1_val);
+
+ if ((s.ox % 12) == 0)
{
- m_dstxbase = m_dstx;
- m_dstxcount = 0;
- m_dstycount = 0;
- m_srcxbase = m_srcx;
- m_scrxcount = 0;
- m_srcycount = 0;
+ s.ox -= 12;
+ if ((s.ox / 12) & 1)
+ {
+ s.oy -= 1;
+ }
+ else
+ {
+ s.oy += 1;
+ }
+ eol = 1;
- for (;;)
+ }
+ else if (s.ox == s.ow)
+ {
+ s.ox -= s.ow % 12;
+ if ((s.ox / 12) & 1)
+ {
+ s.oy -= 1;
+ }
+ else
{
- uint8_t usedata = 0;
+ s.oy += 1;
+ }
+ eol = 1;
+
+ }
+ else
+ {
+ eol = 0;
+ }
- if (lookupoffset < 0x4c110a)
+ if (eol)
+ {
+ if ((s.oy == s.oh) || (s.oy == -1))
+ {
+ s.ox += 12;
+ if ((s.ox / 12) & 1)
{
- usedata = m_pre_data[lookupoffset++];
+ s.oy -= 1;
}
else
{
- //fatalerror("out of data\n");
- }
-
- m_srcx++; m_scrxcount++;
- if (m_scrxcount == m_xsize)
- {
- m_scrxcount = 0;
- m_srcx = m_srcxbase;
- m_srcy++; m_srcycount++;
+ s.oy += 1;
}
-
- if ((write_dest_byte(usedata)) == -1)
- break;
}
-
- break;
}
-
- i += 8;
}
+
+ return 0;
}
WRITE8_MEMBER(gunpey_state::blitter_w)
{
uint16_t *blit_ram = m_blit_ram;
- //printf("gunpey_blitter_w offset %01x data %02x\n", offset,data);
+ //logerror("gunpey_blitter_w offset %01x data %02x\n", offset,data);
blit_ram[offset] = data;
@@ -1157,126 +1013,14 @@ WRITE8_MEMBER(gunpey_state::blitter_w)
if(compression)
{
if(compression == 8)
- {
- // compressed stream format:
- //
- // byte 0 = source width (data is often stored in fairly narrow columns)
-
-#ifdef SHOW_COMPRESSED_DATA_DEBUG
- printf("%02x %02x %02x %02x|%02x %02x %02x %02x|%02x %02x %02x %02x|%02x %02x %02x %02x\n"
- ,blit_ram[0],blit_ram[1],blit_ram[2],blit_ram[3]
- ,blit_ram[4],blit_ram[5],blit_ram[6],blit_ram[7]
- ,blit_ram[8],blit_ram[9],blit_ram[0xa],blit_ram[0xb]
- ,blit_ram[0xc],blit_ram[0xd],blit_ram[0xe],blit_ram[0xf]);
- int count = 0;
- printf("data: ");
- int linespacer = 0;
-#endif
-
-
- m_dstxbase = m_dstx;
- m_dstxcount = 0;
- m_dstycount = 0;
- m_srcxbase = m_srcx;
- m_scrxcount = 0;
- m_srcycount = 0;
-
- m_sourcewide = m_blit_rom[(((m_srcy)&0x7ff)*0x800)+((m_srcx)&0x7ff)]+1;
- m_srcx++;m_scrxcount++; // we don't want to decode the width as part of the data stream..
- m_latched_bits_left = 0;
- m_zero_bit_count = 0;
-
- m_out_of_data = false;
-
- for (;;)
+ {
+ if (decompress_sprite(m_vram, m_srcx, m_srcy, m_xsize, m_ysize, m_dstx, m_dsty))
{
- int test = get_stream_bits(2);
- int data;
- int getbits = 1;
- // don't think this is right.. just keeps some streams in alignment, see 959 in char test for example
- if (test==0x0)
- {
- getbits = 4;
- }
- else if (test==0x1)
- {
- getbits = 1;
- }
- else if (test==0x2)
- {
- getbits = 2;
- }
- else if (test==0x3)
- {
- getbits = 7;
- }
- data = get_stream_bits(getbits);
-
- // hack, really I imagine there is exactly enough compressed data to fill the dest bitmap area when decompressed, but to stop us
- // overrunning into reading other data we terminate on a 0000, which doesn't seem likely to be compressed data.
- if (m_zero_bit_count>=16)
- m_out_of_data = true;
-
-
-
- uint8_t usedata = 0xff;
- if (!m_out_of_data)
- {
- #ifdef SHOW_COMPRESSED_DATA_DEBUG
- //if (count<512)
- {
- {
- if (test==0x0)
- {
- printf("00");
- }
- else if (test==0x1)
- {
- printf("01");
- }
- else if (test==0x2)
- {
- printf("10");
- }
- else if (test==0x3)
- {
- printf("11");
- }
-
- for (int z=0;z<getbits;z++)
- {
- printf("%d", (data>>((getbits-1)-z))&1);
- }
-
- linespacer++;
- if ((linespacer%16) == 0) printf("\n");
-
- printf(" ");
-
- }
- count++;
- }
- #endif
-
- usedata = data;
- }
- else
- usedata = 0x44;
-
- if ((write_dest_byte(usedata))==-1)
- break;
-
+ logerror("[-] Failed to decompress sprite at %04x %04x\n", m_srcx, m_srcy);
}
-
-#ifdef SHOW_COMPRESSED_DATA_DEBUG
- printf("\n");
-#endif
-
- replace_decompressed_sprite();
-
}
else
- printf("unknown compression mode %02x\n",compression);
+ logerror("unknown compression mode %02x\n",compression);
}
else
{
@@ -1290,7 +1034,6 @@ WRITE8_MEMBER(gunpey_state::blitter_w)
for (;;)
{
uint8_t usedata = m_blit_rom[(((m_srcy)&0x7ff)*0x800)+((m_srcx)&0x7ff)];
- m_blit_rom2[(((m_srcy)&0x7ff)*0x800)+((m_srcx)&0x7ff)] = 0x44; // debug
m_srcx++; m_scrxcount++;
if (m_scrxcount==m_xsize)
{
@@ -1305,23 +1048,18 @@ WRITE8_MEMBER(gunpey_state::blitter_w)
}
m_blitter_end_timer->adjust(m_maincpu->cycles_to_attotime(m_xsize*m_ysize));
-
-
-/*
-
-*/
}
}
WRITE8_MEMBER(gunpey_state::blitter_upper_w)
{
- //printf("gunpey_blitter_upper_w %02x %02x\n", offset, data);
+ //logerror("gunpey_blitter_upper_w %02x %02x\n", offset, data);
}
WRITE8_MEMBER(gunpey_state::blitter_upper2_w)
{
- //printf("gunpey_blitter_upper2_w %02x %02x\n", offset, data);
+ //logerror("gunpey_blitter_upper2_w %02x %02x\n", offset, data);
}
@@ -1473,27 +1211,11 @@ TIMER_DEVICE_CALLBACK_MEMBER(gunpey_state::scanline)
if(scanline == 240)
{
- //printf("frame\n");
+ //logerror("frame\n");
irq_check(0x50);
}
}
-
-
-
-
-// this isn't a real decode as such, but the graphic data is all stored in pages 2048 bytes wide at varying BPP levels, some (BG data) compressed with what is likely a lossy scheme
-// palette data is in here too, the blocks at the bottom right of all this?
-static GFXLAYOUT_RAW( gunpey, 2048, 1, 2048*8, 2048*8 )
-
-static GFXDECODE_START( gunpey )
- GFXDECODE_ENTRY( "blit_data", 0, gunpey, 0x0000, 0x1 )
- GFXDECODE_ENTRY( "blit_data2", 0, gunpey, 0x0000, 0x1 )
- GFXDECODE_ENTRY( "vram", 0, gunpey, 0x0000, 0x1 )
-GFXDECODE_END
-
-
-
/***************************************************************************************/
MACHINE_CONFIG_START(gunpey_state::gunpey)
@@ -1510,7 +1232,6 @@ MACHINE_CONFIG_START(gunpey_state::gunpey)
MCFG_SCREEN_PALETTE("palette")
MCFG_PALETTE_ADD_RRRRRGGGGGBBBBB("palette")
- MCFG_GFXDECODE_ADD("gfxdecode", "palette", gunpey)
MCFG_SPEAKER_STANDARD_STEREO("lspeaker","rspeaker")
@@ -1523,7 +1244,6 @@ MACHINE_CONFIG_START(gunpey_state::gunpey)
MCFG_SOUND_ROUTE(1, "rspeaker", 0.25)
MACHINE_CONFIG_END
-
/***************************************************************************************/
ROM_START( gunpey )
@@ -1533,9 +1253,6 @@ ROM_START( gunpey )
ROM_REGION( 0x400000, "blit_data", 0 )
ROM_LOAD( "gp_rom3.025", 0x00000, 0x400000, CRC(f2d1f9f0) SHA1(0d20301fd33892074508b9d127456eae80cc3a1c) )
- ROM_REGION( 0x400000, "blit_data2", 0 ) // debug test
- ROM_COPY( "blit_data", 0x00000, 0x00000, 0x400000 )
-
ROM_REGION( 0x400000, "vram", ROMREGION_ERASEFF )
@@ -1544,23 +1261,12 @@ ROM_START( gunpey )
ROM_REGION( 0x400000, "oki", 0 )
ROM_LOAD( "gp_rom5.622", 0x000000, 0x400000, CRC(f79903e0) SHA1(4fd50b4138e64a48ec1504eb8cd172a229e0e965)) // 1xxxxxxxxxxxxxxxxxxxxx = 0xFF
-
-
- ROM_REGION( 0x3088, "pre_index", 0 )
- ROM_LOAD( "tableoutput.bin", 0x000000, 0x3088, CRC(39c6dd4f) SHA1(61697ad9167e75f321d0cbd1cc98a3aeefb8370f) )
-
- ROM_REGION( 0x4c110a, "pre_data", 0 )
- ROM_LOAD( "dataoutput.bin", 0x000000, 0x4c110a, CRC(eaff7bb8) SHA1(83afdcabb59d202398b1793f1f60052556dd1811) )
ROM_END
-
DRIVER_INIT_MEMBER(gunpey_state,gunpey)
{
m_blit_rom = memregion("blit_data")->base();
- m_blit_rom2 = memregion("blit_data2")->base();
-
m_vram = memregion("vram")->base();
- // ...
}
GAME( 2000, gunpey, 0, gunpey, gunpey, gunpey_state, gunpey, ROT0, "Bandai / Banpresto", "Gunpey (Japan)", 0 )