help with vga textmode

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
trolly
Member
Member
Posts: 52
Joined: Tue Mar 25, 2008 12:26 pm

help with vga textmode

Post by trolly »

Hi,
i want to set a 90x60 textmode
i wrote to the register to enable this mode: it work

but the font should be 8x8 instead 8x16 and i dont know how to set this font... could you help me please

i use asm, the os work in pmode

thank
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

For 80x50 in DexOS, I do this:

Code: Select all

 ;----------------------------------------------------;
 ; Resizes text.                                      ;
 ;----------------------------------------------------;
TextReSize:
	pushad
	mov   ax,1112h					 ; Set 80x50 mode
	mov   bl,0
	int   10h
	call  ReProgamFonts
	popad
	ret

 ;----------------------------------------------------;
 ; Reprogram fonts.                                   ;
 ;----------------------------------------------------;
ReProgamFonts:
	push es
	mov   ax,ds
	mov   es,ax
	mov   bp,DexFont
	mov   cx,00FFh
	xor   dx,dx
	mov   bx,0800h
	mov   ax,1100h
	int   10h					 ; ReProgams Fonts
	pop   es
	ret

In realmode before moving to pmode, you can probly do it in Pmode see here:
http://bos.asmhackers.net/docs/vga_without_bios/
Attachments
DexFonts.asm
These are the fonts, to go with the above code
(12.54 KiB) Downloaded 72 times
trolly
Member
Member
Posts: 52
Joined: Tue Mar 25, 2008 12:26 pm

Post by trolly »

i don't want to use bios interrupt
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

Post by inflater »

For initializing 90x60 I dunno, but here you go for 80x50:

Code: Select all

STATUS_ADDR       EQU       03DAH
MISC_ADDR         EQU       03C2H
SEQ_ADDR          EQU       03C4H
GRACON_ADDR       EQU       03CEH
CRTC_ADDR         EQU       03D4H
ATTRCON_ADDR      EQU       03C0H

MODEK DB 63H, 00H, 03H,01H,03H,00H,02H
      DB 5FH,4FH,50H,82H,55H,81H,0BFH,1FH,00H,47H,06H,07H,00H,00H,00H
      DB 00H,9CH,8EH,8FH,28H,1FH,96H,0B9H,0A3H,0FFH
      DB 00H,00H,00H,00H,00H,10H,0EH,00H,0FFH
      DB 00H,01H,02H,03H,04H,05H,14H,07H,10H,11H,3AH,3BH,3CH,3DH,3EH,3FH
      DB 0CH,00H,0FH,00H,00H

SETMODE:

   ; Send MISC regs
   MOV DX,MISC_ADDR
   MOV AL,[SI]
   OUT DX,AL
   JMP $+2
   INC SI

   MOV DX,STATUS_ADDR
   MOV AL,[SI]
   OUT DX,AL
   JMP $+2
   INC SI

   ; Send SEQ regs
   MOV CX,0
REG_LOOP:
   MOV DX,SEQ_ADDR
   MOV AL,CL
   OUT DX,AL
   JMP $+2

   MOV DX,SEQ_ADDR
   INC DX
   MOV AL,[SI]
   OUT DX,AL
   JMP $+2
   INC SI
   INC CX
   CMP CL,5
   JL REG_LOOP

   ; Clear Protection bits
   MOV AH,0EH
   MOV AL,11H
   AND AH,7FH
   MOV DX,CRTC_ADDR
   OUT DX,AX
   JMP $+2

   ; Send CRTC regs
   MOV CX,0
REG_LOOP2:
   MOV DX,CRTC_ADDR
   MOV AL,CL
   OUT DX,AL
   JMP $+2

   MOV DX,CRTC_ADDR
   INC DX
   MOV AL,[SI]
   OUT DX,AL
   JMP $+2

   INC SI
   INC CX
   CMP CL,25
   JL REG_LOOP2

   ; Send GRAPHICS regs
   MOV CX,0
REG_LOOP3:
   MOV DX,GRACON_ADDR
   MOV AL,CL
   OUT DX,AL
   JMP $+2

   MOV DX,GRACON_ADDR
   INC DX
   MOV AL,[SI]
   OUT DX,AL
   JMP $+2

   INC SI
   INC CX
   CMP CL,9
   JL REG_LOOP3

   MOV DX,STATUS_ADDR
   IN AL,DX
   JMP $+2

   ; Send ATTRCON regs
   MOV CX,0
REG_LOOP4:
   MOV DX,ATTRCON_ADDR
   IN AX,DX

   MOV AL,CL
   OUT DX,AL
   JMP $+2

   MOV AL,[SI]
   OUT DX,AL
   JMP $+2

   INC SI
   INC CX
   CMP CL,21
   JL REG_LOOP4

   MOV AL,20H
   OUT DX,AL
   JMP $+2

   RET

...
YOURCODE:
MOV SI,OFFSET MODEK
CALL SETMODE
(Its a copy-and-paste, but it should work.)

Then, immediately after that, you should set proper palette and load a 80x50 font, which isn't described in the code.

You see, you are at mercy of BIOS interrupts :)
xyzzy
Member
Member
Posts: 391
Joined: Wed Jul 25, 2007 8:45 am
Libera.chat IRC: aejsmith
Location: London, UK
Contact:

Post by xyzzy »

There's some good info and code in here: http://my.execpc.com/CE/AC/geezer/osd/graphics/modes.c

It contains 8x8 and 8x16 fonts and has code to set them, as well as the text mode.
trolly
Member
Member
Posts: 52
Joined: Tue Mar 25, 2008 12:26 pm

Post by trolly »

i know how to set the mode

what i want is: how to load appropriate font
xyzzy
Member
Member
Posts: 391
Joined: Wed Jul 25, 2007 8:45 am
Libera.chat IRC: aejsmith
Location: London, UK
Contact:

Post by xyzzy »

Which is shown in the code I linked, as I said.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Post by egos »

I don't use 90x60 text mode, as in it too small size of symbol matrix. But I'm using 80x30 text mode. It like 90x60 by values placed in vga registers:

Code: Select all

mor: 0xE7

sync: 0x03, 0x00, 0x03, 0x00, 0x02

crt: 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0x0B, 0x3E, 0x00, 0x4F, 0x0D (0x0E), 0x0E (0x0F)
0x00 (pagedisph), 0x00 (pagedispl), 0x00 (superposh), 0x00 (superposl), 0xEA, 0x8C (0x0C)
0xDF, 0x28, 0x1F, 0xE7, 0x04, 0xA3, 0xFF

graph: 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x00, 0xFF

attr: 0x00-0x0F, 0x04 (0x0C - blink), 0x00, 0x0F, 0x08, 0x00

dac(0-15): see palcga.bin
Attachments
palcga.zip
(148 Bytes) Downloaded 56 times
Post Reply