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 2014-07-27 08:26:34

a cat
Member
Registered: 2014-07-27
Posts: 98

Clearing the screen gbdk

hi i am trying to make a simple pong game in c
using the gbdk
but i cant work out how to refresh the screen!
dose anyone know how to clear the screen without using the plot function in some for loops which takes forever?

i am rely stuck on this and there dosent seem to be any tutorial online about making gameboy games

thanks in advance

Last edited by a cat (2014-07-27 08:27:32)


a cat in need of knowledge!!

Offline

 

#2 2014-07-30 05:34:48

LuckyLights
Member
Registered: 2014-07-06
Posts: 20

Re: Clearing the screen gbdk

Hi Cat,

The gameboy hardware dos not work like a Bliter or modern gfx card so there is not a direct color buffer to clear, instead you got 3 different typs of semi dynamic gfx/vram memory. One for background, one for a tile map called the window, and there is OMA/Sprites.

I suggests you read up on it at Pan Docs (http://problemkaputt.de/pandocs.htm) and check out the galaxy example in gbdk.

If you want to work with something thats more like a traditional bliter take a look at the paint example in gbdk.

Offline

 

#3 2014-07-30 07:38:02

a cat
Member
Registered: 2014-07-27
Posts: 98

Re: Clearing the screen gbdk

Thanks ill take a look

sry i diddnt rely get the galaxy.c file
for example why this function?
const unsigned char earth_data[] = {

  /* Tile 0x00 */
  0x07,0x07,0x18,0x1F,0x32,0x2D,0x71,0x4E,0x70,0x4F,0xF8,0x87,0xF8,0x87,0xF8,0x87,
  0xFC,0x83,0xFE,0x81,0x7F,0x40,0x7F,0x40,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00,
  0xC0,0xC0,0xF0,0x30,0x78,0x88,0x3C,0xC4,0x5C,0xA4,0x9E,0x62,0x3E,0xC2,0x3E,0xC2,
  0x5E,0xA2,0x7E,0x82,0x0C,0xF4,0x0C,0xF4,0x98,0x68,0xB0,0x70,0xC0,0xC0,0x00,0x00,
  0x07,0x07,0x1F,0x18,0x2F,0x30,0x4F,0x70,0x6F,0x50,0x9F,0xE0,0x9F,0xE0,0xBF,0xC0,
  0xFF,0x80,0xB7,0xC8,0x63,0x5C,0x43,0x7C,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00,
  0xC0,0xC0,0xB0,0x70,0x18,0xE8,0x0C,0xF4,0x0C,0xF4,0x82,0x7E,0x82,0x7E,0x86,0x7A,
  0xC6,0x3A,0xE6,0x1A,0xF4,0x0C,0xFC,0x04,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00,

  /* Tile 0x08 */
  0x07,0x07,0x1E,0x19,0x20,0x3F,0x40,0x7F,0x42,0x7D,0x81,0xFE,0x81,0xFE,0x83,0xFC,
  0xD7,0xA8,0xBB,0xC4,0x6E,0x51,0x7C,0x43,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00,
  0xC0,0xC0,0x70,0xB0,0xE8,0x18,0xF4,0x0C,0xF4,0x0C,0xFE,0x02,0xFE,0x02,0xFE,0x02,
  0xFE,0x02,0x7E,0x82,0x3C,0xC4,0x3C,0xC4,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00,
  0x07,0x07,0x1B,0x1C,0x20,0x3F,0x40,0x7F,0x40,0x7F,0xE0,0x9F,0x90,0xEF,0x89,0xF6,
  0x8D,0xF2,0x9F,0xE0,0x5E,0x61,0x6F,0x50,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00,
  0xC0,0xC0,0xB0,0x70,0x28,0xD8,0x04,0xFC,0x2C,0xD4,0x1E,0xE2,0x1E,0xE2,0x3E,0xC2,
  0x7E,0x82,0xB6,0x4A,0xE4,0x1C,0xC4,0x3C,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00,

  /* Tile 0x10 */
  0x07,0x07,0x18,0x1F,0x20,0x3F,0x40,0x7F,0x40,0x7F,0xEE,0x91,0xF1,0x8E,0xE0,0x9F,
  0xE0,0x9F,0xF1,0x8E,0x71,0x4E,0x72,0x4D,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00,
  0xC0,0xC0,0xF0,0x30,0x08,0xF8,0x04,0xFC,0x04,0xFC,0x02,0xFE,0x02,0xFE,0x92,0x6E,
  0xD6,0x2A,0xFE,0x02,0xEC,0x14,0xFC,0x04,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00,
  0x07,0x07,0x1D,0x1A,0x36,0x29,0x5C,0x63,0x6C,0x53,0xCE,0xB1,0x9F,0xE0,0x9E,0xE1,
  0xAE,0xD1,0xBF,0xC0,0x47,0x78,0x47,0x78,0x2F,0x30,0x1F,0x18,0x07,0x07,0x00,0x00,
  0xC0,0xC0,0x70,0xB0,0x08,0xF8,0x04,0xFC,0x04,0xFC,0xE2,0x1E,0x32,0xCE,0x0E,0xF2,
  0x0E,0xF2,0x1E,0xE2,0x1C,0xE4,0x2C,0xD4,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00,

  /* Tile 0x18 */
  0x07,0x07,0x1E,0x19,0x33,0x2C,0x49,0x76,0x42,0x7D,0xC4,0xBB,0xC1,0xBE,0xC1,0xBE,
  0xE2,0x9D,0xF3,0x8C,0x78,0x47,0x78,0x47,0x3C,0x23,0x1C,0x1B,0x07,0x07,0x00,0x00,
  0xC0,0xC0,0x70,0xB0,0x68,0x98,0xC4,0x3C,0xC4,0x3C,0xEE,0x12,0xF2,0x0E,0xE2,0x1E,
  0xE2,0x1E,0xF2,0x0E,0x7C,0x84,0x7C,0x84,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00
};
also
what am i drawing to when i do
plot(100, 100, 2);

Last edited by a cat (2014-07-30 07:49:14)


a cat in need of knowledge!!

Offline

 

#4 2014-07-30 08:43:47

LuckyLights
Member
Registered: 2014-07-06
Posts: 20

Re: Clearing the screen gbdk

Hi cat,

That is not a function it's a memory block that contains the pixel data for the spinning earth.

As for plot(100, 100, 2) means your setting the pixel at 100,100 to the index value of 2. The color is determined my pallet register that represents 2 on that tile data buffer. I assume that this is for useing the draw.h API. I haven't used it that mutch to be honest.

Offline

 

#5 2014-07-30 17:26:29

a cat
Member
Registered: 2014-07-27
Posts: 98

Re: Clearing the screen gbdk

sry dont know why i put function
so do you use a special tool to get all those hex values to make a image
or was programming just this hard in 1989?

also what i ment by the question "what a i drawing to when i do plot(100, 100, 2);"
was
am i writing to the window, the oma or the background?

i opened a vram viewer and it seemed that it was both the background and window

and from looking at the vram viewer
it looked like the background is whats being displayed
and the tiles are the data sprites and background
that is ready to be drawn to the screen
is this in any way correct?


a cat in need of knowledge!!

Offline

 

#6 2014-08-01 04:55:42

LuckyLights
Member
Registered: 2014-07-06
Posts: 20

Re: Clearing the screen gbdk

There a lots of tools out there you can use to convert images in to hex data like that.
You can find some of them here: http://gbdev.gg8.se/forums//viewtopic.php?id=3
I made my own tool sense most are for win or DOS and i am on mac: https://github.com/LuckyLights/png2gb

I don't know exactly how the the drawing api works. but from what your reporting and whats commonly know i guess they are plotting in to both the sprite and background tile data.
and then are using both the window and background to display different regions of the screen. This is because one of the tile data blocks can only hold 128 unique tiles. And a full screen coverage would require  20 * 18 = 360 tiles. meaning you still are missing 104 tiles once you filled both tile memory banks. So i guess they swap out data durring lyc interrupts.

Offline

 

#7 2014-08-01 15:03:36

a cat
Member
Registered: 2014-07-27
Posts: 98

Re: Clearing the screen gbdk

Thanks for your help
also try using something called wine to run windows programs on mac/linux

Last edited by a cat (2014-08-01 15:04:24)


a cat in need of knowledge!!

Offline

 

#8 2014-08-08 06:45:29

LuckyLights
Member
Registered: 2014-07-06
Posts: 20

Re: Clearing the screen gbdk

No problem, i would recommend a full visualisations like Parallels or VMWare, instead of emulation like wine.
I use to run a Ubuntu visualisations for gbdk, but i run it native now.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson