Skip to content

Commit

Permalink
removed unnecessary map section from the config
Browse files Browse the repository at this point in the history
  • Loading branch information
nesbox committed May 30, 2021
1 parent e7b594e commit 2d532a6
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 79 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if(Git_FOUND)
)

string(SUBSTRING ${GIT_COMMIT_HASH} 0 7 GIT_COMMIT_HASH)
set(VERSION_HASH " (${GIT_COMMIT_HASH})" )
set(VERSION_HASH ${GIT_COMMIT_HASH} )

execute_process(
COMMAND ${GIT_EXECUTABLE} rev-list HEAD --count
Expand Down
2 changes: 1 addition & 1 deletion build/assets/config.tic.dat

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,6 @@ CRT_SHADER=
-- 254:000000000cc00000cc0000000000000000000000000000000000000000000000
-- </SPRITES>

-- <MAP>
-- 000:8090a0b0c0d0e0f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 001:8191a1b1c1d1e1f100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 002:526200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- </MAP>

-- <WAVES>
-- 000:00000000ffffffff00000000ffffffff
-- 001:0123456789abcdeffedcba9876543210
Expand Down
6 changes: 6 additions & 0 deletions include/tic80.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ extern "C" {
#define TIC80_FULLWIDTH_BITS 8
#define TIC80_FULLWIDTH (1 << TIC80_FULLWIDTH_BITS)
#define TIC80_FULLHEIGHT (TIC80_FULLWIDTH*9/16)

#define TIC80_MARGIN_TOP ((TIC80_FULLHEIGHT - TIC80_HEIGHT) / 2)
#define TIC80_MARGIN_BOTTOM TIC80_MARGIN_TOP
#define TIC80_MARGIN_LEFT ((TIC80_FULLWIDTH - TIC80_WIDTH) / 2)
#define TIC80_MARGIN_RIGHT TIC80_MARGIN_LEFT

#define TIC80_KEY_BUFFER 4
#define TIC80_SAMPLERATE 44100
#define TIC80_FRAMERATE 60
Expand Down
15 changes: 6 additions & 9 deletions src/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,18 +550,15 @@ void tic_core_blit_ex(tic_mem* tic, tic80_pixel_color_format fmt, tic_scanline s

const u32* pal = tic_tool_palette_blit(&tic->ram.vram.palette, fmt);

enum { Top = (TIC80_FULLHEIGHT - TIC80_HEIGHT) / 2, Bottom = Top };
enum { Left = (TIC80_FULLWIDTH - TIC80_WIDTH) / 2, Right = Left };

u32* out = tic->screen;

memset4(&out[0 * TIC80_FULLWIDTH], pal[tic->ram.vram.vars.border], TIC80_FULLWIDTH * Top);
memset4(&out[0 * TIC80_FULLWIDTH], pal[tic->ram.vram.vars.border], TIC80_FULLWIDTH * TIC80_MARGIN_TOP);

u32* rowPtr = out + (Top * TIC80_FULLWIDTH);
u32* rowPtr = out + (TIC80_MARGIN_TOP * TIC80_FULLWIDTH);
for (s32 r = 0; r < TIC80_HEIGHT; r++, rowPtr += TIC80_FULLWIDTH)
{
u32* colPtr = rowPtr + Left;
memset4(rowPtr, pal[tic->ram.vram.vars.border], Left);
u32* colPtr = rowPtr + TIC80_MARGIN_LEFT;
memset4(rowPtr, pal[tic->ram.vram.vars.border], TIC80_MARGIN_LEFT);

s32 pos = (r + tic->ram.vram.vars.offset.y + TIC80_HEIGHT) % TIC80_HEIGHT * TIC80_WIDTH >> 1;

Expand All @@ -573,7 +570,7 @@ void tic_core_blit_ex(tic_mem* tic, tic80_pixel_color_format fmt, tic_scanline s
*(colPtr + (x++ % TIC80_WIDTH)) = pal[val >> 4];
}

memset4(rowPtr + (TIC80_FULLWIDTH - Right), pal[tic->ram.vram.vars.border], Right);
memset4(rowPtr + (TIC80_FULLWIDTH - TIC80_MARGIN_RIGHT), pal[tic->ram.vram.vars.border], TIC80_MARGIN_RIGHT);

if (scanline && (r < TIC80_HEIGHT - 1))
{
Expand All @@ -582,7 +579,7 @@ void tic_core_blit_ex(tic_mem* tic, tic80_pixel_color_format fmt, tic_scanline s
}
}

memset4(&out[(TIC80_FULLHEIGHT - Bottom) * TIC80_FULLWIDTH], pal[tic->ram.vram.vars.border], TIC80_FULLWIDTH * Bottom);
memset4(&out[(TIC80_FULLHEIGHT - TIC80_MARGIN_BOTTOM) * TIC80_FULLWIDTH], pal[tic->ram.vram.vars.border], TIC80_FULLWIDTH * TIC80_MARGIN_BOTTOM);

if (overline)
overline(tic, data);
Expand Down
2 changes: 1 addition & 1 deletion src/studio/studio.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#define KEYBOARD_PERIOD 3

#define TIC_LOCAL ".local/"
#define TIC_LOCAL_VERSION TIC_LOCAL TIC_VERSION "/"
#define TIC_LOCAL_VERSION TIC_LOCAL TIC_VERSION_HASH "/"
#define TIC_CACHE TIC_LOCAL "cache/"

#define TOOLBAR_SIZE 7
Expand Down
2 changes: 1 addition & 1 deletion src/studio/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define TIC_VERSION_POST ""
#endif

#define TIC_VERSION DEF2STR(TIC_VERSION_MAJOR) "." DEF2STR(TIC_VERSION_MINOR) "." DEF2STR(TIC_VERSION_REVISION) TIC_VERSION_STATUS TIC_VERSION_BUILD TIC_VERSION_POST TIC_VERSION_HASH
#define TIC_VERSION DEF2STR(TIC_VERSION_MAJOR) "." DEF2STR(TIC_VERSION_MINOR) "." DEF2STR(TIC_VERSION_REVISION) TIC_VERSION_STATUS TIC_VERSION_BUILD TIC_VERSION_POST " (" TIC_VERSION_HASH ")"
#define TIC_PACKAGE "com.nesbox.tic"
#define TIC_NAME "TIC-80"
#define TIC_NAME_FULL TIC_NAME " tiny computer"
Expand Down
99 changes: 40 additions & 59 deletions src/system/sdl/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,26 +209,25 @@ static u8 getSpritePixel(const tic_tile* tiles, s32 x, s32 y)
static void setWindowIcon()
{
enum{ Size = 64, TileSize = 16, ColorKey = 14, Cols = TileSize / TIC_SPRITESIZE, Scale = Size/TileSize};
tic_api_cls(platform.studio->tic, 0);

u32* pixels = SDL_malloc(Size * Size * sizeof(u32));
DEFER(u32* pixels = SDL_malloc(Size * Size * sizeof(u32)), SDL_free(pixels))
{
const u32* pal = tic_tool_palette_blit(&platform.studio->config()->cart->bank0.palette.scn, platform.studio->tic->screen_format);

const u32* pal = tic_tool_palette_blit(&platform.studio->config()->cart->bank0.palette.scn, platform.studio->tic->screen_format);
for(s32 j = 0, index = 0; j < Size; j++)
for(s32 i = 0; i < Size; i++, index++)
{
u8 color = getSpritePixel(platform.studio->config()->cart->bank0.tiles.data, i/Scale, j/Scale);
pixels[index] = color == ColorKey ? 0 : pal[color];
}

for(s32 j = 0, index = 0; j < Size; j++)
for(s32 i = 0; i < Size; i++, index++)
DEFER(SDL_Surface* surface = SDL_CreateRGBSurfaceFrom(pixels, Size, Size,
sizeof(s32) * BITS_IN_BYTE, Size * sizeof(s32),
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000), SDL_FreeSurface(surface))
{
u8 color = getSpritePixel(platform.studio->config()->cart->bank0.tiles.data, i/Scale, j/Scale);
pixels[index] = color == ColorKey ? 0 : pal[color];
SDL_SetWindowIcon(platform.window, surface);
}

SDL_Surface* surface = SDL_CreateRGBSurfaceFrom(pixels, Size, Size,
sizeof(s32) * BITS_IN_BYTE, Size * sizeof(s32),
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);

SDL_SetWindowIcon(platform.window, surface);
SDL_FreeSurface(surface);
SDL_free(pixels);
}
}

#if defined(TOUCH_INPUT_SUPPORT)
Expand Down Expand Up @@ -264,13 +263,6 @@ static void updateGamepadParts()
}
#endif

static void map2ram()
{
tic_mem* tic = platform.studio->tic;
memcpy(tic->ram.map.data, &platform.studio->config()->cart->bank0.map, sizeof tic->ram.map);
memcpy(tic->ram.tiles.data, &platform.studio->config()->cart->bank0.tiles, sizeof tic->ram.tiles * TIC_SPRITE_BANKS);
}

#if defined(CRT_SHADER_SUPPORT)

void updateTextureBytes(GPU_Image* texture, const void* data, s32 height)
Expand All @@ -296,45 +288,27 @@ static void initTouchGamepad()
{
if(!platform.gamepad.touch.pixels)
{
map2ram();

tic_api_map(platform.studio->tic, 0, 0, TIC_MAP_SCREEN_WIDTH, TIC_MAP_SCREEN_HEIGHT, 0, 0, 0, 0, 1, NULL, NULL);

platform.gamepad.touch.pixels = SDL_malloc(TEXTURE_SIZE * TEXTURE_SIZE * sizeof(u32));
tic_mem* tic = platform.studio->tic;
const tic_bank* bank = &platform.studio->config()->cart->bank0;

if(platform.gamepad.touch.pixels)
{
u32* out = platform.gamepad.touch.pixels;

const u8* in = platform.studio->tic->ram.vram.screen.data;
const u8* end = in + sizeof(platform.studio->tic->ram.vram.screen);
const u32* pal = tic_tool_palette_blit(&platform.studio->config()->cart->bank0.palette.scn, platform.studio->tic->screen_format);
const u32 Delta = ((TIC80_FULLWIDTH*sizeof(u32))/sizeof *out - TIC80_WIDTH);

s32 col = 0;
memcpy(tic->ram.vram.palette.data, &bank->palette.scn, sizeof(tic_palette));
memcpy(tic->ram.tiles.data, &bank->tiles, sizeof(tic_tiles));
tic_api_spr(tic, 0, 0, 0, TIC_SPRITESHEET_COLS, TIC_SPRITESHEET_COLS, NULL, 0, 1, tic_no_flip, tic_no_rotate);
}

while(in != end)
{
u8 low = *in & 0x0f;
u8 hi = (*in & 0xf0) >> TIC_PALETTE_BPP;
*out++ = low ? *(pal + low) : 0;
*out++ = hi ? *(pal + hi) : 0;
in++;
platform.gamepad.touch.pixels = SDL_malloc(TEXTURE_SIZE * TEXTURE_SIZE * sizeof(u32));

col += BITS_IN_BYTE / TIC_PALETTE_BPP;
tic_core_blit(tic, tic->screen_format);

if (col == TIC80_WIDTH)
{
col = 0;
out += Delta;
}
}
for(u32* pix = tic->screen, *end = pix + TIC80_FULLWIDTH * TIC80_FULLHEIGHT; pix != end; ++pix)
if(*pix == tic_rgba(&bank->palette.scn.colors[0]))
*pix = 0;

updateGamepadParts();
}
memcpy(platform.gamepad.touch.pixels, tic->screen, TIC80_FULLWIDTH * TIC80_FULLHEIGHT * sizeof(u32));

memset(&platform.studio->tic->ram.map, 0, sizeof(tic_map));
memset(&platform.studio->tic->ram.tiles, 0, sizeof(tic_tiles) * TIC_SPRITE_BANKS);
ZEROMEM(tic->ram.vram.palette);
ZEROMEM(tic->ram.tiles);
}

if(!platform.gamepad.touch.texture)
Expand All @@ -352,6 +326,8 @@ static void initTouchGamepad()
updateTextureBytes(platform.gamepad.touch.texture, platform.gamepad.touch.pixels, TEXTURE_SIZE);
#endif
}

updateGamepadParts();
}
#endif

Expand Down Expand Up @@ -384,7 +360,7 @@ static void initGPU()

#if defined(TOUCH_INPUT_SUPPORT)
initTouchGamepad();
#endif
#endif
}


Expand Down Expand Up @@ -1044,17 +1020,20 @@ static void renderKeyboard()
{
const s32 tileSize = platform.keyboard.touch.button.size;

enum { Top = TIC80_MARGIN_TOP + 2 * TIC_SPRITESIZE};
enum { Left = TIC80_MARGIN_LEFT + 5 * TIC_SPRITESIZE};

if(!SDL_IsTextInputActive())
{
const SDL_Point* pos = &platform.keyboard.touch.button.pos;
#if defined(CRT_SHADER_SUPPORT)
GPU_Rect src = {0, 2*TIC_SPRITESIZE, TIC_SPRITESIZE * 2, TIC_SPRITESIZE};
GPU_Rect src = {Left, Top, TIC_SPRITESIZE * 2, TIC_SPRITESIZE};
GPU_Rect dest = {(float)pos->x, (float)pos->y, (float)tileSize, (float)tileSize};

GPU_BlitScale(platform.gamepad.touch.texture, &src, platform.gpu.renderer, dest.x, dest.y,
(float)dest.w / TIC_SPRITESIZE, (float)dest.h / TIC_SPRITESIZE);
#else
SDL_Rect src = {0, 2*TIC_SPRITESIZE, TIC_SPRITESIZE * 2, TIC_SPRITESIZE};
SDL_Rect src = {Left, Top, TIC_SPRITESIZE * 2, TIC_SPRITESIZE};
SDL_Rect dest = {pos->x, pos->y, tileSize * 2, tileSize};
SDL_RenderCopy(platform.gpu.renderer, platform.gamepad.touch.texture, &src, &dest);
#endif
Expand Down Expand Up @@ -1083,18 +1062,20 @@ static void renderGamepad()
{input->gamepads.first.y, platform.gamepad.touch.button.y.x, platform.gamepad.touch.button.y.y},
};

enum { Left = TIC80_MARGIN_LEFT + 8 * TIC_SPRITESIZE};

for(s32 i = 0; i < COUNT_OF(Tiles); i++)
{
const Tile* tile = Tiles + i;

#if defined(CRT_SHADER_SUPPORT)
GPU_Rect src = { (float)i * TIC_SPRITESIZE, (float)(tile->press ? TIC_SPRITESIZE : 0), (float)TIC_SPRITESIZE, (float)TIC_SPRITESIZE};
GPU_Rect src = { (float)i * TIC_SPRITESIZE + Left, (float)(tile->press ? TIC_SPRITESIZE : 0) + TIC80_MARGIN_TOP, (float)TIC_SPRITESIZE, (float)TIC_SPRITESIZE};
GPU_Rect dest = { (float)tile->x, (float)tile->y, (float)tileSize, (float)tileSize};

GPU_BlitScale(platform.gamepad.touch.texture, &src, platform.gpu.renderer, dest.x, dest.y,
(float)dest.w / TIC_SPRITESIZE, (float)dest.h / TIC_SPRITESIZE);
#else
SDL_Rect src = {i * TIC_SPRITESIZE, tile->press ? TIC_SPRITESIZE : 0, TIC_SPRITESIZE, TIC_SPRITESIZE};
SDL_Rect src = {i * TIC_SPRITESIZE + Left, (tile->press ? TIC_SPRITESIZE : 0) + TIC80_MARGIN_TOP, TIC_SPRITESIZE, TIC_SPRITESIZE};
SDL_Rect dest = {tile->x, tile->y, tileSize, tileSize};
SDL_RenderCopy(platform.gpu.renderer, platform.gamepad.touch.texture, &src, &dest);
#endif
Expand Down
2 changes: 1 addition & 1 deletion version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
#define TIC_VERSION_STATUS "@VERSION_STATUS@"
#define TIC_VERSION_BUILD "@VERSION_BUILD@"
#define TIC_VERSION_YEAR "@VERSION_YEAR@"
#define TIC_VERSION_HASH "@VERSION_HASH@"
#define TIC_VERSION_HASH "@VERSION_HASH@"

0 comments on commit 2d532a6

Please sign in to comment.