⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 common.h

📁 ESS3890+SL原代码(1*16内存)
💻 H
📖 第 1 页 / 共 2 页
字号:
/* Copyright 2001, ESS Technology, Inc.     /* SCCSID @(#)common.h	1.1 03/13/02 *//* Based on common.h	1.7 12/06/01 *//* * $Log$ *//** VGB: portable GameBoy emulator ***************************//**                                                         **//**                        Common.h                         **//**                                                         **//** This file contains parts of the drivers which are       **//** common for both Unix/X and MSDOS.                       **//**                                                         **//** Copyright (C) Marat Fayzullin 1995-2001                 **//**               John Stiles     1996                      **//**               Marcel de Kogel 1996                      **//**     The contents of this file are property of Marat     **//**     Fayzullin and should only be used as agreed with    **//**     him. The file is confidential. Absolutely no        **//**     distribution allowed.                               **//*************************************************************/#ifdef VGB#include "../const.h"/** RefreshSprites() *****************************************//** Drivers use these functions to draw sprites.            **//*************************************************************/static void RefreshSprites(int Y,byte *PP,register byte *ZBuf);static void CGBRefreshSprites(int Y,byte *PP,register byte *ZBuf);/** HFlip[] **************************************************//** Conversion matrix where result has bits flipped over.   **//*************************************************************/#ifndef HFLIP#define HFLIP#endif /* HFLIP *//** RefreshLine() ********************************************//** Refresh line Y [0-143], including sprites.              **//*************************************************************/void RefreshLine(int Y, int WY){  register byte *T,*R,*Z,*C;  register pixel *P, *PP;  register int D1,Offset,D0,X1,X2,Shift;  byte ZBuf[50],CBuf[176];#if 0   pixel *Pal0, *Pal1;  Pal0 = gmby->Pal0;  Pal1 = gmby->Pal1;#else /* Just refresh palette when XPal is refreshed,*/       /* Now it is moved to SetPalette()             */   pixel Pal0[16],Pal1[16];  /* Precalculate palettes */  for(D1=0;D1<16;D1+=4)  {    Pal0[D1]  =gmby->XPal[BPal[0]+D1];Pal0[D1+1]=gmby->XPal[BPal[1]+D1];    Pal0[D1+2]=gmby->XPal[BPal[2]+D1];Pal0[D1+3]=gmby->XPal[BPal[3]+D1];    Pal1[D1]  =gmby->XPal[WPal[0]+D1];Pal1[D1+1]=gmby->XPal[WPal[1]+D1];    Pal1[D1+2]=gmby->XPal[WPal[2]+D1];Pal1[D1+3]=gmby->XPal[WPal[3]+D1];   }#endif  /* Set P to the start of screen */  P=XBuf+10288+WIDTH*Y;  PP = P;  /* Fill SGB color buffer */  R=gmby->SGBColTab+(Y>>3)*20;  T=CBuf+8;  if(gmby->SGBDisplay==3) GB_memset(T,0,20);  else  {       for(D0=0;D0<20;D0++,T+=8)          T[0]=T[1]=T[2]=T[3]=T[4]=T[5]=T[6]=T[7]=R[D0];   }  /* Drawing background... */  if((LCDCONT&0x81)!=0x81)  {    for(X1=0;X1<160;X1++) *P++=Pal0[0];    for(X1=0;X1<25;X1++) ZBuf[X1]=0x00;  }  else  {    Offset=Y+SCROLLY;                  /* Actual line number */    T=BgdTab+((int)(Offset&0xF8)<<2);  /* Name Table address */    Offset=(Offset&0x07)<<1;           /* Offset inside tile */    Shift=SCROLLX&0x07; /* Pixels to shift by X (0..7)       */    C=CBuf+8-Shift;     /* Start of line in SGB color buffer */    P-=Shift;           /* Start of line in screen buffer    */    Z=ZBuf;             /* Start of line in Z-buffer         */    Z[0]=0x00;          /* Initialize Z-buffer     */    X1=SCROLLX>>3;      /* First character (0..31) */    /* Determine how much background is shown */    X2=(WY>143? 20:(WNDPOSX>7? (WNDPOSX>>3):0))+X1;    /* Drawing tiles... */    for(;X1<=X2;X1++)    {      D0=T[X1&0x1F];                 /* Tile number          */      if(!(LCDCONT&0x10)) D0=(D0+0x80)&0xff;  /* Correct tile number  */      R=ChrGen+((int)D0<<4)+Offset;  /* Tile pattern address */      D0=*R;                         /* First pattern byte   */      D1=(int)(D0|*(R+1))<<Shift;    /* Find opaque pixels   */      Z[0]|=D1>>8;                   /* Update Z-buffer      */      Z[1]=D1&0xFF;      /* Modify screen buffer */      D1=(int)*(R+1)<<1;      D1=(D1&0xAAA)|((D1&0x555)<<7)|(D0&0x55)|((int)(D0&0xAA)<<7);      P[0]=Pal0[C[0]|((D1&0xC000)>>14)];      P[1]=Pal0[C[1]|((D1&0x00C0)>>6 )];      P[2]=Pal0[C[2]|((D1&0x3000)>>12)];      P[3]=Pal0[C[3]|((D1&0x0030)>>4 )];      P[4]=Pal0[C[4]|((D1&0x0C00)>>10)];      P[5]=Pal0[C[5]|((D1&0x000C)>>2 )];      P[6]=Pal0[C[6]|((D1&0x0300)>>8 )];      P[7]=Pal0[C[7]|( D1&0x003      )];      /* Move pointers */      P+=8;Z++;C+=8;    }  }  /* Drawing window... */  if((WY<144)&&(LCDCONT&0x80))  {    /* Window X coordinate */    X1=WNDPOSX>7? WNDPOSX-7:0;    /* Start of window in screen buffer */    P=PP+X1;    Z=ZBuf+(X1>>3)+1; /* Start of window in Z-buffer         */    C=CBuf+8+X1;      /* Start of window in SGB color buffer */    Offset=WY;                         /* Actual line number */    T=WndTab+((int)(Offset&0xF8)<<2);  /* Name Table address */    Offset=(Offset&0x07)<<1;           /* Offset inside tile */    /* Initialize Z-buffer */    Z[0]|=0xFF>>(X1&0x07);    Z++;    /* Drawing tiles... */    for(X1>>=3;X1<(160>>3);X1++)    {      D0=*T;                         /* Tile number          */      if(!(LCDCONT&0x10)) D0=(D0+0x80)&0xff;  /* Correct tile number  */      R=ChrGen+((int)D0<<4)+Offset;  /* Tile pattern address */      Z[0]=0xFF;                     /* Update Z-buffer      */      /* Modify screen buffer */      D0=*R;D1=(int)*(R+1)<<1;      D1=(D1&0xAAA)|((D1&0x555)<<7)|(D0&0x55)|((int)(D0&0xAA)<<7);      P[0]=Pal1[C[0]|((D1&0xC000)>>14)];      P[1]=Pal1[C[1]|((D1&0x00C0)>>6 )];      P[2]=Pal1[C[2]|((D1&0x3000)>>12)];      P[3]=Pal1[C[3]|((D1&0x0030)>>4 )];      P[4]=Pal1[C[4]|((D1&0x0C00)>>10)];      P[5]=Pal1[C[5]|((D1&0x000C)>>2 )];      P[6]=Pal1[C[6]|((D1&0x0300)>>8 )];      P[7]=Pal1[C[7]|( D1&0x0003     )];      /* Move pointers */      P+=8;Z++;C+=8;T++;    }  }  /* Refresh sprites in this scanline */  if((LCDCONT&0x82)==0x82) RefreshSprites(Y,PP,ZBuf+1);}/** CGBRefreshLine() *****************************************//** Refresh line Y [0-143] on a ColorGB, including sprites. **//*************************************************************/void CGBRefreshLine(int Y,int WY){  register byte *T,*R,*Z, *HFlip;  register pixel *P,*PP;  byte ZBuf[50], *XPal;  int D1, Offset, D0, D2, C, X1, X2, Shift;    HFlip = PHFlip;  XPal = gmby->XPal;  /* Set P to the start of screen */  P=XBuf+10288+WIDTH*Y;  PP=P;  /* If screen disabled... */  if(!(LCDCONT&0x80))  {    for(X1=0;X1<160;X1++) *P++=XPal[0];    return;  }  /* Screen enabled: proceed with drawing! */  Offset=Y+SCROLLY;                  /* Actual line number */  T=BgdTab+((int)(Offset&0xF8)<<2);  /* Name Table address */  Offset=(Offset&0x07)<<1;           /* Offset inside tile */  Shift=SCROLLX&0x07; /* Pixels to shift by X (0..7)       */  P-=Shift;           /* Start of line in screen buffer    */  Z=ZBuf;             /* Start of line in Z-buffer         */  Z[0]=Z[25]=0x00;    /* Initialize Z-buffer     */  X1=SCROLLX>>3;      /* First character (0..31) */  /* Determine how much background is shown */  X2=(WY>143? 20:(WNDPOSX>7? (WNDPOSX>>3):0))+X1;  /* Drawing background... */  for(;X1<=X2;X1++)  {    D1=X1&0x1F;                     /* Character offset    */    C=T[D1+0x2000];                 /* Attributes          */    D0=T[D1];                       /* Tile number         */    if(!(LCDCONT&0x10)) D0=(D0+0x80)&0xff;   /* Correct tile number */    /* Tile pattern address is... */    R = ChrGen                            /* ChrGen addr-s */      + ((int)D0<<4)                      /* Tile number   */      + (C&BANK_ATTR?  0x2000:0)          /* Bank number   */      + (C&VFLIP_ATTR? 14-Offset:Offset); /* Off-t in tile */    /* Fetch pattern bytes */    if(C&HFLIP_ATTR) { D0=HFlip[*R];D2=HFlip[*(R+1)]; }    else             { D0=*R;D2=*(R+1); }    /* Find opaque pixels */    D1=(int)(D0|D2)<<Shift;    /* Update Z-buffer */    if(C&PRIOR_ATTR) { Z[25]|=D1>>8;Z[26]=D1&0xFF; } else Z[26]=0x00;    Z[0]|=D1>>8;    Z[1]=D1&0xFF;    /* CGB palette offset */    C=((C&PAL_ATTR)<<2)&0xff;    /* Modify screen buffer */    D1=(int)D2<<1;    D1=(D1&0xAAA)|((D1&0x555)<<7)|(D0&0x55)|((int)(D0&0xAA)<<7);    P[0]=XPal[C|((D1&0xC000)>>14)];    P[1]=XPal[C|((D1&0x00C0)>>6 )];    P[2]=XPal[C|((D1&0x3000)>>12)];    P[3]=XPal[C|((D1&0x0030)>>4 )];    P[4]=XPal[C|((D1&0x0C00)>>10)];    P[5]=XPal[C|((D1&0x000C)>>2 )];    P[6]=XPal[C|((D1&0x0300)>>8 )];    P[7]=XPal[C|( D1&0x003      )];    /* Move pointers */    P+=8;Z++;  }  /* Drawing window... */  if(WY<144)  {    /* Window X coordinate */    X1=WNDPOSX>7? WNDPOSX-7:0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -