Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
20 May, 2013, 05:36:44 *
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 ... 3 4 [5] 6 7 ... 12   Go Down
  Print  
Author Topic: Post your Nspire routines here! -  (Read 15251 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
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: --)
*
Online Online

Gender: Male
Last Login: Today at 05:36:37
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50204


Total Post Ratings: +2611

View Profile WWW
« Reply #60 on: 07 July, 2010, 04:00:29 »
0

How do you prevent the flickering, though?
Logged

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

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
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 #61 on: 07 July, 2010, 04:01:55 »
0

Hmmm...interesting.
I remember my raycaster flickering like crazy until I got double-buffering working.
Are you doing anything special?
Logged
calc84maniac
Epic z80 roflpwner
Coder Of Tomorrow
LV11 Super Veteran (Next: 3000)
*
Offline Offline

Gender: Male
Last Login: 14 May, 2013, 10:02:35
Date Registered: 28 August, 2008, 05:09:05
Location: Right behind you.
Posts: 2735


Total Post Ratings: +373

View Profile
« Reply #62 on: 07 July, 2010, 04:04:07 »
0

Hmmm...interesting.
I remember my raycaster flickering like crazy until I got double-buffering working.
Are you doing anything special?
Well, in my emulators I'm not clearing the buffer and then drawing new graphics. I draw the graphics over the current buffer line-by-line (which is how the systems I'm emulating tend to operate anyway)
Logged

"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman
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: --)
*
Online Online

Gender: Male
Last Login: Today at 05:36:37
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50204


Total Post Ratings: +2611

View Profile WWW
« Reply #63 on: 07 July, 2010, 04:06:41 »
0

oooh I see, that explains why sprites won't flicker while the map is getting displayed. I assume they're drawn at the same time as the map, right?
Logged

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

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
calc84maniac
Epic z80 roflpwner
Coder Of Tomorrow
LV11 Super Veteran (Next: 3000)
*
Offline Offline

Gender: Male
Last Login: 14 May, 2013, 10:02:35
Date Registered: 28 August, 2008, 05:09:05
Location: Right behind you.
Posts: 2735


Total Post Ratings: +373

View Profile
« Reply #64 on: 07 July, 2010, 04:10:28 »
0

oooh I see, that explains why sprites won't flicker while the map is getting displayed. I assume they're drawn at the same time as the map, right?
That's right. It's how some sprites are able to be displayed behind the map.

Actually, now that I think about it, I do have a very minimal form of double-buffering. In my GBC emulator, I draw the 160 pixels in a line to a small buffer, then copy it to the screen buffer (1 or 2 lines depending on the position, for aspect ratio purposes). In the TI-83+ and TI-89 emulators, there is stored an internal buffer of the emulated screen contents, and it is upscaled onto the screen buffer.
Logged

"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman
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: --)
*
Online Online

Gender: Male
Last Login: Today at 05:36:37
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50204


Total Post Ratings: +2611

View Profile WWW
« Reply #65 on: 07 July, 2010, 04:57:17 »
0

Aaah I see ^^

Nice job on the emus regardless, though
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 #66 on: 07 July, 2010, 17:39:38 »
0

I've got the buffering all figured out, but it seems like nmath.h is missing from the skeleton. When I tried to compile a program using line, I got an error saying nmath.h doesn't exist.
Logged




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

apcalc
The Game
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 16:59:33
Date Registered: 20 March, 2010, 16:31:47
Location: 2003 UB313
Posts: 1393


Total Post Ratings: +118

View Profile
« Reply #67 on: 07 July, 2010, 17:56:48 »
0

I've got the buffering all figured out, but it seems like nmath.h is missing from the skeleton. When I tried to compile a program using line, I got an error saying nmath.h doesn't exist.

I am assuming that the abs( function is from nmath.h (that is the only one that did not "exist").  A simple solution would be to write your own abs( function, get rid of the "#include "nmath.h"" at the top and add your own abs( to the header.  Here is a very basic one I wrote.  I am sure that a smaller and faster version could be written:


1
2
3
4
5
6
int abs(int x) {
if (x<0) {
x*=-1;
}
return x;
}
« Last Edit: 07 July, 2010, 17:58:13 by apcalc » 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 #68 on: 07 July, 2010, 19:03:52 »
0

How do I use the sprite function, specifically, how would I define the sprite?
Logged




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

apcalc
The Game
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 16:59:33
Date Registered: 20 March, 2010, 16:31:47
Location: 2003 UB313
Posts: 1393


Total Post Ratings: +118

View Profile
« Reply #69 on: 07 July, 2010, 19:09:29 »
0

Declare a sprite like this:


1
2
3
4
              char sprite[32]={15,15,15,0,0,15,15,15,
                                15,15, 0, 0,0, 0,15,15,
                                15, 0, 0, 0, 0, 0, 0,15,
                                 0 , 0, 0, 0, 0, 0, 0, 0};

The number of elements in the array should be equal to the height*width of the sprite.  Each element should be the color you want the pixel to be.  Bwang's sprite drawing functoin takes the syntax:


1
void sprite(char* scrbuf, char* sprite, int x, int y, int w, int h);

Where scrbuf is the buffer, sprite is the spite you want to draw, x is the x coordinate of the sprite, y is the y coordinate, w is the width, and h is the heigth

If you read my first, unedited post, please disregard it b/c some of the info was wrong. Smiley
« Last Edit: 07 July, 2010, 20:09:26 by apcalc » 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 #70 on: 07 July, 2010, 20:51:36 »
0

Unfortunately, apcalc, I read you unedited post, but now it's all sorted out, and I can play pong on my nspire.  Cool
Logged




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

apcalc
The Game
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 16:59:33
Date Registered: 20 March, 2010, 16:31:47
Location: 2003 UB313
Posts: 1393


Total Post Ratings: +118

View Profile
« Reply #71 on: 07 July, 2010, 22:22:34 »
0

Unfortunately, apcalc, I read you unedited post, but now it's all sorted out, and I can play pong on my nspire.  Cool

Thats great to hear! I was used to the way you draw sprites on the 89, so I just assumed it was the same way. Feel free to ask if you have any more questions! Smiley
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 #72 on: 07 July, 2010, 23:50:04 »
0

That sprite routine is not production ready. It works, but don't use it for anything fancy!
I need to change it to a proper sprite function that copies blocks of memory one row at a time.
I also attached nmath.h/c. Please please please don't use this in sensitive programs! Its slow, poorly written, and not all that accurate (e.g. sine and cosine are approximated with a couple of power series terms) - I was just collecting some routines for personal use. Your mileage with this file will vary, depending on the program.
Here's a nice way to do abs():

1
2
#define abs(a) (a) > 0 ? (a) : -(a)

* nmath.c (0.64 KB - downloaded 50 times.)
* nmath.h (0.22 KB - downloaded 46 times.)
« Last Edit: 07 July, 2010, 23:56:40 by bwang » Logged
apcalc
The Game
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 16:59:33
Date Registered: 20 March, 2010, 16:31:47
Location: 2003 UB313
Posts: 1393


Total Post Ratings: +118

View Profile
« Reply #73 on: 08 July, 2010, 03:41:24 »
0

I've been having a very odd bug with an Nspire C program.  Every time I exit the program pressing ESC (for some reason my loss detection dosen't work) the calculator reboots (the emulator says "CPU Reset") (I have only tried this on the emulator).  All of the other ASM programs I have on the emulator (ncaster, gbc4nspire, ndless demo) work correctly. Also in my code you will see that I have the loss detection commented out.  When I have this part of the code, the calc reboots right after the dialog box displays.  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
47
48
49
#include <os.h>
#include "utils.h"

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

int main(void) {
  char marker[32]={15,15,15,0,0,15,15,15,15,15,0,0,0,0,15,15,15,0,0,0,0,0,0,15,0,0,0,0,0,0,0,0};
  short int leftx,length,ycord,lengthchange;
  float spritepos;
  char* scrbuf = (char*) malloc(SCREEN_BYTES_SIZE);
  char* tempbuf = (char*) malloc(SCREEN_BYTES_SIZE);
  showSimpleDialogBox("TI-Nspire Tunnel","TI-Nspire Tunnel\nWritten in C by Danny Clark\n\nUse the arrow keys to control ship");
  clearScreen();
  leftx=120,length=120,lengthchange=1000,ycord=0;
  spritepos=180;
  clearBuf(scrbuf);
  for(ycord=0;ycord<SCREEN_HEIGHT;ycord++) {
  horizontalline(scrbuf,0,leftx,ycord,0);
  horizontalline(scrbuf,leftx+length,319,ycord,0);}
  sprite(scrbuf,marker,150,236,8,4);
  refresh(scrbuf);
  leftx=120;
  ycord=0;
  while (!isKeyPressed(KEY_NSPIRE_ESC)) {
  if (isKeyPressed(KEY_NSPIRE_LEFT)) {
  sprite(scrbuf,marker,spritepos,236,8,4);
  spritepos-=0.7;
  sprite(scrbuf,marker,spritepos,236,8,4);}
  if (isKeyPressed(KEY_NSPIRE_RIGHT)) {
  sprite(scrbuf,marker,spritepos,236,8,4);
  spritepos+=0.7;
  sprite(scrbuf,marker,spritepos,236,8,4);}
  sprite(scrbuf,marker,spritepos,236,8,4);
  lengthchange--;
  if (lengthchange==0) {length--;lengthchange=1000;}
  scrollScreen(scrbuf,tempbuf,1);
  horizontalline(scrbuf,0,leftx,ycord,0);
  horizontalline(scrbuf,leftx,leftx+length,ycord,15);
  horizontalline(scrbuf,leftx+length,319,ycord,0);
  sprite(scrbuf,marker,spritepos,236,8,4);
  refresh(scrbuf);
  //if (getPixel(spritepos-1,ycord-3)||getPixel(spritepos+8,ycord-3)) {free(scrbuf);free(tempbuf);return 0;}
  }
free(scrbuf);
free(tempbuf);
return 0;
}


Also, I don't have the code for the function horizontal line there but I am sure that is not the problem because it was defined and used well before I experienced this problem.  This program was working fine earlier today, but I made a few small additons and now I have no idea what is causing this.  Also, I made one small modification to the function "scrollScreen(".  I changed the two signs in the function (+ to - and - to +) to make the screen go down instead of up.
« Last Edit: 08 July, 2010, 03:44:11 by apcalc » Logged


calc84maniac
Epic z80 roflpwner
Coder Of Tomorrow
LV11 Super Veteran (Next: 3000)
*
Offline Offline

Gender: Male
Last Login: 14 May, 2013, 10:02:35
Date Registered: 28 August, 2008, 05:09:05
Location: Right behind you.
Posts: 2735


Total Post Ratings: +373

View Profile
« Reply #74 on: 08 July, 2010, 03:54:57 »
0

Are you supposed to be able to use floats as arguments to the sprite routine?
Logged

"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman
Pages: 1 ... 3 4 [5] 6 7 ... 12   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.771 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.