Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

Ads

#1 2024-02-22 06:37:21

m4tt
New member
Registered: 2024-02-22
Posts: 2

set_win_tiles() not working for Gameboy Color

Hello!

I've stumbled upon a problem with displaying a window using set_win_tiles(). Here's an example code:

Code:

#include <gb/gb.h>
#include <gbdk/font.h>

uint8_t map[] = {
  0x12,0x0f,0x16,0x16,0x19
};

void main(void) {
    font_t min_font;

    font_init();
    min_font = font_load(font_min);
    font_set(min_font);

    set_win_tiles(0, 0, 5, 1, map);

    SHOW_WIN;
    DISPLAY_ON;
}

When using the following build commands, the code is running correctly (i.e. it displays "HELLO").

Code:

c:\gbdk\bin\lcc -Wa-l -Wl-m -Wf--debug -Wl-y -Wl-w -c -o main.o main.c
c:\gbdk\bin\lcc -Wa-l -Wl-m -Wf--debug -Wl-y -Wl-w -o main.gb main.o

But when I add '-Wm-yC' flag to build it for a Gameboy Color, the screen is empty.

Does anybody know what should I do to properly display window for a Gameboy Color?

Offline

 

#2 2024-02-22 20:28:37

Ardis
Member
From: USA
Registered: 2019-06-06
Posts: 59
Website

Re: set_win_tiles() not working for Gameboy Color

Did you set a palette? Default palette on a GBC is all white.


Also known as Arvex in other places.

Interceptor (Demo)
https://arvex.itch.io/interceptor

Offline

 

#3 2024-02-23 06:50:36

m4tt
New member
Registered: 2024-02-22
Posts: 2

Re: set_win_tiles() not working for Gameboy Color

I didn't. You're right, after setting a palette the text is displayed. Here's an updated code (for future reference). Thank you!

Code:

#include <gb/gb.h>
#include <gbdk/platform.h>
#include <gbdk/font.h>

uint8_t map[] = {
  0x12,0x0f,0x16,0x16,0x19
};

const palette_color_t palette[] = {
  RGB8(255, 255, 255), RGB8(255, 255, 255), RGB8(255, 255, 255), RGB8(0, 0, 0)
};

void main(void) {
    font_t min_font;

    font_init();
    min_font = font_load(font_min);
    font_set(min_font);
    font_color(0, 0);

    // As there is no set_win_palette() function I guess that
    // palettes for bkg and win are common. Using set_default_palette()
    // works too.
    set_bkg_palette(0, 1, palette);
    set_win_tiles(0, 0, 5, 1, map);

    SHOW_WIN;
    DISPLAY_ON;
}

Offline

 

#4 2024-02-23 16:01:05

Ardis
Member
From: USA
Registered: 2019-06-06
Posts: 59
Website

Re: set_win_tiles() not working for Gameboy Color

Glad I could help.


Also known as Arvex in other places.

Interceptor (Demo)
https://arvex.itch.io/interceptor

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson