User Tools

Site Tools


Sinus table generators

makesin (fast, approximated)

;fast generator via approximation of x^2 parabola
;Copyright © 2012 Busy, optimized by Zilogat0r
mksin:    ld    bc,sintab
          ld    d,c
mksin2:   ld    a,c
          add   a,a
          add   a,a
          ld    e,a
          sbc   a,a
          xor   e
          ld    e,a
          ld    h,d
          ld    l,d
mksin1:   add   hl,de
          dec   a
          jr    nz,mksin1
          ld    a,64
          add   a,c
          add   a,a
          sbc   a,a
          xor   h
          ld    (bc),a
          inc   c
          jr    nz,mksin2
sintab:   ds    256

makesin (alternative)

; sinus	maker. {C} Jordan of exodus
; a: amplitude,	c: offset, hl: adr
;	org  xx00h
mksnt	exx
    	ld   c,a
    	ld   b,01h
    	ld   hl,sintabb
    	ld   e,00h
    	call h800e
    	dec  e
h800e	call h8011
h8011	ld   b,40h
h8013	exx
    	ld   e,(hl)
    	inc  l
    	ld   d,(hl)
    	ld   a,l
    	add  a,b
    	ld   l,a
    	ld   a,c
    	srl  a
    	srl  e
    	jr   nc,h8022
    	add  a,c
h8022	srl  a
    	srl  e
    	jr   nc,h8029
    	add  a,c
h8029	srl  a
    	srl  e
    	jr   nc,h8030
    	add  a,c
h8030	srl  a
    	srl  e
    	jr   nc,h8037
    	add  a,c
h8037	srl  a
    	srl  e
    	jr   nc,h803e
    	add  a,c
h803e	srl  a
    	srl  e
    	jr   nc,h8045
    	add  a,c
h8045	srl  a
    	srl  e
    	jr   nc,h804c
    	add  a,c
h804c	srl  a
    	srl  e
    	jr   nc,h8053
    	add  a,c
h8053	srl  a
    	srl  d
    	jr   nc,h805a
    	add  a,c
h805a	srl  a
    	srl  d
    	jr   nc,h8061
    	add  a,c
h8061	srl  a
    	srl  d
    	jr   nc,h8068
    	add  a,c
h8068	srl  a
    	adc  a,d
    	xor  e
    	jp   p,h8071
    	inc  a
h8071	add  a,c
    	ld   (hl),a
    	inc  l
    	djnz h8013
    	ld   a,b
    	xor  0fch
    	ld   b,a
    	db   00h,00h,32h,00h
    	db   64h,00h,97h,00h
    	db   0c9h,00h,0fbh,00h
    	db   2dh,01h
    	db   5eh,01h,90h,01h
    	db   0c1h,01h,0f2h,01h
    	db   22h,02h,53h,02h
    	db   82h,02h
    	db   0b2h,02h,0e1h,02h
    	db   10h,03h,3eh,03h
    	db   6ch,03h,99h,03h
    	db   0c5h,03h
    	db   0f1h,03h,1dh,04h
    	db   48h,04h,72h,04h
    	db   9bh,04h,0c4h,04h
    	db   0ech,04h
    	db   13h,05h,3ah,05h
    	db   5fh,05h,84h,05h
    	db   0a8h,05h,0cbh,05h
    	db   0edh,05h
    	db   0fh,06h,2fh,06h
    	db   4fh,06h,6dh,06h
    	db   8ah,06h,0a7h,06h
    	db   0c2h,06h
    	db   0ddh,06h,0f6h,06h
    	db   0eh,07h,25h,07h
    	db   3bh,07h,50h,07h
    	db   64h,07h
    	db   77h,07h,88h,07h
    	db   99h,07h,0a8h,07h
    	db   0b6h,07h,0c3h,07h
    	db   0ceh,07h
    	db   0d9h,07h,0e2h,07h
    	db   0eah,07h,0f1h,07h
    	db   0f6h,07h,0fah,07h
    	db   0feh,07h
    	db   0ffh,07h,0ffh,07h

Navigation: general . math . graphic . sound . system . other . back to start

makesin.txt · Last modified: 2017/02/16 13:34 by darkbyte