亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? render.c

?? DC的SEGA_GG模擬器源代碼
?? C
字號:

#include "shared.h"

/* Background drawing function */
void (*render_bg)(int line);

/* Pointer to output buffer */
byte *linebuf;

/* Internal buffer for drawing non 8-bit displays */
byte internal_buffer[0x100];

/* Precalculated pixel table */
word pixel[PALETTE_SIZE];

/* Pattern cache */
byte cache[0x20000];

/* Dirty pattern info */
byte vram_dirty[0x200];
byte is_vram_dirty;

/* Pixel look-up table */
byte lut[0x10000];

/* Attribute expansion table */
dword atex[4] =
{
    0x00000000,
    0x10101010,
    0x20202020,
    0x30303030,
};

/* Display sizes */
int vp_vstart;
int vp_vend;
int vp_hstart;
int vp_hend;


/* Macros to access memory 32-bits at a time (from MAME's drawgfx.c) */

#ifdef ALIGN_DWORD

static __inline__ dword read_dword(void *address)
{
    if ((dword)address & 3)
	{
#ifdef LSB_FIRST  /* little endian version */
        return ( *((byte *)address) +
                (*((byte *)address+1) << 8)  +
                (*((byte *)address+2) << 16) +
                (*((byte *)address+3) << 24) );
#else             /* big endian version */
        return ( *((byte *)address+3) +
                (*((byte *)address+2) << 8)  +
                (*((byte *)address+1) << 16) +
                (*((byte *)address)   << 24) );
#endif
	}
	else
        return *(dword *)address;
}


static __inline__ void write_dword(void *address, dword data)
{
    if ((dword)address & 3)
	{
#ifdef LSB_FIRST
            *((byte *)address) =    data;
            *((byte *)address+1) = (data >> 8);
            *((byte *)address+2) = (data >> 16);
            *((byte *)address+3) = (data >> 24);
#else
            *((byte *)address+3) =  data;
            *((byte *)address+2) = (data >> 8);
            *((byte *)address+1) = (data >> 16);
            *((byte *)address)   = (data >> 24);
#endif
		return;
  	}
  	else
        *(dword *)address = data;
}
#else
#define read_dword(address) *(dword *)address
#define write_dword(address,data) *(dword *)address=data
#endif


/****************************************************************************/


/* Initialize the rendering data */
void render_init(void)
{
    int bx, sx, b, s, bp, bf, sf, c;

    /* Generate 64k of data for the look up table */
    for(bx = 0; bx < 0x100; bx += 1)
    {
        for(sx = 0; sx < 0x100; sx += 1)
        {
            /* Background pixel */
            b  = (bx & 0x0F);

            /* Background priority */
            bp = (bx & 0x20) ? 1 : 0;

            /* Full background pixel + priority + sprite marker */
            bf = (bx & 0x7F);

            /* Sprite pixel */
            s  = (sx & 0x0F);

            /* Full sprite pixel, w/ palette and marker bits added */
            sf = (sx & 0x0F) | 0x10 | 0x40;

            /* Overwriting a sprite pixel ? */
            if(bx & 0x40)
            {
                /* Return the input */
                c = bf;
            }
            else
            {
                /* Work out priority and transparency for both pixels */
                c = bp ? b ? bf : s ? sf : bf : s ? sf : bf;
            }

            /* Store result */
            lut[(bx << 8) | (sx)] = c;
        }
    }

    render_reset();
}


/* Reset the rendering data */
void render_reset(void)
{
    int i;

    /* Clear display bitmap */
    memset(bitmap.data, 0, bitmap.pitch * bitmap.height);

    /* Clear palette */
    for(i = 0; i < PALETTE_SIZE; i += 1)
    {
        palette_sync(i);
    }

    /* Invalidate pattern cache */
    is_vram_dirty = 1;
    memset(vram_dirty, 1, 0x200);
    memset(cache, 0, sizeof(cache));

    /* Set up viewport size */
    if(IS_GG)
    {
        vp_vstart = 24;
        vp_vend   = 168;
        vp_hstart = 6;
        vp_hend   = 26;
    }
    else
    {
        vp_vstart = 0;
        vp_vend   = 192;
        vp_hstart = 0;
        vp_hend   = 32;
    }

    /* Pick render routine */
    render_bg = IS_GG ? render_bg_gg : render_bg_sms;
}


/* Draw a line of the display */
void render_line(int line)
{
    /* Ensure we're within the viewport range */
    if((line < vp_vstart) || (line >= vp_vend)) return;

    /* Point to current line in output buffer */
    linebuf = (bitmap.depth == 8) ? &bitmap.data[(191 - line) * bitmap.pitch] : &internal_buffer[0];

    /* Update pattern cache */
    update_cache();

    /* Blank line */
    if( (!(vdp.reg[1] & 0x40)) || (((vdp.reg[2] & 1) == 0) && (IS_SMS)))
    {
        memset(linebuf + (vp_hstart << 3), BACKDROP_COLOR, BMP_WIDTH);
    }
    else
    {
        /* Draw background */
        render_bg(line);

        /* Draw sprites */
        render_obj(line);

        /* Blank leftmost column of display */
        if(vdp.reg[0] & 0x20)
        {
            memset(linebuf, BACKDROP_COLOR, 8);
        }
    }

    if(bitmap.depth != 8) remap_8_to_16(line);
}


/* Draw the Master System background */
void render_bg_sms(int line)
{
    int locked = 0;
    int v_line = (line + vdp.reg[9]) % 224;
    int v_row  = (v_line & 7) << 3;
    int hscroll = ((vdp.reg[0] & 0x40) && (line < 0x10)) ? 0 : (0x100 - vdp.reg[8]);
    int column = vp_hstart;
    word attr;
    word *nt = (word *)&vdp.vram[vdp.ntab + ((v_line >> 3) << 6)];
    int nt_scroll = (hscroll >> 3);
    int shift = (hscroll & 7);
    dword atex_mask;
    dword *cache_ptr;
    dword *linebuf_ptr = (dword *)&linebuf[0 - shift];

    /* Draw first column (clipped) */
    if(shift)
    {
        int x, c, a;

        attr = nt[(column + nt_scroll) & 0x1F];

#ifndef LSB_FIRST
        attr = (((attr & 0xFF) << 8) | ((attr & 0xFF00) >> 8));
#endif
        a = (attr >> 7) & 0x30;

        for(x = shift; x < 8; x += 1)
        {
            c = cache[((attr & 0x7FF) << 6) | (v_row) | (x)];
            linebuf[(0 - shift) + (x)  ] = ((c) | (a));
        }

        column += 1;
    }

    /* Draw a line of the background */
    for(; column < vp_hend; column += 1)
    {
        /* Stop vertical scrolling for leftmost eight columns */
        if((vdp.reg[0] & 0x80) && (!locked) && (column >= 24))
        {
            locked = 1;
            v_row = (line & 7) << 3;
            nt = (word *)&vdp.vram[((vdp.reg[2] << 10) & 0x3800) + ((line >> 3) << 6)];
        }

        /* Get name table attribute word */
        attr = nt[(column + nt_scroll) & 0x1F];

#ifndef LSB_FIRST
        attr = (((attr & 0xFF) << 8) | ((attr & 0xFF00) >> 8));
#endif
        /* Expand priority and palette bits */
        atex_mask = atex[(attr >> 11) & 3];

        /* Point to a line of pattern data in cache */
        cache_ptr = (dword *)&cache[((attr & 0x7FF) << 6) | (v_row)];
        
        /* Copy the left half, adding the attribute bits in */
        write_dword( &linebuf_ptr[(column << 1)] , read_dword( &cache_ptr[0] ) | (atex_mask));

        /* Copy the right half, adding the attribute bits in */
        write_dword( &linebuf_ptr[(column << 1) | (1)], read_dword( &cache_ptr[1] ) | (atex_mask));
    }

    /* Draw last column (clipped) */
    if(shift)
    {
        int x, c, a;

        char *p = &linebuf[(0 - shift)+(column << 3)];

        attr = nt[(column + nt_scroll) & 0x1F];

#ifndef LSB_FIRST
        attr = (((attr & 0xFF) << 8) | ((attr & 0xFF00) >> 8));
#endif
        a = (attr >> 7) & 0x30;

        for(x = 0; x < shift; x += 1)
        {
            c = cache[((attr & 0x7FF) << 6) | (v_row) | (x)];
            p[x] = ((c) | (a));
        }
    }
}


/* Draw the Game Gear background */
void render_bg_gg(int line)
{
    int v_line = (line + vdp.reg[9]) % 224;
    int v_row  = (v_line & 7) << 3;
    int hscroll = (0x100 - vdp.reg[8]);
    int column;
    word attr;
    word *nt = (word *)&vdp.vram[vdp.ntab + ((v_line >> 3) << 6)];
    int nt_scroll = (hscroll >> 3);
    dword atex_mask;
    dword *cache_ptr;
    dword *linebuf_ptr = (dword *)&linebuf[0 - (hscroll & 7)];

    /* Draw a line of the background */
    for(column = vp_hstart; column <= vp_hend; column += 1)
    {
        /* Get name table attribute word */
        attr = nt[(column + nt_scroll) & 0x1F];

#ifndef LSB_FIRST
        attr = (((attr & 0xFF) << 8) | ((attr & 0xFF00) >> 8));
#endif
        /* Expand priority and palette bits */
        atex_mask = atex[(attr >> 11) & 3];

        /* Point to a line of pattern data in cache */
        cache_ptr = (dword *)&cache[((attr & 0x7FF) << 6) | (v_row)];

        /* Copy the left half, adding the attribute bits in */
        write_dword( &linebuf_ptr[(column << 1)] , read_dword( &cache_ptr[0] ) | (atex_mask));

        /* Copy the right half, adding the attribute bits in */
        write_dword( &linebuf_ptr[(column << 1) | (1)], read_dword( &cache_ptr[1] ) | (atex_mask));
    }
}


/* Draw sprites */
void render_obj(int line)
{
    int i;

    /* Sprite count for current line (8 max.) */
    int count = 0;

    /* Sprite dimensions */
    int width = 8;
    int height = (vdp.reg[1] & 0x02) ? 16 : 8;

    /* Pointer to sprite attribute table */
    byte *st = (byte *)&vdp.vram[vdp.satb];

    /* Adjust dimensions for double size sprites */
    if(vdp.reg[1] & 0x01)
    {
        width *= 2;
        height *= 2;
    }

    /* Draw sprites in front-to-back order */
    for(i = 0; i < 64; i += 1)
    {
        /* Sprite Y position */
        int yp = st[i];

        /* End of sprite list marker? */
        if(yp == 208) return;

        /* Actual Y position is +1 */
        yp += 1;

        /* Wrap Y coordinate for sprites > 240 */
        if(yp > 240) yp -= 256;

        /* Check if sprite falls on current line */
        if((line >= yp) && (line < (yp + height)))
        {
            byte *linebuf_ptr;

            /* Width of sprite */
            int start = 0;
            int end = width;

            /* Sprite X position */
            int xp = st[0x80 + (i << 1)];

            /* Pattern name */
            int n = st[0x81 + (i << 1)];

            /* Bump sprite count */
            count += 1;

            /* Too many sprites on this line ? */
            if((vdp.limit) && (count == 9)) return;

            /* X position shift */
            if(vdp.reg[0] & 0x08) xp -= 8;

            /* Add MSB of pattern name */
            if(vdp.reg[6] & 0x04) n |= 0x0100;

            /* Mask LSB for 8x16 sprites */
            if(vdp.reg[1] & 0x02) n &= 0x01FE;

            /* Point to offset in line buffer */
            linebuf_ptr = (byte *)&linebuf[xp];

            /* Clip sprites on left edge */
            if(xp < 0)
            {
                start = (0 - xp);
            }

            /* Clip sprites on right edge */
            if((xp + width) > 256)        
            {
                end = (256 - xp);
            }

            /* Draw double size sprite */
            if(vdp.reg[1] & 0x01)
            {
                int x;
                byte *cache_ptr = (byte *)&cache[(n << 6) | (((line - yp) >> 1) << 3)];

                /* Draw sprite line */
                for(x = start; x < end; x += 1)
                {
                    /* Source pixel from cache */
                    byte sp = cache_ptr[(x >> 1)];
    
                    /* Only draw opaque sprite pixels */
                    if(sp)
                    {
                        /* Background pixel from line buffer */
                        byte bg = linebuf_ptr[x];
    
                        /* Look up result */
                        linebuf_ptr[x] = lut[(bg << 8) | (sp)];
    
                        /* Set sprite collision flag */
                        if(bg & 0x40) vdp.status |= 0x20;
                    }
                }
            }
            else /* Regular size sprite (8x8 / 8x16) */
            {
                int x;
                byte *cache_ptr = (byte *)&cache[(n << 6) | ((line - yp) << 3)];

                /* Draw sprite line */
                for(x = start; x < end; x += 1)
                {
                    /* Source pixel from cache */
                    byte sp = cache_ptr[x];
    
                    /* Only draw opaque sprite pixels */
                    if(sp)
                    {
                        /* Background pixel from line buffer */
                        byte bg = linebuf_ptr[x];
    
                        /* Look up result */
                        linebuf_ptr[x] = lut[(bg << 8) | (sp)];
    
                        /* Set sprite collision flag */
                        if(bg & 0x40) vdp.status |= 0x20;
                    }
                }
            }
        }
    }
}


/* Update pattern cache with modified tiles */
void update_cache(void)
{
    int i, x, y, c;
    int b0, b1, b2, b3;
    int i0, i1, i2, i3;

    if(!is_vram_dirty) return;
    is_vram_dirty = 0;

    for(i = 0; i < 0x200; i += 1)
    {
        if(vram_dirty[i])
        {
            vram_dirty[i] = 0;

            for(y = 0; y < 8; y += 1)
            {
                b0 = vdp.vram[(i << 5) | (y << 2) | (0)];
                b1 = vdp.vram[(i << 5) | (y << 2) | (1)];
                b2 = vdp.vram[(i << 5) | (y << 2) | (2)];
                b3 = vdp.vram[(i << 5) | (y << 2) | (3)];

                for(x = 0; x < 8; x += 1)
                {
                    i0 = (b0 >> (7 - x)) & 1;
                    i1 = (b1 >> (7 - x)) & 1;
                    i2 = (b2 >> (7 - x)) & 1;
                    i3 = (b3 >> (7 - x)) & 1;

                    c = (i3 << 3 | i2 << 2 | i1 << 1 | i0);

                    cache[0x00000 | (i << 6) | ((y  ) << 3) | (x  )] = c;
                    cache[0x08000 | (i << 6) | ((y  ) << 3) | (7-x)] = c;
                    cache[0x10000 | (i << 6) | ((7-y) << 3) | (x  )] = c;
                    cache[0x18000 | (i << 6) | ((7-y) << 3) | (7-x)] = c;
                }
            }
        }
    }
}


/* Update a palette entry */
void palette_sync(int index)
{
    int r, g, b;

    if(IS_GG)
    {
        r = ((vdp.cram[(index << 1) | 0] >> 1) & 7) << 5;
        g = ((vdp.cram[(index << 1) | 0] >> 5) & 7) << 5;
        b = ((vdp.cram[(index << 1) | 1] >> 1) & 7) << 5;
    }
    else
    {
        r = ((vdp.cram[index] >> 0) & 3) << 6;
        g = ((vdp.cram[index] >> 2) & 3) << 6;
        b = ((vdp.cram[index] >> 4) & 3) << 6;
    }

    bitmap.pal.color[index][0] = r;
    bitmap.pal.color[index][1] = g;
    bitmap.pal.color[index][2] = b;

    pixel[index] = MAKE_PIXEL(r, g, b);

    bitmap.pal.dirty[index] = bitmap.pal.update = 1;
}


void remap_8_to_16(int line)
{
    int i;
    int length = BMP_WIDTH;
    int ofs = BMP_X_OFFSET;
    word *p = (word *)&bitmap.data[((191 - line) * bitmap.pitch) + (ofs << 1)];

    for(i = 0; i < length; i += 1)
    {
        p[i] = pixel[(internal_buffer[(ofs + i)] & PIXEL_MASK)];
    }        
}







?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产在线一区二区综合免费视频| 99久久亚洲一区二区三区青草| 国产精品18久久久久久vr| 99精品视频在线免费观看| 欧美va亚洲va香蕉在线| 亚洲www啪成人一区二区麻豆 | 又紧又大又爽精品一区二区| 韩国av一区二区三区| 欧美日韩国产一级二级| 国产精品视频免费| 久久成人羞羞网站| 欧美日韩精品三区| 亚洲欧美另类小说| av在线一区二区三区| 久久精品亚洲精品国产欧美kt∨ | 亚洲国产成人高清精品| 成人黄色国产精品网站大全在线免费观看| 91精品国产色综合久久ai换脸 | 欧美乱妇15p| 一区二区三区国产精华| 99精品1区2区| 中文字幕一区二区三区乱码在线| 国产福利一区在线| www国产成人| 国产一区二区看久久| 精品黑人一区二区三区久久| 久久97超碰色| 日韩精品一区二区三区中文不卡| 日本伊人午夜精品| 91精品福利在线一区二区三区| 亚洲午夜久久久久中文字幕久| 欧洲色大大久久| 色综合久久综合网欧美综合网| 欧美精品v日韩精品v韩国精品v| 又紧又大又爽精品一区二区| 色猫猫国产区一区二在线视频| 国产精品家庭影院| 一本久久综合亚洲鲁鲁五月天 | 久久精品国产久精国产爱| 777色狠狠一区二区三区| 三级不卡在线观看| 欧美大片在线观看| 国产乱码一区二区三区| 日本一区二区免费在线| 成人精品在线视频观看| 亚洲美女精品一区| 欧美日韩免费视频| 久久精品国产久精国产爱| 国产日韩一级二级三级| 99r国产精品| 性做久久久久久久久| 日韩一区二区三区在线| 国产精品亚洲一区二区三区在线| 国产精品美日韩| 欧美无砖专区一中文字| 美女在线观看视频一区二区| 国产夜色精品一区二区av| 91在线精品一区二区三区| 亚洲第四色夜色| 2020国产精品自拍| 在线亚洲+欧美+日本专区| 日本视频在线一区| 国产精品美女久久久久久久| 欧美高清视频在线高清观看mv色露露十八| 日产国产高清一区二区三区 | 国产亚洲一本大道中文在线| 91亚洲精品久久久蜜桃网站| 日韩电影在线看| 亚洲人精品一区| 日韩欧美在线1卡| 91丝袜美女网| 麻豆91在线观看| 亚洲同性同志一二三专区| 欧美一级黄色片| 91偷拍与自偷拍精品| 国产一区二区在线免费观看| 国产精品久久久一本精品 | 日韩一二三区视频| 91在线国产福利| 激情综合亚洲精品| 水蜜桃久久夜色精品一区的特点| 亚洲国产精华液网站w| 91精选在线观看| 欧美日韩中文国产| 国产69精品久久777的优势| 日韩二区三区在线观看| 亚洲精品日产精品乱码不卡| 久久久天堂av| 日韩欧美一级在线播放| 欧美私模裸体表演在线观看| 成人avav影音| 国产成人午夜高潮毛片| 美女视频一区二区三区| 午夜精品123| 一区二区三区在线不卡| 国产精品午夜春色av| ww亚洲ww在线观看国产| 欧美一区二区三区播放老司机| 欧美午夜免费电影| 色婷婷久久综合| 成人激情免费网站| 成人中文字幕电影| 高清久久久久久| 国产高清久久久久| 国产成人av福利| 国产一区在线视频| 极品美女销魂一区二区三区免费| 美女被吸乳得到大胸91| 老司机精品视频线观看86| 日韩国产欧美在线播放| 日韩综合小视频| 日日摸夜夜添夜夜添精品视频| 午夜久久电影网| 日本视频免费一区| 日韩精品乱码免费| 久久国产精品无码网站| 蜜乳av一区二区三区| 极品美女销魂一区二区三区免费 | 国产亚洲1区2区3区| 久久综合99re88久久爱| 久久综合色综合88| 国产女主播一区| 亚洲欧洲av色图| 亚洲一区二区成人在线观看| 亚洲综合久久av| 免费在线观看精品| 国产精品77777| 成人av资源网站| 色爱区综合激月婷婷| 欧美日韩在线不卡| 日韩视频在线一区二区| www国产精品av| 日韩毛片精品高清免费| 天天亚洲美女在线视频| 久久99精品国产91久久来源| 粉嫩一区二区三区在线看| 99精品欧美一区| 制服视频三区第一页精品| 精品福利在线导航| 国产精品久久久久9999吃药| 亚洲va在线va天堂| 国模少妇一区二区三区| 91在线小视频| 91精品在线免费| 国产精品国产成人国产三级| 天天综合天天做天天综合| 国模大尺度一区二区三区| 99re免费视频精品全部| 91精选在线观看| 1区2区3区欧美| 国产成人自拍网| 在线观看亚洲a| 国产视频一区在线播放| 亚洲综合清纯丝袜自拍| 看片网站欧美日韩| 欧洲日韩一区二区三区| 久久久久国产精品厨房| 一区二区三区美女| 国产成人免费在线| 欧美日韩一区二区三区视频| 久久久91精品国产一区二区三区| 一区二区三区欧美视频| 国产精品1024| 欧美丰满高潮xxxx喷水动漫| 国产精品久久久久aaaa| 久久97超碰国产精品超碰| 在线日韩av片| 国产精品欧美精品| 久久成人羞羞网站| 欧美精品丝袜久久久中文字幕| 久久精品在线免费观看| 日本人妖一区二区| 色综合 综合色| 中文无字幕一区二区三区| 久久激情综合网| 欧美一区二区二区| 亚洲精品日韩综合观看成人91| 国产成人免费视频一区| 欧美一级一区二区| 亚洲444eee在线观看| 一本一道久久a久久精品| 中文字幕乱码一区二区免费| 国产一区二区三区综合| 日韩女优电影在线观看| 中文字幕精品—区二区四季| 伊人夜夜躁av伊人久久| 国产成人精品一区二区三区四区| 国产午夜精品一区二区三区四区| 成人一区在线看| 亚洲女人小视频在线观看| 欧美少妇一区二区| 男人的天堂久久精品| 国产激情精品久久久第一区二区| 欧美日韩中文国产| 亚洲超丰满肉感bbw| 7777精品伊人久久久大香线蕉 | 亚洲图片有声小说| 在线免费观看视频一区| 美女视频一区在线观看| 91精品国产美女浴室洗澡无遮挡|