Annotation of qemu/roms/vgabios/tests/testbios.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.