Quantcast
Channel: Cemetech
Viewing all articles
Browse latest Browse all 75345

Casio Prizm/FX Development & Programming :: RE: Spenceboy98's OFFICIAL Prizm C Help Topic

$
0
0
Author: Spenceboy98
Posted: 11 Oct 2012 07:11:54 pm (GMT -5)

matrefeytontias wrote:
Heya Smile

As Spenceboy98 said, I don't really want the code to be shared, even if I gave it to him in help purposes.

In fact, he needs two LUTs which are the dimension of the screen : one to hold angles to the centre and one to hold a depth calculated from the distance of each pixel to the center of the screen (using the forumlas I gave him).

So the LUTs are required ; you can still malloc them.


I changed the values to smaller(screen, angle_lut, depth_lut). It goes past them, but it reboots at a later point too. I'm gonna try to find where, but if you can see it in the code already(see previous code), tell me.

Edit:
My current code:

Code:
#include "keyboard.hpp"
#include "keyboard_syscalls.h"
#include "math.h"
#include "display.h"
#include "color.h"
#include "Texture.h"
#include "stdlib.h"

#define max(a,b) ((a)>(b))?(a):(b);

int PRGM_GetKey(){
  unsigned char buffer[12];
  PRGM_GetKey_OS( buffer );
  return ( buffer[1] & 0x0F ) * 10 + ( ( buffer[2] & 0xF0 ) >> 4 );
}

 float (*angle_lut)[32];
 float (*depth_lut)[32];
 double relativeX;
 double relativeY;
 int textureX;
 int textureY;
 int tunnel_rotate = 0;
 int tunnel_zoom = 0;
 int TEXTURE_WIDTH = 16;
 int TEXTURE_HEIGHT = 16;
 int w = 32;
 int h = 32;
 int x;
 int y;
 char color;
 char *screen;
 float pi = 3.141592654;
int main() {


 angle_lut = malloc(w * sizeof(*angle_lut));
 if(!angle_lut){
 return 0;
 }
 depth_lut = malloc(w * sizeof(*depth_lut));
 if(!depth_lut)
 {
  free(angle_lut);
  return 0;
 }
 screen = malloc((32*32) * sizeof(char));     // just a buffer
 if(!screen)
 {
  free(angle_lut);
  free(depth_lut);
  return 0;
 }
 for(y = 0; y < h; y+=2)
 {
  relativeY = h / 4 - y;
  for(x = 0; x < w; x+=2)
  {
   relativeX = x - w / 2;
   depth_lut[x][y] = w*h*2 / max(relativeX * relativeX + relativeY * relativeY, 1);
   angle_lut[x][y] = atan2(relativeX, relativeY) * (TEXTURE_WIDTH / pi) * 4;
   PrintXY(1,1,"vvAfterAngleDepth", 0, TEXT_COLOR_BLACK);
   Bdisp_PutDisp_DD();
  }
 }
   PrintXY(1,1,"vvBeforeWhile", 0, TEXT_COLOR_BLACK);
   Bdisp_PutDisp_DD();
  while(1) {
   PrintXY(1,1,"vvAfterWhile", 0, TEXT_COLOR_BLACK);
   Bdisp_PutDisp_DD();
    int key = PRGM_GetKey();
    if(key == KEY_PRGM_MENU) {  GetKey(&key); }
  for(y = 0; y < h; y+=2)
  {
   PrintXY(1,1,"vvFOR1", 0, TEXT_COLOR_BLACK);
   Bdisp_PutDisp_DD();
   for(x = 0; x < w; x+=2)
   {
   PrintXY(1,1,"vvFOR2", 0, TEXT_COLOR_BLACK);
   Bdisp_PutDisp_DD();
    textureX = angle_lut[x][y] + tunnel_rotate;
    textureY = depth_lut[x][y] + tunnel_zoom;
   PrintXY(1,1,"vvColor", 0, TEXT_COLOR_BLACK);
   Bdisp_PutDisp_DD();
    color = texture[(textureY & (TEXTURE_HEIGHT - 1)) * TEXTURE_WIDTH + (textureX & (TEXTURE_WIDTH - 1))];
    if(color != 0xffff)
    {
     Bdisp_SetPoint_DD(x, y, color);
     Bdisp_SetPoint_DD(x + 1, y, color);
     Bdisp_SetPoint_DD(x, y + 1, color);
     Bdisp_SetPoint_DD(x + 1, y + 1, color);
     }
   }
  }
   PrintXY(1,1,"vvEND", 0, TEXT_COLOR_BLACK);
    Bdisp_PutDisp_DD();
    Bdisp_AllCr_VRAM();
  tunnel_zoom += 2;
  }
  return 0;
}


It's resetting after the "AfterAngleDepth", but before the "BeforeWhile". Any Ideas? I'm thinking that it is happening during one of the for loops, but I don't know any more than that.


Viewing all articles
Browse latest Browse all 75345

Trending Articles