BBS: Inland Empire Archive Date: 02-18-93 (20:48) Number: 384 From: CORIDON HENSHAW Refer#: NONE To: ALL Recvd: NO Subj: Matrix Checksum code! Fa Conf: (2) Quik_Bas
Hello All! Here's some matrix checksuming code: ===Chop=== 'NAME: MATRCHK.BAS 'DESC: Matrix checksuming code 'FROM: Coridon Henshaw@1:250/820 'QBS Publishing: YES! DECLARE FUNCTION ChkSum% (BYVAL SSegment%, BYVAL SOffset%, BYVAL SLength%) '^^^ EXTENAL ASM CODE DECLARE FUNCTION MatrixChecksum@ (TextBlock AS STRING, MatrixWidth AS INTEGER) DEFINT A-Z FUNCTION MatrixChecksum@ (TextBlock AS STRING, MatrixWidth AS INTEGER) IF MatrixWidth > 0 AND MatrixWidth <> LEN(TextBlock) THEN MatrixDepth = LEN(TextBlock) \ MatrixWidth REDIM Matrix(MatrixDepth, MatrixWidth) AS STRING * 1 FOR X = 0 TO MatrixDepth FOR Y = 0 TO MatrixWidth Pointer = Pointer + 1 Matrix(X, Y) = MID$(TextBlock, Pointer, 1) NEXT NEXT FOR X = 0 TO MatrixDepth FOR Y = 0 TO MatrixWidth TempString$ = TempString$ + Matrix(X, Y) 'Extract horizontal text NEXT HSum@ = HSum@ + ChkSum%(SSEG(TempString$), SADD(TempString$),_ LEN(TempString$)) TempString$ = "" NEXT FOR Y = 0 TO MatrixWidth FOR X = 0 TO MatrixDepth TempString$ = TempString$ + Matrix(X, Y) 'Extract vertical text NEXT VSum@ = VSum@ + ChkSum%(SSEG(TempString$), SADD(TempString$),_ LEN(TempString$)) TempString$ = "" NEXT MatrixChecksum = (VSum@ + HSum@) * MatrixWidth END IF END FUNCTION ===Chop=== Here's CHKSUM.OBJ, needed for the above: ===Chop=== OPEN"B",#1,"CHKSUM.OBJ":OPEN"B",#2,"H" DO:READ I$:IF I$="-1" THEN EXIT DO PUT #2,,I$: LOOP: I$=" ": SEEK #2,1:DO UNTIL LOC(2)=LOF(2): GET #2,,I$ O$=CHR$(VAL("&H"+I$)):PUT #1,,O$:LOOP:CLOSE:KILL "H" DATA 800C000A63686B73756D2E61736D7096250000064447524F5550044441544104434F44 DATA 45055F444154410B43484B53554D5F5445585439980700482700060401E79807004800 DATA 00050301109A040002FF025F900D0000010643484B53554D0000009188040000A201D1 DATA A02B00010000558BEC1E568E5E0A8B76088B4E0633C00304464983F9007402EBF55E1F DATA 5DCA06005E1F5DCA0600678A02000074 DATA -1 'Yeah, I know hex streams are crappy, but it'll have to do for now... 'Wait until you see BIN2ASCII ;) ===Chop=== If anyone can make the matrix checksum code faster, or convert it to ASM, PLEASE DO! Coridon Henshaw \ Sirrus Software --- GEcho 1.00 * Origin: TCS Concordia - Mail Only - Toronto, Ontario (1:250/820)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET