I’am trying to convert this code to a pde but it just doesnt work form me
#include <avr/pgmspace.h>
#include "leds.h"
#include "pic.h"
#include "sintab.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdio.h>
//Routine to read the sine table from sintab.h
const static char mysin(const char p) {
if (p==-128) return mysin(0);
if (p<-63) return -mysin(127+p);
if (p<0) return -mysin(-p);
if (p>63) return mysin(127-p);
return pgm_read_byte(sintab+p);
}
//Calculates the value of the plasma at location x,y at time n.
const static unsigned char getpixel(const char x, const char y, const short n) {
unsigned char p;
//This is the base of the plasma: nothing more than some strange
//random sine functions. Modify these to modify the shape of the plasma.
p=mysin(x+n)/4;
p+=mysin((x<<2)+(y<<1)+(n<<2))/4;
p+=mysin(-(x<<3)+(y<<1)+(n>>1))/2;
p+=mysin((x<<1)-(y<<3)+(n<<1))/2;
p+=mysin((x<<4)+(y<<4)+(n>>3))/4;
//Take the sine of the result
p=(mysin(p<<1)+128);
return p;
}
int main(void) {
int x,y,n;
//init led board
initleds();
//copy picture from pic.h to display memory
for (x=0; x<512; x++) dispmem[x]=pgm_read_byte(picture+x);
sei(); //let the ledboard-routine do it's job
//Wait. Because the delay routine keeps getting interrupted by the
//(processor intensive) led-board-routines, this'll take much longer than
//the implicated 2 seconds (actually, almost 3 times as long.)
for (x=0; x<200; x++) _delay_ms(10);
//Go and generate plasma for all eternity :)
while(1) {
for (y=0; y<16; y++) {
for (x=0; x<32; x++) {
//Calculate the plasma value at that point and stuff it into the
//display memory
dispmem[x+(y<<5)]=getpixel(x,y,n);
}
}
n++;
}
return 0;
}