Compare commits

..
12 changed files with 94 additions and 94 deletions

View file

@ -754,12 +754,12 @@ Parms struc
Buffer dw ? Buffer dw ?
BufferLength dw ? BufferLength dw ?
Checksum dw ? Checksum dw ?
Parms ends Parmsends
; ;
.model small .model small
.code .code
public _ChecksumChunk public _ChecksumChunk
_ChecksumChunk proc near _ChecksumChunkprocnear
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
_ChecksumChunk endp _ChecksumChunkendp
end end
``` ```

View file

@ -245,7 +245,7 @@ the whole point.)
.stack 100h .stack 100h
.data .data
; Sample string to search through. ; Sample string to search through.
SampleString label byte SampleString labelbyte
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
Start proc near Startprocnear
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
Start endp Startendp
; 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 @@ Start endp
; 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
SearchMaxLength proc near SearchMaxLengthprocnear
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
SearchMaxLength endp SearchMaxLengthendp
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.
SampleString label byte SampleStringlabelbyte
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
Start endp Startendp
; 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
SearchMaxLength endp SearchMaxLengthendp
end Start end Start
``` ```

View file

@ -395,7 +395,7 @@ Parmsends
.model small .model small
.code .code
public _FindString public _FindString
_FindString proc near _FindStringprocnear
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
_FindString endp _FindStringendp
end end
``` ```
@ -492,7 +492,7 @@ Parmsends
.model small .model small
.code .code
public _FindString public _FindString
_FindString proc near _FindStringprocnear
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
_FindString endp _FindStringendp
end end
``` ```
@ -743,7 +743,7 @@ parmsends
.model small .model small
.code .code
public _Div public _Div
_Div proc near _Divprocnear
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
_Div endp _Divendp
end end
``` ```

View file

@ -85,12 +85,12 @@ registers.
; ;
; By Michael Abrash ; By Michael Abrash
; ;
stack segment word stack 'STACK' stacksegmentword stack 'STACK'
db 512 dup (?) db512 dup (?)
stack ends stackends
; ;
data segment word 'DATA' datasegment word 'DATA'
IMAGE_WIDTH EQU 4 ;in bytes IMAGE_WIDTHEQU 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 label byte PatternPlane1 labelbyte
db 32 dup (0ffh,0,0ffh,0) db 32 dup (0ffh,0,0ffh,0)
PatternPlane2 label byte PatternPlane2 labelbyte
db 32 dup (0f0h,0f0h,0f0h,0f0h) db 32 dup (0f0h,0f0h,0f0h,0f0h)
PatternPlane3 label byte PatternPlane3 labelbyte
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
data ends dataends
; ;
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
Start endp Startendp
; ;
; 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.
; ;
DrawImage proc near DrawImageprocnear
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
DrawImage endp DrawImageendp
; ;
; 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
GetImage endp GetImageendp
; ;
; 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
loop VLineLoop loopVLineLoop
; ;
; 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
Start endp Startendp
; ;
; 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.
; ;
SelectSetResetColor proc near SelectSetResetColorprocnear
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 @@ SelectSetResetColor proc near
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
SelectSetResetColor endp SelectSetResetColorendp
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
Start proc near Startprocnear
; ;
; 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
loop DrawDiagonalLoop loopDrawDiagonalLoop
; ;
; 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
Start endp Startendp
code ends code ends
end Start end Start
``` ```

View file

@ -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.)
; ;
ColorNumbers label byte ColorNumberslabelbyte
rept 16 rept 16
db 000h', 0ah, 8, 8, 8, 8 db 000h', 0ah, 8, 8, 8, 8
endm endm
COLOR_ENTRY_LENGTH equ ($-ColorNumbers)/16 COLOR_ENTRY_LENGTHequ($-ColorNumbers)/16
db $' db $'
; ;
CurrentColor db ? CurrentColordb?
; ;
; 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 proc near Start procnear
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
ColorNumbersUp endp ColorNumbersUpendp
; ;
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'
db 512 dup (?) db512 dup (?)
stack ends stack ends
; ;
Data segment word DATA' Data segment word DATA'

View file

@ -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_LINE equ 9 ;index of Maximum Scan Line register MAXIMUM_SCAN_LINEequ 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
Start endp Startendp
;********************************************************************* ;*********************************************************************
; Waits for the leading edge of the vertical sync pulse. ; Waits for the leading edge of the vertical sync pulse.
; ;
@ -328,7 +328,7 @@ Start endp
; ;
; Registers altered: AL, DX ; Registers altered: AL, DX
; ;
WaitForVerticalSyncStart proc near WaitForVerticalSyncStartprocnear
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
; ;
WaitForVerticalSyncEnd proc near WaitForVerticalSyncEndprocnear
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
WaitForVerticalSyncEnd endp WaitForVerticalSyncEndendp
;********************************************************************* ;*********************************************************************
; 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
;********************************************************************* ;*********************************************************************
Data segment Datasegment
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
;********************************************************************* ;*********************************************************************
Start proc near Startproc 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
loop ColumnLoop2 loopColumnLoop2
ror ax,1 ;shift pattern word ror ax,1 ;shift pattern word
dec dx dec dx
jnz RowLoop2 jnz RowLoop2
@ -847,7 +847,7 @@ loop ColumnLoop2
; 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
call PanRight callPanRight
; ;
; 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
Start endp Startendp
;********************************************************************* ;*********************************************************************
; 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
SetPelPan endp SetPelPanendp
;********************************************************************* ;*********************************************************************
; 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
;********************************************************************* ;*********************************************************************
Code ends Codeends
end Start endStart
``` ```
### Notes on Setting and Reading Registers ### Notes on Setting and Reading Registers

View file

@ -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 reprogramming of the VGA. In the next chapter, I'll be set up with very little reof 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_REGISTER macro ADDRESS, INDEX, VALUE CONSTANT_TO_INDEXED_REGISTERmacroADDRESS, 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
cmp cx,-1 cmpcx,-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
WritePixel endp WritePixelendp
; ;
; 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 @@ WritePixel endp
; ;
; Registers altered: AX, CX, DX, SI, ES ; Registers altered: AX, CX, DX, SI, ES
; ;
ReadPixel proc near ReadPixelprocnear
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 @@ ReadPixel proc near
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
lods byte ptr es:[si] ;read the pixel lodsbyte ptr es:[si] ;read the pixel
ret ret
ReadPixel endp ReadPixelendp
; ;
; 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_REGISTER macro ADDRESS, INDEX, VALUE CONSTANT_TO_INDEXED_REGISTERmacroADDRESS, 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.
; ;
call Set320By400Mode callSet320By400Mode
; ;
; 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 @@ call Set320By400Mode
; ;
; 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.
; ;
call GetNextKey callGetNextKey
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 @@ call Set320By400Mode
; ;
; 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.
; ;
call GetNextKey callGetNextKey
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
; ;
Set320By400Mode proc near Set320By400Modeprocnear
; ;
; 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,not 40h ;turn off doubleword and al,not40h ;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.
; ;
ColorBarsUp proc near ColorBarsUpprocnear
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
push bx ;save the row-start color pus h 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
ColorBarsUp endp ColorBarsUpendp
; ;
; Waits for the next key and returns it in AX. ; Waits for the next key and returns it in AX.
; ;
GetNextKey proc near GetNextKeyprocnear
WaitKey: WaitKey:
mov ah,1 mov ah,1
int 16h int 16h
@ -901,9 +901,9 @@ WaitKey:
ret ret
GetNextKey endp GetNextKey endp
; ;
Code ends Codeends
; ;
end Start endStart
``` ```
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

View file

@ -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
; ;
_DATA segment public byte DATA' _DATAsegmentpublic 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
_DATA ends _DATAends
; ;
; 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
_Set360x480Mode proc near _Set360x480Modeprocnear
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 @@ _Set360x480Mode proc near
pop di ;restore C register vars pop di ;restore C register vars
pop si pop si
ret ret
_Set360x480Mode endp _Set360x480Modeendp
; ;
; 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
_Draw360x480Dot proc near _Draw360x480Dotprocnear
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 @@ _Draw360x480Dot proc near
pop si pop si
pop bp ;restore caller's BP pop bp ;restore caller's BP
ret ret
_Draw360x480Dot endp _Draw360x480Dotendp
; ;
; 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
_Read360x480Dot proc near _Read360x480Dotprocnear
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 @@ _Read360x480Dot proc near
pop bp ;restore caller's BP pop bp ;restore caller's BP
ret ret
_Read360x480Dot endp _Read360x480Dot endp
_TEXT ends _TEX Tends
end end
``` ```

View file

@ -532,7 +532,7 @@ FillVertLoop:
jnz FillHorzLoop ;no, do the next column jnz FillHorzLoop ;no, do the next column
ret; ret;
end Start endStart
``` ```
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

View file

@ -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
DrawObject endp DrawObjectendp
; ;
Code ends Code ends
end Start end Start

View file

@ -199,7 +199,7 @@ SCparms ends
align ALIGNMENT align ALIGNMENT
public -CosSin public -CosSin
-CosSin proc near -CosSinprocnear
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
-CosSin endp -CosSinendp
;===================================================================== ;=====================================================================
; 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
-XformVec endp -XformVecendp
;===================================================================== ;=====================================================================
; 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
-ConcatXforms endp -ConcatXformsendp
end end
``` ```

View file

@ -339,7 +339,7 @@ SCparms ends
alignALIGNMENT alignALIGNMENT
public _CosSin public _CosSin
_CosSin proc near _CosSin procnear
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
_XformVec proc near _XformVecprocnear
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
_XformVec endp _XformVecendp
;===================================================================== ;=====================================================================
; 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
_ConcatXforms proc near _ConcatXformsprocnear
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