; and tripple buffering - Tore Jahn Bastiansen\r
; (toreba@ifi.uio.no) for the\r
;-----------------------------------------------------------------------\r
-\r
-\r
include xlib.inc\r
include xmain.inc\r
\r
\r
- .data\r
+ _DATA SEGMENT WORD PUBLIC USE16 'DATA'\r
+;.data\r
\r
\r
; Mode X CRTC register tweaks for various resolutions\r
\r
\r
-LABEL X256Y200 word\r
+X256Y200 LABEL word\r
db 0e3h ; dot clock\r
db 8 ; Number of CRTC Registers to update\r
dw 05f00h ; horz total\r
dw 200\r
\r
\r
-LABEL X256Y240 word\r
+X256Y240 label word\r
db 0e3h ; dot clock\r
db 16 ; Number of CRTC Registers to update\r
dw 05f00h ; horz total\r
dw 376\r
dw 282\r
\r
-LABEL X256Y400 word\r
+X256Y400 label word\r
db 0e3h ; dot clock\r
db 8 ; Number of CRTC Registers to update\r
dw 05f00h ; horz total\r
dw 400\r
\r
\r
-LABEL X256Y480 word\r
+X256Y480 label word\r
db 0e3h ; dot clock\r
db 16 ; Number of CRTC Registers to update\r
dw 05f00h ; horz total\r
\r
DoubleScanFlag db ? ; Flag to indicate double scanned mode\r
\r
+_DATA ENDS\r
+\r
+\r
.code\r
\r
;-------------------------------------------------------------------------\r
mov ax,bx ; no - set logical width = physical\r
\r
@@ValidLogicalWidth:\r
- shr ax,3\r
+ shr ax,1\r
+ shr ax,1\r
+ shr ax,1\r
out dx,al\r
\r
; The EXACT logical pixel width may not have been possible since\r
mov [_RightClip],ax ; Set default Right clip column\r
; screen\r
sub ax,[_ScrnPhysicalByteWidth] ; Calculate and store Max X position\r
- shl ax,2 ; of physical screen in virtual\r
+ shl ax,1 ; of physical screen in virtual\r
+ shl ax,1 ; of physical screen in virtual\r
mov [_MaxScrollX],ax ; screen in pixels\r
mov ax,bx ; set ax to byte width of virt scrn\r
- shl ax,2 ; convert to pixels\r
+ shl ax,1 ; convert to pixels\r
+ shl ax,1 ; convert to pixels\r
mov [_ScrnLogicalPixelWidth],ax ; store virt scrn pixel width\r
mov cx,ax ; save ax (return value)\r
\r
; parts adapted from M. Abrash code.\r
;------------------------------------------------------------------------\r
_x_set_mode proc\r
- ARG mode:word,logicalscrwidth:word\r
+ ;;arg mode:word,logicalscrwidth:word\r
push bp ;preserve caller's stack frame\r
mov bp,sp\r
\r
mov cx,PARAM_COUNT\r
rep stosb\r
\r
- mov cx,[mode]\r
+ mov cx,[BP+4]\r
cmp cx,LAST_X_MODE ; have we selected a valid mode\r
jle @@ValidMode ; Yes !\r
\r
mov [_SplitScrnScanLine],ax ; No splitscrn ==\r
; splitscrn=PhysicalscrnHeight\r
mov bx,ax ; Copy width for later use\r
- shr ax,2 ; Convert to byte width\r
+ shr ax,1 ; Convert to byte width\r
+ shr ax,1 ; Convert to byte width\r
mov [_ScrnPhysicalByteWidth],ax ; Store for later use\r
lodsw ; Load Screen Phys. Height\r
mov [_ScrnPhysicalHeight],ax ; Store for later use\r
\r
; Mode X is set, now set the required logical page width.\r
\r
- mov cx,[logicalscrwidth]\r
+ mov cx,[BP+6]\r
\r
call SetLogicalScrWidth\r
\r
; Written by Themie Gouthas\r
;----------------------------------------------------------------------\r
_x_select_default_plane proc\r
-ARG Plane:byte\r
+ ;arg Plane:byte\r
push bp\r
mov bp,sp ; set up stack frame\r
- mov cl,byte ptr [Plane]\r
+ mov cl,byte ptr [bp+4]\r
\r
; SELECT WRITE PLANE\r
and cl,011b ;CL = plane\r
;----------------------------------------------------------------------\r
\r
_x_set_splitscreen proc\r
- ARG Line:word\r
+ ;arg Line:word\r
push bp\r
mov bp,sp ; set up stack frame\r
push si\r
mov [_PhysicalStartPixelX],ax ; offset within virtual screen\r
mov [_PhysicalStartY],ax\r
mov [_SplitScrnActive],TRUE\r
- mov ax,[Line]\r
+ mov ax,[bp+4]\r
jns @@NotNeg ; Check that Split Scrn start scan line is +ve\r
\r
mov ax,0 ; Since -ve set to 0\r
\r
mov ah,bh\r
and ah,1\r
- shl ah,4\r
+ shl ah,1\r
+ shl ah,1\r
+ shl ah,1\r
+ shl ah,1\r
mov al,OVERFLOW ; Bit 4 of overflow register = Bit 8 of split\r
out dx,al ; screen scan line,\r
inc dx ; So using readability of VGA registers\r
dec dx\r
mov ah,bh\r
and ah,2\r
- ror ah,3\r
+ ror ah,1\r
+ ror ah,1\r
+ ror ah,1\r
mov al,MAX_SCAN_LINE ; Bit 6 of max scan line register =\r
out dx,al ; Bit 9 of split screen scan line\r
inc dx ; As we did before, update the apropriate\r
\r
mov [_ScrnLogicalHeight],ax ; Save Screen Logical Height\r
cmp ax,[_BottomClip]\r
- jle @@BottomClipOK ; Adjust Clip Rectangle if necessary\r
+ jle @@BottomClipOK2 ; Adjust Clip Rectangle if necessary\r
mov [_BottomClip],ax\r
-@@BottomClipOK:\r
+@@BottomClipOK2:\r
sub ax,[_SplitScrnScanLine] ; Update the maximum Y position of\r
mov [_MaxScrollY],ax ; Physical screen in logical screen\r
\r
;------------------------------------------------------------------------\r
\r
_x_page_flip proc\r
- ARG x:word,y:word\r
+ ;arg x:word,y:word\r
push bp ;preserve caller's stack frame\r
mov bp,sp ;point to local stack frame\r
push si\r
\r
- mov si,[x]\r
+ mov si,[bp+4]\r
mov ax,[_ScrnLogicalByteWidth] ; Calculate Offset increment\r
- mov cx,[y]\r
+ mov cx,[bp+6]\r
mul cx ; for Y\r
cmp [_DoubleBufferActive],TRUE ; Do we have double buffering ?\r
je @@DoubleBuffer\r
; Parts addapted from M. Abrash code published in DDJ Mag.\r
;------------------------------------------------------------------------\r
_x_set_start_addr proc\r
- ARG x:word,y:word\r
+ ;arg x:word,y:word\r
push bp\r
mov bp,sp\r
push si\r
\r
- mov si,[x]\r
+ mov si,[bp+4]\r
mov ax,[_ScrnLogicalByteWidth] ; Calculate Offset increment\r
- mov cx,[y] ; for Y\r
+ mov cx,[bp+6] ; for Y\r
mul cx\r
cmp [_DoubleBufferActive],TRUE ; Do we have double buffering ?\r
je @@PageResolution\r
\r
@@AddColumn:\r
mov cx,si\r
- shr cx,2\r
+ shr cx,1\r
+ shr cx,1\r
mov [_PhysicalStartByteX],cx\r
add ax,cx ; add the column offset for X\r
mov bh,al ; setup CRTC start addr regs and\r
cmp [_SplitScrnActive],TRUE\r
je @@SplitScreenEnabled\r
\r
-@@error:\r
+@@error0:\r
mov [_ErrorValue],ERROR\r
pop bp\r
ret\r
\r
@@SplitScreenEnabled:\r
cmp [_CurrXMode],4 ; Do nothing for Modes > 2\r
- jg @@error\r
+ jg @@error0\r
mov bx,[_ScrnPhysicalHeight]\r
\r
mov ax,[_ScrnLogicalHeight]\r
mov [_SplitScrnVisibleHeight],ax\r
\r
or [DoubleScanFlag],0\r
- jz @@NotDoubleScanned\r
+ jz @@NotDoubleScanned0\r
shl bx,1\r
dec bx\r
-@@NotDoubleScanned:\r
+@@NotDoubleScanned0:\r
;mov cl,[DoubleScanFlag] ; Compensate for double scanned modes\r
;shl bx,cl\r
\r
\r
mov ah,bh\r
and ah,1\r
- shl ah,4\r
+ shl ah,1\r
+ shl ah,1\r
+ shl ah,1\r
+ shl ah,1\r
mov al,OVERFLOW ; Bit 4 of overflow register = Bit 8 of split\r
out dx,al ; screen scan line,\r
inc dx ; So using readability of VGA registers\r
dec dx\r
mov ah,bh\r
and ah,2\r
- ror ah,3\r
+ ror ah,1\r
+ ror ah,1\r
+ ror ah,1\r
mov al,MAX_SCAN_LINE ; Bit 6 of max scan line register =\r
out dx,al ; Bit 9 of split screen scan line\r
inc dx ; As we did before, update the apropriate\r
out dx,al\r
sti ; Registers are set, so interrupts are safe\r
\r
-@@done:\r
+@@done0:\r
\r
mov [_ErrorValue],OK\r
pop bp\r
mov bp,sp\r
\r
cmp [_SplitScrnActive],TRUE\r
- je @@SplitScreenEnabled\r
+ je @@SplitScreenEnabled0\r
\r
-@@error:\r
+@@error1:\r
mov [_ErrorValue],ERROR\r
pop bp\r
ret\r
\r
-@@SplitScreenEnabled:\r
+@@SplitScreenEnabled0:\r
cmp [_CurrXMode],4 ; Do nothing for Modes > 2\r
- jg @@error\r
+ jg @@error1\r
\r
mov bx,[_SplitScrnScanLine]\r
mov ax,[_ScrnLogicalHeight] ; Update Max Scroll Y\r
mov [_SplitScrnVisibleHeight],ax\r
\r
or [DoubleScanFlag],0\r
- jz @@NotDoubleScanned\r
+ jz @@NotDoubleScanned1\r
shl bx,1\r
dec bx\r
-@@NotDoubleScanned:\r
+@@NotDoubleScanned1:\r
;mov cl,[DoubleScanFlag] ; Compensate for double scanned modes\r
;shl bx,cl\r
WaitVsyncStart ; wait for vertical retrace\r
\r
mov ah,bh\r
and ah,1\r
- shl ah,4\r
+ shl ah,1\r
+ shl ah,1\r
+ shl ah,1\r
+ shl ah,1\r
mov al,OVERFLOW ; Bit 4 of overflow register = Bit 8 of split\r
out dx,al ; screen scan line,\r
inc dx ; So using readability of VGA registers\r
dec dx\r
mov ah,bh\r
and ah,2\r
- ror ah,3\r
+ ror ah,1\r
+ ror ah,1\r
+ ror ah,1\r
mov al,MAX_SCAN_LINE ; Bit 6 of max scan line register =\r
out dx,al ; Bit 9 of split screen scan line\r
inc dx ; As we did before, update the apropriate\r
out dx,al\r
sti ; Registers are set, so interrupts are safe\r
\r
-@@Done:\r
+@@Done1:\r
mov [_ErrorValue],0\r
pop bp\r
ret\r
\r
\r
_x_adjust_splitscreen proc\r
- ARG ScanLine\r
+ ;arg ScanLine\r
push bp\r
mov bp,sp\r
\r
cmp [_SplitScrnActive],TRUE\r
- je @@SplitScreenEnabled\r
+ je @@SplitScreenEnabled1\r
\r
-@@error:\r
+@@error2:\r
mov [_ErrorValue],ERROR\r
pop bp\r
ret\r
\r
-@@SplitScreenEnabled:\r
+@@SplitScreenEnabled1:\r
cmp [_CurrXMode],4 ; Do nothing for Modes > 2\r
- jg @@error\r
- mov bx,[ScanLine] ; Is the required starting scan line\r
+ jg @@error2\r
+ mov bx,[bp+4] ; Is the required starting scan line\r
cmp bx,[_SplitScrnScanLine] ; valid ?\r
- js @@Done ; No - Then do nothing\r
+ js @@Done2 ; No - Then do nothing\r
\r
@@ValidScanLine:\r
\r
mov [_SplitScrnVisibleHeight],ax\r
\r
or [DoubleScanFlag],0\r
- jz @@NotDoubleScanned\r
+ jz @@NotDoubleScanned2\r
shl bx,1\r
dec bx\r
-@@NotDoubleScanned:\r
+@@NotDoubleScanned2:\r
;mov cl,[DoubleScanFlag] ; Compensate for double scanned modes\r
;shl bx,cl\r
\r
\r
mov ah,bh\r
and ah,1\r
- shl ah,4\r
+ shl ah,1\r
+ shl ah,1\r
+ shl ah,1\r
+ shl ah,1\r
mov al,OVERFLOW ; Bit 4 of overflow register = Bit 8 of split\r
out dx,al ; screen scan line,\r
inc dx ; So using readability of VGA registers\r
dec dx\r
mov ah,bh\r
and ah,2\r
- ror ah,3\r
+ ror ah,1\r
+ ror ah,1\r
+ ror ah,1\r
mov al,MAX_SCAN_LINE ; Bit 6 of max scan line register =\r
out dx,al ; Bit 9 of split screen scan line\r
inc dx ; As we did before, update the apropriate\r
or al,ah\r
out dx,al\r
sti ; Registers are set, so interrupts are safe\r
-@@Done:\r
+@@Done2:\r
mov [_ErrorValue],OK\r
pop bp\r
ret\r
\r
\r
_x_set_doublebuffer proc\r
- ARG PageHeight:word\r
+ ;arg PageHeight:word\r
push bp\r
mov bp,sp\r
\r
mov ax,[_ScrnLogicalHeight] ; Set Maximum D.B. Page height to\r
shr ax,1 ; _ScrnLogicalHeight / 2\r
\r
- mov bx,[PageHeight] ; Is the require D.B. Page Height\r
+ mov bx,[bp+4] ; Is the require D.B. Page Height\r
cmp ax,bx ; > the Maximum D.B. Page Height ?\r
\r
js @@InvalidHeight ; no - jump\r
mov [_ScrnLogicalHeight],ax ; Update logical screen height to\r
; reflect the height of a D.B. page\r
cmp ax,[_BottomClip]\r
- jle @@BottomClipOK ; Adjust Clip Rectangle if necessary\r
+ jle @@BottomClipOK0 ; Adjust Clip Rectangle if necessary\r
mov [_BottomClip],ax\r
-@@BottomClipOK:\r
+@@BottomClipOK0:\r
push ax\r
mul [_ScrnLogicalByteWidth] ; Calculate the offset of the second\r
mov cx,ax ; D.B. Page in video ram\r
;------------------------------------------------------------------------\r
\r
_x_set_tripplebuffer proc\r
- ARG PageHeight:word\r
+ ;arg PageHeight:word\r
push bp\r
mov bp,sp\r
\r
cmp [_DoubleBufferActive],0\r
- jne @@Error\r
+ jne @@Error3\r
cmp [_TrippleBufferActive],0\r
- je @@OkToContinue\r
-@@Error:\r
+ je @@OkToContinue3\r
+@@Error3:\r
mov [_ErrorValue],ERROR\r
pop bp\r
ret\r
\r
-@@OkToContinue:\r
+@@OkToContinue3:\r
mov [_VisiblePageIdx],0 ; Set visible Page to 0\r
mov ax,[_ScrnLogicalHeight] ; Set Maximum T.B. Page height to\r
mov bx,3\r
xor dx,dx\r
idiv bx ; _ScrnLogicalHeight / 3\r
\r
- mov bx,[PageHeight] ; Is the require T.B. Page Height\r
+ mov bx,[bp+4] ; Is the require T.B. Page Height\r
cmp ax,bx ; > the Maximum T.B. Page Height ?\r
\r
- js @@InvalidHeight ; no - jump\r
+ js @@InvalidHeight0 ; no - jump\r
mov ax,bx ; yes - Set the T.B. Page height to\r
; to the maximum allowed.\r
\r
-@@InvalidHeight:\r
+@@InvalidHeight0:\r
mov [_ScrnLogicalHeight],ax ; Update logical screen height to\r
; reflect the height of a T.B. page\r
cmp ax,[_BottomClip]\r
- jle @@BottomClipOK ; Adjust Clip Rectangle if necessary\r
+ jle @@BottomClipOK1 ; Adjust Clip Rectangle if necessary\r
mov [_BottomClip],ax\r
-@@BottomClipOK:\r
+@@BottomClipOK1:\r
push ax\r
mul [_ScrnLogicalByteWidth] ; Calculate the offset of the second\r
mov cx,ax ; D.B. Page in video ram\r
;------------------------------------------------------------------------\r
\r
_x_set_cliprect proc\r
-ARG left:word,top:word,right:word,bottom:word\r
+;arg left:word,top:word,right:word,bottom:word\r
push bp\r
mov bp,sp\r
- mov ax,[left]\r
- mov bx,[right]\r
+ mov ax,[bp+4]\r
+ mov bx,[bp+8]\r
cmp bx,ax\r
jns @@CorrectXOrder\r
xchg bx,ax\r
@@CorrectXOrder:\r
mov [_LeftClip],ax\r
mov [_RightClip],bx\r
- mov ax,[top]\r
- mov bx,[bottom]\r
+ mov ax,[bp+6]\r
+ mov bx,[bp+10]\r
cmp bx,ax\r
jns @@CorrectYOrder\r
xchg bx,ax\r
_x_wait_vsync endp\r
\r
\r
- end\r
+end\r
;\r
\r
_x_put_pix proc\r
- ARG X:word,Y:word,PgOfs:word,Color:word\r
+ ;ARG X:word,Y:word,PgOfs:word,Color:word\r
push bp ;preserve caller's stack frame\r
mov bp,sp ;point to local stack frame\r
\r
mov ax,[_ScrnLogicalByteWidth]\r
- mul [Y] ;offset of pixel's scan line in page\r
- mov bx,[X]\r
+ mul [BP+6] ;offset of pixel's scan line in page\r
+ mov bx,[BP+4]\r
shr bx,1 ;X/4 = offset of pixel in scan line\r
shr bx,1 ;X/4 = offset of pixel in scan line\r
add bx,ax ;offset of pixel in page\r
- add bx,[PgOfs] ;offset of pixel in display memory\r
+ add bx,[BP+8] ;offset of pixel in display memory\r
mov ax,SCREEN_SEG\r
mov es,ax ;point ES:BX to the pixel's address\r
\r
- mov cl,byte ptr [X]\r
+ mov cl,byte ptr [BP+4]\r
and cl,011b ;CL = pixel's plane\r
mov ax,0100h + MAP_MASK ;AL = index in SC of Map Mask reg\r
shl ah,cl ;set only the bit for the pixel's\r
mov dx,SC_INDEX ;set the Map Mask to enable only the\r
out dx,ax ; pixel's plane\r
\r
- mov al,byte ptr [Color]\r
+ mov al,byte ptr [BP+10]\r
mov es:[bx],al ;draw the pixel in the desired color\r
\r
pop bp ;restore caller's stack frame\r
\r
\r
_x_get_pix proc\r
- ARG x:word,y:word,PageBase:word\r
+ ;ARG x:word,y:word,PageBase:word\r
push bp ;preserve caller's stack frame\r
mov bp,sp ;point to local stack frame\r
\r
mov ax,[_ScrnLogicalByteWidth]\r
- mul [Y] ;offset of pixel's scan line in page\r
- mov bx,[X]\r
+ mul [bp+6] ;offset of pixel's scan line in page\r
+ mov bx,[bp+4]\r
shr bx,1\r
shr bx,1 ;X/4 = offset of pixel in scan line\r
add bx,ax ;offset of pixel in page\r
- add bx,[PageBase] ;offset of pixel in display memory\r
+ add bx,[bp+8] ;offset of pixel in display memory\r
mov ax,SCREEN_SEG\r
mov es,ax ;point ES:BX to the pixel's address\r
\r
- mov ah,byte ptr [X]\r
+ mov ah,byte ptr [bp+4]\r
and ah,011b ;AH = pixel's plane\r
mov al,READ_MAP ;AL = index in GC of the Read Map reg\r
mov dx,GC_INDEX ;set the Read Map to read the pixel's\r