;
;TEMPO keisan
;
8182 210C84 TMPSB:LD HL,BPQN
8185 56 LD D,(HL)
8186 23 INC HL
8187 5E LD E,(HL);DE=BPQN(bit per quarter note)
;TEMPO/BPQN
8188 60 LD H,B
8189 69 LD L,C
818A 3E09 LD A,09
;if bit7 of D is '0',shift to left DE
818C CB7A SFTDE:BIT 7,D
818E C29A81 JP NZ,SFTDE2
8191 B7 OR A
8192 CB13 RL E
8194 CB12 RL D
8196 3C INC A
8197 C38C81 JP SFTDE
819A B7 SFTDE2:OR A
819B CB1A RR D
819D CB1B RR E
;if bit7 of H is '0',shift to left HL
819F CB7C SFTHL:BIT 7,H
81A1 C2AD81 JP NZ,SFTHL2
81A4 B7 OR A
81A5 CB15 RL L
81A7 CB14 RL H
81A9 3D DEC A
81AA C39F81 JP SFTHL
81AD B7 SFTHL2:OR A
81AE CB1C RR H
81B0 CB1D RR L
81B2 010000 LD BC,$0000
;divide HL by DE
81B5 B7 DIVHLDE:OR A
81B6 ED52 SBC HL,DE
81B8 D2BC81 JP NC,DIVHLDE2
81BB 19 ADD HL,DE
81BC 3F DIVHLDE2:CCF
81BD CB11 RL C
81BF CB10 RL B
81C1 CB15 RL L
81C3 CB14 RL H
81C5 3D DEC A
81C6 C2B581 JP NZ,DIVHLDE
;BC/2
81C9 B7 OR A
81CA CB18 RR B
81CC CB19 RR C
81CE ED43D682 LD (TIMEDT),BC
81D2 C9 RET
|