public static void retofinv_render_sprites(osd_bitmap bitmap) {
        int offs, sx, sy, flipx, flipy, tile, palette, size;
        int tileofs0, tileofs1, tileofs2, tileofs3;

        for (offs = 0; offs < 127; offs += 2) {
            {
                sx = 311 - (((retofinv_sprite_ram2.read(offs + 1) & 127) << 1)
                        + ((retofinv_sprite_ram3.read(offs + 1) & 128) >> 7)
                        + ((retofinv_sprite_ram2.read(offs + 1) & 128) << 1));

                sy = ((retofinv_sprite_ram2.read(offs) & 127) << 1)
                        + ((retofinv_sprite_ram3.read(offs) & 128) >> 7)
                        + ((retofinv_sprite_ram2.read(offs) & 128) << 1);

                tile = retofinv_sprite_ram1.read(offs);
                size = retofinv_sprite_ram3.read(offs);
                palette = retofinv_sprite_ram1.read(offs + 1) & 0x3f;

                flipx = 0;
                flipy = 0;
                tileofs0 = 0;
                tileofs1 = 1;
                tileofs2 = 2;
                tileofs3 = 3;

                if (flipscreen != 0) {
                    tileofs0 = 2;
                    tileofs2 = 0;
                    tileofs1 = 3;
                    tileofs3 = 1;
                    flipx = flipy = 1;
                }

                if ((size & 12) == 0) {
                    /* Patch for disappearing invadres' missile,
                     could it be Z80 bug ? */
                    if (tile == 0x98) {
                        tile--;
                    }

                    drawgfx(bitmap, Machine.gfx[2],
                            tile,
                            palette,
                            flipx, flipy,
                            sx, sy,
                            Machine.drv.visible_area, TRANSPARENCY_PEN, 0);
                }
                if ((size & 4) != 0) {
                    if (((size & 8) != 0) && (flipscreen != 0)) {
                        sx -= 16;
                    }
                    drawgfx(bitmap, Machine.gfx[2],
                            tile + tileofs0,
                            palette,
                            flipx, flipy,
                            sx, sy + 16,
                            Machine.drv.visible_area, TRANSPARENCY_PEN, 0);

                    drawgfx(bitmap, Machine.gfx[2],
                            tile + tileofs2,
                            palette,
                            flipx, flipy,
                            sx, sy,
                            Machine.drv.visible_area, TRANSPARENCY_PEN, 0);
                }
                if ((size & 8) != 0) {
                    if (flipscreen != 0) {
                        sx += 32;
                    }
                    drawgfx(bitmap, Machine.gfx[2],
                            tile + tileofs1,
                            palette,
                            flipx, flipy,
                            sx - 16, sy + 16,
                            Machine.drv.visible_area, TRANSPARENCY_PEN, 0);

                    drawgfx(bitmap, Machine.gfx[2],
                            tile + tileofs3,
                            palette,
                            flipx, flipy,
                            sx - 16, sy,
                            Machine.drv.visible_area, TRANSPARENCY_PEN, 0);
                }
            }
        }
    }