convert line ends
[canaan.git] / prj / tech / libsrc / dev2d / vgaasm.asm
blobfc971fbc5cf1dc6e1bc9b693de2dccb5e345686e
2 ; $Source: x:/prj/tech/libsrc/dev2d/RCS/vgaasm.asm $
3 ; $Revision: 1.2 $
4 ; $Author: TOML $
5 ; $Date: 1996/10/16 16:07:00 $
7 ; VGA specific code.
9 ; This file is part of the 2d library.
12 .386
14 include cseg.inc
15 include grs.inc
16 include grd.inc
17 include vgaregs.inc
19 _TEXT segment
21 ; The most crashproof piece of code I've ever seen:
22 public vga_get_focus_
23 vga_get_focus_:
24 ret
26 ; takes (x,y) position of new focus in eax, edx.
27 public vga_set_focus_
28 vga_set_focus_:
29 push ebx
30 push ecx
31 push edx
32 push esi
33 ; save new (x,y) position of screen.
34 mov ebx,_grd_screen
35 mov [ebx+GRS_SCREEN_X],ax
36 mov [ebx+GRS_SCREEN_Y],dx
37 mov esi,eax
38 mov ebx,_grd_screen_canvas
39 ; calculate start address = bits-base + y*row + x/4.
40 mov ecx,[ebx+GRS_CANVAS_BM+GRS_BITMAP_BITS]
41 mov eax,[ebx+GRS_CANVAS_BM+GRS_BITMAP_ROW]
42 and eax,0ffffh
43 mul edx
44 add ecx,eax
45 shr esi,2
46 add ecx,esi
47 ;update visible_canvas
48 mov edx,_grd_visible_canvas
49 mov [edx+GRS_CANVAS_BM+GRS_BITMAP_BITS],ecx
51 sub ecx,VGA_BASE
53 ; set VGA start address.
54 mov dx,CRX_ADR
55 mov ah,ch
56 mov al,CR_SAH
57 out dx,ax
58 mov ah,cl
59 inc al ;mov al,CR_SAL
60 out dx,ax
62 pop esi
63 pop edx
64 pop ecx
65 pop ebx
66 ret
68 ; takes start in eax, count in edx, pal_data ebx
69 public vga_get_pal_
70 vga_get_pal_:
71 ; don't bomb if count is <= 0.
72 or edx,edx
73 jle vgp_punt
74 push ebx
75 push ecx
76 push edx
77 lea ecx,[edx+2*edx] ; ecx = 3*count
78 ; send start to notify pel of upcoming read.
79 mov dx,PEL_RADR
80 out dx,al
81 ; read r,g,b values in order from pel data register.
82 mov dx,PEL_DATA
83 vgp_read_pal:
84 in al,dx
85 shl al,2 ;fix up 6-bit values for 2d
86 mov [ebx],al
87 inc ebx
88 dec ecx
89 jnz vgp_read_pal
90 pop edx
91 pop ecx
92 pop ebx
93 vgp_punt:
94 ret
96 ; takes start in eax, count in edx, pal_data ebx
97 public vga_set_pal_
98 vga_set_pal_:
99 ; don't bomb if count is <= 0.
100 or edx,edx
101 jle vsp_punt
102 push ebx
103 push ecx
104 push edx
105 lea ecx,[edx+2*edx] ; ecx = 3*count
106 ; send start to notify pel of upcoming write.
107 mov dx,PEL_WADR
108 out dx,al
109 ; send r,g,b values in order to pel data register.
110 mov dx,PEL_DATA
111 vsp_write_pal:
112 mov al,[ebx]
113 shr al,2 ;fix up 8-bit values for vga
114 out dx,al
115 inc ebx
116 dec ecx
117 jnz vsp_write_pal
118 pop edx
119 pop ecx
120 pop ebx
121 vsp_punt:
124 ; returns 1 if horizontal retrace is in progress.
125 public vga_stat_htrace_
126 vga_stat_htrace_:
127 push edx
128 xor eax,eax
129 mov dx,GEN_STAT1
130 in al,dx
131 and al,MR_HSYNC
132 pop edx
135 ; returns 1 if horizontal retrace is in progress.
136 public vga_stat_vtrace_
137 vga_stat_vtrace_:
138 push edx
139 xor eax,eax
140 mov dx,GEN_STAT1
141 in al,dx
142 and al,MR_VSYNC
143 shr al,3
144 pop edx
147 ; takes width in pixels in eax.
148 public vga_set_width_
149 vga_set_width_:
150 push edx
151 mov dx,CRX_ADR
152 shl ax,5 ;ax=w/8*256
153 mov al,CR_OFFSET
154 out dx,ax
155 pop edx
158 _TEXT ends