encode.asm
Positions turned about, totals, and other helpers. Download · All the source
; ----------------------------------------------------------------- util; index: A = (HL + A), HL left pointing there.index: add a,l ld l,a jr nc,.n inc h.n: ld a,(hl) ret; total: A = the sum of the 25 bytes at HL.total: ld b,25 xor a.l: add a,(hl) inc hl djnz .l ret; highest: A = the highest index of the 25 bytes at HL not zero, or $ff.; Keeps C.highest: ld de,25 add hl,de ld b,25.l: dec hl ld a,(hl) or a jr nz,.f djnz .l.f: ld a,b dec a ret; mul: HL = A x DE (A unsigned), from A's low bits up. Keeps DE.mul: ld hl,0 push de.l: srl a jr nc,.n add hl,de.n: jr z,.x ex de,hl add hl,hl ex de,hl jr .l.x: pop de ret; ratio: A = min(7, HL / DE), 0 for HL negative: a feature's count.ratio: xor a bit 7,h ret nz.l: and a sbc hl,de ret c inc a cp 7 jr nz,.l ret; contact: carry if PA and PB can still hit each other.contact: ld hl,PA call highest ld c,a ld hl,PB call highest ld b,a or c jp m,.no ld a,b add a,c cp 24 ccf ret.no: or a ret