1 /* FCE Ultra - NES/Famicom Emulator
\r
3 * Copyright notice for this file:
\r
4 * Copyright (C) 1998 \Firebug\
\r
5 * Copyright (C) 2002 Ben Parnell
\r
7 * This program is free software; you can redistribute it and/or modify
\r
8 * it under the terms of the GNU General Public License as published by
\r
9 * the Free Software Foundation; either version 2 of the License, or
\r
10 * (at your option) any later version.
\r
12 * This program is distributed in the hope that it will be useful,
\r
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 * GNU General Public License for more details.
\r
17 * You should have received a copy of the GNU General Public License
\r
18 * along with this program; if not, write to the Free Software
\r
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
25 #include <sys/farptr.h>
\r
30 #include "dos-video.h"
\r
33 #define G320x200x256 0x13
\r
35 static void vga_waitretrace(void)
\r
37 while(inp(0x3da)&0x8);
\r
38 while(!(inp(0x3da)&0x8));
\r
41 static void vga_setmode(int mode)
\r
45 memset(®s,0,sizeof(regs));
\r
48 __dpmi_int(0x10,®s);
\r
51 void vga_setpalette(int i, int r, int g, int b)
\r
61 static int vidready=0;
\r
63 /* Part of the VGA low-level mass register setting code derived from
\r
67 #include "vgatweak.c"
\r
69 void SetBorder(void)
\r
72 outportb(0x3c0,(0x11|0x20));
\r
73 outportb(0x3c0,0x80);
\r
76 void TweakVGA(int VGAMode)
\r
82 outportb(0x3C8,0x00);
\r
83 for(I=0;I<768;I++) outportb(0x3C9,0x00);
\r
85 outportb(0x3D4,0x11);
\r
86 I=inportb(0x3D5)&0x7F;
\r
87 outportb(0x3D4,0x11);
\r
92 case 1: for(I=0;I<25;I++) VGAPortSet(v256x240[I]);break;
\r
93 case 2: for(I=0;I<25;I++) VGAPortSet(v256x256[I]);break;
\r
94 case 3: for(I=0;I<25;I++) VGAPortSet(v256x256S[I]);break;
\r
95 case 6: for(I=0;I<25;I++) VGAPortSet(v256x224S[I]);break;
\r
96 case 8: for(I=0;I<25;I++) VGAPortSet(v256x224_103[I]);break;
\r
104 static uint8 palettedbr[256],palettedbg[256],palettedbb[256];
\r
106 static void FlushPalette(void)
\r
112 vga_setpalette(z,palettedbr[x]>>2,palettedbg[x]>>2,palettedbb[x]>>2);
\r
116 void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b)
\r
118 palettedbr[index]=r;
\r
119 palettedbg[index]=g;
\r
120 palettedbb[index]=b;
\r
123 vga_setpalette(index,r>>2,g>>2,b>>2);
\r
128 void FCEUD_GetPalette(uint8 i, uint8 *r, uint8 *g, uint8 *b)
\r
135 static uint32 ScreenLoc;
\r
137 int InitVideo(void)
\r
148 vga_setmode(G320x200x256);
\r
151 TweakVGA(FCEUDvmode);
\r
153 DOSMemSet(ScreenLoc, 128, 256*256);
\r
161 void KillVideo(void)
\r
169 void LockConsole(void){}
\r
170 void UnlockConsole(void){}
\r
171 void BlitScreen(uint8 *XBuf)
\r
176 if(eoptions&4 && !NoWaiting)
\r
179 tlines=erendline-srendline+1;
\r
185 case 1:dest+=(((240-tlines)>>1)<<8);break;
\r
187 case 3:dest+=(((256-tlines)>>1)<<8);break;
\r
189 case 5:dest+=(((240-tlines)>>1)*640+((640-512)>>1));break;
\r
191 case 6:if(tlines>224) tlines=224;dest+=(((224-tlines)>>1)<<8);break;
\r
194 XBuf+=(srendline<<8)+(srendline<<4);
\r
196 _farsetsel(_dos_ds);
\r
197 if(eoptions&DO_CLIPSIDES)
\r
201 "movl $30,%%eax\n\t"
\r
203 "movl (%%esi),%%edx\n\t"
\r
204 "movl 4(%%esi),%%ecx\n\t"
\r
206 "movl %%edx,(%%edi)\n\t"
\r
208 "movl %%ecx,4(%%edi)\n\t"
\r
209 "addl $8,%%esi\n\t"
\r
210 "addl $8,%%edi\n\t"
\r
213 "addl $32,%%esi\n\t"
\r
214 "addl $16,%%edi\n\t"
\r
218 : "S" (XBuf+8), "D" (dest+8), "b" (tlines)
\r
219 : "%eax","%cc","%edx","%ecx" );
\r
225 "movl $32,%%eax\n\t"
\r
227 "movl (%%esi),%%edx\n\t"
\r
228 "movl 4(%%esi),%%ecx\n\t"
\r
230 "movl %%edx,(%%edi)\n\t"
\r
232 "movl %%ecx,4(%%edi)\n\t"
\r
233 "addl $8,%%esi\n\t"
\r
234 "addl $8,%%edi\n\t"
\r
237 "addl $16,%%esi\n\t"
\r
241 : "S" (XBuf), "D" (dest), "b" (tlines)
\r
242 : "%eax","%cc","%edx","%ecx" );
\r