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 2012-12-21 16:41:09

Mills
Member
Registered: 2012-12-21
Posts: 132

GBDK and assembly questios

HI everybody.

I bought a gameboy color two months ago, I already managed to do some demos using gbdk:

https://www.youtube.com/watch?v=XszoSBUiaZo

Now I want to ask some questions about game boy(color), GBDK and asm.

1 - How do i overcome this anoying thing when compiling in GBDK?
(this http://gbdev.gg8.se/forums/viewtopic.php?id=91 didn't work for color tiles and maps)

Code:

ERROR: address overflow (addr c230 >= 8000) lcc: 
C:\gbdk\bin/link-gbz80: No error

2 - I know GBDK has its limits, but it runs fast enought for most things, so i'm not learning assembly (i tried, it looks not very good for game logic...)
  So... how do I include an asm program inside a C one, using GBDK? and how do i call asm rutines from C? (i'm thinking in carillon music player, the best i found)

3 - Just one last question... Is it possible to change background tile atributes while running the game? (with GBDK i just found how to change palettes)


Thanks a lot!

Last edited by Mills (2012-12-21 16:45:36)

Offline

 

#2 2012-12-23 16:52:35

paulc
Member
Registered: 2012-10-23
Posts: 27

Re: GBDK and assembly questios

Hey man,
Questions 1 & 2 I haven't experimented with personally.
Question #3: are you referring to "dynamic tiles" where the tile are animated like on the map screen in Mario Land 2? You can also switch out the map data each frame to give an illusion of animation in the background. I personally haven't tried re-loading the background with new tiles, but it seems you need to load the high #'d tiles first, then the low.

Are you on #gbdev on IRC ?

Offline

 

#3 2012-12-23 17:12:54

paulc
Member
Registered: 2012-10-23
Posts: 27

Re: GBDK and assembly questios

Hey, I just checked out that YouTube video of your game... wow! That's looking really amazing! Reminds me of the NES Lolo games. And the parallax is looking really cool. Doesn't make me think of a GBC game. And I see you are already using animated tiles on the waterfall. On the clouds it looks like you're using an interlaced effect for transparency, but could you also flicker it on and off quickly for a similar effect?

As for mixing Assembly and GBDK, have you checked this out?:  http://www.devrs.com/gb/files/asm_gbdk.txt
It's from:  http://www.devrs.com/gb/ccode.php
Hope that helps

Offline

 

#4 2012-12-23 19:45:55

Mills
Member
Registered: 2012-12-21
Posts: 132

Re: GBDK and assembly questios

paulc wrote:

Hey, I just checked out that YouTube video of your game... wow! That's looking really amazing! Reminds me of the NES Lolo games. And the parallax is looking really cool. Doesn't make me think of a GBC game. And I see you are already using animated tiles on the waterfall. On the clouds it looks like you're using an interlaced effect for transparency, but could you also flicker it on and off quickly for a similar effect?

As for mixing Assembly and GBDK, have you checked this out?:  http://www.devrs.com/gb/files/asm_gbdk.txt
It's from:  http://www.devrs.com/gb/ccode.php
Hope that helps

Thanks for answering, I sometimes go to gbdev on irc, not many people sad.
I already found the asm + c samples, but i don't understand them very well... i want to generate the asm code with carillon player (it creates the code in windows) and then include it inside a c program.

For the clouds of my demo, i change the sprite position every frame, so, one cloud makes two transparent ones, and the waterfalls are just 4 sprites.

Now the big trouble is still the address overflow one...

I solved the animated bkg problem, I reloaded bkg tiles every frame, and it looks really good, I think a bunch of different backgrounds would create a nice video effect but first i have to solve the overflow problem.
here is a youtube video, showing an animated bkg

http://www.youtube.com/watch?v=wUQXIL8I … e=youtu.be

In "cpu_fast()" mode (8Mhz), it runs at a smooth 60 fps consuming 75% cpu. 
I used to own a 8086, 8Mhz that could run another world (aka out of this world). How different  are z80 and 8086?. Could the GBC run "another world"?. I tested some drawing options, and i got some vectors moving very well, but just on DMG mode, no color...

Last edited by Mills (2012-12-26 07:26:14)

Offline

 

#5 2012-12-27 00:04:07

paulc
Member
Registered: 2012-10-23
Posts: 27

Re: GBDK and assembly questios

Here's an example game with source that uses bank switching.  Maybe it will help:

http://web.archive.org/web/200008212227 … raven3.zip

Here's the page it's from:
http://web.archive.org/web/200008212227 … v/gbc.html

If you compile each of your banks separately are there any problems? In other words, does all the information fit into each bank fine?

I too would like to know how to incorporate ASM with C, as I have ASM from XMPCK that I converted from MML.

Offline

 

#6 2012-12-27 09:35:15

Mills
Member
Registered: 2012-12-21
Posts: 132

Re: GBDK and assembly questios

paulc wrote:

Here's an example game with source that uses bank switching.  Maybe it will help:

http://web.archive.org/web/200008212227 … raven3.zip

Here's the page it's from:
http://web.archive.org/web/200008212227 … v/gbc.html

If you compile each of your banks separately are there any problems? In other words, does all the information fit into each bank fine?

I too would like to know how to incorporate ASM with C, as I have ASM from XMPCK that I converted from MML.

When i compile each bank separately, it fits ok, the problem is the makefile.

I read the sample code, it loads .dat images... that's the problem, i read in the other post, gbdk goes crazy when including big c arrays.. so i have to load the tiles and maps in .s or .z80 format, and i don't know how to do it.

Thanks a lot.

Last edited by Mills (2012-12-27 10:13:48)

Offline

 

#7 2012-12-27 15:48:41

paulc
Member
Registered: 2012-10-23
Posts: 27

Re: GBDK and assembly questios

Could you share the file you're looking to compile from multiple banks? I'd like to give it a shot.
Also, I think I found an example demo that has source that uses both ASM and C.
"Vectrony" by DarkFader - you can dl here: http://www.subport.org/gbc/files/demos/vectrony.zip

EDIT: I just realized that link doesn't have the source. This one should:  http://darkfader.net/gbc/files/Vectrony.zip

There's also a lot of good demo roms on that site.

Another idea would be to ask the question on the GBA forum here:
http://forum.gbadev.org/viewforum.php?f … p;start=50

Last edited by paulc (2012-12-27 15:52:40)

Offline

 

#8 2012-12-27 18:30:45

Mills
Member
Registered: 2012-12-21
Posts: 132

Re: GBDK and assembly questios

paulc wrote:

Could you share the file you're looking to compile from multiple banks? I'd like to give it a shot.
Also, I think I found an example demo that has source that uses both ASM and C.
"Vectrony" by DarkFader - you can dl here: http://www.subport.org/gbc/files/demos/vectrony.zip

EDIT: I just realized that link doesn't have the source. This one should:  http://darkfader.net/gbc/files/Vectrony.zip

There's also a lot of good demo roms on that site.

Another idea would be to ask the question on the GBA forum here:
http://forum.gbadev.org/viewforum.php?f … p;start=50

Thanks, i looked inside vectrony. it looks like the graphics are .bin and they are converted to .o, I tried this, but no way.

This is my source, it tries to load a bkg image from the simpsons, and then a big donut made of sprites.. (it should load it..).
https://dl.dropbox.com/u/757056/GameBoy … 20TEST.zip

Last edited by Mills (2012-12-27 18:43:14)

Offline

 

#9 2012-12-27 21:32:58

paulc
Member
Registered: 2012-10-23
Posts: 27

Re: GBDK and assembly questios

Here's the solution, as far as I can gather from the "Raven" example approach:


In your "main.c" file, rather than including the code in that file, you reference it from the linked files like so:

        //=====================bank 2
     SWITCH_ROM_MBC1(2);
        maptiles();
       
        //=====================bank 3
     SWITCH_ROM_MBC1(3);
        sprites();
       
       


In "Donut.c" you would have this for "bank 3":       
               
void sprites(void)
{
    int v = 0;   
    VBK_REG = 0;
        set_sprite_data(0, 36, TileLabel); //Sprites
        for (v = 0; v<37;v++)       
        set_sprite_tile(v, v); // link sprite v to tile v        
    VBK_REG = 1;
}



Here's the file I worked on:  http://www.filefactory.com/file/62gnl9094l4b/

Let me know if that dl works.

It compiled into a 64KB rom, but since I'm sure there's some graphical issues since I don't know what the original image was supposed to look like.
But the point here is that I think this approach should work, and doesn't require any ASM.

Last edited by paulc (2012-12-27 21:33:55)

Offline

 

#10 2012-12-28 06:28:09

Mills
Member
Registered: 2012-12-21
Posts: 132

Re: GBDK and assembly questios

paulc wrote:

Here's the solution, as far as I can gather from the "Raven" example approach:
In your "main.c" file, rather than including the code in that file, you reference it from the linked files... ;

Solved! i read again the other post http://gbdev.gg8.se/forums/viewtopic.php?id=91
You just have to do the following:

Using GameBoy map builder and GameBoy tile designer, export your maps and tiles as .z80.
The .z80 looks like this:

Code:

 
...
...
..
; This file was generated by GBTD v2.2

 SECTION "Tiles", HOME

; CGBpalette entries.
TileLabelCGB::
DB $00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00

; Start of tile array.
TileLabel::
DB $00,$00,$00,$00,$00,$00,$00,$00
DB ...
..
..
..

Using notepad++ or similar, replace the "$" by "0x" and "DB by ".db".
Erase all the commented lines, add the variables and rename the file to .s

The resulting file.s looks like this:

Code:

.globl _TileLabelCGB
.globl _TileLabel
.dw _TileLabelCGB
.dw _TileLabel

; CGBpalette entries.
_TileLabelCGB:
.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
.db 0x00,0x00,0x00,0x00

; Start of tile array.
_TileLabel:
.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00

Compile in GBDK

Code:

lcc -Wa-l -c -o file.o file.s

Add this to the main.c file:

Code:

extern unsigned char TileLabel[];
extern unsigned char TileLabelCGB[];

If the data doesn't fit inside a bank, just use banks and the overflow error won't show smile.

Thanks a lot.

Last edited by Mills (2013-01-01 11:43:03)

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson