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.


Messages - Matrefeytontias

Pages: 1 ... 71 72 [73] 74 75 ... 133
1081
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 :)

1082
Computer Programming / Re: Decent Mode 7 tutorial?
« on: June 20, 2013, 01:21:29 pm »
In fact, if you have read Permadi's tutorial entirely, Mode 7 is exactly floorcasting. I don't know what's the difference between these two, if any.

Anyway, the only good Mode 7 tutorial I've seen so far is the one at helixsoft : http://www.helixsoft.nl/articles/circle/sincos.htm . It's actually an entire article about amazing things you can do with sin() and cos() functions, and the last example is Mode 7. Though, the author uses the library Allegro, so he might make some calculations automatic (and he sometimes uses fixed-point arithmetic, which is absolutely confusing).

1083
Calculator C / Re: [Ndless] Tunnel
« on: June 20, 2013, 04:11:39 am »
Nice :) now try to look around and to bend the tunnel ;D

1084
News / Re: Ten TI Z80 calculator games you might have forgotten
« on: June 19, 2013, 08:53:19 pm »
Thanks for "featuring" Super Crate Box :D but as Hayleia said, it's compatible with 6 MHz calcs, since it was entirely written on a TI-83+.fr.

1085
Calculator C / Re: [Ndless] Tunnel
« on: June 19, 2013, 04:40:23 am »
Oh you're using it. So I know why there are those vertical lines on the texture : you're trying to use 3-bytes bitmaps but my function only loads correctly 16-bits non-paletted bitmaps.

EDIT : error spotted. You must not cast to unsigned when calculating distance and angle, because pixels at the left of te center have negative angles.

1086
The Axe Parser Project / Re: Features Wishlist
« on: June 19, 2013, 01:08:05 am »
Hayleia :
Assuming that each image is 8*8 (thus 8 bytes long) and that x and y go from 0 to tilemap_width-1 and tilemap_height-1 respectively (in number of sprites, not pixels) and X and Y go from 0 to 11 and 7 respectively
Here are your For loops.
And I don't think a Menu( command really is a good idea. I'm afraid that it could make beginners lazy, since they would have a command to do everything.

1087
Calculator C / Re: [Ndless] Tunnel
« on: June 19, 2013, 01:02:01 am »
Then be sure that you don't cast to unsigned too early in the calculations.

Can you post the code on pastebin or whatever, that I could look at it ?

1088
Calculator C / Re: [Ndless] Tunnel
« on: June 18, 2013, 04:21:18 pm »
And that doesn't work ? Weird .__.

Try replacing the cast with abs(), just to be sure.

1089
The Axe Parser Project / Re: Features Wishlist
« on: June 18, 2013, 04:16:56 pm »
In fact, a non-smooth tilemapper is such a simple thing that it can be expressed in one line of code. Assuming that each image is 8*8 (thus 8 bytes long) and that x and y go from 0 to tilemap_width-1 and tilemap_height-1 respectively (in number of sprites, not pixels) and X and Y go from 0 to 11 and 7 respectively :

Pt-On(X*8,Y*8,{y*tilemap_width+x+tilemap_pointer}*8+tiles_images_pointer)

Of course, I just did all the work for you, but it's just to show that tilemappers are not "extremely hard" as you said :)

1090
Calculator C / Re: [Ndless] Tunnel
« on: June 18, 2013, 04:02:10 pm »
^ that, but also I was actually asking for the calculations you replaced by "blah" ;D

1091
Calculator C / Re: [Ndless] Tunnel
« on: June 18, 2013, 03:16:42 pm »
No, I didn't mean that ; how do you calculate x and y from the code you posted ? Those are the ones you need to cast to unsigned int before moduling them.

1092
Calculator C / Re: [Ndless] Tunnel
« on: June 18, 2013, 02:35:06 pm »
I can't see your code since my phone is real shit, but seeing at the result it seems that somehow your implementation of the algorithm doesn't work with negative numbers. I'd recommend casting the angle and depth to unsigned int before using the modulo when you get the texels.

1093
TI-Nspire / Re: [Ndless C] nRayC, a raycasting library for TI-Nspire
« on: June 18, 2013, 05:52:43 am »
My goal is to write a stand-alone lib, so there's no chance that I'd use any other lib.

1094
TI-BASIC / Re: from the lower to the higher
« on: June 17, 2013, 07:53:41 am »
If it's the same than with z80 basic (TI-Basic for TI-82 to 84+), then you can access each element of a list this way :
Code: [Select]
temp(1)
temp(2)
temp(3)
...

1095
TI-Nspire / Re: [Ndless C] nRayC, a raycasting library for TI-Nspire
« on: June 15, 2013, 09:13:59 am »
Thanks hoffa, I'll use this one :)

Pages: 1 ... 71 72 [73] 74 75 ... 133