Skip to content

Commit

Permalink
map dimensions moved to ram since they are used a lot more than I tho…
Browse files Browse the repository at this point in the history
…ught
  • Loading branch information
Zal0 committed Aug 2, 2019
1 parent 55db118 commit 0d8c8a3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions common/include/MapInfo.h
Expand Up @@ -4,15 +4,15 @@
#include "TilesInfo.h"

struct MapInfoInternal {
unsigned char width;
unsigned char height;
unsigned char* data;
unsigned char* attributes;
struct TilesInfo* tiles;
};

struct MapInfo {
unsigned char bank;
unsigned char width;
unsigned char height;
struct MapInfoInternal const* data;
};

Expand Down
16 changes: 8 additions & 8 deletions common/src/Scroll.c
Expand Up @@ -141,15 +141,15 @@ void InitScrollTilesLEGACY(UINT8 first_tile, UINT8 n_tiles, UINT8* tile_data, UI

void InitScrollLEGACY(UINT16 map_w, UINT16 map_h, unsigned char* map, const UINT8* coll_list, const UINT8* coll_list_down, UINT8 bank, unsigned char* color_map)
{
struct MapInfoInternal internal_data = {map_w, map_h, map, color_map, 0};
struct MapInfo data = {bank, &internal_data};
struct MapInfoInternal internal_data = {map, color_map, 0};
struct MapInfo data = {bank, map_w, map_h, &internal_data};
InitScroll(&data, coll_list, coll_list_down);
}

void ScrollSetMapLEGACY(UINT16 map_w, UINT16 map_h, unsigned char* map, UINT8 bank, unsigned char* color_map)
{
struct MapInfoInternal internal_data = {map_w, map_h, map, color_map, 0};
struct MapInfo data = {bank, &internal_data};
struct MapInfoInternal internal_data = {map, color_map, 0};
struct MapInfo data = {bank, map_w, map_h, &internal_data};
ScrollSetMap(&data);
}

Expand All @@ -171,7 +171,7 @@ void InitScrollTiles(UINT8 first_tile, struct TilesInfo* tiles) {

void InitWindow(UINT8 x, UINT8 y, struct MapInfo* map) {
PUSH_BANK(map->bank);
set_win_tiles(x, y, map->data->width, map->data->height, map->data->data);
set_win_tiles(x, y, map->width, map->height, map->data->data);

#ifdef CGB
if(map->data->attributes) {
Expand Down Expand Up @@ -205,8 +205,8 @@ void ClampScrollLimits(UINT16* x, UINT16* y) {

void ScrollSetMap(struct MapInfo* map_data) {
PUSH_BANK(map_data->bank);
scroll_tiles_w = map_data->data->width;
scroll_tiles_h = map_data->data->height;
scroll_tiles_w = map_data->width;
scroll_tiles_h = map_data->height;
scroll_map = map_data->data->data;
scroll_cmap = map_data->data->attributes;
scroll_x = 0;
Expand Down Expand Up @@ -429,7 +429,7 @@ UINT8 ScrollFindTile(struct MapInfo* map, UINT8 tile,
PUSH_BANK(map->bank);
for(xt = start_x; xt != start_x + w; ++ xt) {
for(yt = start_y; yt != start_y + h; ++ yt) {
if(map->data->data[map->data->width * yt + xt] == (UINT16)tile) { //That cast over there is mandatory and gave me a lot of headaches
if(map->data->data[map->width * yt + xt] == (UINT16)tile) { //That cast over there is mandatory and gave me a lot of headaches
goto done;
}
}
Expand Down
4 changes: 2 additions & 2 deletions tools/gbm2c/gbm2c.cpp
Expand Up @@ -252,15 +252,15 @@ int main(int argc, char* argv[])

fprintf(file, "\n#include \"MapInfo.h\"\n");
fprintf(file, "const struct MapInfoInternal %s_internal = {\n", map_export_settings.label_name);
fprintf(file, "\t%d, //width\n", map.width);
fprintf(file, "\t%d, //height\n", map.height);
fprintf(file, "\t%s_map, //map\n", map_export_settings.label_name);
fprintf(file, "\t%s, //attributes\n", "0"); //TODO
fprintf(file, "\t%s, //tiles info\n", "0"); //TODO
fprintf(file, "};");

fprintf(file, "\nstruct MapInfo %s = {\n", map_export_settings.label_name);
fprintf(file, "\t%d, //bank\n", bank);
fprintf(file, "\t%d, //width\n", map.width);
fprintf(file, "\t%d, //height\n", map.height);
fprintf(file, "\t&%s_internal, //data\n", map_export_settings.label_name);
fprintf(file, "};");

Expand Down
Binary file modified tools/gbm2c/gbm2c.exe
Binary file not shown.

0 comments on commit 0d8c8a3

Please sign in to comment.