=========================================================================== BBS: The Abacus * HST/DS * Potterville, MI Date: 04-23-93 (19:01) Number: 84 From: ROBERT CHURCH Refer#: NONE To: ALL Recvd: NO Subj: Assembley direct screen w Conf: (35) Quick Basi --------------------------------------------------------------------------- Here's an assembly routine I wrote for writing a QB near string directly to vide o ram. If anyone notices any room for improvement, please let me know. I'd like to hear your comments. ; fprint - writes a string directly to the video buffer ; DECLARE SUB FPrint (S$, BYVAL Attr%, BYVAL Row%, BYVAL Col%) .Model Medium, Basic .Data VidSegment dw 0 .Code fprint proc uses SI DI, str_ptr:word, attr:word, row:word, col:word Mov AX, row Dec AX ; (160 * (row - 1)) + (2 * (col - 1)) Mov DX, 160 Imul DX Mov DX, col Dec DX Shl DX, 1 Add AX, DX Mov DI, AX ; the offset into video memory in which to ; print is now in DI Mov BX, VidSegment ; figure out if the routine has been called yet Cmp BX, 0 Je GetVidSegment ; call the initionaliztion routine SetupLoop: Mov ES, BX ; load the video buffer's segment into ES Mov AX, Attr ; put the attribute in AX Mov SI, str_ptr ; load the QB string, length in CX, ptr in SI Mov CX, [SI] Mov SI, [SI+2] ; Current register contents: ; AX = Attribute word ; CX = string length ; SI = pointer to string ; DI = offset into video memory at which to print ; ES = video memory segment Cld LoopHere: ; entry point of loop Movsb ; copy the next char in the string to vid ram Mov ES:[DI], AL ; copy the attribute to vid ram Inc DI ; move to the next position on the screen Loop LoopHere ; loop until CX = 0 Jmp ExitProc GetVidSegment: Xor AX, AX ; set ES to segment 0 Mov ES, AX Mov AX, ES:[463h] ; figure out if we're mono or color Cmp AH, 0B4h Jne Color ; if not equal, color Mov VidSegment, 0B000h ;Set the VidSegment to 0B000h, monochrome Jmp Return Color: Mov VidSegment, 0B800h ;color Return: Mov BX, VidSegment ; either way, load BX with the segment Jmp SetupLoop ExitProc: Ret fprint endp end Here's the .OBJ file for those of you without assemblers. 'Save this script to a file, edit out all of the non-QB related text and 'execute it in a QB environment to retrieve FPRINT.OBJ. DEFINT A-Z:FOR A=0 TO 6:P(A)=2^A:NEXT:OPEN "B",1,"FPRINT.OBJ" T$="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789()" G"aYaakygCYLMB05sqt1eYwwcaayarhj1tvbfbefevbrWqprurf8frbrvqlyeusLKt G"u9fvfHfvXG5baGuyayabb0kMhaascaqbdeGdAsaac8VaFbzdaaqagyeusLKtubaa G"aKiIeaaaIgq0GAaacaaaaaawGwgabaaavTi7wD1IgHas6cka3R(IwzGsrl(acVi( G"l6baam4(aqhgoo8IgPWI2XWImSiDcWpPMGybhjE(RpcKZaSJaBsOJraG8tBDjCSb G"aaaaWU(bqESbaaaa4UOhaaW6g)LxDPmcaShNvaaXAqracqmsueGaehffbiaXxrra G"cKTIcaaa0b" N=247:K=255:IF LEN(C$)<>330 THEN ?"Bad script file!":BEEP:END FOR A=1 TO N:LOCATE,1:?(100&*A)\N"% Done";:IF L=0 THEN GOSUB G:L=6 W=T\P(6-L):GOSUB G:W=W OR T*P(L):L=L-2:B$=CHR$(W AND K):PUT 1,,B$:NEXT ?:IF C<>244 THEN ?"Bad checksum!":BEEP:END ELSE ?"Success!":END G:I=I+1:T=INSTR(T$,MID$(C$,I,1))-1:C=(C+T)*2:C=C\256+(C AND K):RETURN SUB G(A$):SHARED C$:C$=C$+RTRIM$(A$):END SUB >-= Rob =-< --- FMail 0.90 * Origin: -= Floating Point =- Hillsboro, Oregon (1:105/330.3) SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1 SEEN-BY: 153/752 154/40 77 157/2 159/100 125 430 575 950 203/23 209/209 SEEN-BY: 280/1 390/1 396/1 15 397/2 2230/100 2440/5 3603/20