;PT2.1, PT2.4PhF, PT3.xx universal searcher by Andrey Bogdanovich aka Spectre. 15.03.2005. ;IN: IX-Start address, BC-Length. ;OUT: IX-Song start address, ;BC-Length (positions), (BC in PT2 was broken - fixed AC,Bulba) ;A: 0-PT3, 1-PT2. ;Z = not found (added by AC) FINDPT LD A,B OR C RET Z LD A,(IX+0) ;Temp OR A JR Z,FPTEND2 CP #40 JR NC,FPTEND2 LD A,(IX+1) ;Len OR A JR Z,FPTEND2 CP (IX+2) ;Loop JR C,FPTEND2 EXX PUSH IX POP HL LD DE,-#64 ADD HL,DE LD C,(IX+3) ;patterns if PT3, 0 if PT2, LD B,(IX+4) ;displace if PT2.4Ph ADD HL,BC DEC HL LD A,(HL) INC A JR NZ,FPT2 LD L,(IX+69) ;ornaments LD H,(IX+70) ; ADD HL,DE ;ornaments-#64 EX DE,HL ;HL->DE LD HL,-201-1 ADD HL,BC ;PT3: A=0 JR FPT3 FPT2 PUSH IX POP HL LD E,(IX+99) ;patterns LD D,(IX+100) ; ADD HL,DE DEC HL LD A,(HL) INC A JR NZ,FPTEND INC A; PT2: A=1 LD L,(IX+67) ;ornaments LD H,(IX+68) ; SBC HL,BC ;for PT2.4Ph PUSH HL LD HL,-131-1 ADD HL,DE POP DE FPT3 LD C,A LD A,(IX+1) ;Len SUB L JR NZ,FPTEND PUSH IX POP HL ADD HL,DE LD A,C CP (HL) JR NZ,FPTEND INC HL XOR (HL) ;may be 0 or 1 DEC A JR NZ,FPTEND INC HL OR (HL) JR Z,FOUNDPT FPTEND EXX FPTEND2 INC IX DEC BC JR FINDPT FOUNDPT LD B,A OR C LD C,(IX+1) ;Len RET NZ ;PT2 LD DE,-#64 ADD IX,DE DEC D ;NZ RET