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 2019-11-30 03:56:17

obscuredesign79
Member
Registered: 2019-11-02
Posts: 11

how to fix twitching window layer

hello gameboy dev forum. i new at programming in c\c++ and ive been learning  how to make gameboy games with it using gbdk. while im learning to code, i wanted to learn it in c first and maybe i can move to assembly. i hope its okay to ask these question here and not get too annoyed.

im just following a youtube channel called gamingmonsters and in it, the person teaches you programming gameboy in c. i was doing his tutorial for window layer or hud. For some reason when i run the rom the window layer twitches. i have a youtube video demonstration the effect. can you guys help me? thanks.

sample video of the window layer twitching
https://youtu.be/K8_WFtI2_bI

my code

Code:

  
  1 #include <gb/gb.h>
  2 #include "level01Tiles.c"
  3 #include "level01Map.c"
  4 #include <gb/font.h>
  5 #include "window01Map.c"
  6 
  7 void performantDelay(UINT8 numloops){
  8 
  9     UINT8 i;
 10     for(i=0;i<numloops;i++){
 11         wait_vbl_done();
 12     }
 13 }
 14 
 15 void fontINIT()
 16 {
 17     font_t minFont;
 18     font_init();
 19     minFont = font_load(font_min);
 20     font_set(minFont);
 21 }
 22 
 23 void main()
 24 {
 25 
 26     SHOW_BKG;
 27     SHOW_WIN;
 28     DISPLAY_ON;
 29 
 30     fontINIT();
 31 
 32     set_bkg_data(38, 13, level01Tiles);
 33     set_bkg_tiles(0, 0, 40, 18, level01Map);
 34 
 35     set_win_tiles(0, 0, 9, 1, window01Map);
 36     move_win(0, 136);
 37 
 38 
 39     while(1)
 40     {
 41         scroll_bkg(1, 0);
 42 //      delay(100);
 43         performantDelay(1);
 44     }
 45 
 46 }

Last edited by obscuredesign79 (2019-11-30 03:57:54)

Offline

 

#2 2019-11-30 07:20:09

nitro2k01
Administrator
Registered: 2008-02-22
Posts: 249

Re: how to fix twitching window layer

This is a glitch in the window rendering. WX (the window X position) value is the actual position plus 7. You can use 1-6 to scroll the window slightly to the left of the screen. However, the value 0 is glitchy and gives you the effect you've discovered, where the window X position is influenced by the background X position. What you most likely want is to set the X position value to 7, which positions the window at the left edge of the screen.

Code:

move_win(7, 136);

Blog: Gameboy Genius
"A journey of a thousand miles begins with one small step"
Old Chinese Proverb

Offline

 

#3 2019-11-30 10:30:11

obscuredesign79
Member
Registered: 2019-11-02
Posts: 11

Re: how to fix twitching window layer

thank you so much for pointing that out nitro2k01. the window doesnt twitch anymore.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson