home *** CD-ROM | disk | FTP | other *** search
- SEARCH LD IX,PREFIX
- LD BC,(NO2SRCH)
- LD HL,(BGNSRCH)
- LD DE,4096
- SCH010 LD A,B
- OR C
- JR Z,SCH030 ;go if more to search
- LD A,(IX) ;p/u lsb of PREFIX
- CPIR ;in PRELSB table?
- JR NZ,SCH030 ;go if not
- LD (SCH020+1),HL ;store addr of char + 1
- DEC HL ;-> actual char
- ADD HL,DE ;-> PREMSB value
- LD A,(IX+1) ;p/u msb of PREFIX
- CP (HL) ;msbs match?
- JR NZ,SCH020 ;go if not
- ADD HL,DE ;-> SUFLSB value
- LD A,(IX+2) ;p/u suffix
- CP (HL) ;suffix lsbs match?
- SCH020 LD HL,$-$ ;addr of char + 1
- JR NZ,SCH010 ;CPIR again if no match
- ;
- LD (BGNSRCH),HL ;update these for next
- LD (NO2SRCH),BC ; invocation
- DEC HL ;HL = addr of char
- LD DE,PRELSB ;DE = table base
- SBC HL,DE ;calc offset
- LD (PREFIX),HL ;this is slot #
- CP A ;Z means "string found"
- RET
- ;
- SCH030 LD B,H ;here if string not found
- LD C,L ;store addr of char + 1
- LD DE,PREMSB ;are we past table end?
- OR A
- SBC HL,DE
- JR NC,SCH040 ;go if so
- ;
- LD H,B ;here to record string
- LD L,C ;addr of char + 1
- LD DE,PRELSB+6 ;table base + # root values + 2
- LD (BGNSRCH),DE ; (would be 258 for 256-color image)
- OR A
- SBC HL,DE ;calc # of slots filled
- INC HL
- LD (NO2SRCH),HL
- ;
- LD H,B
- LD L,C ;-> next PRELSB posn
- LD A,(IX)
- LD (HL),A ;store new prefix lsb
- LD DE,4096
- ADD HL,DE ;-> next PREMSB posn
- LD A,(IX+1)
- LD (HL),A ;store new prefix msb
- ADD HL,DE ;-> next SUFLSB posn
- LD A,(IX+2)
- LD (HL),A
- RET ;w/NZ means string not found
- ;
- ; here if table full
- ;
- SCH040 CALL OUTCODE ;send prefix to file
- LD HL,CLRCODE
- LD (PREFIX),HL
- CALL OUTCODE ;clear table (OUTCODE resets search params
- ; (BGNSRCH, NO2SRCH, CODESIZ, MAXCODE, etc.)
- LD HL,(SUFFIX)
- LD (PREFIX),HL ;new root value string in PREFIX-SUFFIX
- CP A ;set Z to trick calling routine into thinking
- RET ; root in PREFIX was found via search
- ;
-