commit
4028269fe1
12 changed files with 94 additions and 94 deletions
|
|
@ -754,12 +754,12 @@ Parms struc
|
||||||
Buffer dw ?
|
Buffer dw ?
|
||||||
BufferLength dw ?
|
BufferLength dw ?
|
||||||
Checksum dw ?
|
Checksum dw ?
|
||||||
Parmsends
|
Parms ends
|
||||||
;
|
;
|
||||||
.model small
|
.model small
|
||||||
.code
|
.code
|
||||||
public _ChecksumChunk
|
public _ChecksumChunk
|
||||||
_ChecksumChunkprocnear
|
_ChecksumChunk proc near
|
||||||
push bp
|
push bp
|
||||||
mov bp,sp
|
mov bp,sp
|
||||||
push si ;save C's register variable
|
push si ;save C's register variable
|
||||||
|
|
@ -779,7 +779,7 @@ ChecksumLoop:
|
||||||
pop si ;restore C's register variable
|
pop si ;restore C's register variable
|
||||||
pop bp
|
pop bp
|
||||||
ret
|
ret
|
||||||
_ChecksumChunkendp
|
_ChecksumChunk endp
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -245,7 +245,7 @@ the whole point.)
|
||||||
.stack 100h
|
.stack 100h
|
||||||
.data
|
.data
|
||||||
; Sample string to search through.
|
; Sample string to search through.
|
||||||
SampleString labelbyte
|
SampleString label byte
|
||||||
db ‘This is a sample string of a long enough length '
|
db ‘This is a sample string of a long enough length '
|
||||||
db ‘so that raw searching speed can outweigh any '
|
db ‘so that raw searching speed can outweigh any '
|
||||||
db ‘extra set-up time that may be required.',0
|
db ‘extra set-up time that may be required.',0
|
||||||
|
|
@ -263,7 +263,7 @@ NoByteFoundMsg db 0dh,0ah
|
||||||
db ‘Buffer exhausted with no match.', 0dh, 0ah, ‘$'
|
db ‘Buffer exhausted with no match.', 0dh, 0ah, ‘$'
|
||||||
|
|
||||||
.code
|
.code
|
||||||
Startprocnear
|
Start proc near
|
||||||
mov ax,@data ;point to standard data segment
|
mov ax,@data ;point to standard data segment
|
||||||
mov ds,ax
|
mov ds,ax
|
||||||
mov dx,offset Prompt
|
mov dx,offset Prompt
|
||||||
|
|
@ -289,7 +289,7 @@ PrintStatus:
|
||||||
int 21h ;report status
|
int 21h ;report status
|
||||||
mov ah,4ch ;return to DOS
|
mov ah,4ch ;return to DOS
|
||||||
int 21h
|
int 21h
|
||||||
Startendp
|
Start endp
|
||||||
|
|
||||||
; Function to search a buffer of a specified length until either a
|
; Function to search a buffer of a specified length until either a
|
||||||
; specified byte or a zero byte is encountered.
|
; specified byte or a zero byte is encountered.
|
||||||
|
|
@ -306,7 +306,7 @@ Startendp
|
||||||
; byte is found
|
; byte is found
|
||||||
; Carry Flag = set if searched-for byte found, reset otherwise
|
; Carry Flag = set if searched-for byte found, reset otherwise
|
||||||
|
|
||||||
SearchMaxLengthprocnear
|
SearchMaxLength proc near
|
||||||
cld
|
cld
|
||||||
SearchMaxLengthLoop:
|
SearchMaxLengthLoop:
|
||||||
lodsb ;get the next byte
|
lodsb ;get the next byte
|
||||||
|
|
@ -324,7 +324,7 @@ ByteFound:
|
||||||
;we found the searched-for byte
|
;we found the searched-for byte
|
||||||
stc ;return "found" status
|
stc ;return "found" status
|
||||||
ret
|
ret
|
||||||
SearchMaxLengthendp
|
SearchMaxLength endp
|
||||||
end Start
|
end Start
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -350,7 +350,7 @@ all the difference.
|
||||||
.stack 100h
|
.stack 100h
|
||||||
.data
|
.data
|
||||||
; Sample string to search through.
|
; Sample string to search through.
|
||||||
SampleStringlabelbyte
|
SampleString label byte
|
||||||
db ‘This is a sample string of a long enough length '
|
db ‘This is a sample string of a long enough length '
|
||||||
db ‘so that raw searching speed can outweigh any '
|
db ‘so that raw searching speed can outweigh any '
|
||||||
db ‘extra set-up time that may be required.',0
|
db ‘extra set-up time that may be required.',0
|
||||||
|
|
@ -403,7 +403,7 @@ PrintStatus:
|
||||||
|
|
||||||
mov ah,4ch ;return to DOS
|
mov ah,4ch ;return to DOS
|
||||||
int 21h
|
int 21h
|
||||||
Startendp
|
Start endp
|
||||||
|
|
||||||
; Function to search a buffer of a specified length until either a
|
; Function to search a buffer of a specified length until either a
|
||||||
; specified byte or a zero byte is encountered.
|
; specified byte or a zero byte is encountered.
|
||||||
|
|
@ -468,7 +468,7 @@ ByteFound:
|
||||||
; we found the searched-for byte
|
; we found the searched-for byte
|
||||||
stc ;return "found" status
|
stc ;return "found" status
|
||||||
ret
|
ret
|
||||||
SearchMaxLengthendp
|
SearchMaxLength endp
|
||||||
end Start
|
end Start
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -395,7 +395,7 @@ Parmsends
|
||||||
.model small
|
.model small
|
||||||
.code
|
.code
|
||||||
public _FindString
|
public _FindString
|
||||||
_FindStringprocnear
|
_FindString proc near
|
||||||
push bp ;preserve caller's stack frame
|
push bp ;preserve caller's stack frame
|
||||||
mov bp,sp ;point to our stack frame
|
mov bp,sp ;point to our stack frame
|
||||||
push si ;preserve caller's register variables
|
push si ;preserve caller's register variables
|
||||||
|
|
@ -458,7 +458,7 @@ FindStringDone:
|
||||||
pop si
|
pop si
|
||||||
pop bp ;restore caller's stack frame
|
pop bp ;restore caller's stack frame
|
||||||
ret
|
ret
|
||||||
_FindStringendp
|
_FindString endp
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -492,7 +492,7 @@ Parmsends
|
||||||
.model small
|
.model small
|
||||||
.code
|
.code
|
||||||
public _FindString
|
public _FindString
|
||||||
_FindStringprocnear
|
_FindString proc near
|
||||||
push bp ;preserve caller's stack frame
|
push bp ;preserve caller's stack frame
|
||||||
mov bp,sp ;point to our stack frame
|
mov bp,sp ;point to our stack frame
|
||||||
push si ;preserve caller's register variables
|
push si ;preserve caller's register variables
|
||||||
|
|
@ -559,7 +559,7 @@ FindStringDone:
|
||||||
pop si
|
pop si
|
||||||
pop bp ;restore caller's stack frame
|
pop bp ;restore caller's stack frame
|
||||||
ret
|
ret
|
||||||
_FindStringendp
|
_FindString endp
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -743,7 +743,7 @@ parmsends
|
||||||
.model small
|
.model small
|
||||||
.code
|
.code
|
||||||
public _Div
|
public _Div
|
||||||
_Divprocnear
|
_Div proc near
|
||||||
push bp ;preserve caller's stack frame
|
push bp ;preserve caller's stack frame
|
||||||
mov bp,sp ;point to our stack frame
|
mov bp,sp ;point to our stack frame
|
||||||
push si ;preserve caller's register variables
|
push si ;preserve caller's register variables
|
||||||
|
|
@ -778,7 +778,7 @@ DivLoop:
|
||||||
pop si
|
pop si
|
||||||
pop bp ;restore caller's stack frame
|
pop bp ;restore caller's stack frame
|
||||||
ret
|
ret
|
||||||
_Divendp
|
_Div endp
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,12 +85,12 @@ registers.
|
||||||
;
|
;
|
||||||
; By Michael Abrash
|
; By Michael Abrash
|
||||||
;
|
;
|
||||||
stacksegmentword stack 'STACK'
|
stack segment word stack 'STACK'
|
||||||
db512 dup (?)
|
db 512 dup (?)
|
||||||
stackends
|
stack ends
|
||||||
;
|
;
|
||||||
datasegment word 'DATA'
|
data segment word 'DATA'
|
||||||
IMAGE_WIDTHEQU 4 ;in bytes
|
IMAGE_WIDTH EQU 4 ;in bytes
|
||||||
IMAGE_HEIGHT EQU 32 ;in pixels
|
IMAGE_HEIGHT EQU 32 ;in pixels
|
||||||
LEFT_BOUND EQU 10 ;in bytes
|
LEFT_BOUND EQU 10 ;in bytes
|
||||||
RIGHT_BOUND EQU 66 ;in bytes
|
RIGHT_BOUND EQU 66 ;in bytes
|
||||||
|
|
@ -105,11 +105,11 @@ READ_MAP EQU 4 ;Read Map register index in GC
|
||||||
;
|
;
|
||||||
PatternPlane0 label byte
|
PatternPlane0 label byte
|
||||||
db 32 dup (0ffh,0ffh,0,0)
|
db 32 dup (0ffh,0ffh,0,0)
|
||||||
PatternPlane1 labelbyte
|
PatternPlane1 label byte
|
||||||
db 32 dup (0ffh,0,0ffh,0)
|
db 32 dup (0ffh,0,0ffh,0)
|
||||||
PatternPlane2 labelbyte
|
PatternPlane2 label byte
|
||||||
db 32 dup (0f0h,0f0h,0f0h,0f0h)
|
db 32 dup (0f0h,0f0h,0f0h,0f0h)
|
||||||
PatternPlane3 labelbyte
|
PatternPlane3 label byte
|
||||||
db 32 dup (0cch,0cch,0cch,0cch)
|
db 32 dup (0cch,0cch,0cch,0cch)
|
||||||
;
|
;
|
||||||
; Temporary storage for 16-color image during animation.
|
; Temporary storage for 16-color image during animation.
|
||||||
|
|
@ -124,7 +124,7 @@ ImagePlane3 db 32*4 dup (?)
|
||||||
ImageX dw 40 ;in bytes
|
ImageX dw 40 ;in bytes
|
||||||
ImageY dw 100 ;in pixels
|
ImageY dw 100 ;in pixels
|
||||||
ImageXDirection dw 1 ;in bytes
|
ImageXDirection dw 1 ;in bytes
|
||||||
dataends
|
data ends
|
||||||
;
|
;
|
||||||
code segment word 'CODE'
|
code segment word 'CODE'
|
||||||
assume cs:code,ds:data
|
assume cs:code,ds:data
|
||||||
|
|
@ -197,12 +197,12 @@ DelayLoop:
|
||||||
int 10h
|
int 10h
|
||||||
mov ah,4ch
|
mov ah,4ch
|
||||||
int 21h
|
int 21h
|
||||||
Startendp
|
Start endp
|
||||||
;
|
;
|
||||||
; Draws the image at offset DS:SI to the current image location in
|
; Draws the image at offset DS:SI to the current image location in
|
||||||
; VGA memory.
|
; VGA memory.
|
||||||
;
|
;
|
||||||
DrawImageprocnear
|
DrawImage proc near
|
||||||
mov ax,VGA_SEGMENT
|
mov ax,VGA_SEGMENT
|
||||||
mov es,ax
|
mov es,ax
|
||||||
call GetImageOffset ;ES:DI is the destination address for the
|
call GetImageOffset ;ES:DI is the destination address for the
|
||||||
|
|
@ -233,7 +233,7 @@ DrawImageLoop:
|
||||||
cmp al,10h ;have we done all four planes?
|
cmp al,10h ;have we done all four planes?
|
||||||
jnz DrawImagePlaneLoop
|
jnz DrawImagePlaneLoop
|
||||||
ret
|
ret
|
||||||
DrawImageendp
|
DrawImage endp
|
||||||
;
|
;
|
||||||
; Copies the image from its current location in VGA memory into the
|
; Copies the image from its current location in VGA memory into the
|
||||||
; buffer at DS:DI.
|
; buffer at DS:DI.
|
||||||
|
|
@ -274,7 +274,7 @@ GetImageLoop:
|
||||||
push es
|
push es
|
||||||
pop ds ;restore original DS
|
pop ds ;restore original DS
|
||||||
ret
|
ret
|
||||||
GetImageendp
|
GetImage endp
|
||||||
;
|
;
|
||||||
; Erases the image at its current location.
|
; Erases the image at its current location.
|
||||||
;
|
;
|
||||||
|
|
@ -435,7 +435,7 @@ VLineLoop:
|
||||||
; provides the data written to display
|
; provides the data written to display
|
||||||
; memory, and AL is actually ignored)
|
; memory, and AL is actually ignored)
|
||||||
add di,SCREEN_WIDTH-1 ;point to the next scan line
|
add di,SCREEN_WIDTH-1 ;point to the next scan line
|
||||||
loopVLineLoop
|
loop VLineLoop
|
||||||
;
|
;
|
||||||
; Select write mode 0 and read mode 1.
|
; Select write mode 0 and read mode 1.
|
||||||
;
|
;
|
||||||
|
|
@ -513,12 +513,12 @@ WaitKeyLoop:
|
||||||
int 10h ;return to text mode
|
int 10h ;return to text mode
|
||||||
mov ah,4ch
|
mov ah,4ch
|
||||||
int 21h ;done
|
int 21h ;done
|
||||||
Startendp
|
Start endp
|
||||||
;
|
;
|
||||||
; Enables set/reset for all planes, and sets the set/reset color
|
; Enables set/reset for all planes, and sets the set/reset color
|
||||||
; to AL.
|
; to AL.
|
||||||
;
|
;
|
||||||
SelectSetResetColorprocnear
|
SelectSetResetColor proc near
|
||||||
mov dx,GC_INDEX
|
mov dx,GC_INDEX
|
||||||
push ax ;preserve color
|
push ax ;preserve color
|
||||||
mov al,SET_RESET
|
mov al,SET_RESET
|
||||||
|
|
@ -533,7 +533,7 @@ SelectSetResetColorprocnear
|
||||||
mov al,0fh
|
mov al,0fh
|
||||||
out dx,al ;enable set/reset for all planes
|
out dx,al ;enable set/reset for all planes
|
||||||
ret
|
ret
|
||||||
SelectSetResetColorendp
|
SelectSetResetColor endp
|
||||||
code ends
|
code ends
|
||||||
end Start
|
end Start
|
||||||
```
|
```
|
||||||
|
|
@ -636,7 +636,7 @@ COLOR_DONT_CARE EQU 7 ;Color Don't Care register index in GC
|
||||||
;
|
;
|
||||||
code segment word 'CODE'
|
code segment word 'CODE'
|
||||||
assume cs:code
|
assume cs:code
|
||||||
Startprocnear
|
Start proc near
|
||||||
;
|
;
|
||||||
; Select graphics mode 12h.
|
; Select graphics mode 12h.
|
||||||
;
|
;
|
||||||
|
|
@ -698,7 +698,7 @@ DrawDiagonalLoop:
|
||||||
; point to the next scan line
|
; point to the next scan line
|
||||||
ror al,1 ;move the pixel mask one pixel to the right
|
ror al,1 ;move the pixel mask one pixel to the right
|
||||||
adc bx,0 ;advance to the next byte if the pixel mask wrapped
|
adc bx,0 ;advance to the next byte if the pixel mask wrapped
|
||||||
loopDrawDiagonalLoop
|
loop DrawDiagonalLoop
|
||||||
;
|
;
|
||||||
; Wait for a key to be pressed to end, then return to text mode and
|
; Wait for a key to be pressed to end, then return to text mode and
|
||||||
; return to DOS.
|
; return to DOS.
|
||||||
|
|
@ -713,7 +713,7 @@ WaitKeyLoop:
|
||||||
int 10h ;return to text mode
|
int 10h ;return to text mode
|
||||||
mov ah,4ch
|
mov ah,4ch
|
||||||
int 21h ;done
|
int 21h ;done
|
||||||
Startendp
|
Start endp
|
||||||
code ends
|
code ends
|
||||||
end Start
|
end Start
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -557,14 +557,14 @@ x= x+1
|
||||||
; Used to label the colors of the color bars. (Color values are
|
; Used to label the colors of the color bars. (Color values are
|
||||||
; filled in on the fly.)
|
; filled in on the fly.)
|
||||||
;
|
;
|
||||||
ColorNumberslabelbyte
|
ColorNumbers label byte
|
||||||
rept 16
|
rept 16
|
||||||
db ‘000h', 0ah, 8, 8, 8, 8
|
db ‘000h', 0ah, 8, 8, 8, 8
|
||||||
endm
|
endm
|
||||||
COLOR_ENTRY_LENGTHequ($-ColorNumbers)/16
|
COLOR_ENTRY_LENGTH equ ($-ColorNumbers)/16
|
||||||
db ‘$'
|
db ‘$'
|
||||||
;
|
;
|
||||||
CurrentColordb?
|
CurrentColor db ?
|
||||||
;
|
;
|
||||||
; Space for the array of 16 colors we'll pass to the BIOS, plus
|
; Space for the array of 16 colors we'll pass to the BIOS, plus
|
||||||
; an overscan setting of black.
|
; an overscan setting of black.
|
||||||
|
|
@ -574,7 +574,7 @@ Data ends
|
||||||
;
|
;
|
||||||
Code segment
|
Code segment
|
||||||
assume cs:Code, ds:Data
|
assume cs:Code, ds:Data
|
||||||
Start procnear
|
Start proc near
|
||||||
cld
|
cld
|
||||||
mov ax,Data
|
mov ax,Data
|
||||||
mov ds,ax
|
mov ds,ax
|
||||||
|
|
@ -764,7 +764,7 @@ ColorNumberLoop:
|
||||||
mov dx,offset ColorNumbers
|
mov dx,offset ColorNumbers
|
||||||
int 21h ;put up the attribute numbers
|
int 21h ;put up the attribute numbers
|
||||||
ret
|
ret
|
||||||
ColorNumbersUpendp
|
ColorNumbersUp endp
|
||||||
;
|
;
|
||||||
Start endp
|
Start endp
|
||||||
Code ends
|
Code ends
|
||||||
|
|
@ -820,7 +820,7 @@ WAIT_KEY macro
|
||||||
endm
|
endm
|
||||||
;
|
;
|
||||||
stack segment para stack ‘STACK'
|
stack segment para stack ‘STACK'
|
||||||
db512 dup (?)
|
db 512 dup (?)
|
||||||
stack ends
|
stack ends
|
||||||
;
|
;
|
||||||
Data segment word ‘DATA'
|
Data segment word ‘DATA'
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ SCREEN_WIDTH equ 640
|
||||||
SCREEN_HEIGHT equ 350
|
SCREEN_HEIGHT equ 350
|
||||||
CRTC_INDEX equ 3d4h ;CRT Controller Index register
|
CRTC_INDEX equ 3d4h ;CRT Controller Index register
|
||||||
OVERFLOW equ 7 ;index of Overflow reg in CRTC
|
OVERFLOW equ 7 ;index of Overflow reg in CRTC
|
||||||
MAXIMUM_SCAN_LINEequ 9 ;index of Maximum Scan Line register
|
MAXIMUM_SCAN_LINE equ 9 ;index of Maximum Scan Line register
|
||||||
; in CRTC
|
; in CRTC
|
||||||
START_ADDRESS_HIGH equ 0ch ;index of Start Address High register
|
START_ADDRESS_HIGH equ 0ch ;index of Start Address High register
|
||||||
; in CRTC
|
; in CRTC
|
||||||
|
|
@ -318,7 +318,7 @@ CountVerticalSyncsLoop:
|
||||||
int 10h ;return to text mode
|
int 10h ;return to text mode
|
||||||
mov ah,4ch
|
mov ah,4ch
|
||||||
int 21h ;return to DOS
|
int 21h ;return to DOS
|
||||||
Startendp
|
Start endp
|
||||||
;*********************************************************************
|
;*********************************************************************
|
||||||
; Waits for the leading edge of the vertical sync pulse.
|
; Waits for the leading edge of the vertical sync pulse.
|
||||||
;
|
;
|
||||||
|
|
@ -328,7 +328,7 @@ Startendp
|
||||||
;
|
;
|
||||||
; Registers altered: AL, DX
|
; Registers altered: AL, DX
|
||||||
;
|
;
|
||||||
WaitForVerticalSyncStartprocnear
|
WaitForVerticalSyncStart proc near
|
||||||
mov dx,INPUT_STATUS_0
|
mov dx,INPUT_STATUS_0
|
||||||
WaitNotVerticalSync:
|
WaitNotVerticalSync:
|
||||||
in al,dx
|
in al,dx
|
||||||
|
|
@ -349,7 +349,7 @@ WaitForVerticalSyncStart endp
|
||||||
;
|
;
|
||||||
; Registers altered: AL, DX
|
; Registers altered: AL, DX
|
||||||
;
|
;
|
||||||
WaitForVerticalSyncEndprocnear
|
WaitForVerticalSyncEnd proc near
|
||||||
mov dx,INPUT_STATUS_0
|
mov dx,INPUT_STATUS_0
|
||||||
WaitVerticalSync2:
|
WaitVerticalSync2:
|
||||||
in al,dx
|
in al,dx
|
||||||
|
|
@ -360,7 +360,7 @@ WaitNotVerticalSync2:
|
||||||
test al,08h
|
test al,08h
|
||||||
jnz WaitNotVerticalSync2
|
jnz WaitNotVerticalSync2
|
||||||
ret
|
ret
|
||||||
WaitForVerticalSyncEndendp
|
WaitForVerticalSyncEnd endp
|
||||||
;*********************************************************************
|
;*********************************************************************
|
||||||
; Sets the start address to the value specifed by StartAddress.
|
; Sets the start address to the value specifed by StartAddress.
|
||||||
; Wait for the trailing edge of vertical sync before setting so that
|
; Wait for the trailing edge of vertical sync before setting so that
|
||||||
|
|
@ -751,7 +751,7 @@ MyStack segment para stack 'STACK'
|
||||||
db 512 dup (0)
|
db 512 dup (0)
|
||||||
MyStack ends
|
MyStack ends
|
||||||
;*********************************************************************
|
;*********************************************************************
|
||||||
Datasegment
|
Data segment
|
||||||
SplitScreenLine dw ? ;line the split screen currently
|
SplitScreenLine dw ? ;line the split screen currently
|
||||||
; starts after
|
; starts after
|
||||||
StartAddress dw ? ;display memory offset at which
|
StartAddress dw ? ;display memory offset at which
|
||||||
|
|
@ -763,7 +763,7 @@ Data ends
|
||||||
Code segment
|
Code segment
|
||||||
assume cs:Code, ds:Data
|
assume cs:Code, ds:Data
|
||||||
;*********************************************************************
|
;*********************************************************************
|
||||||
Startproc near
|
Start proc near
|
||||||
mov ax,Data
|
mov ax,Data
|
||||||
mov ds,ax
|
mov ds,ax
|
||||||
;
|
;
|
||||||
|
|
@ -837,7 +837,7 @@ ColumnLoop2:
|
||||||
; panning effects can be seen easily
|
; panning effects can be seen easily
|
||||||
inc di
|
inc di
|
||||||
inc di
|
inc di
|
||||||
loopColumnLoop2
|
loop ColumnLoop2
|
||||||
ror ax,1 ;shift pattern word
|
ror ax,1 ;shift pattern word
|
||||||
dec dx
|
dec dx
|
||||||
jnz RowLoop2
|
jnz RowLoop2
|
||||||
|
|
@ -847,7 +847,7 @@ loopColumnLoop2
|
||||||
; screen jerks back and forth as the pel panning setting cycles.
|
; screen jerks back and forth as the pel panning setting cycles.
|
||||||
;
|
;
|
||||||
mov cx,200 ;pan 200 pixels to the left
|
mov cx,200 ;pan 200 pixels to the left
|
||||||
callPanRight
|
call PanRight
|
||||||
;
|
;
|
||||||
; Wait for a key press (don't echo character).
|
; Wait for a key press (don't echo character).
|
||||||
;
|
;
|
||||||
|
|
@ -904,7 +904,7 @@ endif
|
||||||
int 10h ;return to text mode
|
int 10h ;return to text mode
|
||||||
mov ah,4ch
|
mov ah,4ch
|
||||||
int 21h ;return to DOS
|
int 21h ;return to DOS
|
||||||
Startendp
|
Start endp
|
||||||
;*********************************************************************
|
;*********************************************************************
|
||||||
; Waits for the leading edge of the vertical sync pulse.
|
; Waits for the leading edge of the vertical sync pulse.
|
||||||
;
|
;
|
||||||
|
|
@ -997,7 +997,7 @@ SetPelPan proc near
|
||||||
mov al,[PelPan]
|
mov al,[PelPan]
|
||||||
out dx,al ;load the new Pel Pan setting
|
out dx,al ;load the new Pel Pan setting
|
||||||
ret
|
ret
|
||||||
SetPelPanendp
|
SetPelPan endp
|
||||||
;*********************************************************************
|
;*********************************************************************
|
||||||
; Sets the scan line the split screen starts after to the scan line
|
; Sets the scan line the split screen starts after to the scan line
|
||||||
; specified by SplitScreenLine.
|
; specified by SplitScreenLine.
|
||||||
|
|
@ -1104,8 +1104,8 @@ DoSetStartAddress:
|
||||||
ret
|
ret
|
||||||
PanRight endp
|
PanRight endp
|
||||||
;*********************************************************************
|
;*********************************************************************
|
||||||
Codeends
|
Code ends
|
||||||
endStart
|
end Start
|
||||||
```
|
```
|
||||||
|
|
||||||
### Notes on Setting and Reading Registers
|
### Notes on Setting and Reading Registers
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ the way up to 360x480—and that's with the vanilla IBM VGA!
|
||||||
|
|
||||||
In this chapter, I'm going to focus on one of my favorite 256-color
|
In this chapter, I'm going to focus on one of my favorite 256-color
|
||||||
modes, which provides 320x400 resolution and two graphics pages and can
|
modes, which provides 320x400 resolution and two graphics pages and can
|
||||||
be set up with very little reof the VGA. In the next chapter, I'll
|
be set up with very little reprogramming of the VGA. In the next chapter, I'll
|
||||||
discuss higher-resolution 256-color modes, and starting in Chapter 47,
|
discuss higher-resolution 256-color modes, and starting in Chapter 47,
|
||||||
I'll cover the high-performance "Mode X" 256-color programming that many
|
I'll cover the high-performance "Mode X" 256-color programming that many
|
||||||
games use.
|
games use.
|
||||||
|
|
@ -283,7 +283,7 @@ endif
|
||||||
;
|
;
|
||||||
; Macro to output a constant value to an indexed VGA register.
|
; Macro to output a constant value to an indexed VGA register.
|
||||||
;
|
;
|
||||||
CONSTANT_TO_INDEXED_REGISTERmacroADDRESS, INDEX, VALUE
|
CONSTANT_TO_INDEXED_REGISTER macro ADDRESS, INDEX, VALUE
|
||||||
mov dx,ADDRESS
|
mov dx,ADDRESS
|
||||||
mov ax,(VALUE shl 8) + INDEX
|
mov ax,(VALUE shl 8) + INDEX
|
||||||
OUT_WORD
|
OUT_WORD
|
||||||
|
|
@ -309,7 +309,7 @@ ColorLoop:
|
||||||
; line descriptor list
|
; line descriptor list
|
||||||
LineLoop:
|
LineLoop:
|
||||||
mov cx,[si+StartX] ;set the initial X coordinate
|
mov cx,[si+StartX] ;set the initial X coordinate
|
||||||
cmpcx,-1
|
cmp cx,-1
|
||||||
jz LinesDone ;a descriptor with a -1 X
|
jz LinesDone ;a descriptor with a -1 X
|
||||||
; coordinate marks the end
|
; coordinate marks the end
|
||||||
; of the list
|
; of the list
|
||||||
|
|
@ -341,7 +341,7 @@ LinesDone:
|
||||||
;
|
;
|
||||||
call GetNextKey
|
call GetNextKey
|
||||||
mov ax,0003h
|
mov ax,0003h
|
||||||
int 10h text mode
|
int 10h ;text mode
|
||||||
mov ah,4ch
|
mov ah,4ch
|
||||||
int 21h ;done
|
int 21h ;done
|
||||||
;
|
;
|
||||||
|
|
@ -477,7 +477,7 @@ WritePixel proc near
|
||||||
; the pixel
|
; the pixel
|
||||||
mov es:[di],bl ;draw the pixel
|
mov es:[di],bl ;draw the pixel
|
||||||
ret
|
ret
|
||||||
WritePixelendp
|
WritePixel endp
|
||||||
;
|
;
|
||||||
; Reads the color of the pixel at the specified location in 320x400
|
; Reads the color of the pixel at the specified location in 320x400
|
||||||
; 256-color mode.
|
; 256-color mode.
|
||||||
|
|
@ -491,7 +491,7 @@ WritePixelendp
|
||||||
;
|
;
|
||||||
; Registers altered: AX, CX, DX, SI, ES
|
; Registers altered: AX, CX, DX, SI, ES
|
||||||
;
|
;
|
||||||
ReadPixelprocnear
|
ReadPixel proc near
|
||||||
mov ax,VGA_SEGMENT
|
mov ax,VGA_SEGMENT
|
||||||
mov es,ax ;point to display memory
|
mov es,ax ;point to display memory
|
||||||
mov ax,SCREEN_WIDTH/4
|
mov ax,SCREEN_WIDTH/4
|
||||||
|
|
@ -511,9 +511,9 @@ ReadPixelprocnear
|
||||||
mov dx,GC_INDEX
|
mov dx,GC_INDEX
|
||||||
OUT_WORD ;set to read from the proper plane for
|
OUT_WORD ;set to read from the proper plane for
|
||||||
; the pixel
|
; the pixel
|
||||||
lodsbyte ptr es:[si] ;read the pixel
|
lods byte ptr es:[si] ;read the pixel
|
||||||
ret
|
ret
|
||||||
ReadPixelendp
|
ReadPixel endp
|
||||||
;
|
;
|
||||||
; Waits for the next key and returns it in AX.
|
; Waits for the next key and returns it in AX.
|
||||||
;
|
;
|
||||||
|
|
@ -690,7 +690,7 @@ endif
|
||||||
;
|
;
|
||||||
; Macro to output a constant value to an indexed VGA register.
|
; Macro to output a constant value to an indexed VGA register.
|
||||||
;
|
;
|
||||||
CONSTANT_TO_INDEXED_REGISTERmacroADDRESS, INDEX, VALUE
|
CONSTANT_TO_INDEXED_REGISTER macro ADDRESS, INDEX, VALUE
|
||||||
mov dx,ADDRESS
|
mov dx,ADDRESS
|
||||||
mov ax,(VALUE shl 8) + INDEX
|
mov ax,(VALUE shl 8) + INDEX
|
||||||
OUT_WORD
|
OUT_WORD
|
||||||
|
|
@ -702,7 +702,7 @@ Start proc near
|
||||||
;
|
;
|
||||||
; Set 320x400 256-color mode.
|
; Set 320x400 256-color mode.
|
||||||
;
|
;
|
||||||
callSet320By400Mode
|
call Set320By400Mode
|
||||||
;
|
;
|
||||||
; We're in 320x400 256-color mode, with page 0 displayed.
|
; We're in 320x400 256-color mode, with page 0 displayed.
|
||||||
; Let's fill page 0 with color bars slanting down and to the right.
|
; Let's fill page 0 with color bars slanting down and to the right.
|
||||||
|
|
@ -722,7 +722,7 @@ callSet320By400Mode
|
||||||
;
|
;
|
||||||
; Wait for a key and flip to page 1 when one is pressed.
|
; Wait for a key and flip to page 1 when one is pressed.
|
||||||
;
|
;
|
||||||
callGetNextKey
|
call GetNextKey
|
||||||
CONSTANT_TO_INDEXED_REGISTER CRTC_INDEX,START_ADDRESS_HIGH,80h
|
CONSTANT_TO_INDEXED_REGISTER CRTC_INDEX,START_ADDRESS_HIGH,80h
|
||||||
;set the Start Address High register
|
;set the Start Address High register
|
||||||
; to 80h, for a start address of 8000h
|
; to 80h, for a start address of 8000h
|
||||||
|
|
@ -735,7 +735,7 @@ callSet320By400Mode
|
||||||
;
|
;
|
||||||
; Wait for another key and flip back to page 0 when one is pressed.
|
; Wait for another key and flip back to page 0 when one is pressed.
|
||||||
;
|
;
|
||||||
callGetNextKey
|
call GetNextKey
|
||||||
CONSTANT_TO_INDEXED_REGISTER CRTC_INDEX,START_ADDRESS_HIGH,00h
|
CONSTANT_TO_INDEXED_REGISTER CRTC_INDEX,START_ADDRESS_HIGH,00h
|
||||||
;set the Start Address High register
|
;set the Start Address High register
|
||||||
; to 00h, for a start address of 0000h
|
; to 00h, for a start address of 0000h
|
||||||
|
|
@ -757,7 +757,7 @@ Start endp
|
||||||
;
|
;
|
||||||
; Output: none
|
; Output: none
|
||||||
;
|
;
|
||||||
Set320By400Modeprocnear
|
Set320By400Mode proc near
|
||||||
;
|
;
|
||||||
; First, go to normal 320x200 256-color mode, which is really a
|
; First, go to normal 320x200 256-color mode, which is really a
|
||||||
; 320x400 256-color mode with each line scanned twice.
|
; 320x400 256-color mode with each line scanned twice.
|
||||||
|
|
@ -831,7 +831,7 @@ CONSTANT_TO_INDEXED_REGISTER SC_INDEX,MAP_MASK,0fh
|
||||||
out dx,al
|
out dx,al
|
||||||
inc dx
|
inc dx
|
||||||
in al,dx
|
in al,dx
|
||||||
and al,not40h ;turn off doubleword
|
and al,not 40h ;turn off doubleword
|
||||||
out dx,al
|
out dx,al
|
||||||
dec dx
|
dec dx
|
||||||
mov al,MODE_CONTROL
|
mov al,MODE_CONTROL
|
||||||
|
|
@ -853,7 +853,7 @@ Set320By400Mode endp
|
||||||
; make them slant down and to the left, 0 to make
|
; make them slant down and to the left, 0 to make
|
||||||
; them vertical.
|
; them vertical.
|
||||||
;
|
;
|
||||||
ColorBarsUpprocnear
|
ColorBarsUp proc near
|
||||||
mov ax,VGA_SEGMENT
|
mov ax,VGA_SEGMENT
|
||||||
mov es,ax ;point to display memory
|
mov es,ax ;point to display memory
|
||||||
sub bh,bh ;start with color 0
|
sub bh,bh ;start with color 0
|
||||||
|
|
@ -867,7 +867,7 @@ RowLoop:
|
||||||
;4 pixels at each address, so
|
;4 pixels at each address, so
|
||||||
; each 320-pixel row is 80 bytes wide
|
; each 320-pixel row is 80 bytes wide
|
||||||
; in each plane
|
; in each plane
|
||||||
pus h bx ;save the row-start color
|
push bx ;save the row-start color
|
||||||
ColumnLoop:
|
ColumnLoop:
|
||||||
MAP_SELECT = 1
|
MAP_SELECT = 1
|
||||||
rept 4 ;do all 4 pixels at this address with
|
rept 4 ;do all 4 pixels at this address with
|
||||||
|
|
@ -887,11 +887,11 @@ MAP_SELECT = MAP_SELECT shl 1
|
||||||
dec si ;count down lines on the screen
|
dec si ;count down lines on the screen
|
||||||
jnz RowLoop
|
jnz RowLoop
|
||||||
ret
|
ret
|
||||||
ColorBarsUpendp
|
ColorBarsUp endp
|
||||||
;
|
;
|
||||||
; Waits for the next key and returns it in AX.
|
; Waits for the next key and returns it in AX.
|
||||||
;
|
;
|
||||||
GetNextKeyprocnear
|
GetNextKey proc near
|
||||||
WaitKey:
|
WaitKey:
|
||||||
mov ah,1
|
mov ah,1
|
||||||
int 16h
|
int 16h
|
||||||
|
|
@ -901,9 +901,9 @@ WaitKey:
|
||||||
ret
|
ret
|
||||||
GetNextKey endp
|
GetNextKey endp
|
||||||
;
|
;
|
||||||
Codeends
|
Code ends
|
||||||
;
|
;
|
||||||
endStart
|
end Start
|
||||||
```
|
```
|
||||||
|
|
||||||
When you run Listing 31.2, note the extremely smooth edges and fine
|
When you run Listing 31.2, note the extremely smooth edges and fine
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ WORD_OUTS_OK equ 1 ;set to 0 to assemble for
|
||||||
; computers that can't handle
|
; computers that can't handle
|
||||||
; word outs to indexed VGA registers
|
; word outs to indexed VGA registers
|
||||||
;
|
;
|
||||||
_DATAsegmentpublic byte ‘DATA'
|
_DATA segment public byte ‘DATA'
|
||||||
;
|
;
|
||||||
; 360x480 256-color mode CRT Controller register settings.
|
; 360x480 256-color mode CRT Controller register settings.
|
||||||
; (Courtesy of John Bridges.)
|
; (Courtesy of John Bridges.)
|
||||||
|
|
@ -171,7 +171,7 @@ vptbl dw 06b00h ; horz total
|
||||||
dw 00616h ; v blank end
|
dw 00616h ; v blank end
|
||||||
dw 0e317h ; turn on byte mode
|
dw 0e317h ; turn on byte mode
|
||||||
vpend label word
|
vpend label word
|
||||||
_DATAends
|
_DATA ends
|
||||||
;
|
;
|
||||||
; Macro to output a word value to a port.
|
; Macro to output a word value to a port.
|
||||||
;
|
;
|
||||||
|
|
@ -199,7 +199,7 @@ _TEXTsegment byte public ‘CODE'
|
||||||
; Returns: nothing
|
; Returns: nothing
|
||||||
;
|
;
|
||||||
public _Set360x480Mode
|
public _Set360x480Mode
|
||||||
_Set360x480Modeprocnear
|
_Set360x480Mode proc near
|
||||||
push si ;preserve C register vars
|
push si ;preserve C register vars
|
||||||
push di
|
push di
|
||||||
mov ax,12h ; start with mode 12h
|
mov ax,12h ; start with mode 12h
|
||||||
|
|
@ -239,7 +239,7 @@ _Set360x480Modeprocnear
|
||||||
pop di ;restore C register vars
|
pop di ;restore C register vars
|
||||||
pop si
|
pop si
|
||||||
ret
|
ret
|
||||||
_Set360x480Modeendp
|
_Set360x480Mode endp
|
||||||
;
|
;
|
||||||
; Draws a pixel in the specified color at the specified
|
; Draws a pixel in the specified color at the specified
|
||||||
; location in 360x480 256-color mode.
|
; location in 360x480 256-color mode.
|
||||||
|
|
@ -258,7 +258,7 @@ Color dw ? ;color in which to draw (in the
|
||||||
DParms ends
|
DParms ends
|
||||||
;
|
;
|
||||||
public _Draw360x480Dot
|
public _Draw360x480Dot
|
||||||
_Draw360x480Dotprocnear
|
_Draw360x480Dot proc near
|
||||||
push bp ;preserve caller's BP
|
push bp ;preserve caller's BP
|
||||||
mov bp,sp ;point to stack frame
|
mov bp,sp ;point to stack frame
|
||||||
push si ;preserve C register vars
|
push si ;preserve C register vars
|
||||||
|
|
@ -289,7 +289,7 @@ _Draw360x480Dotprocnear
|
||||||
pop si
|
pop si
|
||||||
pop bp ;restore caller's BP
|
pop bp ;restore caller's BP
|
||||||
ret
|
ret
|
||||||
_Draw360x480Dotendp
|
_Draw360x480Dot endp
|
||||||
;
|
;
|
||||||
; Reads the color of the pixel at the specified
|
; Reads the color of the pixel at the specified
|
||||||
; location in 360x480 256-color mode.
|
; location in 360x480 256-color mode.
|
||||||
|
|
@ -306,7 +306,7 @@ ReadY dw ? ;Y coordinate from which to read
|
||||||
RParms ends
|
RParms ends
|
||||||
;
|
;
|
||||||
public _Read360x480Dot
|
public _Read360x480Dot
|
||||||
_Read360x480Dotprocnear
|
_Read360x480Dot proc near
|
||||||
push bp ;preserve caller's BP
|
push bp ;preserve caller's BP
|
||||||
mov bp,sp ;point to stack frame
|
mov bp,sp ;point to stack frame
|
||||||
push si ;preserve C register vars
|
push si ;preserve C register vars
|
||||||
|
|
@ -336,7 +336,7 @@ _Read360x480Dotprocnear
|
||||||
pop bp ;restore caller's BP
|
pop bp ;restore caller's BP
|
||||||
ret
|
ret
|
||||||
_Read360x480Dot endp
|
_Read360x480Dot endp
|
||||||
_TEX Tends
|
_TEXT ends
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -532,7 +532,7 @@ FillVertLoop:
|
||||||
jnz FillHorzLoop ;no, do the next column
|
jnz FillHorzLoop ;no, do the next column
|
||||||
ret;
|
ret;
|
||||||
|
|
||||||
endStart
|
end Start
|
||||||
```
|
```
|
||||||
|
|
||||||
Note the jagged lines at the corners of the screen when you run Listing
|
Note the jagged lines at the corners of the screen when you run Listing
|
||||||
|
|
|
||||||
|
|
@ -720,7 +720,7 @@ DrawLoop:
|
||||||
dec dx ;count down the lines of the image
|
dec dx ;count down the lines of the image
|
||||||
jnz DrawLoop
|
jnz DrawLoop
|
||||||
ret
|
ret
|
||||||
DrawObjectendp
|
DrawObject endp
|
||||||
;
|
;
|
||||||
Code ends
|
Code ends
|
||||||
end Start
|
end Start
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ SCparms ends
|
||||||
|
|
||||||
align ALIGNMENT
|
align ALIGNMENT
|
||||||
public -CosSin
|
public -CosSin
|
||||||
-CosSinprocnear
|
-CosSin proc near
|
||||||
push bp ;preserve stack frame
|
push bp ;preserve stack frame
|
||||||
mov bp,sp ;set up local stack frame
|
mov bp,sp ;set up local stack frame
|
||||||
|
|
||||||
|
|
@ -272,7 +272,7 @@ CSDone:
|
||||||
|
|
||||||
pop bp;restore stack frame
|
pop bp;restore stack frame
|
||||||
ret
|
ret
|
||||||
-CosSinendp
|
-CosSin endp
|
||||||
;=====================================================================
|
;=====================================================================
|
||||||
; Matrix multiplies Xform by SourceVec, and stores the result in
|
; Matrix multiplies Xform by SourceVec, and stores the result in
|
||||||
; DestVec. Multiplies a 4x4 matrix times a 4x1 matrix; the result
|
; DestVec. Multiplies a 4x4 matrix times a 4x1 matrix; the result
|
||||||
|
|
@ -351,7 +351,7 @@ pop di;restore register variables
|
||||||
pop si
|
pop si
|
||||||
pop bp;restore stack frame
|
pop bp;restore stack frame
|
||||||
ret
|
ret
|
||||||
-XformVecendp
|
-XformVec endp
|
||||||
;=====================================================================
|
;=====================================================================
|
||||||
; Matrix multiplies SourceXform1 by SourceXform2 and stores the
|
; Matrix multiplies SourceXform1 by SourceXform2 and stores the
|
||||||
; result in DestXform. Multiplies a 4x4 matrix times a 4x4 matrix;
|
; result in DestXform. Multiplies a 4x4 matrix times a 4x4 matrix;
|
||||||
|
|
@ -475,7 +475,7 @@ pop di;restore register variables
|
||||||
pop si
|
pop si
|
||||||
pop bp;restore stack frame
|
pop bp;restore stack frame
|
||||||
ret
|
ret
|
||||||
-ConcatXformsendp
|
-ConcatXforms endp
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -339,7 +339,7 @@ SCparms ends
|
||||||
|
|
||||||
alignALIGNMENT
|
alignALIGNMENT
|
||||||
public _CosSin
|
public _CosSin
|
||||||
_CosSin procnear
|
_CosSin proc near
|
||||||
push bp ;preserve stack frame
|
push bp ;preserve stack frame
|
||||||
mov bp,sp ;set up local stack frame
|
mov bp,sp ;set up local stack frame
|
||||||
|
|
||||||
|
|
@ -597,7 +597,7 @@ FixedMulDone:
|
||||||
|
|
||||||
align ALIGNMENT
|
align ALIGNMENT
|
||||||
public _XformVec
|
public _XformVec
|
||||||
_XformVecprocnear
|
_XformVec proc near
|
||||||
push bp ;preserve stack frame
|
push bp ;preserve stack frame
|
||||||
mov bp,sp ;set up local stack frame
|
mov bp,sp ;set up local stack frame
|
||||||
push si ;preserve register variables
|
push si ;preserve register variables
|
||||||
|
|
@ -704,7 +704,7 @@ endif ;USE386
|
||||||
pop si
|
pop si
|
||||||
pop bp ;restore stack frame
|
pop bp ;restore stack frame
|
||||||
ret
|
ret
|
||||||
_XformVecendp
|
_XformVec endp
|
||||||
|
|
||||||
;=====================================================================
|
;=====================================================================
|
||||||
; Matrix multiplies SourceXform1 by SourceXform2 and stores the
|
; Matrix multiplies SourceXform1 by SourceXform2 and stores the
|
||||||
|
|
@ -741,7 +741,7 @@ CXparms ends
|
||||||
|
|
||||||
align ALIGNMENT
|
align ALIGNMENT
|
||||||
public _ConcatXforms
|
public _ConcatXforms
|
||||||
_ConcatXformsprocnear
|
_ConcatXforms proc near
|
||||||
push bp ;preserve stack frame
|
push bp ;preserve stack frame
|
||||||
mov bp,sp ;set up local stack frame
|
mov bp,sp ;set up local stack frame
|
||||||
push si ;preserve register variables
|
push si ;preserve register variables
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue