Skip to content

Commit

Permalink
Add square border for alignment usage
Browse files Browse the repository at this point in the history
  • Loading branch information
epbarger committed Aug 31, 2023
1 parent 5156051 commit d91847d
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 3 deletions.
Binary file added assets/border.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
87 changes: 87 additions & 0 deletions src/border.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
//AUTOGENERATED FILE FROM png2asset

#include <stdint.h>
#include <gbdk/platform.h>
#include <gbdk/metasprites.h>

BANKREF(border)

const palette_color_t border_palettes[32] = {
RGB8( 0, 0, 0), RGB8( 34, 32, 52), RGB8( 69, 40, 60), RGB8(102, 57, 49)
,
RGB8(143, 86, 59), RGB8(223,113, 38), RGB8(217,160,102), RGB8(238,195,154)
,
RGB8(251,242, 54), RGB8(153,229, 80), RGB8(106,190, 48), RGB8( 55,148,110)
,
RGB8( 75,105, 47), RGB8( 82, 75, 36), RGB8( 50, 60, 57), RGB8( 63, 63,116)
,
RGB8( 48, 96,130), RGB8( 91,110,225), RGB8( 99,155,255), RGB8( 95,205,228)
,
RGB8(203,219,252), RGB8(255,255,255), RGB8(155,173,183), RGB8(132,126,135)
,
RGB8(105,106,106), RGB8( 89, 86, 82), RGB8(118, 66,138), RGB8(172, 50, 50)
,
RGB8(217, 87, 99), RGB8(215,123,186), RGB8(143,151, 74), RGB8(138,111, 48)

};

const uint8_t border_tiles[144] = {
0x00,0x00,0x7f,0x7f,
0x7f,0x7f,0x7f,0x7f,
0x7f,0x7f,0x7f,0x7f,
0x7f,0x7f,0x7f,0x7f,
0x00,0x00,0xff,0xff,
0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,
0x00,0x00,0xfe,0xfe,
0xfe,0xfe,0xfe,0xfe,
0xfe,0xfe,0xfe,0xfe,
0xfe,0xfe,0xfe,0xfe,
0x7f,0x7f,0x7f,0x7f,
0x7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4,0xb4,0xb4,0xb4,0xb4,0xb5,
0xb3,0xb4,0xb4,0xb4,0xb4,0xb4,0xb4,0xb4,0xb4,0xb4,0xb4,0xb4,0xb4,0xb4,0xb4,0xb4,0xb4,0xb4,0xb4,0xb5,
0xb6,0xb7,0xb7,0xb7,0xb7,0xb7,0xb7,0xb7,0xb7,0xb7,0xb7,0xb7,0xb7,0xb7,0xb7,0xb7,0xb7,0xb7,0xb7,0xb8,
};
27 changes: 27 additions & 0 deletions src/border.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//AUTOGENERATED FILE FROM png2asset
#ifndef METASPRITE_border_H
#define METASPRITE_border_H

#include <stdint.h>
#include <gbdk/platform.h>
#include <gbdk/metasprites.h>

#define border_TILE_ORIGIN 176
#define border_TILE_W 8
#define border_TILE_H 8
#define border_WIDTH 160
#define border_HEIGHT 144
#define border_TILE_COUNT 9
#define border_PALETTE_COUNT 8
#define border_COLORS_PER_PALETTE 4
#define border_TOTAL_COLORS 32
#define border_MAP_ATTRIBUTES 0

BANKREF_EXTERN(border)

extern const palette_color_t border_palettes[32];
extern const uint8_t border_tiles[144];

extern const unsigned char border_map[360];

#endif
16 changes: 13 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Better Button Test v4
Better Button Test v5
GBDK 2020 for Game Boy
*/

Expand All @@ -11,6 +11,8 @@
#include <gbdk/console.h>
#include <gbdk/font.h>

#include "border.h"


// RAM function stuff
#define objectDistance(a, b) ((void *)&(b) - (void *)&(a))
Expand Down Expand Up @@ -134,6 +136,11 @@ void setupFonts() {
minFontInvert = font_load(font_min);
}

void drawBorder() {
set_bkg_data(border_TILE_ORIGIN, border_TILE_COUNT, border_tiles);
set_bkg_tiles(0, 0, 20u, 18u, border_map);
}

void printAtWith(char str[], uint8_t x, uint8_t y, font_t font) {
font_set(font);
gotoxy(x, y);
Expand Down Expand Up @@ -164,7 +171,9 @@ font_t pressedFont(uint8_t key) {
}

void clearMessageArea() {
printAtWith(" ", 0, 14, minFont);
printAtWith(" ", 1, 14, minFont);
printAtWith(" ", 1, 15, minFont);
printAtWith(" ", 1, 16, minFont);
}

void whiteScreen() {
Expand Down Expand Up @@ -314,7 +323,7 @@ void draw() {
if (inMenu) {
font_set(ibmFont);
gotoxy(1,1);
printf("Theme: %s ", (char*)themeNames[themeIndex]);
printf("Theme: %s", (char*)themeNames[themeIndex]);

if (usingFlashSave) {
printAtWith("USING FLASH CONFIG", 1, 14, minFontInvert);
Expand Down Expand Up @@ -415,6 +424,7 @@ void main(void) {
loadSettings();
initSound();
setupFonts();
drawBorder();

if (_cpu == CGB_TYPE) set_bkg_palette(0, 1, palettes[themeIndex]);

Expand Down

0 comments on commit d91847d

Please sign in to comment.