>>> Continued from previous message
;-=] ScrollText [=---------------------------------------------------------
;This is the "Heart" of the program, which plots/scrolls the text on the
;screen. It goes into a repeating loop, until a key is pressed on the
;keyboard, where it exits.
ScrollText PROC
mov SI,offset msg ;SI = start of the message
S1:
mov BX,offset bits ;BX = start of the bit table
lodsb ;load a character from message into AL
or AL,AL ;test for NUL character?
jz ScrollText ;if found, restart the loop (repeat)
S2:
push AX ;otherwise, save it (AX) to the stack
mov CL,[BX] ;CL = current bit value for testing
or CL,CL ;check it for NUL?
jz S3 ;yes, then reset bits, get new char
inc BX ;no, then increment BX for next bit
push BX ;save it onto the stack
push CX ;push the bit again onto the stack
push AX ;push the character again to the stack
call PlotChar ;and plot one Y line of the letter
call ScrollScreen ;then scroll that line left by one
mov AH,01h ;KEYBOARD - Check for Keypress
int KEYBOARD ;call to check for a key
jnz S4 ;if yes, then exit this loop
pop BX ;restore BX from stack
pop AX ;restore AX from stack
jmp S2 ;loop to S2 for each bit (8 times)
S3: ;when all 8-bits are done come here.
add SP,2 ;remove the prior push AX
jmp S1 ;jump to S1 for the next character
S4: ;come here on a keypress
xor AH,AH ;KEYBOARD - Read Key
int KEYBOARD ;call it to "buffer" the pressed key
add SP,4 ;remove push AX,push BX from stack
ret
ScrollText ENDP
;-=] PlotPixel [=-----------------------------------------------------------
;This plots a pixel at position X, Y in COLOR to the MCGA screen using
;direct memory writes. The X,Y,COLOR values are PUSHED onto the stack in that
;order before the call.
PlotPixel PROC ;PlotPixel( x, y, color )
push BP ;save BP to the stack so we can load
mov BP,SP ;it with SP to access the stack
mov AX,320 ;offset = x + y * 320 (AX=320)
mul word ptr [BP+6] ;AX = AX * y
add AX,[BP+8] ;AX = AX + x
mov BX,AX ;BX = AX
mov AL,[BP+4] ;AL = color
mov ES:[BX],AL ;move pixel/color to the screen
pop BP ;restore BP from stack
ret 6 ;return and clear pushed variables
PlotPixel ENDP
;-=] PlotChar [=-----------------------------------------------------------
;Plots one Y line of the 8x8 font at the X position specified by the 8-bit
;value. ie bit 7 (128) would be the first line (X=0) The BIT and the CHAR
;values are pushed in that order prior to the call.
PlotChar PROC ;PlotChar( bit, char )
push BP
mov BP,SP
push DS ;save DS to the stack
push SI ;save SI to the stack
mov AX,0F000h ;setup DS to point into the BIOS
mov DS,AX
mov AX,8 ;offset = char * 8 (AX = 8)
mul byte ptr [BP+4] ;AX = AX * char
add AX,0FA6Eh ;AX = AX + FA6E (start of font char)
;The font starts at offset FA6E within the BIOS. Since each letter is 8 bytes
;long, we must calculate the starting offset for the given char. Hmm, since
;this is x 8 I could use a shift here...
mov SI,AX ;SI = the start of the font char
xor CX,CX ;use CX as a counter, zero it
mov BX,offset colors ;BX = start of the color table
PC0:
push BX ;save BX to the stack
mov AX,319 ;AX = 319 (X position) where we plot
push AX ;save to the stack
mov AX,ScrollY ;AX = starting Y position
add AX,CX ;plus the current count (0-7)
push AX ;save to stack for PlotPixel later on
lodsb ;load a font data byte into AL
test AL,[BP+6] ;test the bit against this pattern
jz PC1 ;was the bit off? then jump to PC1
mov AL,CS:[BX] ;else the bit was ON, get a color from
jmp PC2 ;the table and jump over zero code
PC1:
xor AL,AL ;bit off, so put a black (0) pixel
PC2:
push AX ;push the color to the stack (AX) and
call PlotPixel ;then plot it to the screen
pop BX ;restore BX from stack (color table)
inc BX ;increment BX to the next color
inc CX ;increment CX for the next Y position
cmp CX,8 ;have we done 8 pixels yet?
jne PC0 ;no, then keep looping until we have
pop SI ;else, restore SI, DS, BP from stack
pop DS
pop BP
ret 4 ;return and clear pushed variables
PlotChar ENDP
>>> Continued to next message
* OLX 2.1 TD * Backup not found: (A)bort (R)etry (P)anic
--- Maximus/2 3.01
---------------
* Origin: Frog Hollow Port Moody BC 604-469-0264/0284 (1:153/290)
|