REM sine9.bas - a program to generate a sine wave table for tone generation REM REM Table is output to a file in a format which can be inserted or included REM into the tone generator PIC program. REM Table is 8 bit - 256 entries - starts at midscale (128) REM REM 07/15/99 Chuck Olson, WB9KZY REM Jackson Harbor Press REM http://jacksonharbor.home.att.net/ REM jacksonharbor@att.net INPUT "Enter Code Table Output Filename: "; n$ OPEN n$ FOR OUTPUT AS #1 REM This is a 256 entry table FOR i = 0 TO 255 REM Calculate the sine value for the "angle" (i/256) z = SIN(2 * i * 3.14159 / 256) REM Scale the sine value from a -1 to +1 range to a 0 to 255 (8 bit) range y = CINT((z + 1) * 127.5) REM "print" the results to a file in the retlw table format. REM retlw is a return from a subroutine call with the value specified REM in the w register. PRINT #1, " retlw "; y; ";"; i, z NEXT i CLOSE