Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Matrefeytontias

Pages: 1 2 [3] 4 5 ... 7
31
TI Z80 / [Contest 2013][Axe] Advanced powdertoy
« on: October 10, 2013, 02:09:14 am »
Hey guys,

"I'm thirsty" will be my entry for the Calculator Gaming Roots contest. I don't know if it'll be finished in time, but we'll see.

So basically there is a little boy who found a dragon egg in the countryside. The dragon born and is very hungry, so the little boy give him meat. Then, the little dragon is very thirsty, but the little boy can't make him drink since the dragon drinks kerosen. So instead he brings his dragon to a special laboratory, and scientists will take care of bringing kerosen to the dragon.

You are one of those scientists, and you must bring the liquid kerosen to the dragon through levels full of obstacles using the different objects of the level. The game will feature realistic water physics, among other things. Screenshots coming soon.

Stay tuned :)

32
Hey guys,

I've been working on another axiom for 3D, this time to work with 3D vectors (I planned more things) !

Just check the attached photos of a 32-sided solid sphere (no animated gif because no PC) knowing that I only draw lines (no filled triangles), and that it runs at approximately 6 FPS at 6 MHz on a TI-83+ non-SE :)

For now, all 3D rotation/projection is done in Axe, and the backface culling is done with the 3 current functions of the axiom, MakeVec(pt1,pt2,output), DotProd(vec1,vec2) and CrossProd(vec1,vec2,output). Source and binaries will come when I'll have a PC <_<

WARNING ! HUGE AND BADLY TAKEN PHOTOS FROM A PHONE ! That's all I have atm.

EDIT(shmibs): scaled down

33
TI Z80 / [z80 ASM] Unnamed set of 3D routines
« on: July 04, 2013, 04:49:13 am »
<cross-posted from Cemetech>

Hallaw people,

I finally got something related with 3D working in ASM ! :D <this is a bit like a dream coming true for me :P>

Well, nothing too unbelievable, but I'm happy with what I have so far :)

So, I wrote 3 main routines, and a few other ones you can use, but these latter are not focused on 3D.

Main 3D routines :
  • BuildMatrix : builds the XY composite rotation matrix given the rotation angle about X and Y axis, respectively in b and c. The advantage is that you can rotate several vertices about the same angle without recalculating the rotation for each vertex.
  • ApplyMatrix : applies the matrix stored from AX to CZ (some .db in the program) to the three points stored at inX, inY and inZ and stores the result at outX, outY and outZ (more .dw). This is not necessarily a rotation matrix, but BuildMatrix writes to this area.
  • ProjectVertex : does the necessary calculation to project a vertex on-screen. Takes outX, outY and outZ as parameters and outputs at outX and outY. outZ remains unchanged.
Others routines provided (only because they are used by the 3 above routines) :
  • multHL_DE : performs HL*DE and stores the result in HL.
  • divHL64 : I let you guess.
  • mulHL64 : ↑ this.
  • AextendSignDE : converts the 8-bits signed number in A to a 16-bits signed number in DE.
  • getSin, getCos : retrieves the entry corresponding to the angle A in the trig look-up table (1-byte entries scaled to 64, so it goes from -64 to 64).
  • HLsignedDivDE : performs signed HL/DE, result in HL.
  • HLdivDE : performs unsigned HL/DE, result in HL (by Xeda112358).
Screenshot ? Yes, definitely :P



If you have any comment on the routines I described before I release the source, please tell me :)

34
ASM / [z80] 16 by 16 signed division
« on: July 01, 2013, 12:37:58 pm »
Hello people,

I need a HLbyDE signed division, but I can't find one on Google ...

Does any of you have that ?

35
Calculator C / We MUST port that to Ndless
« on: June 25, 2013, 10:04:35 am »
http://luis.net/projects/processing/wormhole/

It would be oh so awesome *.*

Although it's written for Processing, it's still Java → close to C++, so it should be feasible.

36
TI Z80 / [Axe] The Cutting Edge of Axe (an Axe 4k demo program)
« on: June 25, 2013, 06:27:25 am »
Hallaw guys,

To show my faith into Axe, I build a demo program in Axe. :) By "demo", I mean a program that shows what the language can do when pushed to its maximum :D

Well, I'm not saying I pushed Axe to its limit (ask Runer112 for that) but that I tried to write scenes that you don't see everywhere (in Axe at least) :)

The demo is named The Cutting Edge of Axe, is exactly 4088 bytes (not only executable, but also data) and contains 5 stunning scenes :) It's a Noshell program, so you can just run it with Asm(). Quickly press [enter] to go to the next scene. There isn't any command since it's a demo ;D

So, I let you download it (attached, the executable is TCEOAXE.8xp and the source DEMO.8xp), and for those without a TI-8x+, screenshot in spoiler ;D

Spoiler For If you have a TI-8x+, download the demo instead:

Of course, it fully runs at 6 MHz ;)

Enjoy, and as ever, share comments :)

37
Axe / [Tutorial] Optimize pixel-by-pixel drawing
« on: June 21, 2013, 09:22:36 am »
Hallaw,

When you have to draw a great part of the screen pixel by pixel (like for a game of life), the program usually become reaaally slow, since Axe is not good at pixel drawing. So I've thought of a method to greatly speed up this kind of tasks.

So, how does it work ? You know that the TI-z80-s screen (excepted the 84+ C) takes 1 byte to code 8 pixels, so that 1 bit = 1 pixel. The technique consists in calculating each pixel as we would do normally, and then turn on or off the corresponding bit of a variable instead of turning it on on the screen (which is absolutely slower). Then, when the 8 bits of the variable have been modified the way you wanted, you can directly store the variable in the corresponding byte of the buffer, thus turning on/off 8 pixels at a time. Of course, this'll only work if the width of area you want to paint is a multiple of 8.

So let's do it !

Let's say that our function is named BuildByte, since that's what it does.

First, we need a counter. This counter must send a signal every 8 times we call it.

:.Only once
:0→C
:
:Lbl BuildByte
:If C++^8
:.The counter doesn't send the signal
:Else
:.It does
:End
:...


Then, we need the variable which will contain the pixels data :
:.It must be initialized to 0 at the beginning of the program
:0→B


Say that the function BuildByte takes three arguments, the X-coordinate of the byte where the pixel must be drawn (not the pixel, so it must be a number between 0 and 11), the Y-coordinate of the pixel (between 0 and 63), then 0 if the current pixel must be white, or 1 if it must be black. We need to put this 0 or 1 to the corresponding bit of B. Then if C is a multiple of 8, then it means that the 8 bits of B have been set, and we store B in the corresponding byte of L6.

But how do we do set the corresponding bit precisely, and not any other bit ? It's actually pretty simple : we always set the first bit, and then if C modulo 8 is not 0, we shift B left once. Why that ? After 7 shifts, the first pixel/bit you passed to the function will become the last bit → the first pixel of the byte when it's on-screen.

:Lbl BuildByte
:.r1 is the X coordinate
:;r2 is the Y coordinate
:.r3 is the value of the pixel
:
:r3 or B→B
:If C++^8
:B*2→B
:Else
:B→{r2*12+r1+L6}
:0→B
:End
:Return


Remember that this will be efficient only if a relatively high number of calculations are needed for each pixel. For example, this plasma program I wrote a while ago uses this method (attached screenshot runs at 6 MHz).

Hoping that this'll help you :)

38
TI-Nspire / [Ndless C] nRayC, a raycasting library for TI-Nspire
« on: June 12, 2013, 02:58:18 pm »
Hallaw guys,

This is something I wanted to do since ... a year or two :P but I never got it to understand and apply correctly the technique of raycasting.

BUT ! Now it's done :D

So I wrote this library which I named nRayC, because it's an Nspire lib about RAYcasting to be used in C ;D

Although this library is mainly focused on raycasting, it's not its only use : I also included a bunch of functions, like pixel, line and even triangle (why not) drawing, tile detection, bitmaps loading and stuffs.

Currently, the library features raycasting rendered by a unique function :

void nRC_rayCasting(int *map, Vector player, ScreenPoint mapDimensions, Vector dir, Vector planeVec, uint16_t *textures, char *buffer)

It also provides two structures as you can see, ScreenPoint and Vector. I don't release anything for now because I don't think it's ready to be released, but I attach a screenshot of what it can do :)

I'm working actively on it, so expect progress every 2 days ;D

Share comments :)

39
TI-Nspire / Matrefeytontias's various animations
« on: June 11, 2013, 11:20:24 am »
Hallaw people,

In my free time I like to program some small animations on my calc, and I thought it could be cool to make a topic to show you the ones that I think should be shown :)

[Ndless C] Plasma (I know this already exists, but it doesn't use SDL anymore, for this I reused part of a library I'm writing to deal with screen and pixels). My library handles cross-compatibility, so you can use the same *.tns file for both CX and non-CX calcs :)

It takes ≈ 6 seconds to start because it has to compute and store 76800 * 7 sines and 76800 * 2 square roots in a table in order to get a decent execution speed :P

40
Calculator C / [Ndless] Problem with raycasting
« on: June 07, 2013, 01:26:47 pm »
Hallaw,

I've been working on ray casting since a little time and definitely can't make it work right. It's just crashing right now, and before crashing it did wrong maths.

I arranged the code like an engine (because that's want I'm wanting to do), so I can be sure that the problem is located in the nRC_rayCasting function.

Here is the full code (3 files) :

Spoiler For nRayC.c:
Code: [Select]
#include <os.h>

// Useful structures
typedef struct
{
int x;
int y;
} ScreenPoint;

// Functions

// Miscellaneous defines
#define abs(x) (x < 0 ? -x : x)
#define map(x, in_min, in_max, out_min, out_max) ((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min)

#define nRC_248mul(a,b) ((a*b) >> 8)
#define nRC_248div(a,b) ((a << 8) / b)

// Trigonometry

#define nRC_Sin(angle) nRC_Cos(angle + 64)

int nRC_Cos(int angle)
{
// Beware ! All trigonometry is done in base 256 !
int table[256]={128,128,128,128,127,127,127,126,126,125,124,123,122,122,121,119,118,117,116,114,113,111,110,108,106,105,103,101,99,97,95,93,91,248,86,84,81,79,76,74,71,68,66,63,60,58,55,52,49,46,43,40,37,34,31,28,25,22,19,16,13,9,6,3,0,-3,-6,-9,-13,-16,-19,-22,-25,-28,-31,-34,-37,-40,-43,-46,-49,-52,-55,-58,-60,-63,-66,-68,-71,-74,-76,-79,-81,-84,-86,-248,-91,-93,-95,-97,-99,-101,-103,-105,-106,-108,-110,-111,-113,-114,-116,-117,-118,-119,-121,-122,-122,-123,-124,-125,-126,-126,-127,-127,-127,-128,-128,-128,-128,-128,-128,-128,-127,-127,-127,-126,-126,-125,-124,-123,-122,-122,-121,-119,-118,-117,-116,-114,-113,-111,-110,-108,-106,-105,-103,-101,-99,-97,-95,-93,-91,-248,-86,-84,-81,-79,-76,-74,-71,-68,-66,-63,-60,-58,-55,-52,-49,-46,-43,-40,-37,-34,-31,-28,-25,-22,-19,-16,-13,-9,-6,-3,0,3,6,9,13,16,19,22,25,28,31,34,37,40,43,46,49,52,55,58,60,63,66,68,71,74,76,79,81,84,86,248,91,93,95,97,99,101,103,105,106,108,110,111,113,114,116,117,118,119,121,122,122,123,124,125,126,126,127,127,127,128,128,128};
return table[angle & 0xff];
}

#define nRC_Tan(angle) nRC_248div(nRC_Sin(angle), nRC_Cos(angle))

// Drawing functions

void nRC_setPixel(ScreenPoint pixel, int color, char* buffer)
{
int temp;
if(pixel.x < 319 && pixel.x > 0 &&
pixel.y < 239 && pixel.y > 0)
{
if(is_cx) // color LCD, 16 bpp
{
buffer[temp = ((pixel.y * 320 + pixel.x) * 2)]  = color & 0xff;
buffer[temp + 1] = color >> 8 & 0xff;
}
else // monochrome LCD, 4 bpp
{
temp = (pixel.y * 160 + pixel.x/2);
if(pixel.x & 1)
{
buffer[temp] = (buffer[temp] & 0xf0) | (color & 0x0f);
}
else
{
buffer[temp] = (buffer[temp] & 0x0f) | (color << 4 & 0xf0);
}
}
}
}

#define nRC_drawHorizontalLine(origin, end, constant, color, buffer) nRC_drawLineShared(origin, end, constant, color, buffer, 0)
#define nRC_drawVerticalLine(origin, end, constant, color, buffer) nRC_drawLineShared(origin, end, constant, color, buffer, 1)

void nRC_drawLineShared(int origin, int end, int constant, int color, char *buffer, int side)
{
ScreenPoint pixel;
int i,j;

if(constant > 0 && constant < (side ? 319 : 239))
{
i = min(origin, end);
j = max(origin, end);

if(!side)
{
pixel.y = constant;
for(pixel.x = i; pixel.x < j; pixel.x++) nRC_setPixel(pixel, color, buffer);
}
else
{
pixel.x = constant;
for(pixel.y = i; pixel.y < j; pixel.y++) nRC_setPixel(pixel, color, buffer);
}
}
}

void nRC_drawLine(ScreenPoint pt1, ScreenPoint pt2, int color, char* buffer)
{
    int dx, dy, inx, iny, e;
    
    dx = pt2.x - pt1.x;
    dy = pt2.y - pt1.y;
    inx = dx > 0 ? 1 : -1;
    iny = dy > 0 ? 1 : -1;
 
    dx = abs(dx);
    dy = abs(dy);
    
    if(dx >= dy) {
        dy <<= 1;
        e = dy - dx;
        dx <<= 1;
        while (pt1.x != pt2.x) {
            nRC_setPixel(pt1, color, buffer);
            if(e >= 0) {
                pt1.y += iny;
                e-= dx;
            }
            e += dy; pt1.x += inx;
        }
    } else {
        dx <<= 1;
        e = dx - dy;
        dy <<= 1;
        while (pt1.y != pt2.y) {
            nRC_setPixel(pt1, color, buffer);
            if(e >= 0) {
pt1.x += inx;
                e -= dy;
            }
            e += dx; pt1.y += iny;
        }
    }
    nRC_setPixel(pt1, color, buffer);
}

void nRC_fillTriangle(ScreenPoint pt1, ScreenPoint pt2, ScreenPoint pt3, int color, char *buffer)
{
int dx1, dx2, x1, x2, y, i;
ScreenPoint intermediate;

// Sort points from lowest to highest Y
if(pt1.y > pt2.y)
{
intermediate = pt1;
pt1 = pt2;
pt2 = intermediate;
}
if(pt2.y > pt3.y)
{
intermediate = pt2;
pt2 = pt3;
pt3 = intermediate;
}
if(pt1.y > pt2.y)
{
intermediate = pt1;
pt1 = pt2;
pt2 = intermediate;
}

// dx1 = (x2 - x1) / (y2 - y1)
dx1 = ((pt2.x - pt1.x) << 8) / ((pt2.y != pt1.y) ? pt2.y - pt1.y : 1);
// dx2 = (x3 - x1) / (y3 - y1)
dx2 = ((pt3.x - pt1.x) << 8) / ((pt3.y != pt1.y) ? pt3.y - pt1.y : 1);
x1 = x2 = pt1.x << 8;
y = pt1.y;

// X values are multiplied by 256 to handle a sort of a decimal part to make calculations, and thus slopes,
// more accurate. It's called a fixed .8 part, since it's only 8 bits.
for(i = 0; i < 2; i++)
{
do
{
nRC_drawHorizontalLine(x1 >> 8, x2 >> 8, y, color, buffer);
x1 += dx1;
x2 += dx2;
y++;
} while(y < pt2.y);

// dx1 = (x3 - x2) / (y3 - y2)
dx1 = ((pt3.x - pt2.x) << 8) / ((pt3.y != pt2.y) ? pt3.y - pt2.y : 1);
pt2.y = pt3.y;
}
}

inline void nRC_clearBuf(char *buffer)
{
memset(buffer, 0, SCREEN_BYTES_SIZE);
}

inline void nRC_dispBuf(char *buffer)
{
memcpy(SCREEN_BASE_ADDRESS, buffer, SCREEN_BYTES_SIZE);
}

// Ray casting

void nRC_rayCasting(int *map, ScreenPoint player, ScreenPoint mapDimensions, int fov, int angle, char *buffer)
{
int rayX, rayY, dx, dy, d1, d2, currentAngle, distFromProjPlane;
int deltaAngle, midFov;
int constantTan, flag, i = 0;
unsigned char currentUsableAngle;

deltaAngle = nRC_248div(fov, 320);
midFov = fov / 2;
currentAngle = ((angle - midFov) << 8) & 0xffff;
distFromProjPlane = 64*277;


for(i = 0; i < 320; i++)
{
currentAngle += deltaAngle;
currentAngle &= 0xffff;
currentUsableAngle = currentAngle >> 8;
constantTan = nRC_Tan(currentUsableAngle);

// Calculate distance from closest horizontal edge

if(currentUsableAngle & 127)
{
rayY = (currentUsableAngle < 128 ? ((player.y >> 6) + 1) << 6 : ((player.y >> 6) << 6) - 1);
rayX = (unsigned char)(currentUsableAngle + 64) & 127 ? nRC_248div(abs(rayY - player.y), constantTan) + player.x : player.x;

dy = currentUsableAngle < 128 ? 64 : -64;
dx = (unsigned char)(currentUsableAngle + 64) & 127 ? nRC_248div(64, constantTan) : 0;

//printf("rayX = %d ; rayY = %d ; dx = %d ; dy = %d\n", rayX, rayY, dx, dy);
//printf("currentUsableAngle = %d\n", currentUsableAngle);

if (map[(rayY >> 6) * mapDimensions.x + (rayX >> 6)])
{
d1 = nRC_248div(abs(player.y - rayY), (nRC_Sin(currentUsableAngle) ? nRC_Sin(currentUsableAngle) << 1 : 1));
goto skip1;
}

flag = 0;

while(1)
{
rayX += dx;
rayY += dy;
flag = rayX > 64 * mapDimensions.x || rayY > 64 * mapDimensions.y;
if (map[(rayY >> 6) * mapDimensions.x + (rayX >> 6)] || flag) break;
}
d1 = flag ? 50000000 : nRC_248div(abs(player.y - rayY), (nRC_Sin(currentUsableAngle) ? nRC_Sin(currentUsableAngle) << 1 : 1));
}
else d1 = 50000000;

skip1:
d1 = nRC_248mul(d1, nRC_Cos(angle - currentUsableAngle));

// At this point we have the distance from the closest horizontal edge in d1
// Now calculate distance from the closest vertical edge

if((unsigned char)(currentUsableAngle + 64) & 127)
{
rayX = (unsigned char)(currentUsableAngle - 64) < 128 ? ((player.x >> 6) << 6) - 1 : ((player.x >> 6) + 1) << 6;
rayY = nRC_248mul(abs(player.x - rayX), constantTan) + player.y;

dx = (unsigned char)(currentUsableAngle - 64) < 128 ? -64 : 64;
dy = nRC_248mul(64, constantTan);

if (map[(rayY >> 6) * mapDimensions.x + (rayX >> 6)])
{
d2 = nRC_248div(abs(player.x - rayX), (nRC_Cos(currentUsableAngle) ? nRC_Cos(currentUsableAngle) << 1 : 1));
goto skip2;
}

flag = 0;

while(1)
{
rayX += dx;
rayY += dy;
flag = rayX > 64 * mapDimensions.x || rayY > 64 * mapDimensions.y;
if (map[(rayY >> 6) * mapDimensions.x + (rayX >> 6)] || flag) break;
}
d2 = flag ? 50000000 : nRC_248div(abs(player.x - rayX), (nRC_Cos(currentUsableAngle) ? nRC_Cos(currentUsableAngle) << 1 : 1));
}
else d2 = 50000000;
skip2:
d2 = nRC_248mul(d2, nRC_Cos(angle - currentUsableAngle));

// Calculate the height of the current wall slice
d1 = distFromProjPlane / min(d1, d2);
nRC_drawVerticalLine((240 - d1) >> 1, (240 + d1) >> 1, i, 0xf800, buffer);
}
}
Spoiler For nRayC.h:
Code: [Select]
typedef struct
{
int x;
int y;
} ScreenPoint;

#define abs(x) (x < 0 ? -x : x)
#define map(x, in_min, in_max, out_min, out_max) ((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min)

#define nRC_248mul(a,b) ((a*b) >> 8)
#define nRC_248div(a,b) ((a << 8) / b)

#define nRC_Sin(angle) nRC_Cos(angle + 64)
extern int nRC_Cos(unsigned char angle);

extern void nRC_rayCasting(int *map, ScreenPoint player, ScreenPoint mapDimensions, int fov, int angle, char *buffer);

#define nRC_drawHorizontalLine(origin, end, constant, color, buffer) nRC_drawLineShared(origin, end, constant, color, buffer, 0)
#define nRC_drawVerticalLine(origin, end, constant, color, buffer) nRC_drawLineShared(origin, end, constant, color, buffer, 1)
void nRC_drawLineShared(int origin, int end, int constant, int color, char *buffer, int side);
extern void nRC_setPixel(ScreenPoint pixel, int color, char* buffer);
extern void nRC_drawLine(ScreenPoint pt1, ScreenPoint pt2, int color, char *buffer);
extern void nRC_fillTriangle(ScreenPoint pt1, ScreenPoint pt2, ScreenPoint pt3, int color, char *buffer);
extern inline void nRC_clearBuf(char *buffer);
extern inline void nRC_dispBuf(char *buffer);
Spoiler For test.c:
Code: [Select]
#include <os.h>
#include "nRayC.h"

int main(void)
{
int map[256] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
ScreenPoint player = { 448, 448 }, mapDim = { 16, 16 };
unsigned char angle, *buffer;

buffer = malloc(SCREEN_BYTES_SIZE);
if(!buffer) exit(0);

nRC_clearBuf(buffer);

angle = 64;

while(!isKeyPressed(KEY_NSPIRE_ESC))
{
nRC_rayCasting(map, player, mapDim, 60, angle, buffer);
nRC_dispBuf(buffer);
nRC_clearBuf(buffer);

angle += isKeyPressed(KEY_NSPIRE_RIGHT) - isKeyPressed(KEY_NSPIRE_LEFT);

if(isKeyPressed(KEY_NSPIRE_UP))
{
player.x = ((player.x << 6) + nRC_Cos(angle)) >> 6;
player.y = ((player.y << 6) + nRC_Sin(angle)) >> 6;
}
else if(isKeyPressed(KEY_NSPIRE_DOWN))
{
player.x = ((player.x << 6) - nRC_Cos(angle)) >> 6;
player.y = ((player.y << 6) - nRC_Sin(angle)) >> 6;
}
if(isKeyPressed(KEY_NSPIRE_PLUS)) printf("%d", angle);
}

free(buffer);
return 0;
}

Let me know if you see anything wrong (don't preoccupate of any function but nRC_rayCasting please).

Thanks by advance :)

EDIT : attached the tns that is crashing after jacobly asked for it.

41
Calculator C / [Ndless] Weird error
« on: June 02, 2013, 12:36:19 pm »
Hallaw,

I'm stuck with a weird error when programming with Ndless. The emulated Ti-Nspire CX (not sure if CAS) crashes when executing :
Code: [Select]
int* D3_sortFaces(Vertex *vertexTable, Vertex camera, int **faces, int numberOfFaces, int *verticesPerFace)
{
int i, j, flag, intermediate;
char *order;
int *zAverage;

order = malloc(numberOfFaces * sizeof(char));
if(order == NULL)
{
printf("error with order");
return NULL;
}

zAverage = malloc(numberOfFaces * sizeof(int));
if(zAverage == NULL)
{
free(order);
printf("error with zAverage");
return NULL;
}

for(i = 0; i < numberOfFaces; i++)
{
order[i] = i;
zAverage[i] = 0;
for(j = 0; j < verticesPerFace[i]; j++)
{
printf("%d,%d\n",i,j);
zAverage[i] += vertexTable[faces[i][j]].z - camera.z; // crashes here
}
zAverage[i] /= verticesPerFace[i];
}
printf("zAverage passed");
// etc
Given :
Code: [Select]
char faces[6][4] = { {0, 1, 2, 3}, {4, 5, 6, 7}, {0, 4, 7, 3}, {3, 2, 6, 7}, {0, 1, 5, 4}, {1, 5, 6, 2 } };
char *order;
int vpf[6] = { 4, 4, 4, 4, 4, 4 };


// ...
// rotated is a 8 elements-large table of bunches of 3 values
order = D3_sortFaces(rotated, (Vertex){0, 0, -150}, faces, 6, vpf);

I don't know if you understand well, but I don't want to release a complete source for now :/

What this does is that it displays "0,0", \n then "Reset" and → crash.

If you have any idea of what's wrong, please tell me :(

42
TI Z80 / [Axe] DualStar
« on: May 05, 2013, 05:22:04 am »
Hallaw people,

Yesterday I got bored and wrote this small game in 30-40 minutes :P It's a 2 players minigame, so you'll need two calcs, a link cable and a friend.

You were engaged in an epic space battle against your greatest enemy when you see that your trajectories slowly brings you in an asteroid field ... which can change direction due to gravity perturbation.

So the point of it is that you must blast each other while dodging the other's shots and the asteroids that move on the screen. Your ship fires automatically and aims the other ship, so you only have to take care of avoiding being touched by anything. On the left side of each calc you can see a line that empties slowly ; when it's empty, the asteroid field starts moving in another random direction - so try to get away of any asteroid to avoid a sudden hit.

As I said, I coded this in less than an hour, so I didn't make any menu, nor even any automatic quit :P so basically, when the game stops, the player which has "Done" written on his calc loose, and the other win. If you win, press [clear] to exit the game.

Also, I only ask to one user to press [2nd] when the two are ready. So if you press without your friend ready, press [clear] and retry. To sum up, if something goes wrong, press [clear], I inserted a [clear] key detection in all loops of the game :P

The player who hits [2nd] first will be the empty square, and the other player the black square.

It's a pixel-based detection, so you can't say "meeeeeh this hitbox is bugged" :P

Spoiler For Badly taken huge photo:

Source (DUAL.8xp) and binaries (DUALSTAR.8xp) attached.

Enjoy and as ever, share comments :)

43
Art / General sprite requests
« on: April 09, 2013, 12:38:14 pm »
Hey guys,

I'm in needs of sprites for IkarugaX, so by the way I thought that I could create (if it's not done already, please tell me if it's the case) a general sprite request topic, to avoid creating several ones for each game.

So, I need a 32*24 monochrome spaceship sprite, facing down. It's intended to be the first boss, so please make it look like a villain :P

Also, there's something to care about : the hit box has to be as large as possible, and obligatory rectangle-shaped.

That's all, thanks by advance :)

44
TI Z80 / [Axe] Ikaruga X
« on: April 01, 2013, 10:24:08 am »
Hey guys,

Today I'm starting another project : Ikaruga X, a port of Ikaruga, this time in Axe !

For those who don't know what Ikaruga is, it's a danmaku (also bullet hell), a game where bullets are as numerous on screen as pixels. Here's an image which says, in my opinion, pretty well what Ikaruga is :



The goal is simple : reach the end of the level, while blasting everything you can see.

But it's easier said than done : bullets are everywhere, and you can't dodge them all. No, you can't. Don't try. I'm being literal. But your spaceship is a special spaceship : it has two "modes", black and white. So while you are in black mode, black bullets don't hurt you, and while you are in white mode, white bullets don't hurt you.

Planned features :
  • A lot of enemies. A LOT.
  • At least ten times as many bullets as enemies
  • MOAR WEAPONS
  • Epic boss battles
  • Various levels
  • And more, why not

For now, I've got the spaceship designed (tell me if you like it) and the shoot engine working for the very first weapon level.



I eventually thought of playing the game with your calc sideways, with the ship facing right instead of facing up. I think it'll be easier to play. Again, tell me your opinion about that.



LATEST UPDATE : http://ourl.ca/18622/347492

LATEST prgmIKRGLVLS (needed to play) : http://www.omnimaga.org/index.php?action=dlattach;topic=16025.0;attach=15136

45
Hey guys,

I'm currently adapting F-Zero to use with the hoffa and t_k' mode7 engine, but I can't make it display a simple rotoscaled map. I didn't ask them because there's been a while they didn't even log in <_<

So, I adapted a little bit the engine to make it work with non-square maps, but it keep not working.

Original m7.c :
Code: [Select]
#include <os.h>
#include <SDL.h>

#include "m7.h"

void m7BuildLut(m7Vec_t lut[M7_SCREEN_HEIGHT]) {
    int screenRow;
    for (screenRow = 0; screenRow < M7_SCREEN_HEIGHT; ++screenRow) {
        float cameraV = (((float)screenRow / (float)M7_SCREEN_HEIGHT) * 2.0F - 1.0F);

        float rayX = M7_VIEW_PLANE_H;
        float rayY = 1.0F;
        float rayZ = M7_VIEW_PLANE_V * cameraV;

        float intersectY = (M7_VIEW_HEIGHT / rayZ) * rayY;
        float intersectX = (M7_VIEW_HEIGHT / rayZ) * rayX;

        lut[screenRow].x = M7_FLOAT_TO_FIX(intersectX);
        lut[screenRow].y = M7_FLOAT_TO_FIX(intersectY);
    }
}

void m7LoadTex(Uint8 tex[M7_NUM_TEX][M7_TEX_SIZE][M7_TEX_SIZE], ...) {
    va_list ap;
    int i, j, k;

    va_start(ap, tex);
    for (i = 0; i < M7_NUM_TEX; ++i) {
        SDL_Surface* surf = va_arg(ap, SDL_Surface*);
        for (j = 0; j < M7_TEX_SIZE; j++)
            for (k = 0; k < M7_TEX_SIZE; k++)
                tex[i][j][k] = nSDL_GetPixel(surf, k, j);
    }
    va_end(ap);
}

void m7Render(SDL_Surface *screen,
              m7Vec_t lut[M7_SCREEN_HEIGHT],
              Uint8 tilemap[M7_MAP_SIZE][M7_MAP_SIZE],
              Uint8 tex[M7_NUM_TEX][M7_TEX_SIZE][M7_TEX_SIZE],
              m7Vec_t pos,
              Sint32 heading) {
    int screenX, screenY;
    for (screenY = (M7_SCREEN_HEIGHT / 2) + 1; screenY < M7_SCREEN_HEIGHT; ++screenY) {
        m7Vec_t map = lut[screenY];
        m7Vec_t mapXStep = {-map.x / (M7_SCREEN_WIDTH / 2), 0};
       
        Sint32 sinHeading = m7SinLut(heading);
        Sint32 cosHeading = m7CosLut(heading);
       
        m7RotateVec(&map, sinHeading, cosHeading);
        m7RotateVec(&mapXStep, sinHeading, cosHeading);
       
        map.x += pos.x;
        map.y += pos.y;
       
        for (screenX = 0; screenX < M7_SCREEN_WIDTH; ++screenX) {
            Uint8 color = 0;

            if (map.x >= 0 && map.x < M7_INT_TO_FIX(M7_MAP_SIZE)
             && map.y >= 0 && map.y < M7_INT_TO_FIX(M7_MAP_SIZE))
                color = tex[(int)tilemap[map.y >> M7_TEX_SIZE]
                                        [map.x >> M7_TEX_SIZE]]
                           [(map.y & 0xFFFF) >> 12]
                           [(map.x & 0xFFFF) >> 12];

            map.x += mapXStep.x;
            map.y += mapXStep.y;

            M7_SET_PIXEL8(screenX, screenY, color);
        }
    }
    SDL_UpdateRect(screen, 0, M7_SCREEN_HEIGHT / 2, M7_SCREEN_WIDTH, M7_SCREEN_HEIGHT / 2);
}
(m7.h only contains some very basic defines)

Modified m7.c :
Code: [Select]
#include <os.h>
#include <SDL.h>

#include "m7.h"

void m7BuildLut(m7Vec_t lut[M7_SCREEN_HEIGHT]) {
    int screenRow;
    for (screenRow = 0; screenRow < M7_SCREEN_HEIGHT; ++screenRow) {
        float cameraV = (((float)screenRow / (float)M7_SCREEN_HEIGHT) * 2.0F - 1.0F);

        float rayX = M7_VIEW_PLANE_H;
        float rayY = 1.0F;
        float rayZ = M7_VIEW_PLANE_V * cameraV;

        float intersectY = (M7_VIEW_HEIGHT / rayZ) * rayY;
        float intersectX = (M7_VIEW_HEIGHT / rayZ) * rayX;

        lut[screenRow].x = M7_FLOAT_TO_FIX(intersectX);
        lut[screenRow].y = M7_FLOAT_TO_FIX(intersectY);
    }
}

void m7LoadTex(Uint8 tex[M7_NUM_TEX][M7_TEX_SIZE][M7_TEX_SIZE], ...) {
    va_list ap;
    int i, j, k;

    va_start(ap, tex);
    for (i = 0; i < M7_NUM_TEX; ++i) {
        SDL_Surface* surf = va_arg(ap, SDL_Surface*);
        for (j = 0; j < M7_TEX_SIZE; j++)
            for (k = 0; k < M7_TEX_SIZE; k++)
                tex[i][j][k] = nSDL_GetPixel(surf, k, j);
    }
    va_end(ap);
}

void m7LoadTexArray(Uint8 tex[M7_NUM_TEX][M7_TEX_SIZE][M7_TEX_SIZE], SDL_Surface *src)
{
int i,j,k;
for(i = 0; i < M7_NUM_TEX; i++)
for(k = 0; k < M7_TEX_SIZE; k++)
for(j = 0; j < M7_TEX_SIZE; j++)
tex[i][k][j] = nSDL_GetPixel(src, j, i * M7_TEX_SIZE + k);
}

void m7Render(SDL_Surface *screen,
              m7Vec_t lut[M7_SCREEN_HEIGHT],
              Uint8 **tilemap,
              Uint8 tex[M7_NUM_TEX][M7_TEX_SIZE][M7_TEX_SIZE],
              m7Vec_t pos,
              Sint32 heading,
  Uint8 mapWidth,
  Uint8 mapHeight) {
    int screenX, screenY;
    for (screenY = (M7_SCREEN_HEIGHT / 2) + 1; screenY < M7_SCREEN_HEIGHT; ++screenY) {
        m7Vec_t map = lut[screenY];
        m7Vec_t mapXStep = {-map.x / (M7_SCREEN_WIDTH / 2), 0};
       
        Sint32 sinHeading = m7SinLut(heading);
        Sint32 cosHeading = m7CosLut(heading);
       
        m7RotateVec(&map, sinHeading, cosHeading);
        m7RotateVec(&mapXStep, sinHeading, cosHeading);
       
        map.x += pos.x;
        map.y += pos.y;
       
        for (screenX = 0; screenX < M7_SCREEN_WIDTH; ++screenX) {
            Uint8 color = 0;

            if (map.x >= 0 && map.x < M7_INT_TO_FIX(mapWidth)
             && map.y >= 0 && map.y < M7_INT_TO_FIX(mapHeight))
                color = tex[(int)tilemap[map.y >> M7_TEX_SIZE]
                                        [map.x >> M7_TEX_SIZE]]
                           [(map.y & 0xFFFF) >> 12]
                           [(map.x & 0xFFFF) >> 12];

            map.x += mapXStep.x;
            map.y += mapXStep.y;

            M7_SET_PIXEL8(screenX, screenY, color);
        }
    }
    SDL_UpdateRect(screen, 0, M7_SCREEN_HEIGHT / 2, M7_SCREEN_WIDTH, M7_SCREEN_HEIGHT / 2);
}

demo.c (from the engine's zip, works) :
Code: [Select]
#include <os.h>
#include <SDL/SDL.h>

#include "m7.h"
#include "gfx.h"

SDL_Surface *screen;

SDL_Surface *loadTex(unsigned short *data) {
    SDL_Surface *tex, *tmp;
    tmp = nSDL_LoadImage(data);
    tex = SDL_DisplayFormat(tmp);
    SDL_FreeSurface(tmp);
    return tex;
}

int main(void) {
    m7Vec_t lut[M7_SCREEN_HEIGHT];
    Uint8 tilemap[M7_MAP_SIZE][M7_MAP_SIZE];
    Uint8 tex[M7_NUM_TEX][M7_TEX_SIZE][M7_TEX_SIZE];
    m7Vec_t pos = {M7_INT_TO_FIX(2), M7_INT_TO_FIX(4)};
    Sint32 heading = 0;

    SDL_Surface *texMushroom, *texFB, *texCartman, *texYoshi;
    nSDL_Font *font;
    const SDL_VideoInfo *info;
    Uint32 curTime = 0;
    Uint32 oldTime = 0;
    int fps = 0;
    int num_frames = 0;
    int done = 0;
    int i, j;

    SDL_Init(SDL_INIT_VIDEO);
    screen = SDL_SetVideoMode(M7_SCREEN_WIDTH, M7_SCREEN_HEIGHT, M7_BPP, SDL_SWSURFACE);
    font = nSDL_LoadFont(NSDL_FONT_TINYTYPE, 255, 255, 255);
    texMushroom = loadTex(ntiMushroom);
    texFB = loadTex(ntiFB);
    texCartman = loadTex(ntiCartman);
    texYoshi = loadTex(ntiYoshi);
    SDL_FillRect(screen, NULL, 0);
    info = SDL_GetVideoInfo();
    nSDL_DrawString(screen, font, 0, 0, "M7 engine test\nnSDL %s\n%dx%d\n%d-bit/%d-bit",
                    NSDL_VERSION, info->current_w, info->current_h, info->vfmt->BitsPerPixel, is_cx ? 16 : 4);
    SDL_Flip(screen);

    srand(42);
    for (i = 0; i < M7_MAP_SIZE; ++i)
        for (j = 0; j < M7_MAP_SIZE; ++j)
            tilemap[i][j] = rand() % 4;

    m7BuildLut(lut);
    m7LoadTex(tex, texMushroom, texFB, texCartman, texYoshi);

    while(!done) {
        m7Vec_t moveDist = {M7_INT_TO_FIX(0), M7_FLOAT_TO_FIX(0.25)};
        SDL_Rect fpsRect = {M7_SCREEN_WIDTH - 40, 0, 40, 8};

        m7RotateVec(&moveDist, m7SinLut(heading), m7CosLut(heading));

        if (isKeyPressed(KEY_NSPIRE_8)) m7AddVec(&pos, &moveDist);
        if (isKeyPressed(KEY_NSPIRE_2)) m7SubVec(&pos, &moveDist);
        if (isKeyPressed(KEY_NSPIRE_6)) m7AddVec(&pos, m7RotateVec(&moveDist, M7_INT_TO_FIX(1), 0));
        if (isKeyPressed(KEY_NSPIRE_4)) m7SubVec(&pos, m7RotateVec(&moveDist, M7_INT_TO_FIX(1), 0));
        if (isKeyPressed(KEY_NSPIRE_9)) heading -= 0x400;
        if (isKeyPressed(KEY_NSPIRE_7)) heading += 0x400;
        if (isKeyPressed(KEY_NSPIRE_ESC)) done = 1;

        m7Render(screen, lut, tilemap, tex, pos, heading);

        SDL_FillRect(screen, &fpsRect, 0);
        nSDL_DrawString(screen, font, fpsRect.x, fpsRect.y, "%d FPS", fps);
        SDL_UpdateRect(screen, fpsRect.x, fpsRect.y, fpsRect.w, fpsRect.h);
        curTime = SDL_GetTicks();
        if(curTime - oldTime <= 993) /* Clock set to 993 Hz by nSDL */
            ++num_frames;
        else {
            fps = num_frames;
            num_frames = 0;
            oldTime = curTime;
        }
    }

    SDL_FreeSurface(texYoshi);
    SDL_FreeSurface(texCartman);
    SDL_FreeSurface(texFB);
    SDL_FreeSurface(texMushroom);
    nSDL_FreeFont(font);
    SDL_Quit();

    return 0;
}

main.c (mine, doesn't work) :
Code: [Select]
#include <os.h>
#include <SDL.h>
#include "m7.h"

SDL_Surface *loadTex(unsigned short *data)
{
SDL_Surface *tex, *temp;
temp = nSDL_LoadImage(data);
tex = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
return tex;
}

int main(int argc, char *argv[])
{
// Mode7-relative variables
m7Vec_t lut[M7_SCREEN_HEIGHT];
#include "muteCityTilemap.h"
#include "muteCityTileset.h"
#include "blueFalcon.h"
Uint8 finalTex[M7_NUM_TEX][M7_TEX_SIZE][M7_TEX_SIZE];
m7Vec_t pos = {M7_INT_TO_FIX(1), M7_INT_TO_FIX(1)};
Sint32 heading = 0;

SDL_Surface *screen, *shipSurface, *tiles;
SDL_Rect shipRect, shipSrcRect;

shipRect.x = 136;
shipRect.y = 190;

shipSrcRect.x = (shipSrcRect.y = 0);
shipSrcRect.w = 48;
shipSrcRect.h = 31;

SDL_Init(SDL_INIT_VIDEO);

int speed = 0, rotationSpeed = 0;

screen = SDL_SetVideoMode(M7_SCREEN_WIDTH, M7_SCREEN_HEIGHT, M7_BPP, SDL_SWSURFACE);

shipSurface = nSDL_LoadImage(blueFalconSprite);
SDL_SetColorKey(shipSurface, SDL_SRCCOLORKEY, SDL_MapRGB(shipSurface->format, 0xff, 0, 0xff));

tiles = loadTex(muteCityTileset);

m7BuildLut(lut);
m7LoadTexArray(finalTex, tiles);

while(1)
{
m7Vec_t moveDist = {M7_INT_TO_FIX(0), M7_FLOAT_TO_FIX(0.25)};

m7RotateVec(&moveDist, m7SinLut(heading), m7CosLut(heading));

if(isKeyPressed(KEY_NSPIRE_ESC)) break;
if(isKeyPressed(KEY_NSPIRE_DOWN)) m7SubVec(&pos, &moveDist);
if(isKeyPressed(KEY_NSPIRE_LEFT))
{
heading -= 0x400;
shipSrcRect.y = 62;
}
if(isKeyPressed(KEY_NSPIRE_RIGHT))
{
heading += 0x400;
shipSrcRect.y = 31;
}
if(!isKeyPressed(KEY_NSPIRE_LEFT) && !isKeyPressed(KEY_NSPIRE_RIGHT)) shipSrcRect.y = 0;
if(isKeyPressed(KEY_NSPIRE_UP)) m7AddVec(&pos, &moveDist);

m7Render(screen, lut, muteCityTilemap, finalTex, pos, heading, 792, 366);

}

SDL_FreeSurface(tiles);
SDL_FreeSurface(shipSurface);
SDL_Quit();

return 0;
}

The *.h I use are always image datas.

You can download the engine here : http://ourl.ca/18123/337001

If you can help me, I'd be glad :(

Pages: 1 2 [3] 4 5 ... 7