0 Members and 4 Guests are viewing this topic.
No, change several names, sorry ^^
push hl ld hl, $C8*2 or a sbc hl, de add hl, de ;essentially, cp DE pop hl
ld hl, tokenHook ld de, smallEditRam ;nothing touches this, ever ld bc, tokenHookEnd-tokenHook ldir ;copy it to a place where it won't get destroyed ld a, 1 ;1 means ram ld hl, smallEditRam bcall(_enableTokenHook) rettokenHook: .db $83 ;necessary for hooks, indicates that it hasn't been overwritten push hl;Test the first token;DE contains the token ld hl, $C8*2 ;sinh( or a sbc hl, de add hl, de ;essentially, cp DE jr z, cscToken;Test the next token ld hl, $CA*2 ;cosh( or a sbc hl, de add hl, de ;essentially, cp DE pop hl ret nzsecToken: ld hl, secText-tokenHook+smallEditRam-1 retcscToken: pop hl ld hl, cscText-tokenHook+smallEditRam-1 retcscText: .db 4, "csc(" ;length, then stringSecToken: .db 4, "sec("tokenHookEnd:
Up !I found this and now I use it, so thank you thepenguin77 TiAddict : to use hooks with Mimas, you must use the length and the hex codes of the ascii catacteres instead of the length and the string.Code: [Select]cscText:.db 4,$63,$73,$63,$28; instead of.db 4,"csc("And I've a question : with your code thepenguin77, how do you define several hooks in one file ?
cscText:.db 4,$63,$73,$63,$28; instead of.db 4,"csc("
.db 4,'c','s','c','('
tokenHook: .db $83 push hl ld hl,TokenTable ld b,0TokenSearchLoop: ld a,e cp (hl) inc hl jr z,ChkByte2NotTokenMatch: inc hl ld c,(hl) inc c add hl,bc ld a,(hl) or a jr nz,TokenSearchLoop pop hl retChkByte2: ld a,d cp (hl) jr nz,NotTokenMatch ex (sp),hl pop hl ld de,8478h push de inc hl ld c,(hl) inc c \ inc c dec hl ldir pop hl retNoChange:TokenTable: .db $06,0,8,"lFactor",5 .db $0C,0,7,"WriteM",$C1 .db $10,0,6,"ReadW(" .db $20,0,6,"ReadB(" .db $28,0,7,"Insert(" .db $36,0,7,"ClrPart" .db $38,0,7,"RunPart" .db $3A,0,8,"AddPart(" .db $3C,0,9,"PartType(" .db $44,0,5,"Misc(" .db $58,0,1,5Fh .db $BE,0,5,"call " .db $38,1,5,"Rect(" .db $3C,1,5,"Tile(" .db $3E,1,7,"Sprite(" .db $40,1,8,"TileMap(" .db $48,1,9,"Contrast(" .db $4E,1,9,"ShiftBuf(" .db $62,1,7,"WriteB(" .db $70,1,4,"Inv(" .db $72,1,7,"WriteW(" .db $A6,1,4,"For " .db $B4,1,7,"GetInc(" .db $BC,1,7,"SetBuf " .db $C0,1,8,"SetFont " .db $CE,1,8,"MakeVar(" .db $D0,1,8,"FindVar(" .db 0
ld a,b or a ret nz
You already said it and it works
ld hl,tokenHookld de,smallEditRamld bc,tokenEnd-tokenHookldirld a,1ld hl,smallEditRambcall _enableTokenHookret
ORG userMem-2 DB $BB,$6DStart: LD HL,TokenHook LD DE,smallEditRAM LD BC,TokenHookEnd-TokenHook LDIR LD A,1 LD HL,smallEditRAM BCALL $4F99 RET;TokenHook: RORG smallEditRAM DB $83 PUSH HL LD HL,$0180 OR A SBC HL,DE POP HL RET NZ LD HL,Lambda RETLambda: DB 1,2,$C2,'(' RORG LPCTokenHookEnd:
ld hl,TokenTable
ld hl,smallEditRAM+TokenTable-tokenHook
ORG userMem-2 DB $BB,$6DStart: IM 1 BCALL DelRes LD HL,TokenHook LD DE,statVars LD BC,TokenHookEnd-TokenHook LDIR LD A,1 LD HL,statVars BCALL $4F99 RET;TokenHook: RORG statVars DB $83 LD A,B OR A RET NZ PUSH HL LD HL,TokenTable;LD B,0TokenSearchLoop: LD A,E CP (HL) INC HL JR Z,ChkByte2NotTokenMatch: INC HL LD C,(HL) INC C ADD HL,BC LD A,(HL) INC A JR NZ,TokenSearchLoop POP HL RETChkByte2: LD A,D CP (HL) JR NZ,NotTokenMatch POP BC RETTokenTable: DW $06 DB 8 DB "lFactor" DB 5 DW $0C DB 7 DB "WriteM" DB $C1 DW $10 DB 6 DB "ReadW(" DW $20 DB 6 DB "ReadB(" DW $28 DB 7 DB "Insert(" DW $36 DB 7 DB "ClrPart" DW $38 DB 7 DB "RunPart" DW $3A DB 8 DB "AddPart(" DW $3C DB 9 DB "PartType(" DW $44 DB 5 DB "Misc(" DW $58 DB 1 DB $5F DW $BE DB 5 DB "call " DW $0138 DB 5 DB "Rect(" DW $013C DB 5 DB "Tile(" DW $013E DB 7 DB "Sprite(" DW $0140 DB 8 DB "TileMap(" DW $0148 DB 9 DB "Contrast(" DW $014E DB 9 DB "ShiftBuf(" DW $0162 DB 7 DB "WriteB(" DW $0170 DB 4 DB "Inv(" DW $0172 DB 7 DB "WriteW(" DW $01A6 DB 4 DB "For " DW $01B4 DB 7 DB "GetInc(" DW $01BC DB 7 DB "SetBuf " DW $01C0 DB 8 DB "SetFont " DW $01CE DB 8 DB "MakeVar(" DW $01D0 DB 8 DB "FindVar(" DB $FF RORG LPCTokenHookEnd: