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.
Hi people !
I'm currently programming a little game in asm and I've got a question about windows. I've been able to place a window on the screen but I need the color $00 to be transparent. Is it possible or did I have to use sprites instead ?
Thanks !
Last edited by Glad (2016-01-09 17:46:49)
Offline
I read the PanDocs about windows and I've got my answer... Apparently I can't display a custom sized window since it cover all the background so I will just use sprites. Never use them before, I'm a bit scared.
Offline
Well it depends on what you want to do with your window. You can always move it to the top / bottom or a side of your screen in order to have a menu. In the screenshot above for example, the window has been moved to the top so that only two line of the screen are used :
You can also use sprites as you mentioned, but don't forget that they are limited in numbers.
Offline
So technically, I can make a custom sized window ?
I mean, if I place my window at the bottom of the screen and make it flash by enable/disable the window on [rLCDC], it will work ?
I want it to work like the picture below (the window is in the red rectangle)
Last edited by Glad (2016-01-10 11:59:34)
Offline
Yeah, you should be able do that by moving your window (there's some registers for that).
But if you have only that text to animate, sprites should be enough though.
Last edited by Xephyr (2016-01-10 12:17:59)
Offline
So I load a 20*18 tiles window and put the upper lft corner at the bottom of my screen and it will work ?
Offline
Moving it to the right and/or bottom of the screen is easy, because the overhang is just not drawn. Having it at the top or left is hard, because you then need to disable it on the correct line in order for it to be drawn.
cYa,
Tauwasser
Offline
It looks like you either write to the Bg, or you accidentally switched the tile base from 0x8800 to 0x8000 or something.
cYa,
Tauwasser
Offline
For displaying the BG, I put this in [rLCDC] : %11010001
And when I need my window to pop, I write this in [rLCDC] : %1111001
I've read the pandoc and the gameboy programming guide but I can't find out where I'm wrong !
Maybe It's a problem with the bit 4 for the BG and window tile data selection...
Offline
Just flipping that bit shouldn't write garbage to the screen. Can you show us some more code?
EDIT: bit, not but.
Last edited by l0k1 (2016-01-11 00:02:56)
Offline
here is the two function for displaying the main menu screen and the window :
Main_Menu:
di
call LCD_Off
xor A
ld [rSCX],A
ld [rSCY],A
ld HL, Menu_Tiles
ld DE,$95 * $10 ;Chargement de 146 tiles
call Load_Tiles_Into_VRAM
ld HL,Menu_Map
call Screen_Load_0_20x18
ld A,%11010001 ;BG On -
ld [rLCDC],A
ei
call Fade_In_Black
ret
SECTION "Press_Start_Window",HOME
Press_Start_Window:
di
call LCD_Off
ld A,7
ld [rWX],A
ld A, $6D
ld [rWY],A
ld HL, Press_Start_Tiles
ld DE,$1B * $10 ;Chargement de 27 tiles
call Load_Tiles_Into_VRAM
ld HL,Press_Start_Map
call Screen_Load_1_20x18
ld A,%11110001 ;Window+BG On
ld [rLCDC],A
ei
ret
and here's the sub fonctions for loading the screen and loading the window
Screen_Load_0_20x18:
ld DE,18 ;this many y-lines.
ld BC,_SCRN0-(12) ;background tile map 0. subtracting 12, as it'll be added in again soon.
.y_line_loop
push DE ;Storing the Y-Line coord for later.
ld DE,12 ;first, we need to increase _SCRN0 location by 12*16, and ignore all the tiles off screen
.inc_bgmap_location
inc BC
dec DE
ld A,E
or D
jp nz,.inc_bgmap_location
ld DE,20 ;x-length, 20 tiles at 16 bytes each
.x_line_loop
ld A,[HL+] ;where the magic happens
ld [BC],A
inc BC
dec DE
ld A,E
or D
jp nz,.x_line_loop
pop DE ;after we've got done loading an x-line, we need to check our y-line
dec DE
ld A,E
or D
jp nz,.y_line_loop
ret
SECTION "20x18 Screen Load 1",HOME
;Used for loading a map into the BG map area at $9800 that is 20x18 tiles.
;HL must be at the start of the tile data.
;Assumes rSCX & rSCY are at 0,0.
Screen_Load_1_20x18:
ld DE,18 ;this many y-lines.
ld BC,_SCRN1-(12) ;background tile map 1. subtracting 12, as it'll be added in again soon.
.y_line_loop_w
push DE ;Storing the Y-Line coord for later.
ld DE,12 ;first, we need to increase _SCRN1 location by 12*16, and ignore all the tiles off screen
.inc_winmap_location
inc BC
dec DE
ld A,E
or D
jp nz,.inc_winmap_location
ld DE,20 ;x-length, 20 tiles at 16 bytes each
.x_line_loop_w
ld A,[HL+] ;where the magic happens
ld [BC],A
inc BC
dec DE
ld A,E
or D
jp nz,.x_line_loop_w
pop DE ;after we've got done loading an x-line, we need to check our y-line
dec DE
ld A,E
or D
jp nz,.y_line_loop_w
ret
I use some sample of your SuperHappyFunBubbleTime project for doing this !
Last edited by Glad (2016-01-10 21:51:04)
Offline
Glad to see my code is helping someone. =] Use all you need!
First, a thought - the note you have under the section heading for Screen_Load_1_20x18 should read that it's loading data to $9C00, not $9800.
But! That's not important. =]
It looks like the error is coming in with your second use of Load_Tiles_Into_VRAM. When you call that the second time, it's overwriting the tiles you put in on the first Load_Tiles_Into_VRAM call, which is why "garbage" is being shown on the screen.
What I'd do to fix is load all the tiles right away, so you don't have to call it a second time.
Or, use sprites for the "Press Start" text.
Either way, really good looking opening screen. Puts mine to shame!
Offline
Thank you very much L0k1 ! I will try to load all the tiles together and see if it's change something. If it don't I will go for the sprites !
Offline
Took me 3 hours but I did it ! I've load all my tiles at the same time like you suggest and it worked !
Thank you so much guys !
Offline
Awesome! Happy you got it working.
grumpily gets back to working on his own bugs
Last edited by l0k1 (2016-01-12 03:26:31)
Offline