Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose console sprite structure to control transparency. #7

Open
BitJag opened this issue Jul 6, 2022 · 0 comments
Open

Expose console sprite structure to control transparency. #7

BitJag opened this issue Jul 6, 2022 · 0 comments

Comments

@BitJag
Copy link

BitJag commented Jul 6, 2022

There have been a few times where I have needed to make the console background transparent while debugging. Just to make it so a black box isn't covering up a portion of the screen.

When a console is created new_custom_console() the Console structure's address is assigned to the FILE->data pointer. This pointer is of type void, so it seems you can't access the members of Console without knowing the exact byte position that controls the transparency of the sprite relative to the start address of the FILE->data pointer.

There is workaround I have for this by re-declaring the Console structure in my program's header file, and then assigning the data member of my FILE structure that I use for my console to a new Console structure pointer. Below is an example of this.

//program.h

//type definition copied from new_custom_console.c into my program's header
typedef struct {
  short int x;
  short int y;
  short int width;
  short int height;
  sprite *s;
} Console;

//declare a FILE structure in order to open a new console with
FILE *myConsole;
//program.c

//create the console
myConsole = open_custom_console(d, 3, 8, 0, 40, 4, 15);

//set the data member to a temporary Console structure to gain access to the hidden sprite structure
Console *co = myConsole->data;

//now I can make the console background transparent
co->s->trans = 1;

This works, but I wanted to see if there might be a chance of adjusting the FILE structure could be altered to not lose the ability to access the sprite structure in the Console structure.For example like this:

FILE->Console->s->trans = 1;

Doing it this way would reduce the lines of code needed, not needing to keep track of two structures to change members of one of those structures.

If this isn't possible, could we at least make the type Console more globally accessible as opposed to keeping it only in new_custom_console.c, so I don't have to redefine the Console type in my program's head files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant