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 2017-06-20 15:19:13

DoYouEvenFish
Member
Registered: 2017-03-11
Posts: 18

Drawing the window in the top right hand corner of the screen.

For the rom that I've been working on, I want the menu (which is on the window layer) to appear in the top right hand corner of the screen. However, when I put the menu in the top right hand corner a section of the background beneath the menu is hidden due to it being covered by the window. How do I stop this? I know that part of the window layer hides the background and have been able to move the window to the bottom of the screen to stop it from hiding the background before, however for this I want the menu to be at the top of the screen and not the bottom. I know that I could also copy background data to the window so that this area isn't blank, however this seems very inefficient and makes it difficult (not impossible though) to have scrolling rooms.

Tl;dr how do I stop the window from hiding the background if the window is at the top of the screen?

This is the screen before the menu is shown:
https://i.imgur.com/ERAdVCP.png

And this is the screen after the menu is shown:
https://i.imgur.com/NInjcOU.png

Offline

 

#2 2017-06-20 19:22:57

Tauwasser
Member
Registered: 2010-10-23
Posts: 160

Re: Drawing the window in the top right hand corner of the screen.

Check the current line and disable the window when it's finished displaying. Enable at start of vblank.

Offline

 

#3 2017-06-20 21:02:19

DoYouEvenFish
Member
Registered: 2017-03-11
Posts: 18

Re: Drawing the window in the top right hand corner of the screen.

How do I check the current line it is drawing on? I'm looking through the functions that gbdk comes with, but with using the function set_win_tiles I don't think you can check the current line it is drawing on. Also how would you disable the window when it's finished? The only thing I can find that does anything like that is HIDE_WIN, but obviously that just hides the entire window layer.

Offline

 

#4 2017-06-20 23:23:05

cabbage
New member
Registered: 2016-06-10
Posts: 5

Re: Drawing the window in the top right hand corner of the screen.

set up an interrupt.. for example:

STAT_REG|=0x40;//enable LYC=LY interrupt
LYC_REG=64;//the scanline on which to trigger
disable_interrupts();
add_LCD(an_lcd_interrupt_func);
enable_interrupts();
set_interrupts(LCD_IFLAG|VBL_IFLAG);

and make your interrupt function
void an_lcd_interrupt_func(){HIDE_WIN;}//hide the window, triggers at the scanline LYC

at vsync (e.g. in your game loop), SHOW_WIN

on the specified scanline (LYC_REG), the interrupt occurs (in this case, running an_lcd_interrupt_func)
this is off the top of my head; maybe something is incorrect... but you get the idea

Offline

 

#5 2017-06-21 03:23:15

Jonas
Member
From: Frankfurt, Germany
Registered: 2016-06-06
Posts: 112
Website

Re: Drawing the window in the top right hand corner of the screen.

The same concept is explained here in some more detail: http://gbdev.gg8.se/forums/viewtopic.php?id=345

Offline

 

#6 2017-06-25 11:35:26

DoYouEvenFish
Member
Registered: 2017-03-11
Posts: 18

Re: Drawing the window in the top right hand corner of the screen.

Thank you for helping, I have it working now.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson