|
|
1.1 ! root 1: /* ! 2: Hatari - high640x8.c ! 3: ! 4: This file is distributed under the GNU Public License, version 2 or at your ! 5: option any later version. Read the file gpl.txt for details. ! 6: ! 7: NeXT mono, memory to SDL_Surface ! 8: */ ! 9: ! 10: static inline void putpixelbw(SDL_Surface * surface, Uint16 x, Uint16 y, Uint32 col) ! 11: ! 12: { ! 13: ! 14: /* Nombre de bits par pixels de la surface d'écran */ ! 15: Uint8 bpp = surface->format->BytesPerPixel; ! 16: /* Pointeur vers le pixel à remplacer (pitch correspond à la taille ! 17: d'une ligne d'écran, c'est à dire (longueur * bitsParPixel) ! 18: pour la plupart des cas) */ ! 19: ! 20: Uint8 * p1 = ((Uint8 *)surface->pixels) + y * surface->pitch + x * bpp; ! 21: ! 22: ! 23: Uint32 color = colors[col]; ! 24: ! 25: switch(bpp) { ! 26: case 1: ! 27: ! 28: *p1 = color; ! 29: ! 30: break; ! 31: ! 32: case 2: ! 33: ! 34: *(Uint16 *)p1 = color; ! 35: ! 36: break; ! 37: ! 38: case 3: ! 39: if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { ! 40: ! 41: p1[0] = (color >> 16) & 0xff; ! 42: p1[1] = (color >> 8) & 0xff; ! 43: p1[2] = color & 0xff; ! 44: ! 45: } else { ! 46: ! 47: p1[0] = color & 0xff; ! 48: p1[1] = (color >> 8) & 0xff; ! 49: p1[2] = (color >> 16) & 0xff; ! 50: ! 51: } ! 52: break; ! 53: ! 54: case 4: ! 55: ! 56: *(Uint32 *)p1 = color; ! 57: break; ! 58: } ! 59: ! 60: } ! 61: ! 62: ! 63: static inline void putpixel(SDL_Surface * surface, Uint16 x, Uint16 y, Uint32 color) ! 64: ! 65: { ! 66: ! 67: /* Nombre de bits par pixels de la surface d'écran */ ! 68: Uint8 bpp = surface->format->BytesPerPixel; ! 69: /* Pointeur vers le pixel à remplacer (pitch correspond à la taille ! 70: d'une ligne d'écran, c'est à dire (longueur * bitsParPixel) ! 71: pour la plupart des cas) */ ! 72: ! 73: Uint8 * p1 = ((Uint8 *)surface->pixels) + y * surface->pitch + x * bpp; ! 74: ! 75: ! 76: switch(bpp) { ! 77: case 1: ! 78: ! 79: *p1 = color; ! 80: ! 81: break; ! 82: ! 83: case 2: ! 84: ! 85: *(Uint16 *)p1 = color; ! 86: ! 87: break; ! 88: ! 89: case 3: ! 90: if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { ! 91: ! 92: p1[0] = (color >> 16) & 0xff; ! 93: p1[1] = (color >> 8) & 0xff; ! 94: p1[2] = color & 0xff; ! 95: ! 96: } else { ! 97: ! 98: p1[0] = color & 0xff; ! 99: p1[1] = (color >> 8) & 0xff; ! 100: p1[2] = (color >> 16) & 0xff; ! 101: ! 102: } ! 103: break; ! 104: ! 105: case 4: ! 106: ! 107: *(Uint32 *)p1 = color; ! 108: break; ! 109: } ! 110: ! 111: } ! 112: ! 113: static char buffer[832*1152*4]; ! 114: ! 115: static void InvalidateScreenBuffer(void) { ! 116: int i; ! 117: #if ENABLE_DIMENSION ! 118: if (ConfigureParams.Screen.nMonitorType==MONITOR_TYPE_DIMENSION) { ! 119: for (i = 0; i < (832*1152*4); i++) ! 120: buffer[i] = ND_vram[i]+1; ! 121: return; ! 122: } ! 123: #endif ! 124: for (i = 0; i < (832*1152/4); i++) { ! 125: buffer[i] = NEXTVideo[i]+1; ! 126: } ! 127: } ! 128: ! 129: static void ConvertHighRes_640x8Bit(void) ! 130: { ! 131: int y, x; ! 132: int col; ! 133: static int first=1; ! 134: int adr; ! 135: ! 136: if (first) { ! 137: first=0; ! 138: for (x=0;x<4;x++) ! 139: colors[x] = SDL_MapRGB(sdlscrn->format, sdlColors[x].r, sdlColors[x].g, sdlColors[x].b); ! 140: for (x=0;x<4096;x++) ! 141: hicolors[x]=SDL_MapRGB(sdlscrn->format,((x&0x0F00)>>4)|((x&0x0F00)>>8),(x&0x00F0)|((x&0x00F0)>>4),((x&0x000F)<<4)|(x&0x000F)); ! 142: } ! 143: ! 144: #if ENABLE_DIMENSION ! 145: /* dimension */ ! 146: if (ConfigureParams.Screen.nMonitorType==MONITOR_TYPE_DIMENSION) { ! 147: for (y = 0; y < 832; y++) ! 148: { ! 149: adr=(y*288*16)+16; ! 150: ! 151: for (x = 0; x < 1120; x++) ! 152: { ! 153: if ((buffer[adr]!=ND_vram[adr]) || (buffer[adr+1]!=ND_vram[adr+1]) || (buffer[adr+2]!=ND_vram[adr+2])) { ! 154: col=((ND_vram[adr]<<16) | (ND_vram[adr+1]<<8) | (ND_vram[adr+2])); ! 155: putpixel(sdlscrn,x,y,col); ! 156: buffer[adr]=ND_vram[adr]; ! 157: buffer[adr+1]=ND_vram[adr+1]; ! 158: buffer[adr+2]=ND_vram[adr+2]; ! 159: } ! 160: adr+=4; ! 161: } ! 162: } ! 163: return; ! 164: } ! 165: #endif ! 166: ! 167: /* non turbo color */ ! 168: if ((ConfigureParams.System.bColor) && (!(ConfigureParams.System.bTurbo)) ){ ! 169: for (y = 0; y < 832; y++) ! 170: { ! 171: adr=y*288*8; ! 172: ! 173: for (x = 0; x < 1120; x++) ! 174: { ! 175: if ((buffer[adr]!=NEXTColorVideo[adr]) || (buffer[1+adr]!=NEXTColorVideo[1+adr])) { ! 176: col=( (NEXTColorVideo[adr]<<8) | (NEXTColorVideo[1+adr]) )>>4; ! 177: putpixel(sdlscrn,x,y,hicolors[col]); ! 178: buffer[adr]=NEXTColorVideo[adr]; ! 179: buffer[adr+1]=NEXTColorVideo[adr+1]; ! 180: } ! 181: adr+=2; ! 182: } ! 183: } ! 184: return; ! 185: } ! 186: ! 187: /* turbo color */ ! 188: if ((ConfigureParams.System.bColor) && ((ConfigureParams.System.bTurbo))){ ! 189: for (y = 0; y < 832; y++) ! 190: { ! 191: adr=y*280*8; ! 192: ! 193: for (x = 0; x < 1120; x++) ! 194: { ! 195: if ((buffer[adr]!=NEXTColorVideo[adr]) || (buffer[1+adr]!=NEXTColorVideo[1+adr])) { ! 196: col=( (NEXTColorVideo[adr]<<8) | (NEXTColorVideo[1+adr]) )>>4; ! 197: putpixel(sdlscrn,x,y,hicolors[col]); ! 198: buffer[adr]=NEXTColorVideo[adr]; ! 199: buffer[adr+1]=NEXTColorVideo[adr+1]; ! 200: } ! 201: adr+=2; ! 202: } ! 203: } ! 204: return; ! 205: } ! 206: ! 207: if (ConfigureParams.System.bTurbo) { ! 208: for (y = 0; y < 832; y++) ! 209: { ! 210: adr=y*280; ! 211: for (x = 0; x < 1120; x+=4) ! 212: { ! 213: if (buffer[adr]!=NEXTVideo[adr]) { ! 214: col=(NEXTVideo[adr]&0xC0)>>6; ! 215: putpixelbw(sdlscrn,x,y,col); ! 216: col=(NEXTVideo[adr]&0x30)>>4; ! 217: putpixelbw(sdlscrn,x+1,y,col); ! 218: col=(NEXTVideo[adr]&0x0C)>>2; ! 219: putpixelbw(sdlscrn,x+2,y,col); ! 220: col=(NEXTVideo[adr]&0x03); ! 221: putpixelbw(sdlscrn,x+3,y,col); ! 222: buffer[adr]=NEXTVideo[adr]; ! 223: } ! 224: adr+=1; ! 225: } ! 226: } ! 227: } ! 228: else { ! 229: ! 230: for (y = 0; y < 832; y++) ! 231: { ! 232: adr=y*288; ! 233: for (x = 0; x < 1120; x+=4) ! 234: { ! 235: if (buffer[adr]!=NEXTVideo[adr]) { ! 236: col=(NEXTVideo[adr]&0xC0)>>6; ! 237: putpixelbw(sdlscrn,x,y,col); ! 238: col=(NEXTVideo[adr]&0x30)>>4; ! 239: putpixelbw(sdlscrn,x+1,y,col); ! 240: col=(NEXTVideo[adr]&0x0C)>>2; ! 241: putpixelbw(sdlscrn,x+2,y,col); ! 242: col=(NEXTVideo[adr]&0x03); ! 243: putpixelbw(sdlscrn,x+3,y,col); ! 244: buffer[adr]=NEXTVideo[adr]; ! 245: } ! 246: adr+=1; ! 247: } ! 248: } ! 249: ! 250: } ! 251: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.