* WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

Author Topic: Graphics and other system routines  (Read 10142 times)

0 Members and 1 Guest are viewing this topic.

Offline DarkestEx

  • Super User
  • Join Date: Jan 2015
  • Location: Germany
  • Posts: 1324
  • Post Rating Ratio: +10/-2
    • @0xbmuessig
    • @muessigb
    • My homepage
  • Gender: Male
Re: Graphics and other system routines
« Reply #30 on: October 21, 2015, 02:02:01 pm »
The copyright notice must be distributed with the binaries. That means you can put a credits screen, have it in a readme or even on a flier that comes with the console.
Yea, still I don't want to credit them. We aren't using foreign code so far and I don't want to start it. I will just rewrite it.
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc, Hewlett-Packard 100LX, Hewlett-Packard 95LX
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Hewlett-Packard 95LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s, IBM X60t, Nintendo DS Lite, Nintendo GameBoy Color, Nintendo GameCube, Xbox 360, Palm m5


Avatar drewn for me by Tabbes.

Offline Snektron

  • Lvl 69 Russian Snake
  • Super User
  • Join Date: Dec 2014
  • Location: Netherlands
  • Posts: 3165
  • Post Rating Ratio: +32/-0
  • SSSssssss.....
    • RobinDeWalvis
    • Kzyrox
    • RobinDeWalvis
    • quantuminfinity
  • Gender: Male
Re: Graphics and other system routines
« Reply #31 on: October 21, 2015, 02:35:41 pm »
It would also be cool to have some kind of overridable setPixel function. That way you can make simple pixel shaders run :)
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Offline DarkestEx

  • Super User
  • Join Date: Jan 2015
  • Location: Germany
  • Posts: 1324
  • Post Rating Ratio: +10/-2
    • @0xbmuessig
    • @muessigb
    • My homepage
  • Gender: Male
Re: Graphics and other system routines
« Reply #32 on: October 21, 2015, 03:21:34 pm »
It would also be cool to have some kind of overridable setPixel function. That way you can make simple pixel shaders run :)
How do you mean?
Also all graphic functions are drawing directly to the buffer not using the setPixel at all for speed.
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc, Hewlett-Packard 100LX, Hewlett-Packard 95LX
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Hewlett-Packard 95LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s, IBM X60t, Nintendo DS Lite, Nintendo GameBoy Color, Nintendo GameCube, Xbox 360, Palm m5


Avatar drewn for me by Tabbes.

Offline Snektron

  • Lvl 69 Russian Snake
  • Super User
  • Join Date: Dec 2014
  • Location: Netherlands
  • Posts: 3165
  • Post Rating Ratio: +32/-0
  • SSSssssss.....
    • RobinDeWalvis
    • Kzyrox
    • RobinDeWalvis
    • quantuminfinity
  • Gender: Male
Re: Graphics and other system routines
« Reply #33 on: October 21, 2015, 03:26:41 pm »
Well, you can make an inline setPixel function for simplicity's sake, right? :)
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Offline adekto

  • Full User
  • Join Date: Aug 2015
  • Location:
  • Posts: 26
  • Post Rating Ratio: +0/-0
Re: Graphics and other system routines
« Reply #34 on: October 21, 2015, 04:07:28 pm »
the pixel comand is in there and used by some of my code, so you can use it
i think you can also acces the hole buffer if you want, not sure how thoug ( you prefer a getpixel or specific regions?)

Offline Adriweb

  • Full User
  • Join Date: Jan 2015
  • Location: France & Canada
  • Posts: 423
  • Post Rating Ratio: +7/-1
    • Adriweb
    • @Adriweb
    • Adriweb
    • @UC-UIrbk5SuaUCvnV6SQvt-Q
    • /u/Adriweb
    • Adriweb
    • TI-Planet.org
  • Gender: Male
Re: Graphics and other system routines
« Reply #35 on: October 21, 2015, 04:20:43 pm »
Is this useful in some way? https://github.com/adriweb/BetterLuaAPI-for-TI-Nspire/blob/master/BetterLuaAPI.lua#L198-L222
(round rect routines, which I adapted from somewhere a long time ago)
  • Calculators owned: TI-Nspire CX CAS, TI-Nspire CX, TI-Nspire CAS (x3), TI-Nspire (x2), TI-Nspire CM-C CAS, TI-Nspire CAS+, TI-80, TI-82 Stats.fr, TI-82 Plus, TI-83 Plus, TI-83 Plus.fr USB, TI-84+, TI-84+ Pocket SE, TI-84+ C Silver Edition, TI-84 Plus CE, TI-89 Titanium, TI-86, TI-Voyage 200, TI-Collège Plus, TI-Collège Plus Solaire, 3 HP, some Casios
Co-founder & co-administrator of TI-Planet and Inspired-Lua

Offline Snektron

  • Lvl 69 Russian Snake
  • Super User
  • Join Date: Dec 2014
  • Location: Netherlands
  • Posts: 3165
  • Post Rating Ratio: +32/-0
  • SSSssssss.....
    • RobinDeWalvis
    • Kzyrox
    • RobinDeWalvis
    • quantuminfinity
  • Gender: Male
Re: Graphics and other system routines
« Reply #36 on: October 21, 2015, 06:09:29 pm »
I've made a ploygon fill algoritm. the speed is okay i think, but it still requires a sort for every horizontal line of pixels. I've used bubble sort for now but its easily changable.

Code: [Select]
public void polygon(int... points)
{
final int accuracy = 8;

if (points.length % 2 != 0 || points.length < 6)
return;

int[] get = new int[points.length / 2 * 5];
int getn = 0;
int [] xpt = new int[points.length / 2];
int xptn;

int pymax = 0, pymin = height-1;

for (int i=0; i<points.length; i+=2)
{
int x0 = points[i];
int y0 = points[i+1];
int x1 = points[(i+2)%points.length];
int y1 = points[(i+3)%points.length];

if (y0 > y1)
{
get[getn] = y1;
get[getn+1] = y0;
get[getn+2] = (x0-x1<<accuracy)/(y0-y1); // inverse slope
get[getn+3] = x0;
get[getn+4] = x0;
getn += 5;
}else if (y0 != y1)
{
get[getn] = y0;
get[getn+1] = y1;
get[getn+2] = (x1-x0<<accuracy)/(y1-y0); // inverse slope
get[getn+3] = x1;
get[getn+4] = x0;
getn += 5;
}

pymax = Math.max(y0, pymax);
pymin = Math.min(y0, pymin);
}

for (int scan=pymin+1; scan <= pymax; scan++)
{
xptn = 0;
for (int i=0; i<getn; i+=5)
if (scan > get[i] && scan <= get[i+1])
xpt[xptn++] = ((scan - get[i+1])*get[i+2]>>accuracy) + get[i+3];

bubbleSort(xpt, xptn);

for (int i=0; i<xptn-1; i+=2)
for (int x = xpt[i]; x < xpt[i+1]; x++)
setPixel(x, scan);
}
}

public void bubbleSort(int[] array, int n)
{
    boolean swapped = true;
    int j = 0;
    int tmp;
    while (swapped)
    {
    swapped = false;
    j++;
    for (int i = 0; i < n-j; i++)
    {
    if (array[i] > array[i+1])
    {
    tmp = array[i];
    array[i] = array[i+1];
    array[i+1] = tmp;
    swapped = true;
    }
    }
    }
}

note: "int... points" is anotherway of writing "int[] points" in java. The difference is you can supply the arguments without making them an array first, ie polygon(0, 10, 10, 10, 10, 0); which is the same as polygon(new int[]{0, 10, 10, 10, 10, 0});  ;)

Since it uses ints only and a slope is a value which usually is a floating point number ive mutiplied it with a number (the accuracy constant). To save on precious cpu cycles i've used shift instead of multiply/divide
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Offline DarkestEx

  • Super User
  • Join Date: Jan 2015
  • Location: Germany
  • Posts: 1324
  • Post Rating Ratio: +10/-2
    • @0xbmuessig
    • @muessigb
    • My homepage
  • Gender: Male
Re: Graphics and other system routines
« Reply #37 on: October 22, 2015, 11:08:18 pm »
I've made a ploygon fill algoritm. the speed is okay i think, but it still requires a sort for every horizontal line of pixels. I've used bubble sort for now but its easily changable.

Code: [Select]
public void polygon(int... points)
{
final int accuracy = 8;

if (points.length % 2 != 0 || points.length < 6)
return;

int[] get = new int[points.length / 2 * 5];
int getn = 0;
int [] xpt = new int[points.length / 2];
int xptn;

int pymax = 0, pymin = height-1;

for (int i=0; i<points.length; i+=2)
{
int x0 = points[i];
int y0 = points[i+1];
int x1 = points[(i+2)%points.length];
int y1 = points[(i+3)%points.length];

if (y0 > y1)
{
get[getn] = y1;
get[getn+1] = y0;
get[getn+2] = (x0-x1<<accuracy)/(y0-y1); // inverse slope
get[getn+3] = x0;
get[getn+4] = x0;
getn += 5;
}else if (y0 != y1)
{
get[getn] = y0;
get[getn+1] = y1;
get[getn+2] = (x1-x0<<accuracy)/(y1-y0); // inverse slope
get[getn+3] = x1;
get[getn+4] = x0;
getn += 5;
}

pymax = Math.max(y0, pymax);
pymin = Math.min(y0, pymin);
}

for (int scan=pymin+1; scan <= pymax; scan++)
{
xptn = 0;
for (int i=0; i<getn; i+=5)
if (scan > get[i] && scan <= get[i+1])
xpt[xptn++] = ((scan - get[i+1])*get[i+2]>>accuracy) + get[i+3];

bubbleSort(xpt, xptn);

for (int i=0; i<xptn-1; i+=2)
for (int x = xpt[i]; x < xpt[i+1]; x++)
setPixel(x, scan);
}
}

public void bubbleSort(int[] array, int n)
{
    boolean swapped = true;
    int j = 0;
    int tmp;
    while (swapped)
    {
    swapped = false;
    j++;
    for (int i = 0; i < n-j; i++)
    {
    if (array[i] > array[i+1])
    {
    tmp = array[i];
    array[i] = array[i+1];
    array[i+1] = tmp;
    swapped = true;
    }
    }
    }
}

note: "int... points" is anotherway of writing "int[] points" in java. The difference is you can supply the arguments without making them an array first, ie polygon(0, 10, 10, 10, 10, 0); which is the same as polygon(new int[]{0, 10, 10, 10, 10, 0});  ;)

Since it uses ints only and a slope is a value which usually is a floating point number ive mutiplied it with a number (the accuracy constant). To save on precious cpu cycles i've used shift instead of multiply/divide
Nice :)

This is the final color palette in case somebody hasn't seen it yet:
http://docs.ninjabyte.eu/microcat/global_palette.html
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc, Hewlett-Packard 100LX, Hewlett-Packard 95LX
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Hewlett-Packard 95LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s, IBM X60t, Nintendo DS Lite, Nintendo GameBoy Color, Nintendo GameCube, Xbox 360, Palm m5


Avatar drewn for me by Tabbes.

Offline xlibman

  • Omni founder & CW co-founder
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18793
  • Post Rating Ratio: +98/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Graphics and other system routines
« Reply #38 on: October 23, 2015, 06:24:13 am »
Quote from: Streetwalrus
--- Quote from: DarkestEx on Today at 03:30:03 pm ---I really don't like the licence of the code. It requires us to include a copyright. I think its better to use the functions provided earlier in this topic.

--- End quote ---
That's just the BSD license, the "copyright notice" is only a request for credits.
Sure, but i don't like and can't include the licence into the binary image. I want to have as much of the code written by us or people interested in the project as possible. I don't like reusing others code when not required. In this case, as we have most functions that we will use provided by either the great people here, written ourselves or adapted from MIT code, I think we will just rewirite the external code.
I think my main gripe with using code that requires copyrights like this would be the fact the readme or console is littered with watermarks. Imagine if everytime you start the console you were forced to display some splash screen with the company logo of the people who wrote the code or something (like when starting a Game Maker game)

It's fine if the only place where you are forced to put credits in is the readme or credits screen, though, since those aren't intrusive. But I guess using your own code would be better since it makes it easier to sell the console.
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Streetwalrus

  • Professional slacker
  • Super User
  • Original 5
  • Join Date: Nov 2014
  • Location: Israel
  • Posts: 2903
  • Post Rating Ratio: +20/-0
  • ƎW∀⅁ ƎH⊥
  • Gender: Male
Re: Graphics and other system routines
« Reply #39 on: October 23, 2015, 06:34:38 am »
These licenses are made exactly so that you can freely reuse the code for anything. I think it's pretty fair that the author is asking for credits.
  • Calculators owned: TI-80, HP 40G, TI-84 Plus rev G (yay 128k RAM), TI-83 Plus Silver Edition (broken LCD), TI-82 Stats.fr (black), TI-Nspire CX rev C (yay Nlaunchy), TI-83+ SE ViewScreen



Offline xlibman

  • Omni founder & CW co-founder
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18793
  • Post Rating Ratio: +98/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Graphics and other system routines
« Reply #40 on: October 23, 2015, 06:42:42 am »
Yeah I know. I am mostly talking about licenses that requires using anything that looks like a watermark or advertising. Imagine playing First Fantasy Microcat with ads plastered everywhere O.O
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Streetwalrus

  • Professional slacker
  • Super User
  • Original 5
  • Join Date: Nov 2014
  • Location: Israel
  • Posts: 2903
  • Post Rating Ratio: +20/-0
  • ƎW∀⅁ ƎH⊥
  • Gender: Male
Re: Graphics and other system routines
« Reply #41 on: October 23, 2015, 06:44:00 am »
Lol that's abusive, no one would want to use code under such a license.
  • Calculators owned: TI-80, HP 40G, TI-84 Plus rev G (yay 128k RAM), TI-83 Plus Silver Edition (broken LCD), TI-82 Stats.fr (black), TI-Nspire CX rev C (yay Nlaunchy), TI-83+ SE ViewScreen



Offline DarkestEx

  • Super User
  • Join Date: Jan 2015
  • Location: Germany
  • Posts: 1324
  • Post Rating Ratio: +10/-2
    • @0xbmuessig
    • @muessigb
    • My homepage
  • Gender: Male
Re: Graphics and other system routines
« Reply #42 on: October 23, 2015, 07:18:45 am »
These licenses are made exactly so that you can freely reuse the code for anything. I think it's pretty fair that the author is asking for credits.
Sure but I don't want to use such code when not absolutely required.
That's my final word on this.
I really don't want to plaster my binary files with copyright notices for single functions.
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc, Hewlett-Packard 100LX, Hewlett-Packard 95LX
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Hewlett-Packard 95LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s, IBM X60t, Nintendo DS Lite, Nintendo GameBoy Color, Nintendo GameCube, Xbox 360, Palm m5


Avatar drewn for me by Tabbes.

Offline semiprocoder

  • Full User
  • Join Date: May 2015
  • Location:
  • Posts: 282
  • Post Rating Ratio: +2/-0
    • awesommee333
    • 114/11470
  • Gender: Male
Re: Graphics and other system routines
« Reply #43 on: November 13, 2015, 12:22:13 am »
wait are you still suporting 16 bit color mode?
Also do you want a pure triangle draw code, because I could easily make one, as I made one in lua that I deleted, as it was(a bit) slower than filling polygons,at least on computer. However, it only sorts the points. Also, lua uses decimals, while I would use integers in the c code for this.
« Last Edit: November 13, 2015, 12:26:25 am by semiprocoder »
  • Calculators owned: ti nspire, ti 84 plus se
My cemetech username is awesommee333.

Offline DarkestEx

  • Super User
  • Join Date: Jan 2015
  • Location: Germany
  • Posts: 1324
  • Post Rating Ratio: +10/-2
    • @0xbmuessig
    • @muessigb
    • My homepage
  • Gender: Male
Re: Graphics and other system routines
« Reply #44 on: November 13, 2015, 12:37:19 am »
wait are you still suporting 16 bit color mode?
Also do you want a pure triangle draw code, because I could easily make one, as I made one in lua that I deleted, as it was(a bit) slower than filling polygons,at least on computer. However, it only sorts the points. Also, lua uses decimals, while I would use integers in the c code for this.
No true 16 bit colors aren't supported anymore. Though you can cheat by using the 39 dynamic palette colors that you can assign any 16 bit color to. You can use these dynamic colors everywhere from sprites to all drawing functions.

About the triangle code, I would love to have yours if you post it here. I am glad about any graphic function that is useful in game making and has no requirement for floating point :)
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc, Hewlett-Packard 100LX, Hewlett-Packard 95LX
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Hewlett-Packard 95LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s, IBM X60t, Nintendo DS Lite, Nintendo GameBoy Color, Nintendo GameCube, Xbox 360, Palm m5


Avatar drewn for me by Tabbes.

 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio BroniesQC TI-Planet BosaikNet