Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
23 May, 2013, 20:39:02 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: 1 2 [3] 4 5 ... 13   Go Down
  Print  
Author Topic: Post your Nspire routines here! -  (Read 15413 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
bwang
LV7 Elite (Next: 700)
*******
Offline Offline

Last Login: 11 August, 2012, 12:59:06
Date Registered: 20 June, 2009, 01:42:58
Posts: 632

Topic starter
Total Post Ratings: +19

View Profile
« Reply #30 on: 24 May, 2010, 04:14:37 »
0

Thanks to bwang, to access time use

1
int time = * (unsigned*) 0x90090000
Since that is memory-mapped hardware, you need to use * (volatile unsigned*)
Really? yoshi13 tells me just * (unsigned*) worked.
Logged
calc84maniac
Epic z80 roflpwner
Coder Of Tomorrow
LV11 Super Veteran (Next: 3000)
*
Offline Offline

Gender: Male
Last Login: 20 May, 2013, 21:27:24
Date Registered: 28 August, 2008, 05:09:05
Location: Right behind you.
Posts: 2735


Total Post Ratings: +373

View Profile
« Reply #31 on: 24 May, 2010, 04:16:36 »
0

If you have optimization enabled, a loop that waits for this time value to reach a certain amount will probably optimize so 0x90090000 is only read once and that value is compared for the rest of the loop. Using "volatile" will guarantee that the memory will literally be read every time it is referenced.
Logged

"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman
t0xic_kitt3n
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: 13 May, 2013, 01:56:35
Date Registered: 16 June, 2010, 20:46:00
Location: w,x,y,z
Posts: 1583


Total Post Ratings: +32

View Profile
« Reply #32 on: 16 June, 2010, 20:59:48 »
0

I'm having trouble compiling with the skeleton environment. I was able to successfully compile the Ndless demo, whereas Bwang's raycaster and a small test program I wrote won't compile. It seems to not be loading the headers properly.

Here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <os.h>
#include <common.h>
#include <utils.h>

asm(".string \"PRG\"\n");

int main()

{
  int antx = 160;
  int anty = 120;
  int dir = 1;
 
  while (!isKeyPressed(KEY_NSPIRE_ESC)) {
    if (getpixel(antx,anty) == 15) {
      setpixel(anty,antx,0);
      dir = dir - 1;
      }
    else {
      setpixel(anty,antx,15);
      dir = dir + 1;
      }
    if (dir == 0)
      dir = 4;
    else if (dir == 5)
      dir = 1;
    if (dir == 1)
      antx = antx - 1;
    else if (dir == 2)
      anty = anty + 1;
    else if (dir == 3)
      antx = antx + 1;
    else
      anty = anty - 1;
    if (antx == 0)
      antx = 320;
    else if (antx == 321)
      antx = 1;
    if (anty == 0)
      anty = 240;
    else if (anty ==  241)
      anty = 1;
   }
   return 0;
}

And the the full output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
arm-elf-gcc -mcpu=arm7tdmi -O3 -Wall -W -fpie -fno-merge-constants -c -I./header
s -D NON_CAS main.c
In file included from ./headers/os.h:17,
                 from main.c:1:
./headers/common.h:62:20: warning: missing whitespace after the macro name
./headers/common.h:71:22: warning: missing whitespace after the macro name
./headers/common.h:114:20: warning: missing whitespace after the macro name
./headers/common.h:114:1: warning: "KEY_NSPIRE_" redefined
./headers/common.h:62:1: warning: this is the location of the previous definitio
n
./headers/common.h:116:20: warning: missing whitespace after the macro name
./headers/common.h:116:1: warning: "KEY_NSPIRE_" redefined
./headers/common.h:114:1: warning: this is the location of the previous definiti
on
main.c: In function 'setPixel':
main.c:23: warning: implicit declaration of function 'getpixel'
main.c:24: warning: implicit declaration of function 'setpixel'
main.c:52: warning: 'return' with a value, in function returning void
main.c: In function 'main':
main.c:53: error: expected declaration or statement at end of input
make: *** [main.o] Error 1

If it matters, I'm using the arm-elf-gcc version of yagarto.
Logged




██████  ██  ██  ███████           ████    ██    ██   ██ ███████
█ ██ █  ██  ██   ██   █          ██  ██  ████   ███ ███  ██   █
  ██    ██  ██   ██             ██   ██ ██  ██  ███████  ██    
  ██    ██  ██   ██  █         ██       ██  ██  ███████  ██  █
  ██    ██████   █████         ██       ██  ██  ██ █ ██  █████ 
  ██    ██  ██   ██  █         ██   ███ ██████  ██   ██  ██  █
  ██    ██  ██   ██             ██   ██ ██  ██  ██   ██  ██    
  ██    ██  ██   ██   █          ██  ██ ██  ██  ██   ██  ██   █
 ████   ██  ██  ███████           █████ ██  ██  ██   ██ ███████

bwang
LV7 Elite (Next: 700)
*******
Offline Offline

Last Login: 11 August, 2012, 12:59:06
Date Registered: 20 June, 2009, 01:42:58
Posts: 632

Topic starter
Total Post Ratings: +19

View Profile
« Reply #33 on: 16 June, 2010, 22:48:31 »
0

Fixed code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <os.h>
//notice the quotes around utils.h
#include "utils.h"

asm(".string \"PRG\"\n");

int main()
{
  int antx = 160;
  int anty = 120;
  int dir = 1;

  while (!isKeyPressed(KEY_NSPIRE_ESC)) {
    if (getPixel(antx,anty) == 15) {
      setPixel(anty,antx,0);
      dir = dir - 1;
      }
    else {
      setPixel(anty,antx,15);
      dir = dir + 1;
      }
    if (dir == 0)
      dir = 4;
    else if (dir == 5)
      dir = 1;
    if (dir == 1)
      antx = antx - 1;
    else if (dir == 2)
      anty = anty + 1;
    else if (dir == 3)
      antx = antx + 1;
    else
      anty = anty - 1;
    if (antx == 0)
      antx = 320;
    else if (antx == 321)
      antx = 1;
    if (anty == 0)
      anty = 240;
    else if (anty ==  241)
      anty = 1;
   }
   return 0;
}
I also updated skeleton.zip to use willrandship's common.h, as well as some other minor changes.
« Last Edit: 16 June, 2010, 22:51:01 by bwang » Logged
t0xic_kitt3n
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: 13 May, 2013, 01:56:35
Date Registered: 16 June, 2010, 20:46:00
Location: w,x,y,z
Posts: 1583


Total Post Ratings: +32

View Profile
« Reply #34 on: 18 June, 2010, 00:24:32 »
0

I tried that, and I'm still getting the same error message.

-Edit: I feel so stupid! The problem with the getPixel and setPixel was me not capitalizing the P. Now, I get the demo.bin and demo.elf files, but maketns won't work. Here's the error message:


1
2
3
process_begin: CreateProcess(C:\Users\Amar\Desktop\skeleton\tools\MakeTNS\MakeTNS, ./tools/MakeTNS/MakeTNS demo.bin demo-noncas.tns, ...) failed.
make (e=193): Error 193
make: *** [demo] Error 193
« Last Edit: 18 June, 2010, 00:39:59 by fb39ca4 » Logged




██████  ██  ██  ███████           ████    ██    ██   ██ ███████
█ ██ █  ██  ██   ██   █          ██  ██  ████   ███ ███  ██   █
  ██    ██  ██   ██             ██   ██ ██  ██  ███████  ██    
  ██    ██  ██   ██  █         ██       ██  ██  ███████  ██  █
  ██    ██████   █████         ██       ██  ██  ██ █ ██  █████ 
  ██    ██  ██   ██  █         ██   ███ ██████  ██   ██  ██  █
  ██    ██  ██   ██             ██   ██ ██  ██  ██   ██  ██    
  ██    ██  ██   ██   █          ██  ██ ██  ██  ██   ██  ██   █
 ████   ██  ██  ███████           █████ ██  ██  ██   ██ ███████

bwang
LV7 Elite (Next: 700)
*******
Offline Offline

Last Login: 11 August, 2012, 12:59:06
Date Registered: 20 June, 2009, 01:42:58
Posts: 632

Topic starter
Total Post Ratings: +19

View Profile
« Reply #35 on: 18 June, 2010, 07:19:00 »
0

What does manually running the MakeTNS command do?
yoshi13 said he installed mingw first, then msys.
« Last Edit: 18 June, 2010, 07:21:21 by bwang » Logged
t0xic_kitt3n
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: 13 May, 2013, 01:56:35
Date Registered: 16 June, 2010, 20:46:00
Location: w,x,y,z
Posts: 1583


Total Post Ratings: +32

View Profile
« Reply #36 on: 18 June, 2010, 15:48:57 »
0

Windows says its not a valid program. I am not using minGW or msys, just yagarto and yagarto-tools.
« Last Edit: 18 June, 2010, 15:49:59 by fb39ca4 » Logged




██████  ██  ██  ███████           ████    ██    ██   ██ ███████
█ ██ █  ██  ██   ██   █          ██  ██  ████   ███ ███  ██   █
  ██    ██  ██   ██             ██   ██ ██  ██  ███████  ██    
  ██    ██  ██   ██  █         ██       ██  ██  ███████  ██  █
  ██    ██████   █████         ██       ██  ██  ██ █ ██  █████ 
  ██    ██  ██   ██  █         ██   ███ ██████  ██   ██  ██  █
  ██    ██  ██   ██             ██   ██ ██  ██  ██   ██  ██    
  ██    ██  ██   ██   █          ██  ██ ██  ██  ██   ██  ██   █
 ████   ██  ██  ███████           █████ ██  ██  ██   ██ ███████

bwang
LV7 Elite (Next: 700)
*******
Offline Offline

Last Login: 11 August, 2012, 12:59:06
Date Registered: 20 June, 2009, 01:42:58
Posts: 632

Topic starter
Total Post Ratings: +19

View Profile
« Reply #37 on: 18 June, 2010, 22:02:40 »
0

Hmmm...my fault Sad The MakeTNS in the skeleton is a Linux version. Go get a fresh copy of Ndless and copy the MakeTNS in it to the appropriate directory.
I shall fix the skeleton when I have time.
EDIT: Fixed!
« Last Edit: 18 June, 2010, 22:11:50 by bwang » Logged
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 18:03:25
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50227


Total Post Ratings: +2615

View Profile WWW
« Reply #38 on: 18 June, 2010, 23:38:04 »
0

Nice to see an update (and to see you return), bwang ^^
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
t0xic_kitt3n
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: 13 May, 2013, 01:56:35
Date Registered: 16 June, 2010, 20:46:00
Location: w,x,y,z
Posts: 1583


Total Post Ratings: +32

View Profile
« Reply #39 on: 19 June, 2010, 18:22:20 »
0

I replaced makeTNS and it worked! My test program was a Langton's Ant, which runs crazy fast! Now my only problem is that the calc crashes when I press esc. Anyone know why that's happening?
Logged




██████  ██  ██  ███████           ████    ██    ██   ██ ███████
█ ██ █  ██  ██   ██   █          ██  ██  ████   ███ ███  ██   █
  ██    ██  ██   ██             ██   ██ ██  ██  ███████  ██    
  ██    ██  ██   ██  █         ██       ██  ██  ███████  ██  █
  ██    ██████   █████         ██       ██  ██  ██ █ ██  █████ 
  ██    ██  ██   ██  █         ██   ███ ██████  ██   ██  ██  █
  ██    ██  ██   ██             ██   ██ ██  ██  ██   ██  ██    
  ██    ██  ██   ██   █          ██  ██ ██  ██  ██   ██  ██   █
 ████   ██  ██  ███████           █████ ██  ██  ██   ██ ███████

bwang
LV7 Elite (Next: 700)
*******
Offline Offline

Last Login: 11 August, 2012, 12:59:06
Date Registered: 20 June, 2009, 01:42:58
Posts: 632

Topic starter
Total Post Ratings: +19

View Profile
« Reply #40 on: 19 June, 2010, 22:59:06 »
0

You might be running out of bounds with your setPixel().
Logged
calc84maniac
Epic z80 roflpwner
Coder Of Tomorrow
LV11 Super Veteran (Next: 3000)
*
Offline Offline

Gender: Male
Last Login: 20 May, 2013, 21:27:24
Date Registered: 28 August, 2008, 05:09:05
Location: Right behind you.
Posts: 2735


Total Post Ratings: +373

View Profile
« Reply #41 on: 20 June, 2010, 01:52:32 »
0

Yeah, looking at that code, you getPixel(antx,anty) but setPixel(anty,antx,color). Is it supposed to be x,y or y,x?
Logged

"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman
t0xic_kitt3n
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: 13 May, 2013, 01:56:35
Date Registered: 16 June, 2010, 20:46:00
Location: w,x,y,z
Posts: 1583


Total Post Ratings: +32

View Profile
« Reply #42 on: 21 June, 2010, 01:20:18 »
0

Oh, I think the code I posted was an old version. My current version fills the whole screen.
Logged




██████  ██  ██  ███████           ████    ██    ██   ██ ███████
█ ██ █  ██  ██   ██   █          ██  ██  ████   ███ ███  ██   █
  ██    ██  ██   ██             ██   ██ ██  ██  ███████  ██    
  ██    ██  ██   ██  █         ██       ██  ██  ███████  ██  █
  ██    ██████   █████         ██       ██  ██  ██ █ ██  █████ 
  ██    ██  ██   ██  █         ██   ███ ██████  ██   ██  ██  █
  ██    ██  ██   ██             ██   ██ ██  ██  ██   ██  ██    
  ██    ██  ██   ██   █          ██  ██ ██  ██  ██   ██  ██   █
 ████   ██  ██  ███████           █████ ██  ██  ██   ██ ███████

bwang
LV7 Elite (Next: 700)
*******
Offline Offline

Last Login: 11 August, 2012, 12:59:06
Date Registered: 20 June, 2009, 01:42:58
Posts: 632

Topic starter
Total Post Ratings: +19

View Profile
« Reply #43 on: 21 June, 2010, 01:51:34 »
0

If your pixels travel out of the screen and you don't check the bounds, you will get a crash.
Logged
bwang
LV7 Elite (Next: 700)
*******
Offline Offline

Last Login: 11 August, 2012, 12:59:06
Date Registered: 20 June, 2009, 01:42:58
Posts: 632

Topic starter
Total Post Ratings: +19

View Profile
« Reply #44 on: 21 June, 2010, 07:59:55 »
0

Hmmm...I have to doublepost Sad
I edited the first post and attached some possibly useful fast (addition only) circle and line routines.
Logged
Pages: 1 2 [3] 4 5 ... 13   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.273 seconds with 30 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.