static void draw_sprites(osd_bitmap bitmap) {
        /* sprite information is scattered through memory */
        /* and uses a portion of the text layer memory (outside the visible area) */
        UBytePtr spriteram_area1 = new UBytePtr(spriteram, 0x28);
        UBytePtr spriteram_area2 = new UBytePtr(spriteram_2, 0x28);
        UBytePtr spriteram_area3 = new UBytePtr(kyugo_videoram, 0x28);

        int n;

        for (n = 0; n < 12 * 2; n++) {
            int offs, y, sy, sx, color;

            offs = 2 * (n % 12) + 64 * (n / 12);

            sx = spriteram_area3.read(offs + 1) + 256 * (spriteram_area2.read(offs + 1) & 1);
            if (sx > 320) {
                sx -= 512;
            }

            sy = 255 - spriteram_area1.read(offs);
            if (flipscreen != 0) {
                sy = 240 - sy;
            }

            color = spriteram_area1.read(offs + 1) & 0x1f;

            for (y = 0; y < 16; y++) {
                int attr2, code, flipx, flipy;

                attr2 = spriteram_area2.read(offs + 128 * y);
                code = spriteram_area3.read(offs + 128 * y);
                if ((attr2 & 0x01) != 0) {
                    code += 512;
                }
                if ((attr2 & 0x02) != 0) {
                    code += 256;
                }
                flipx = attr2 & 0x08;
                flipy = attr2 & 0x04;
                if (flipscreen != 0) {
                    flipx = NOT(flipx);
                    flipy = NOT(flipy);
                }

                drawgfx(bitmap, Machine.gfx[1],
                        code,
                        color,
                        flipx, flipy,
                        sx, flipscreen != 0 ? sy - 16 * y : sy + 16 * y,
                        Machine.drv.visible_area, TRANSPARENCY_PEN, 0);
            }
        }
    }