plasmag: more sine reversing

This commit is contained in:
Vince Weaver 2023-09-03 23:32:26 -04:00
parent d1bcefc04a
commit 1f4db2b7ed
5 changed files with 88 additions and 26 deletions

View File

@ -1,9 +1,8 @@
; PLASMAGORIA
; just part3
; by French Touch
; original code by French Touch
; this is just part3 and size optimized
; just the graphics, no music
.include "hardware.inc"
@ -77,7 +76,7 @@ BP3:
; ROUTINES PRE CALCUL
; ============================================================================
PRECALC1:
lda PARAM1
lda PARAM1 ; self modify various parts
sta pc_off1+1
lda PARAM2
sta pc_off2+1
@ -86,17 +85,20 @@ PRECALC1:
lda PARAM4
sta pc_off4+1
; Table1(X) = sin1(PARAM1+X)+sin2(PARAM1+X)
; Table2(X) = sin3(PARAM3+X)+sin1(PARAM4+X)
ldx #$28 ; 40
pc_b1:
pc_off1:
lda SIN1
lda sin1
pc_off2:
adc SIN2
adc sin2
sta Table1,X
pc_off3:
lda SIN3
lda sin3
pc_off4:
adc SIN1
adc sin1
sta Table2,X
inc pc_off1+1
@ -116,12 +118,13 @@ pc_off4:
rts
; ============================================================================
; ROUTINES AFFICHAGES
; Display Routines
; ROUTINES AFFICHAGES
; ============================================================================
; AFFICHAGE "NORMAL"
; Display "Normal"
; AFFICHAGE "NORMAL"
AFFICH_NOR2:
bit $C050 ; gfx (lores)
@ -183,9 +186,10 @@ TTH: .byte $08,$08,$09,$09,$0A,$0A,$0B,$0B
.align 256
;align 255,0
SIN1: ; 256
; This appears to be roughly 47+32*sin(x)+16*sin(2x)
sin1: ; 256
.byte $2E,$30,$32,$34,$35,$36,$38,$3A,$3C,$3C,$3E,$40,$41,$42,$44,$45,$47,$47,$49,$4A,$4B,$4C,$4D,$4E,$4F,$50,$51,$52,$53,$53,$54,$54
.byte $55,$55,$56,$57,$57,$58,$58,$57,$58,$58,$58,$58,$58,$58,$58,$58,$58,$57,$57,$57,$56,$56,$55,$54,$55,$54,$53,$52,$52,$51,$50,$4F
.byte $4E,$4E,$4D,$4C,$4B,$4B,$4A,$49,$48,$47,$46,$45,$45,$44,$42,$42,$41,$41,$3F,$3F,$3D,$3D,$3C,$3B,$3B,$39,$39,$39,$38,$38,$37,$36
@ -195,7 +199,8 @@ SIN1: ; 256
.byte $0F,$0F,$0E,$0D,$0C,$0C,$0B,$0A,$09,$09,$08,$08,$08,$07,$06,$07,$06,$06,$06,$06,$05,$06,$05,$05,$06,$05,$06,$06,$07,$07,$08,$08
.byte $09,$09,$0A,$0B,$0B,$0C,$0C,$0D,$0F,$0F,$10,$12,$12,$14,$15,$16,$17,$19,$1A,$1B,$1D,$1E,$20,$21,$22,$24,$26,$27,$28,$2A,$2C,$2E
SIN2: ; 256
; This appears to be roughly 47+32*sin(4x)+16*sin(3x)
sin2: ; 256
.byte $2E,$33,$38,$3C,$40,$43,$47,$4B,$4E,$51,$54,$56,$59,$5A,$5C,$5D,$5D,$5E,$5E,$5D,$5C,$5A,$59,$57,$55,$53,$4F,$4C,$49,$46,$42,$3E
.byte $3A,$36,$32,$2E,$2A,$26,$23,$1F,$1C,$18,$15,$12,$10,$0E,$0C,$0A,$09,$08,$07,$07,$07,$07,$09,$0A,$0B,$0D,$0F,$11,$13,$16,$19,$1C
.byte $1F,$22,$26,$29,$2C,$2F,$32,$36,$38,$3B,$3E,$3F,$42,$44,$46,$47,$48,$49,$4B,$4B,$4B,$4A,$4A,$49,$49,$48,$46,$44,$43,$41,$3F,$3C
@ -205,7 +210,8 @@ SIN2: ; 256
.byte $3E,$41,$45,$48,$4B,$4C,$4F,$51,$53,$54,$55,$55,$57,$57,$57,$56,$55,$53,$52,$50,$4E,$4B,$49,$45,$42,$3F,$3B,$37,$34,$30,$2C,$27
.byte $23,$1F,$1C,$18,$14,$11,$0E,$0B,$09,$07,$05,$03,$02,$01,$00,$00,$01,$01,$02,$03,$05,$07,$0A,$0D,$10,$13,$17,$1A,$1E,$22,$26,$2A
SIN3: ; 256
; This appears to be roughly 38+24*sin(3x)+16*sin(8x)
sin3: ; 256
.byte $26,$2C,$31,$35,$39,$3D,$40,$42,$44,$45,$45,$46,$45,$43,$42,$40,$3C,$3A,$38,$36,$33,$31,$30,$2F,$2F,$2E,$2F,$2F,$30,$33,$33,$36
.byte $37,$3A,$3C,$3C,$3E,$3E,$3D,$3D,$3B,$39,$36,$34,$30,$2B,$28,$23,$1D,$19,$14,$11,$0C,$09,$07,$04,$03,$03,$03,$03,$04,$07,$09,$0C
.byte $0F,$13,$16,$18,$1B,$1E,$20,$22,$22,$23,$24,$24,$23,$22,$21,$20,$1D,$1C,$1B,$1A,$19,$19,$19,$1A,$1C,$1E,$20,$23,$27,$2B,$2F,$33
@ -216,7 +222,8 @@ SIN3: ; 256
.byte $15,$18,$1A,$1B,$1D,$1E,$1F,$1F,$1F,$1F,$1E,$1D,$1B,$18,$16,$14,$10,$0E,$0C,$0B,$09,$08,$08,$09,$0A,$0C,$0E,$11,$14,$19,$1D,$22
.if 0
SIN4: ; 256
; This appears to be roughly 64+64*sin(x)
sin4: ; 256
.byte $40,$41,$43,$44,$46,$47,$49,$4A,$4C,$4D,$4F,$50,$52,$53,$55,$56,$58,$59,$5B,$5C,$5D,$5F,$60,$61,$63,$64,$65,$67,$68,$69,$6A,$6B
.byte $6C,$6D,$6F,$70,$71,$72,$73,$73,$74,$75,$76,$77,$78,$78,$79,$7A,$7A,$7B,$7B,$7C,$7C,$7D,$7D,$7D,$7E,$7E,$7E,$7F,$7F,$7F,$7F,$7F
.byte $7F,$7F,$7F,$7F,$7F,$7F,$7E,$7E,$7E,$7D,$7D,$7D,$7C,$7C,$7B,$7B,$7A,$7A,$79,$78,$78,$77,$76,$75,$74,$73,$73,$72,$71,$70,$6F,$6D

View File

@ -1,3 +1,4 @@
CC = gcc
CFLAGS = -O2 -Wall
LFLAGS =
MATH_LFLAGS = -lm

View File

@ -1,4 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323846264338327950
@ -75,18 +76,54 @@ int main(int argc, char **argv) {
int i;
int ours[256];
int ours[256],current=0;
int diff=0;
int which=0;
if (argc>1) {
which=atoi(argv[1]);
}
for(i=0;i<256;i++) {
/* start 46, peak=88, 21 */
ours[i]=round(47.0+
32.0*sin(i*(PI*2.0/256.0))+
16.0*sin(i*(PI*2.0/128.0)));
//printf("%d %d\n",i,sin1[i]);
printf("%d: %d %d\n",i,sin1[i],ours[i]);
if (ours[i]!=sin1[i]) {
// printf("%d: %d %d\n",i,sin1[i],ours[i]);
if (which==0) {
/* start 46, peak=88 */
ours[i]=round(47.0+
32.0*sin(i*(PI*2.0/256.0))+
16.0*sin(2.0*i*(PI*2.0/256.0)));
printf("%d: %d\n",i,sin1[i]-ours[i]);
current=sin1[i];
}
if (which==1) {
ours[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)));
printf("%d: %d\n",i,sin2[i]-ours[i]);
current=sin2[i];
}
if (which==2) {
ours[i]=round(38.0+
24.0*sin(3.0*i*(PI*2.0/256.0))+
16.0*sin(8.0*i*(PI*2.0/256.0)));
printf("%d: %d (%d %d)\n",i,
sin3[i]-ours[i],sin3[i],ours[i]);
current=sin3[i];
}
if (which==3) {
/* start 46, peak=88, 21 */
ours[i]=round(64.0+
64.0*sin(i*(PI*2.0/256.0)));
printf("%d: %d (%d %d)\n",
i,sin4[i]-ours[i],sin4[i],ours[i]);
current=sin4[i];
}
if (ours[i]!=current) {
diff++;
}
}

View File

@ -3,8 +3,16 @@ import matplotlib.pyplot as plt
import numpy as np
import cmath
#sin1
#sin3 = (46,48,50,52,53,54,56,58,60,60,62,64,65,66,68,69,71,71,73,74,75,76,77,78,79,80,81,82,83,83,84,84,85,85,86,87,87,88,88,87,88,88,88,88,88,88,88,88,88,87,87,87,86,86,85,84,85,84,83,82,82,81,80,79,78,78,77,76,75,75,74,73,72,71,70,69,69,68,66,66,65,65,63,63,61,61,60,59,59,57,57,57,56,56,55,54,54,53,53,52,52,51,50,50,50,49,49,49,48,49,48,48,48,48,47,47,48,47,47,47,47,47,47,47,46,47,47,47,46,47,47,47,47,46,47,47,47,46,47,47,46,46,47,46,46,45,46,45,45,45,44,44,44,43,43,43,42,42,41,40,40,39,39,38,38,37,37,35,35,34,33,33,32,31,31,29,29,28,27,26,25,25,23,22,22,21,20,19,19,18,17,16,15,15,14,13,12,12,11,10,9,9,8,8,8,7,6,7,6,6,6,6,5,6,5,5,6,5,6,6,7,7,8,8,9,9,10,11,11,12,12,13,15,15,16,18,18,20,21,22,23,25,26,27,29,30,32,33,34,36,38,39,40,42,44,46)
#sin2
#sin3 = (46,51,56,60,64,67,71,75,78,81,84,86,89,90,92,93,93,94,94,93,92,90,89,87,85,83,79,76,73,70,66,62,58,54,50,46,42,38,35,31,28,24,21,18,16,14,12,10,9,8,7,7,7,7,9,10,11,13,15,17,19,22,25,28,31,34,38,41,44,47,50,54,56,59,62,63,66,68,70,71,72,73,75,75,75,74,74,73,73,72,70,68,67,65,63,60,58,56,53,51,48,46,44,42,40,38,36,34,33,32,31,31,30,30,29,29,30,30,31,32,33,34,36,37,39,41,43,45,46,48,51,53,55,56,58,60,61,62,63,63,64,64,65,64,64,63,63,62,61,59,58,56,54,52,49,47,45,43,41,37,35,33,31,29,27,25,24,22,21,20,20,19,19,19,19,20,22,23,24,26,28,29,32,35,38,40,44,46,50,53,56,59,62,65,69,72,75,76,79,81,83,84,85,85,87,87,87,86,85,83,82,80,78,75,73,69,66,63,59,55,52,48,44,39,35,31,28,24,20,17,14,11,9,7,5,3,2,1,0,0,1,1,2,3,5,7,10,13,16,19,23,26,30,34,38,42)
# sin3
#sin3 = (38,44,49,53,57,61,64,66,68,69,69,70,69,67,66,64,60,58,56,54,51,49,48,47,47,46,47,47,48,51,51,54,55,58,60,60,62,62,61,61,59,57,54,52,48,43,40,35,29,25,20,17,12,9,7,4,3,3,3,3,4,7,9,12,15,19,22,24,27,30,32,34,34,35,36,36,35,34,33,32,29,28,27,26,25,25,25,26,28,30,32,35,39,43,47,51,55,61,64,68,71,74,76,77,78,78,77,76,74,71,69,65,60,57,53,50,46,43,40,38,37,35,35,34,34,36,36,37,38,41,42,42,43,44,43,43,41,40,37,35,32,28,25,21,16,13,9,7,4,2,1,0,0,0,2,3,6,10,13,17,21,27,31,35,39,43,45,48,50,51,52,53,53,51,51,50,48,46,45,44,43,42,42,42,43,44,46,48,50,54,56,59,62,66,69,71,73,75,75,75,74,73,71,69,66,61,58,53,48,43,38,34,30,26,23,20,19,17,16,16,16,18,18,20,21,24,26,27,29,30,31,31,31,31,30,29,27,24,22,20,16,14,12,11,9,8,8,9,10,12,14,17,20,25,29,34)
# sin4
sin3 = (64,65,67,68,70,71,73,74,76,77,79,80,82,83,85,86,88,89,91,92,93,95,96,97,99,100,101,103,104,105,106,107,108,109,111,112,113,114,115,115,116,117,118,119,120,120,121,122,122,123,123,124,124,125,125,125,126,126,126,127,127,127,127,127,127,127,127,127,127,127,126,126,126,125,125,125,124,124,123,123,122,122,121,120,120,119,118,117,116,115,115,114,113,112,111,109,108,107,106,105,104,103,101,100,99,97,96,95,93,92,91,89,88,86,85,83,82,80,79,77,76,74,73,71,70,68,67,65,63,62,60,59,57,56,54,53,51,50,48,47,45,44,42,41,39,38,36,35,34,32,31,30,28,27,26,24,23,22,21,20,19,18,16,15,14,13,12,12,11,10,9,8,7,7,6,5,5,4,4,3,3,2,2,2,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,4,4,5,5,6,7,7,8,9,10,11,12,12,13,14,15,16,18,19,20,21,22,23,24,26,27,28,30,31,32,34,35,36,38,39,41,42,44,45,47,48,50,51,53,54,56,57,59,60,62)
sin3 = (46,48,50,52,53,54,56,58,60,60,62,64,65,66,68,69,71,71,73,74,75,76,77,78,79,80,81,82,83,83,84,84,85,85,86,87,87,88,88,87,88,88,88,88,88,88,88,88,88,87,87,87,86,86,85,84,85,84,83,82,82,81,80,79,78,78,77,76,75,75,74,73,72,71,70,69,69,68,66,66,65,65,63,63,61,61,60,59,59,57,57,57,56,56,55,54,54,53,53,52,52,51,50,50,50,49,49,49,48,49,48,48,48,48,47,47,48,47,47,47,47,47,47,47,46,47,47,47,46,47,47,47,47,46,47,47,47,46,47,47,46,46,47,46,46,45,46,45,45,45,44,44,44,43,43,43,42,42,41,40,40,39,39,38,38,37,37,35,35,34,33,33,32,31,31,29,29,28,27,26,25,25,23,22,22,21,20,19,19,18,17,16,15,15,14,13,12,12,11,10,9,9,8,8,8,7,6,7,6,6,6,6,5,6,5,5,6,5,6,6,7,7,8,8,9,9,10,11,11,12,12,13,15,15,16,18,18,20,21,22,23,25,26,27,29,30,32,33,34,36,38,39,40,42,44,46)
#x = np.arange(0,256,1)
# discrete works better if periodicity matches range (?)

View File

@ -1,4 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
static int sin1[256]={
0x2E,0x30,0x32,0x34,0x35,0x36,0x38,0x3A,
@ -71,10 +72,18 @@ static int sin4[256]={
int main(int argc, char **argv) {
int i;
int which=0;
if (argc>1) {
which=atoi(argv[1]);
}
for(i=0;i<256;i++) {
//printf("%d %d\n",i,sin1[i]);
printf("%d,",sin1[i]);
if (which==0) printf("%d,",sin1[i]);
if (which==1) printf("%d,",sin2[i]);
if (which==2) printf("%d,",sin3[i]);
if (which==3) printf("%d,",sin4[i]);
}
printf("\n");