MateoConLechuga wrote:
seanlego23 wrote:
Lionel Debroux wrote:
What do you mean by "erase sprites" precisely ? Erase sprite data, or more probably, reset the pixels from a sprite from a screen buffer to some color (equivalent of the B/W or grayscale XOR mode) ?

Reset the pixels. By what you said, it seams there is a way to do that.

Um, just redraw the screen using double buffering or erase the sprite using a rectangle or something. Double buffering prevents bad graphical artifacts. Experiment; honestly there is more power in these libs than most early game systems.

I think I'll do what Unicorn did and just reset the pixels that before the new sprite location. If that seems to not work, then I'll use the buffer.
It's a lot easier to use a buffer, and it looks a lot cleaner and nicer, but hey, whatever floats your boat Smile
MateoConLechuga wrote:
It's a lot easier to use a buffer, and it looks a lot cleaner and nicer, but hey, whatever floats your boat Smile

Yah I just tried it, still blinks and doesn't work as good as I want it to. Guess I'm using the buffer. I'll work on that tomorrow afternoon.
Resetting pixels from a sprite to sounds like the use case for background save & restore functions Smile
I keep getting error messages from these lines of code in the graphx.h header:

Code:
/**
 * Used for accessing the palette directly
 * 256 is valid only for the 8 bpp mode
 */
uint16_t gfx_palette[256] _At 0xE30200;
/**
 * Array of the LCD VRAM
 */
uint8_t gfx_vram[2][240][320] _At 0xD40000;
#define gfx_vbuffer (*(uint8_t (*)[240][320])0xE30014)

Any idea how to fix?
It didn't start happening until I created a subprogram(or another .c file).

Edit:
And now it's saying that there is an error just after the uint8_t *map;

Code:
typedef struct gfx_tilemap {
   uint8_t *map;             /* pointer to indexed map array */
   gfx_image_t **tiles;          /* pointer to tiles */
   uint8_t tile_height;      /* individual tile height */
   uint8_t tile_width;       /* individual tile width */
   uint8_t draw_height;      /* number of rows to draw in the tilemap */
   uint8_t draw_width;       /* number of cols to draw tilemap */
   uint8_t type_width;       /* 2^type_width = tile_width */
   uint8_t type_height;      /* 2^type_height = tile_height */
   uint8_t height;           /* total number of rows in the tilemap */
   uint8_t width;            /* total number of cols in the tilemap */
   uint8_t y_loc;            /* y pixel location to begin drawing at */
   uint24_t x_loc;           /* x pixel location to begin drawing at */
} gfx_tilemap_t;
[/b]
I even redownloaded the CEdev folder and replaced everything. I made sure my includes were: #include <lib\ce\graphx.h>
So I'm at a complete loss.
If you haven't changed any code in the libraries, it is probably your code's fault. You could post that for us to look at...
Unicorn wrote:
If you haven't changed any code in the libraries, it is probably your code's fault. You could post that for us to look at...


This is where the errors first started.

Code:
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <tice.h>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "settings.h"
#include "external.h"
#include <lib\ce\graphx.h>
#include <lib\ce\keypadc.h>

int8_t settings() {
    gfx_SetDraw(gfx_buffer);
    gfx_FillScreen(0x80);
    gfx_PrintStringXY("Start City:", 20, 10);
    gfx_PrintStringXY("<   Chicago    >", 100, 10);
    startcity = (startCity | chicago);
    do {
        gfx_SetDraw(gfx_buffer);
        key = os_GetCSC();
        switch (key) {
            case 2:         //left
                switch (startcity) {
                    case (startCity | chicago):
                        gfx_PrintStringXY("<   Boston   >", 100, 10);
                        startcity = (startCity | boston);
                        break;
                    case (startCity | NYC):
                        gfx_PrintStringXY("<   Chicago   >", 100, 10);
                        startcity = (startCity | chicago);
                        break;
                    case (startCity | stLouis):
                        gfx_PrintStringXY("<   NYC   >", 100, 10);
                        startcity = (startCity | NYC);
                        break;
                    case (startCity | boston):
                        gfx_PrintStringXY("<   St. Louis   >", 100, 10);
                        startcity = (startCity | stLouis);
                        break;
                }
            case 3:         //right
                switch (startcity) {
                    case (startCity | chicago):
                        gfx_PrintStringXY("<   NYC   >", 100, 10);
                        startcity = (startCity | NYC);
                        break;
                    case (startCity | NYC):
                        gfx_PrintStringXY("<   St. Louis   >", 100, 10);
                        startcity = (startCity | stLouis);
                        break;
                    case (startCity | stLouis):
                        gfx_PrintStringXY("<   Boston   >", 100, 10);
                        startcity = (startCity | boston);
                        break;
                    case (startCity | boston):
                        gfx_PrintStringXY("<   Chicago   >", 100, 10);
                        startcity = (startCity | chicago);
                        break;
                }
        }
        gfx_SwapDraw();
    } while (kb_ScanGroup(kb_group_1) != kb_2nd);
    return startcity;
}

The main.c compiled correctly. So it's not there.
What do you think about a FillPolygon function? I was trying to figure out an answer for StrawberryFrostedPopTart's post and I just couldn't figure it out. Then I thought well maybe the C libraries had it. It didn't. So I mentioned this idea. I would try to create a prototype, but I understand very little assembly code and that's what these libraries use. Just a thought. Smile
Because this is more of a routine that can be implemented with great ease in many different styles in C, there was no real point to adding one yet. Smile An outline function works fine, paired with a flood fill algorithm. Another option would be scan line rendering, but meh.
I agree with you about the fact that the routine could be implemented outside the library, using one of the well-documented relevant algorithms. However, for general-purpose code, I'm not a fan of your first proposed solution Smile

Quote:
An outline function works fine, paired with a flood fill algorithm.

In ideal conditions, drawing the outline then using flood fill works, albeit more slowly and with higher stack/heap usage than filled polygon drawing functions using better algorithms.
For arbitrary regions over a composite background which may contain the target color:
* 4-way flood fill falls apart fairly easily;
* 8-way flood fill requires special outline drawing code, which goes out of its way to prevent trivial escapes to the other side of the region. Classic Bresenham line drawing doesn't do the job for this use case.
Where would I find a good flood fill algorithm then?
You can google it.

I believe Wikipedia has a good page on it, I was trying to figure it out myself a while back. Got discouraged though Razz
Does anyone know how to click a key in code? Like instead of clicking the key actually, you virtually do it in the code.
Or...
Does anyone know how to reset the kb_ScanGroup() because if you have two functions each with a while/do-while loop, and they both use kb_ScanGroup(kb_group_1) != kb_2nd to exit the function? Because which ever comes second in the program, automatically closes after 1 execution or 0 depending on the loop.
seanlego23 wrote:
Does anyone know how to reset the kb_ScanGroup() because if you have two functions each with a while/do-while loop, and they both use kb_ScanGroup(kb_group_1) != kb_2nd to exit the function? Because which ever comes second in the program, automatically closes after 1 execution or 0 depending on the loop.

You could wait until the key has been released, so there isn't a key being pressed that could be detected by the second function.

Code:
while(kb_AnyKey()) {}
or
while(os_GetCSC()) {}
That makes so much sense. I'll try it when I have some free time, which should be late tonight. Thanks.
In my train program, I have multiple .c files. I use the graphx, keypadc, and fileioc libs. The graphx lib keeps giving me warnings about this code:

Code:
/**
 * Used for accessing the palette directly
 * 256 is valid only for the 8 bpp mode
 */
uint16_t gfx_palette[256] _At 0xE30200;
/**
 * Array of the LCD VRAM
 */
uint8_t gfx_vram[2][240][320] _At 0xD40000;
#define gfx_vbuffer (*(uint8_t (*)[240][320])0xE30014)

Specifically the lines with _At on them. Ever since I created the multiple files, it's been giving me these warnings. If I put it all back into main.c, everything is fine. Is there anything I can do to get rid of this? My code compiles fine links fine with no errors. Is there something I have to put in the makefile so it doesn't do this?
I blame the idiot that put declarations inside of a header file. This is super easy to fix, it just means it is referencing multiple copies of itself, which could cause a so called segment overlap. The program itself is fine, and I'll fix that in about a month when I get back. But it shouldn't have any adverse effects, just a minor annoyance for now until it is resolved. Smile
MateoConLechuga wrote:
I blame the idiot that put declarations inside of a header file. This is super easy to fix, it just means it is referencing multiple copies of itself, which could cause a so called segment overlap. The program itself is fine, and I'll fix that in about a month when I get back. But it shouldn't have any adverse effects, just a minor annoyance for now until it is resolved. Smile

That's exactly what it says. Thanks. Smile
When running the graphx demo_6 (the second tilemap one) after making it yourself the calculator crashes. It starts decompression (or so it seems) and then crashes.

I didn't edit anything, if you are wondering. It doesn't seem to work with the newest version of the SDK.
Yeah, I am aware of this, and haven't been able to do much about it currently. The way decompression works is rather silly, and I would highly recommend no one uses anything of the sort until I can fix it in 2 weeks Smile Sorry about that.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» Goto page Previous  1, 2, 3 ... 7, 8, 9 ... 15, 16, 17  Next
» View previous topic :: View next topic  
Page 8 of 17
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement