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.

#1 2017-06-29 18:29:47

StonyyBird
New member
Registered: 2017-06-29
Posts: 5

Window at top and bottom

Hi all,

I'm trying to display the window at both, the top and bottom of the screen. The LYC_REG interrupt is set to disable and reenable the window at lines 8 and 130.

The problem is, that the window is flickering. Sometimes the background is displayed shortly. Also the window content at the bottom is not displayed.

Could this be an issue of my code or of the BGB emulator? Displaying the window at either the top or the bottom works fine.

Here is my gbdk code, maybe you can tell me what's wrong. Thanks

Code:

#include <gb/gb.h> 

enum
{
    TOP_LCY_INTERRUPT = 8,
    BOTTOM_LCY_INTERRUPT = 130
};

void WindowUpdate() {
    if (LYC_REG == (UINT8) TOP_LCY_INTERRUPT)
    {
        // should be line 8, so disable the window
        HIDE_WIN;

        // next trigger at line 136
        LYC_REG = (UINT8) BOTTOM_LCY_INTERRUPT;
    }
    else
    {
        // should be line 136, so enable the window
        SHOW_WIN;

        // next trigger at line 8 will be set at VBL interrupt
        LYC_REG = (UINT8) TOP_LCY_INTERRUPT;
    }
}

void main() {
    disable_interrupts();
    add_VBL(...);

    add_TIM(...);
    TMA_REG = ...;
    TAC_REG = ...;

    add_LCD(WindowUpdate);
    STAT_REG = 0x40U; // http://bgb.bircd.org/pandocs.htm#lcdstatusregister
    SHOW_WIN;
    LYC_REG = (UINT8) TOP_LCY_INTERRUPT;

    set_interrupts(VBL_IFLAG | TIM_IFLAG | LCD_IFLAG);
    enable_interrupts();

  while (1) { ... }
}

Offline

 

#2 2017-06-29 19:47:23

AntonioND
Member
Registered: 2014-06-17
Posts: 134
Website

Re: Window at top and bottom

Not sure about the flickering, I haven't checked the code, but the window is a bit weird when it comes to the LY. If you hide the window at one line and then show it in another one, it will start drawing from the last line that was drawn, not from the one that the scroll in WY would make you think.

Maybe it's worth using the background for both things. Just change the bg map and tiles (and scroll) instead of hiding/showing the window.

Offline

 

#3 2017-06-30 03:12:51

StonyyBird
New member
Registered: 2017-06-29
Posts: 5

Re: Window at top and bottom

AntonioND wrote:

[...], but the window is a bit weird when it comes to the LY. If you hide the window at one line and then show it in another one, it will start drawing from the last line that was drawn, not from the one that the scroll in WY would make you think.

That's true, I just tested it and now the bottom line will be drawn with content. The flickering is still there, however.

I will try using the background instead of the window, thanks for this idea.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson