Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
21 May, 2013, 04:28:59 *
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   Go Down
  Print  
Author Topic: Sprites and Maps in C 68k -  (Read 2728 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
Lionel Debroux
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Yesterday at 19:51:42
Date Registered: 17 December, 2009, 09:37:25
Location: France
Posts: 1853

Total Post Ratings: +208

View Profile WWW
« Reply #15 on: 29 January, 2012, 21:24:19 »
+1

Don't write to LCD_MEM in grayscale mode Smiley
Logged

Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.
Kiligolo
LV5 Advanced (Next: 300)
*****
Offline Offline

Gender: Male
Last Login: 13 January, 2013, 11:35:54
Date Registered: 11 October, 2010, 18:01:20
Location: France
Posts: 218


Topic starter
Total Post Ratings: +5

View Profile
« Reply #16 on: 29 January, 2012, 21:25:22 »
0

It's ranman's code: http://www.omnimaga.org/index.php?topic=6438.msg116833#msg116833 :p
Logged

Spoiler for Calcul Mental:
Version 1.3 :100%!!
Here is a program that reduces your dependence on the calculator! Click here!
Spoiler for Some screen shots:
       
The screenshots are in french but there is an english version
Lionel Debroux
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Yesterday at 19:51:42
Date Registered: 17 December, 2009, 09:37:25
Location: France
Posts: 1853

Total Post Ratings: +208

View Profile WWW
« Reply #17 on: 29 January, 2012, 21:28:06 »
0

Ranman's code was meant for B/W, but grayscale is another story Wink

See http://debrouxl.github.com/gcc4ti/gray.html#GrayGetPlane :
Quote
GrayGetPlane returns a pointer to the grayscale plane plane. Valid values for plane are LIGHT_PLANE and DARK_PLANE. To draw in black, draw in both planes.

Note: Do not assume that any plane is on 0x4C00 when in grayscale mode, due to hardware version 2 support. Also do not assume that the 2 grayscale planes are consecutive, this is not the case on hardware version 1.

Some software grayscale implementations have two consecutive grayscale planes, but the one in TIGCC and GCC4TI doesn't.
« Last Edit: 29 January, 2012, 21:30:06 by Lionel Debroux » Logged

Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.
Kiligolo
LV5 Advanced (Next: 300)
*****
Offline Offline

Gender: Male
Last Login: 13 January, 2013, 11:35:54
Date Registered: 11 October, 2010, 18:01:20
Location: France
Posts: 218


Topic starter
Total Post Ratings: +5

View Profile
« Reply #18 on: 29 January, 2012, 21:58:42 »
0

Thanks it's works!

But now i have a problem when i stop the program. The light plane is displayed in black and there is white rectangles which appear and disapear on the screen, i can't do anything. (Fortunatly i am on tiEmu)...
Logged

Spoiler for Calcul Mental:
Version 1.3 :100%!!
Here is a program that reduces your dependence on the calculator! Click here!
Spoiler for Some screen shots:
       
The screenshots are in french but there is an english version
Lionel Debroux
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Yesterday at 19:51:42
Date Registered: 17 December, 2009, 09:37:25
Location: France
Posts: 1853

Total Post Ratings: +208

View Profile WWW
« Reply #19 on: 29 January, 2012, 22:02:02 »
+1

When exiting by ESC, you immediately "return 0;" instead of falling out of the outer while(), which calls GrayOff() Wink

If if still doesn't work properly after that, make sure you aren't drawing past the beginning or the end of the screen, and try using ClipSprite8 instead of Sprite8 Smiley

And if your map is only read from, but not written to, you really should declare it "static const", so that it ends up as a constant in your program's code, instead of being constructed onto the stack: it will be both smaller and faster.
« Last Edit: 29 January, 2012, 22:15:47 by Lionel Debroux » Logged

Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.
Xeda112358
Xombie. I am it.
Coder Of Tomorrow
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Last Login: Today at 03:27:42
Date Registered: 31 October, 2010, 08:46:36
Location: Land of Little Cubes and Tea, NY
Posts: 3743


Total Post Ratings: +598

View Profile
« Reply #20 on: 29 January, 2012, 22:08:45 »
0

sorry to interrupt again .___.
I tried modifying the code to suite my purposes and I keep getting these errors and I don't know why Big frown

'MAP_Y' undeclared (first use in this function).
'MAP_X' undeclared (first use in this function).
Unused variable 'map1'.


EDIT: also, KERNELBASE.dll seems to have a lot of issues with me, so ever time I get an error, it freezes and uses up tons of system resources and I have to press F10 a bazillion times and click okay on a bunch of popup error messages
« Last Edit: 29 January, 2012, 22:12:09 by Xeda112358 » Logged



Grammer Download (2.29.04.12)
Latest update (possibly incomplete)
My pastebin
Spoiler for FileSyst:
FileSyst is an application that provides a folder and filesystem for the TI-83+/84+ calculators. It is designed to be easy to access and use in BASIC, and it can be used to access game files and save data, or to create a command prompt, among other things:

Spoiler for Graphiti:
This is a graph explorer for graph theory. It will require lots of work to finish. Currently you can:
Add/delete vertices
Add edges (direction not shown, but they are directed)
Arrange vertices in a circle (in the future, you will be able to define levels of rings and the number of nodes in each)
Create complete graphs quickly

Plans:
Add adjacency matrix viewer
Deleting edges
Multiple graphs support
Arrows for directed graphs
Planarity testing
Matrix operations
Weighted edges
Chromatic polynomials
Chromatic numbers

Spoiler for Stats:

Samocal             [o---------]
Virtual Processor   [o---------]
EnG                 [oo--------]
Grammer             [ooo-------]
AsmComp             [ooo-------]
Partex              [oooo------]
BatLib              [oooooooo--]
Grammer82           [----------]
Grammer68000        [----------]


Pseudonyms:  Zeda, Xeda, Thunderbolt
Languages:   English, français
Programming: z80 Assmebly
             Grammer
             TI-BASIC (83/84/+/SE, 89/89t/92)
Known For:   -Creator of the Grammer programming language
              (Winning program of zContest2011)
             -BatLib- One of the most feature packed libraries for BASIC programmers available
              with over 100 functions and a simple programming language
             -Learning to program z80 in hexadecimal before using an assembler (no computer was
              available!)
╔═╦╗░╠═╬╣▒║ ║║▓╚═╩╝█


Torio
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: 18 May, 2013, 18:43:54
Date Registered: 24 January, 2012, 18:53:25
Location: France
Posts: 82

Total Post Ratings: +22

View Profile
« Reply #21 on: 29 January, 2012, 22:16:32 »
0

You have an error because MAP_X and MAP_Y are not defined in the code you copied.
You have to put before the code :


1
2
#define MAP_X 20
#define MAP_Y 12

I guess it should be 20 and 12 according to the table map1, but I'm not sure.
Logged

Sorry about my mistakes, I'm French.

Projects :  Pokemon TI-89 | Ti-Tank
Kiligolo
LV5 Advanced (Next: 300)
*****
Offline Offline

Gender: Male
Last Login: 13 January, 2013, 11:35:54
Date Registered: 11 October, 2010, 18:01:20
Location: France
Posts: 218


Topic starter
Total Post Ratings: +5

View Profile
« Reply #22 on: 29 January, 2012, 22:27:32 »
+1

Lionel > Yes
Xeda >

1
2
3
4
#include <tigcclib.h>

#define MAP_X 20
#define MAP_Y 12
It's the map size.
For map1 error:

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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
unsigned char game_sprites[2][8] = //array of sprites
{ //Grass
   0b00000000,
   0b00101000,
   0b00010000,
   0b00000000,
   0b00000101,
   0b00000010,
   0b01010000,
   0b00100000,
},
{ //tree
   0b00000000,
   0b00000000,
   0b00111110,
   0b01111111,
   0b01111111,
   0b01111111,
   0b00111110,
   0b00001000,
}

unsigned char map[8][8] =
{
   {1,1,1,1,1,1,1,1},
   {1,0,0,0,0,0,0,1},
   {1,0,0,0,0,0,0,1},
   {1,0,0,0,0,0,0,1},
   {1,0,0,0,0,0,0,1},
   {1,0,0,0,0,0,0,1},
   {1,0,0,0,0,0,0,1},
   {1,1,1,1,1,1,1,1},
};
//0 = Grass and 1 = Tree
//Drawing:
int tilemap_x, tilemap_y;
int lcd_x, lcd_y;
unsigned char* pSprite;
unsigned char sprite_index;

// initialize the lcd Y value since we starting the first row
lcd_y = 0;

for (tilemap_y = 0; tilemap_y < 8; tilemap_y++)
{
  // initialize the lcd X value since we are starting a new collumn
  lcd_x = 0;

  for (tilemap_x = 0; tilemap_x < 8; tilemap_x++)
  {
    // first, get the sprite index from the tilemap
    sprite_index = game_tilemap[tilemap_y][tilemap_x];

    // second, get the pointer (address) to the sprite
    pSprite = &game_sprites[sprite_index][0];

    // draw the sprite to the screen
    Sprite8 (lcd_x, lcd_y, 8, pSprite, LCD_MEM, SPRT_RPLC); // --> TIGCC lib

    // increment the lcd X position in preparation for next sprite
    lcd_x = lcd_x + 8;
  }

  // increment the lcd Y position in preparation for next row of sprites
  lcd_y = lcd_y + 8;
}
Logged

Spoiler for Calcul Mental:
Version 1.3 :100%!!
Here is a program that reduces your dependence on the calculator! Click here!
Spoiler for Some screen shots:
       
The screenshots are in french but there is an english version
Kiligolo
LV5 Advanced (Next: 300)
*****
Offline Offline

Gender: Male
Last Login: 13 January, 2013, 11:35:54
Date Registered: 11 October, 2010, 18:01:20
Location: France
Posts: 218


Topic starter
Total Post Ratings: +5

View Profile
« Reply #23 on: 29 January, 2012, 22:33:35 »
0

Thanks lionel im very tired today i go to sleep! :p
Logged

Spoiler for Calcul Mental:
Version 1.3 :100%!!
Here is a program that reduces your dependence on the calculator! Click here!
Spoiler for Some screen shots:
       
The screenshots are in french but there is an english version
Xeda112358
Xombie. I am it.
Coder Of Tomorrow
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Last Login: Today at 03:27:42
Date Registered: 31 October, 2010, 08:46:36
Location: Land of Little Cubes and Tea, NY
Posts: 3743


Total Post Ratings: +598

View Profile
« Reply #24 on: 29 January, 2012, 23:00:29 »
0

Thank you much! I wasn't sure how to define MAP_X and MAP_Y, but now I know! Thanks!
Logged



Grammer Download (2.29.04.12)
Latest update (possibly incomplete)
My pastebin
Spoiler for FileSyst:
FileSyst is an application that provides a folder and filesystem for the TI-83+/84+ calculators. It is designed to be easy to access and use in BASIC, and it can be used to access game files and save data, or to create a command prompt, among other things:

Spoiler for Graphiti:
This is a graph explorer for graph theory. It will require lots of work to finish. Currently you can:
Add/delete vertices
Add edges (direction not shown, but they are directed)
Arrange vertices in a circle (in the future, you will be able to define levels of rings and the number of nodes in each)
Create complete graphs quickly

Plans:
Add adjacency matrix viewer
Deleting edges
Multiple graphs support
Arrows for directed graphs
Planarity testing
Matrix operations
Weighted edges
Chromatic polynomials
Chromatic numbers

Spoiler for Stats:

Samocal             [o---------]
Virtual Processor   [o---------]
EnG                 [oo--------]
Grammer             [ooo-------]
AsmComp             [ooo-------]
Partex              [oooo------]
BatLib              [oooooooo--]
Grammer82           [----------]
Grammer68000        [----------]


Pseudonyms:  Zeda, Xeda, Thunderbolt
Languages:   English, français
Programming: z80 Assmebly
             Grammer
             TI-BASIC (83/84/+/SE, 89/89t/92)
Known For:   -Creator of the Grammer programming language
              (Winning program of zContest2011)
             -BatLib- One of the most feature packed libraries for BASIC programmers available
              with over 100 functions and a simple programming language
             -Learning to program z80 in hexadecimal before using an assembler (no computer was
              available!)
╔═╦╗░╠═╬╣▒║ ║║▓╚═╩╝█


Kiligolo
LV5 Advanced (Next: 300)
*****
Offline Offline

Gender: Male
Last Login: 13 January, 2013, 11:35:54
Date Registered: 11 October, 2010, 18:01:20
Location: France
Posts: 218


Topic starter
Total Post Ratings: +5

View Profile
« Reply #25 on: 30 January, 2012, 19:55:41 »
0

Hi! I have a big problem with dynamic allocation...
Here is the code:

1
2
3
4
5
6
int i, j;
unsigned char ** map = malloc(MAP_Y * sizeof(unsigned char));
for (i = 0; i < MAP_Y; i++)
{
map[i] = malloc(MAP_X * sizeof(unsigned char));
}
and at the end :

1
2
3
4
5
for (i = 0; i < MAP_Y ; i++)
{
free(map[i]);
}
free(map);
When i start the program, the Ti89 display BUSY icon and freeze but when i add ngetchx(); in this part of code:

1
2
3
4
5
6
7
8
int i, j;
unsigned char ** map = malloc(MAP_Y * sizeof(unsigned char));
for (i = 0; i < MAP_Y; i++)
{
                printf("%d",i);
                ngetchx(); //Here
map[i] = malloc(MAP_X * sizeof(unsigned char));
}
The 89 don't freeze and the program start but when i stop the program and i go to Var-Link menu, my asm program is now and expression (64000bytes).
I'm lost
« Last Edit: 30 January, 2012, 19:55:51 by Kiligolo » Logged

Spoiler for Calcul Mental:
Version 1.3 :100%!!
Here is a program that reduces your dependence on the calculator! Click here!
Spoiler for Some screen shots:
       
The screenshots are in french but there is an english version
Lionel Debroux
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Yesterday at 19:51:42
Date Registered: 17 December, 2009, 09:37:25
Location: France
Posts: 1853

Total Post Ratings: +208

View Profile WWW
« Reply #26 on: 30 January, 2012, 20:15:59 »
+1

I'm not sure why you need dynamic allocation here ?
(and by they way, two-dimensional arrays suck for efficiency)

The symptoms (BUSY on exit, program size changed, program behaviour changing by adding unrelated lines) point out to severe memory corruption, by overflowing buffers on the heap. Check your code Smiley
Logged

Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.
Kiligolo
LV5 Advanced (Next: 300)
*****
Offline Offline

Gender: Male
Last Login: 13 January, 2013, 11:35:54
Date Registered: 11 October, 2010, 18:01:20
Location: France
Posts: 218


Topic starter
Total Post Ratings: +5

View Profile
« Reply #27 on: 30 January, 2012, 20:37:10 »
0

Ok i'm going to try without it.
Logged

Spoiler for Calcul Mental:
Version 1.3 :100%!!
Here is a program that reduces your dependence on the calculator! Click here!
Spoiler for Some screen shots:
       
The screenshots are in french but there is an english version
Torio
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: 18 May, 2013, 18:43:54
Date Registered: 24 January, 2012, 18:53:25
Location: France
Posts: 82

Total Post Ratings: +22

View Profile
« Reply #28 on: 30 January, 2012, 22:08:27 »
+1

I'm not sure but I think you have a memory corruption because when you call malloc for the first time, you will allocate unsigned char for *map.
But in the for loop, the array will contain not an unsigned char, but a pointer so it is a long int.
So the adress to which *map points to will be wrong.
That will cause a corruption when freeing the array.

What you should do is :

1
unsigned char *map = malloc(MAP_X * MAP_Y * sizeof(unsigned char));
Logged

Sorry about my mistakes, I'm French.

Projects :  Pokemon TI-89 | Ti-Tank
Kiligolo
LV5 Advanced (Next: 300)
*****
Offline Offline

Gender: Male
Last Login: 13 January, 2013, 11:35:54
Date Registered: 11 October, 2010, 18:01:20
Location: France
Posts: 218


Topic starter
Total Post Ratings: +5

View Profile
« Reply #29 on: 31 January, 2012, 21:09:29 »
0

Thanks for your help! My program is okay now :p

* POKéMON.zip (6.65 KB - downloaded 27 times.)
Logged

Spoiler for Calcul Mental:
Version 1.3 :100%!!
Here is a program that reduces your dependence on the calculator! Click here!
Spoiler for Some screen shots:
       
The screenshots are in french but there is an english version
Pages: 1 [2] 3   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.416 seconds with 31 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.