OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 16, 2024 8:13 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: How do i switch from 80*25 vga text mode to 320*200 mode
PostPosted: Sun Oct 11, 2020 10:30 am 
Offline

Joined: Fri Jul 31, 2020 9:53 am
Posts: 1
in the past 2-3 days. I've been looking for a way to switch between vga modes. With some example code written in C. But i couldn't find anything helpful. Please help


Top
 Profile  
 
 Post subject: Re: How do i switch from 80*25 vga text mode to 320*200 mode
PostPosted: Mon Oct 12, 2020 3:15 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 01, 2019 3:50 pm
Posts: 39
Location: France
Have you done any kind of attempt (whether it's just simple code or anything else)? Do you have a hard time trying to understand something in the documentation? Tell us everything! :)


Top
 Profile  
 
 Post subject: Re: How do i switch from 80*25 vga text mode to 320*200 mode
PostPosted: Mon Oct 12, 2020 5:21 am 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 3192
Nobody should use the 320x200 mode anymore. Bit-plane and palette mapped modes are big no-nos. If you want to use VGA / VBE, make sure you use one that uses RGB components directly. The best alternative is probably to boot with EFI and use the EFI mode linear frame buffer. It's a lot easier than to set up a decent VBE mode.


Top
 Profile  
 
 Post subject: Re: How do i switch from 80*25 vga text mode to 320*200 mode
PostPosted: Mon Oct 12, 2020 6:26 am 
Offline
Member
Member

Joined: Sat Mar 10, 2018 10:16 am
Posts: 296
Easiest way is use bios:
Code:
  mov ah, 0x00
  mov al, 13 ;300x220 mode
  int 10h

If this isn't working for you, this code (from https://files.osdev.org/mirrors/geezer/osd/graphics/modes.c) can do same result:
Code:

#define   VGA_AC_INDEX      0x3C0
#define   VGA_AC_WRITE      0x3C0
#define   VGA_AC_READ      0x3C1
#define   VGA_MISC_WRITE      0x3C2
#define VGA_SEQ_INDEX      0x3C4
#define VGA_SEQ_DATA      0x3C5
#define   VGA_DAC_READ_INDEX   0x3C7
#define   VGA_DAC_WRITE_INDEX   0x3C8
#define   VGA_DAC_DATA      0x3C9
#define   VGA_MISC_READ      0x3CC
#define VGA_GC_INDEX       0x3CE
#define VGA_GC_DATA       0x3CF
/*         COLOR emulation      MONO emulation */
#define VGA_CRTC_INDEX      0x3D4      /* 0x3B4 */
#define VGA_CRTC_DATA      0x3D5      /* 0x3B5 */
#define   VGA_INSTAT_READ      0x3DA

#define   VGA_NUM_SEQ_REGS   5
#define   VGA_NUM_CRTC_REGS   25
#define   VGA_NUM_GC_REGS      9
#define   VGA_NUM_AC_REGS      21
#define   VGA_NUM_REGS      (1 + VGA_NUM_SEQ_REGS + VGA_NUM_CRTC_REGS + \
            VGA_NUM_GC_REGS + VGA_NUM_AC_REGS)

unsigned char g_320x200x256[] =
{
/* MISC */
   0x63,
/* SEQ */
   0x03, 0x01, 0x0F, 0x00, 0x0E,
/* CRTC */
   0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F,
   0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x9C, 0x0E, 0x8F, 0x28,   0x40, 0x96, 0xB9, 0xA3,
   0xFF,
/* GC */
   0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
   0xFF,
/* AC */
   0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
   0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
   0x41, 0x00, 0x0F, 0x00,   0x00
};

void write_regs(unsigned char *regs)
{
   unsigned i;

/* write MISCELLANEOUS reg */
   outportb(VGA_MISC_WRITE, *regs);
   regs++;
/* write SEQUENCER regs */
   for(i = 0; i < VGA_NUM_SEQ_REGS; i++)
   {
      outportb(VGA_SEQ_INDEX, i);
      outportb(VGA_SEQ_DATA, *regs);
      regs++;
   }
/* unlock CRTC registers */
   outportb(VGA_CRTC_INDEX, 0x03);
   outportb(VGA_CRTC_DATA, inportb(VGA_CRTC_DATA) | 0x80);
   outportb(VGA_CRTC_INDEX, 0x11);
   outportb(VGA_CRTC_DATA, inportb(VGA_CRTC_DATA) & ~0x80);
/* make sure they remain unlocked */
   regs[0x03] |= 0x80;
   regs[0x11] &= ~0x80;
/* write CRTC regs */
   for(i = 0; i < VGA_NUM_CRTC_REGS; i++)
   {
      outportb(VGA_CRTC_INDEX, i);
      outportb(VGA_CRTC_DATA, *regs);
      regs++;
   }
/* write GRAPHICS CONTROLLER regs */
   for(i = 0; i < VGA_NUM_GC_REGS; i++)
   {
      outportb(VGA_GC_INDEX, i);
      outportb(VGA_GC_DATA, *regs);
      regs++;
   }
/* write ATTRIBUTE CONTROLLER regs */
   for(i = 0; i < VGA_NUM_AC_REGS; i++)
   {
      (void)inportb(VGA_INSTAT_READ);
      outportb(VGA_AC_INDEX, i);
      outportb(VGA_AC_WRITE, *regs);
      regs++;
   }
/* lock 16-color palette and unblank display */
   (void)inportb(VGA_INSTAT_READ);
   outportb(VGA_AC_INDEX, 0x20);
}

void set_vga_300x220(void) {
  write_regs(g_320x200x256);
}


But I didn't work with VGA in C too long so sorry if this code includes some mistake.

_________________
https://github.com/VendelinSlezak/BleskOS


Top
 Profile  
 
 Post subject: Re: How do i switch from 80*25 vga text mode to 320*200 mode
PostPosted: Tue Oct 20, 2020 1:22 pm 
Offline
Member
Member
User avatar

Joined: Mon May 22, 2017 5:56 am
Posts: 815
Location: Hyperspace
rdos wrote:
Nobody should use the 320x200 mode anymore. Bit-plane and palette mapped modes are big no-nos. If you want to use VGA / VBE, make sure you use one that uses RGB components directly. The best alternative is probably to boot with EFI and use the EFI mode linear frame buffer. It's a lot easier than to set up a decent VBE mode.

Palettes can be nice for certain visual styles. Bit-plane is a pain if you try to tackle it with normal graphics algorithms, but I do remember a web page claiming it can be really powerful if you know how to use it. I think there was something about a barrel shifter.

_________________
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie


Top
 Profile  
 
 Post subject: Re: How do i switch from 80*25 vga text mode to 320*200 mode
PostPosted: Tue Oct 20, 2020 2:38 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5134
Are you perhaps thinking of this page? VGA does have some interesting hardware for manipulating planar graphics, but modern display adapters implement VGA compatibility as a separate unit from the rest of the adapter (if they have VGA compatibility at all) so it's not especially useful.

It's a lot more useful if you're writing a driver for some ancient SVGA chip...


Top
 Profile  
 
 Post subject: Re: How do i switch from 80*25 vga text mode to 320*200 mode
PostPosted: Fri Oct 23, 2020 6:59 am 
Offline
Member
Member
User avatar

Joined: Mon May 22, 2017 5:56 am
Posts: 815
Location: Hyperspace
Thanks! It's not the page I remember, but it's interesting nonetheless. I might use it with the thoroughly retro Forths I'm thinking of implementing for fun.

_________________
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 575 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group