static void draw_sprites(osd_bitmap bitmap, int priority) {
        int offs, sx, sy;

        for (offs = 4096 - 32; offs >= 0; offs -= 32) {
            int code;
            int attr = stfight_sprite_ram.read(offs + 1);
            int flipx = (((attr & 0x10) != 0 ? 1 : 0)
                    ^ stfight_flipscreen);
            int flipy = (stfight_flipscreen);
            int color = attr & 0x0f;
            int pri = (attr & 0x20) >> 5;

            if (pri != priority) {
                continue;
            }

            sy = stfight_sprite_ram.read(offs + 2);
            sx = stfight_sprite_ram.read(offs + 3);

            // non-active sprites have zero y coordinate value
            if (sy > 0) {
	            // sprites which wrap onto/off the screen have
                // a sign extension bit in the sprite attribute
                if (sx >= 0xf0) {
                    if ((((attr & 0x80) != 0 ? 1 : 0)
                            ^ stfight_flipscreen) != 0) {
                        sx -= 0x100;
                    }
                }

                if (stfight_flipscreen != 0) {
                    sy = 256 - 16 - sy;
                    sx = 256 - 16 - sx;
                }

                code = stfight_sprite_base + stfight_sprite_ram.read(offs);

                drawgfx(bitmap, Machine.gfx[4],
                        code,
                        color,
                        flipx, flipy,
                        sx, sy,
                        Machine.drv.visible_area, TRANSPARENCY_PEN, 0x0f);
            }
        }
    }