www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/12/16/16:41:03

From: ANTHONY APPLEYARD <A DOT APPLEYARD AT fs1 DOT mt DOT umist DOT ac DOT uk>
To: DJGPP AT SUN DOT SOE DOT CLARKSON DOT EDU
Date: Fri, 16 Dec 1994 16:34:11 GMT
Subject: Re: New PC: driver or screen funny when in Gnu C

  dj AT stealth DOT ctron DOT com (DJ Delorie) replied on Wed 14 Dec 94 10:43:00 -0500:-
  > The bank flipping isn't happening, so you are always writing to the first
64K of video memory. You need to either use GR or GRX to handle the page
flipping for you, or manually program your VGA card. Selecting the mode with
GRX (heck, <<selecting any mode>>) enables the automatic page flipping.

  Which I did. The new form of my program follows at the end of this message
(with `extern "C"': thanks for the tip).
  With the 3rd line of my `main()' as `GrSetBIOSMode(0x64,640,480,64*1024);',
my program error exited at run time in function `int_set_BIOS_mode()' in
C:\DJGPP\CONTRIB\LIBGRX\SRC\SETMODE.C with the error remark printed by its
154th line (`fputs("GrSetMode: unknown adapter type in driver\n",stderr);')
(perhaps due to `set_BIOS_mode(BIOSno,width,height,colors,&mode)' on its 129th
line returning zero into the local variable `flags').
  With the 3rd line of main() as `GrSetBIOSMode(0x12,640,480,16);' as
hereinunder, the program ran to completion but yet again plotted all screen
address offsets as the remainder left after dividing by 0x10000.
  .......................................................
#include <stdio.h>
#include <math.h>
#include <builtin.h>
#include <stdio.h>
#include <std.h>
#include <pc.h>
extern "C" void GrSetBIOSMode(int,int,int,int);
/*-----*/
long _ax,_bx,_cx,_dx; long _si,_di,_bp,_es; long GP_4; short GP_2; char GP_1;
#define _SWOPR() /* swop registers with saved registers */ ({ \
asm("xchgl %eax,__ax"); asm("xchgl %ebx,__bx"); asm("xchgl %ecx,__cx"); \
asm("xchgl %edx,__dx"); asm("xchgl %esi,__si"); asm("xchgl %edi,__di"); \
asm("xchgl %ebp,__bp");})
/*-----*/
void int10() {_SWOPR(); asm("int $0x10"); _SWOPR();}
void int21() {_SWOPR(); asm("int $0x21"); _SWOPR();}
/*-----*/
unsigned char get_key(){_ax=0x0700; int21(); return _ax&255;}
/*-----*/
unsigned char gp_mode(void) {_ax=0x0f00; int10(); return _ax&255;}
/*-----*/
void gp_mode(char m) {_ax=m; int10();
if(m!=gp_mode()) printf("\007error: this computer has no mode 0x%1x\n",m);}
/*-----*/
class Screen{public:
short int wide,high; char mode,type; unsigned short*screen;
Screen(int Wide,int High,int Mode,unsigned short*scr=0);};
/*-----*/
Screen::Screen(int Wide,int High,int Mode,unsigned short*scr){
wide=Wide; high=High; mode=Mode;
screen=scr?(unsigned short*)scr:(unsigned short*)0xd0000000;}
/*-----*/
unsigned short color(int r,int g,int b) {r>>=3; g>>=2; b>>=3;
unsigned short i=(r<<11)|(g<<5)|b;
return i /* ((i&0xff00)>>8)|((i&0x00ff)<<8) */ ;}
/*-----*/
void Graphmode(Screen&scr){gp_mode(scr.mode);}
void Textmode(){gp_mode(3);}
/*----------*/
main(){long int r,g,b,i,j,k; unsigned short*screen=0;
FILE*debug=fopen("t$debug","w"); unsigned short S[640*480];
GrSetBIOSMode(0x12,640,480,16);
Screen scr(640,480,0x64,screen); /* this on my PC is a 64K-color mode */
Graphmode(scr); k=0;
for(r=0;r<256;r+=8) for(g=0;g<256;g+=4) for(b=0;b<256;b+=8) {
    i=(b>>3)+((g>>2)&15)*32; j=(r>>3)+(g>>6)*32; S[i+j*640]=color(r,g,b);}
for(i=0;i<480;i++) S[i*641]=0;
for(j=i=0;i<640*128;i++,j++) {
    if(j==640*32) {k=get_key(); if(!k) get_key();}
    scr.screen[j]=S[i];}
if(!get_key()) get_key(); OUT: Textmode();
printf("%08x\n",i);}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019