1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
|
/*
This is a little turbo C program that executes
several int10, and let you inspect the content
of the vgabios area
It is used to test the behavior of the vgabios
*/
#include <stdio.h>
#include <dos.h>
#include <conio.h>
typedef unsigned char Bit8u;
typedef unsigned short Bit16u;
typedef struct
{Bit8u initial;
Bit8u current;
Bit16u nbcols;
Bit16u regen;
Bit16u start;
Bit16u curpos[8];
Bit8u curtyp;
Bit8u curpage;
Bit16u crtc;
Bit16u msr;
Bit16u cgapal;
Bit8u nbrows;
Bit16u cheight;
Bit8u ctl;
Bit8u switches;
Bit8u modeset;
Bit8u dcc;
Bit16u vsseg;
Bit16u vsoffset;
} BIOSAREA;
void int10ax0003(struct REGPACK *regs)
{
regs->r_ax=0x0003;
intr(0x10,regs);
}
void int10ax02(struct REGPACK *regs)
{
regs->r_ax=0x0200;
regs->r_bx=0x0000;
regs->r_dx=0x1710;
intr(0x10,regs);
printf("We are now at 24/17");
}
void int10ax03(struct REGPACK *regs)
{
regs->r_ax=0x0300;
regs->r_bx=0x0000;
intr(0x10,regs);
printf("\nCursor is ax%04x cx%04x dx%04x\n",regs->r_ax,regs->r_cx,regs->r_dx);
}
void int10ax0501(struct REGPACK *regs)
{
regs->r_ax=0x0501;
intr(0x10,regs);
regs->r_ax=0x0e61;
regs->r_bx=0x0000;
intr(0x10,regs);
printf("We are now on page 2");
}
void int10ax0602(struct REGPACK *regs)
{
regs->r_ax=0x0602;
regs->r_bx=0x0700;
regs->r_cx=0x0101;
regs->r_dx=0x0a0a;
intr(0x10,regs);
printf("Scrolled 2 up");
}
void int10ax0702(struct REGPACK *regs)
{
regs->r_ax=0x0702;
regs->r_bx=0x0700;
regs->r_cx=0x0101;
regs->r_dx=0x0a0a;
intr(0x10,regs);
printf("Scrolled 2 down");
}
void int10ax08(struct REGPACK *regs)
{
regs->r_ax=0x0800;
regs->r_bx=0x0000;
intr(0x10,regs);
}
void int10ax09(struct REGPACK *regs)
{
char attr;
regs->r_ax=0x0501;
intr(0x10,regs);
for(attr=0;attr<16;attr++)
{printf("%02x ",attr);
regs->r_ax=0x0961+attr;
regs->r_bx=0x0100+attr;
regs->r_cx=0x0016;
intr(0x10,regs);
printf("\n");
}
}
void int10ax0a(struct REGPACK *regs)
{
regs->r_ax=0x0501;
intr(0x10,regs);
regs->r_ax=0x0a62;
regs->r_bx=0x0101;
regs->r_cx=0x0016;
intr(0x10,regs);
}
void int10ax0f(struct REGPACK *regs)
{
regs->r_ax=0x0501;
intr(0x10,regs);
regs->r_ax=0x0f00;
intr(0x10,regs);
}
void int10ax1b(struct REGPACK *regs)
{unsigned char table[64];
unsigned char far *ptable;
int i;
regs->r_ax=0x0501;
intr(0x10,regs);
regs->r_ax=0x1b00;
regs->r_bx=0x0000;
ptable=&table;
regs->r_es=FP_SEG(ptable);
regs->r_di=FP_OFF(ptable);
printf("Read state info in %04x:%04x\n",regs->r_es,regs->r_di);
intr(0x10,regs);
for(i=0;i<64;i++)
{if(i%16==0)printf("\n%02x ",i);
printf("%02x ",table[i]);
}
printf("\n");
}
static unsigned char var[64];
void int10ax13(struct REGPACK *regs)
{unsigned char far *pvar;
pvar=&var;
regs->r_ax=0x1300;
regs->r_bx=0x000b;
regs->r_dx=0x1010;
regs->r_cx=0x0002;
regs->r_es=FP_SEG(pvar);
regs->r_bp=FP_OFF(pvar);
pokeb(regs->r_es,regs->r_bp,'t');
pokeb(regs->r_es,regs->r_bp+1,'b');
printf("Writing from %04x:%04x\n",regs->r_es,regs->r_bp);
intr(0x10,regs);
}
void switch_50(struct REGPACK *regs)
{
regs->r_ax=0x1202;
regs->r_bx=0x3000;
intr(0x10,regs);
regs->r_ax=0x0003;
intr(0x10,regs);
regs->r_ax=0x1112;
regs->r_bx=0x0000;
intr(0x10,regs);
}
char exec_function(struct REGPACK *regs)
{char c;
printf("--- Functions --------------------\n");
printf("a. int10 ax0003\t");
printf("b. int10 ax02\t");
printf("c. int10 ax03\t");
printf("d. int10 ax0501\n");
printf("e. int10 ax0602\t");
printf("f. int10 ax0702\t");
printf("g. int10 ax08\t");
printf("h. int10 ax09\t");
printf("i. int10 ax0a\n");
printf("j. int10 ax0f\t");
printf("k. int10 ax1b\t");
printf("l. int10 ax13\n");
printf("q. Quit\t");
printf("r. switch to 50 lines\n");
c=getche();
switch(c)
{case 'a':
int10ax0003(regs);
break;
case 'b':
int10ax02(regs);
break;
case 'c':
int10ax03(regs);
break;
case 'd':
int10ax0501(regs);
break;
case 'e':
int10ax0602(regs);
break;
case 'f':
int10ax0702(regs);
break;
case 'g':
int10ax08(regs);
break;
case 'h':
int10ax09(regs);
break;
case 'i':
int10ax0a(regs);
break;
case 'j':
int10ax0f(regs);
break;
case 'k':
int10ax1b(regs);
break;
case 'l':
int10ax13(regs);
break;
case 'q':
break;
case 'r':
switch_50(regs);
break;
default:
printf("No such function!\n");
}
if(c=='q')return 1;
while(kbhit()==0);
c=getch();
return 0;
}
void read_bios_area(BIOSAREA *biosarea)
{
biosarea->initial=peekb(0x40,0x10);
biosarea->current=peekb(0x40,0x49);
biosarea->nbcols=peek(0x40,0x4a);
biosarea->regen=peek(0x40,0x4c);
biosarea->start=peek(0x40,0x4e);
biosarea->curpos[0]=peek(0x40,0x50);
biosarea->curpos[1]=peek(0x40,0x52);
biosarea->curpos[2]=peek(0x40,0x54);
biosarea->curpos[3]=peek(0x40,0x56);
biosarea->curpos[4]=peek(0x40,0x58);
biosarea->curpos[5]=peek(0x40,0x5a);
biosarea->curpos[6]=peek(0x40,0x5c);
biosarea->curpos[7]=peek(0x40,0x5e);
biosarea->curtyp=peek(0x40,0x60);
biosarea->curpage=peekb(0x40,0x62);
biosarea->crtc=peek(0x40,0x63);
biosarea->msr=peekb(0x40,0x65);
biosarea->cgapal=peekb(0x40,0x66);
biosarea->nbrows=peekb(0x40,0x84);
biosarea->cheight=peek(0x40,0x85);
biosarea->ctl=peekb(0x40,0x87);
biosarea->switches=peekb(0x40,0x88);
biosarea->modeset=peekb(0x40,0x89);
biosarea->dcc=peekb(0x40,0x8a);
biosarea->vsseg=peek(0x40,0xa8);
biosarea->vsoffset=peek(0x40,0xaa);
}
void show_bios_area(BIOSAREA *biosarea)
{
printf("--- BIOS area --------------------\n");
printf("initial : %02x\t",biosarea->initial);
printf("current : %02x\t",biosarea->current);
printf("nbcols : %04x\t",biosarea->nbcols);
printf("regen : %04x\t",biosarea->regen);
printf("start : %04x\n",biosarea->start);
printf("curpos : %04x %04x %04x %04x %04x %04x %04x %04x\n",
biosarea->curpos[0], biosarea->curpos[1], biosarea->curpos[2], biosarea->curpos[3],
biosarea->curpos[4], biosarea->curpos[5], biosarea->curpos[6], biosarea->curpos[7]);
printf("curtyp : %04x\t",biosarea->curtyp);
printf("curpage : %02x\t",biosarea->curpage);
printf("crtc : %04x\t",biosarea->crtc);
printf("msr : %04x\n",biosarea->msr);
printf("cgapal : %04x\t",biosarea->cgapal);
printf("nbrows-1: %02x\t",biosarea->nbrows);
printf("cheight : %04x\t",biosarea->cheight);
printf("ctl : %02x\n",biosarea->ctl);
printf("switches: %02x\t",biosarea->switches);
printf("modeset : %02x\t",biosarea->modeset);
printf("dcc : %02x\t",biosarea->dcc);
printf("vs : %04x:%04x\n",biosarea->vsseg,biosarea->vsoffset);
}
void show_regs(struct REGPACK *regs)
{
printf("--- Registers --------------------\n");
printf("ax %04x\t",regs->r_ax);
printf("bx %04x\t",regs->r_bx);
printf("cx %04x\t",regs->r_cx);
printf("dx %04x\t",regs->r_dx);
printf("ds %04x\t",regs->r_ds);
printf("si %04x\t",regs->r_si);
printf("es %04x\t",regs->r_es);
printf("di %04x\n",regs->r_di);
}
void reset_videomode()
{
struct REGPACK regs;
regs.r_ax=0x0003;
intr(0x10,®s);
}
void main()
{
BIOSAREA biosarea;
struct REGPACK regs;
directvideo=0;
while(1)
{
read_bios_area(&biosarea);
reset_videomode();
show_bios_area(&biosarea);
show_regs(®s);
if(exec_function(®s)!=0)break;
}
}
|