diff --git a/graphics/gr/plasmagoria/Makefile b/graphics/gr/plasmagoria/Makefile index db54c9b1..3e633480 100644 --- a/graphics/gr/plasmagoria/Makefile +++ b/graphics/gr/plasmagoria/Makefile @@ -32,7 +32,7 @@ plasmag.o: plasmag.s PLASMAG_TINY: plasmag_tiny.o ld65 -o PLASMAG_TINY plasmag_tiny.o -C $(LINKERSCRIPTS)/apple2_4000.inc -plasmag_tiny.o: plasmag_tiny.s gr_gbascalc.s +plasmag_tiny.o: plasmag_tiny.s gr_gbascalc.s make_tables.s ca65 -o plasmag_tiny.o plasmag_tiny.s -l plasmag_tiny.lst ### diff --git a/graphics/gr/plasmagoria/make_tables.s b/graphics/gr/plasmagoria/make_tables.s new file mode 100644 index 00000000..c82540e9 --- /dev/null +++ b/graphics/gr/plasmagoria/make_tables.s @@ -0,0 +1,222 @@ +; code to use the FAC (floating point accumulator) +; to generate plasmagoria sine tables + +; 232 bytes = initial implementation +; 218 bytes = increment high byte of destination instead of loading +; 208 bytes = modify 1->4 on the fly +; 205 bytes = make page increment common code +; 198 bytes = convert thirty-two to twenty-four on fly +; 188 bytes = convert forty-seven to thirty-eight with one byte +; 173 bytes = assume constants on same page +; 171 bytes = optimize save/load of loop index +; 169 bytes = optimize multiply by 8 +; 166 bytes = separate common sin code +; 164 bytes = move more to common sin code +; 162 bytes = move more to common sin code + +qint = $EBF2 ; convert FAC to 32-bit int? +fadd = $E7BE ; FAC = (Y:A)+FAC +movmf = $EB2B ; move fac to mem: round FAC and store at Y:X +fmult = $E97F ; FAC = (Y:A) * FAC +float = $EB93 ; signed value in A to FAC +sin = $EFF1 + +ARG = $A5 ; A5-AA +FAC = $9D ; 9D-A2 + +; code uses: 5E/5F "index" in load arg from Y:A +; uses ARG (A5-AA) for argument +; uses FAC (9D-A2) + +TEMP1 = $FE +OURX = $FF + +sin1 = $2000 +sin2 = $2100 +sin3 = $2200 +save = $2300 + +HGR = $F3E2 + +make_tables: + + ;==================================================== + ; sin1[i]=round(47.0+ + ; 32.0*sin(i*(PI*2.0/256.0))+ + ; 16.0*sin(2.0*i*(PI*2.0/256.0))); + + ; sin1[i]=round(47.0+ + ; 16*(2.0*sin(i*(PI*2.0/256.0))+ + ; sin(2.0*i*(PI*2.0/256.0))); + + + ; already set up for this one + + jsr make_sin_table + + ;=================================================== + ; sin2[i]=round(47.0+ + ; 32.0*sin(4.0*i*(PI*2.0/256.0))+ + ; 16.0*sin(3.0*i*(PI*2.0/256.0))); + + ; 47 is same, 32 is same, 16 is same + + ; convert one to four + lda #$7d ; only one byte different + sta one_input + + ; load 3 instead of 2 (assume on same page) + lda #3 + ; load 3 input (assume on same page) + lda #forty_seven + jsr fadd ; FAC=FAC+constant + + jsr qint ; convert to integer + + lda FAC+4 ; get bottom byte + + ldx OURX + +sin_table_dest_smc: + sta sin1,X ; save to memory + + inx ; move to next + + bne sin_loop ; loop until done + + inc sin_table_dest_smc+2 ; point to next location + + rts + + + ;============================== + ; sin_common + ;============================== + ; A = low byte for input multiplier + ; X = low byte for result multiplier +sin_common: + stx TEMP1 + pha + lda OURX + jsr float ; FAC = float(OURX) (again) + pla + + ldy #>one_input ; high byte, assume always same + + jsr fmult ; FAC=FAC*(constant from RAM) + + jsr sin ; FAC=sin(FAC) + + ldy #>thirty_two ; high byte, assume always same + lda TEMP1 + + jsr fmult ; FAC=constant*FAC + + ldy #>save + ldx #