Thursday, 3 May 2012

Digging up old relics...

Some of you may know I go waaaaaay back programming stuff on the ZX81 right upto to todays monster machines (compared to the ZX81 ;) ) well after dredging up the old source code I have I found some stuff I thought I lost, this was written in C with assembly for speed and was amazing at what it did heres a small snippet:

void VGAinit ()
{
 asm mov ah,0
 asm mov al,0x13
 asm int 0x10

  Screen2=(unsigned char *)malloc(64000);
  if (Screen2==NULL){
   printf("Video memory error\n\n");
   exit(0);
  }
  Buffer = Screen2;
}

void SVGAinit (unsigned char mode)
{
 asm mov ah,0
 asm mov al,mode
 asm int 0x10

  Screen2=(unsigned char *)malloc(307200);
  if (Screen2==NULL){
   printf("Video memory error\n\n");
   exit(0);
  }
  Buffer = Screen2;
}


//This resets the display to text mode
void Textinit ()
{
 asm mov ah,0
 asm mov al,0x03
 asm int 0x10

 free(Screen2);
}


Basically all this does is set the graphics mode either VGA or SVGA and text mode when you want to exit back to MS-DOS, its amazing how everything has changed (not always for the best eh). These files date back to 1993. Man now I feel old ;)

More soon...

More oldies code:
void mouseon(void)
{
 asm{
  mov ax, 0x0001
  int 0x33
 }
}

void mouseoff(void)
{
 asm{
  mov ax, 0x0002
  int 0x33
 }
}

unsigned char resetmouse(void){
 unsigned int mouse_type;
 unsigned int driver_status;
 unsigned char return_value;

 asm{
 mov ax, 0x0000
 int 0x33
 mov driver_status, ax
 mov mouse_type, bx
 }

 if (driver_status==0xFFFF) {
  switch (mouse_type) {
  case 0x0000: return_value = 0; break;//1
  case 0x0002: return_value = 2; break;//2
  case 0x0003: return_value = 3; break;//3
  case 0xFFFF: return_value = 4; break;//?
  }
 }else{
  printf("Error:No mouse detected\n");//duff
  printf("\nDRACOS requires a mouse to function correctly with the correct driver\n\n");
  exit(0);
 }
 return return_value;
}

int mouseinfo(int rd)
{
 in.r_ax = 3;
 intr(0x33, &in);
 switch(rd){
 case 1 : return(in.r_cx);
 case 2 : return(in.r_dx);
 case 3 : return(in.r_bx & 1); //left button
 case 4 : return(in.r_bx & 2); //right button
 case 5 : return(in.r_bx & 4); //middle button
 }
 return(-1);
}


Basically this does all the mouse routines to get details from my mouse driver :D

DISCLAIMER:Although I have used these routines for years I cannot guarantee that they will work as intended on every operating system and computer configuration out there, the risk of their use is the users in its entirety, neither myself, Emm or Graveyard Dogs will be held responsible from their use.

Okay for all those who are using bootcamp with a mac and keep 'losing the wifi' connection its not a hardware issue its a driver issue. I would recommend looking on www.x-drivers.com for your driver model relevant to your mac and download and install it. Bootcamp's drivers arent 100% perfect and sometimes after an hour or so of continuous use drop out every five minutes after I installed the windows drivers its ok again :D

No comments:

Post a Comment

blogdigger