Git Product home page Git Product logo

zgb's Introduction

ZGB

ZGB is a Game Boy / Game Boy Color engine that lets you write your own games in C or asm.

It uses GBDK 2020 but expands it to give you some common functionallity for writing games such as: a main loop, sprites spawning, sprites life cycle, sprites animations, collison management, easily getting assets into the game, music, fx...

gif gif gif

Getting started

  • Installing ZGB
    • Download the latest release
    • Run install.bat (this will create a new environment var ZGB_PATH pointing to %ZGB%/common)

NOTE: ensure ZGB path doesn't contain any spaces (more info here)

Documentation

Check the wiki and this README

Support

Features

(Click on any feature to expand it)

Easy makefile support

In most cases you just need a small makefile like this

PROJECT_NAME = ZGB_TEMPLATE

all: build_gb

# Number of banks (must be a power of 2): A (Automatic), 2, 4, 8, 16, 32...
N_BANKS = A

# Music player: HUGETRACKER(default) or GBT_PLAYER
MUSIC_PLAYER = GBT_PLAYER

# Default hardware sprites size: SPRITES_8x16(default) or SPRITES_8x8
DEFAULT_SPRITES_SIZE = SPRITES_8x16

include $(ZGB_PATH)/src/MakefileCommon

When you make any changes to any of the source files of your project, or any of the assets, only that file will be recompiled. The internal Makefile that comes with ZGB creates a list of dependencies and only compiles what is needed saving you a lot of time. It will also help you a lot if you work with a version control system, like git


Transparent asset management

ZGB will automatically turn all your assets files into C data:

  • Graphics
    • .gbr from Game Boy Tile Designer
    • .gbm from Game Boy Map Builder
    • .png than can be used for backgrounds or sprites
  • Musics
    • .mod for gbt-player
    • .uge for hUGETracker

In order to use any of these data in your code you need to declare it first using

IMPORT_MAP(<map_filename_without_extension>)
IMPORT_TILES(<map_filename_without_extension>)
DECLARE_MUSIC(<map_filename_without_extension>)

Main Loop

gif


States

All ZGB games must contain at least one State. This state must be assigned on ZGBMain.c

UINT8 next_state = StateGame;

When ZGB starts it will call the START function of this State. Then on each frame it will call the UPDATE function until SetState is called to assign a new State

Creating a new State
  1. Create a new file < YourNewState >.c containing this:
#include "Banks/SetAutoBank.h"

void START() {
}

void UPDATE() {
}
  1. Register this new State in ZGBMain.h
#define STATES             \
...
_STATE(<YourNewState>)       \
STATE_DEF_END

Now, whenever you want to enter this new state you just need to call SetState(< YourNewState >)


Sprites

You can manually add Sprites calling SpriteMangerAdd(type, x, y). ZGB will call the START function of this Sprite first and then it will call UPDATE on each frame until the Sprite is removed. You can manually remove an Sprite with the function SpriteManagerRemove (faster) or SpriteManagerRemoveSprite and then the engine will call its DESTROY function.

Sprites will also be removed when getting off screen limits. You can configure how far you allow them to go before the engine disposes them with the fields lim_x and lim_y

Usually you will create an Sprite in the START function of your State and assing it to scroll_target, so that the camera follows it

void START() {
	scroll_target = SpriteManagerAdd(SpritePlayer, 50, 50);
	...
}

You can create your sprites with the Game Boy Tile Designer or you can use pngs. Create your sprites in the res/sprites folder so that the Makefile can identify them as sprites and pass the proper parameters to png2asset.

gbr sprites Use Game Boy Tile Designer included in /env/tools/gbtd22/GBTD.exe to create gbr sprites. Don't worry too much about the TileSize choosen, remember that empty tiles will be discarded

The first time you compile the gbr a .meta will be created with the default params passed to png2asset. You may want to take a look specially at the collision info to adjust the collider

-px 0 -py 0 -pw 32 -ph 32

Check the png2asset params here

png sprites

GBTD has a few limitations:

  • The maximum sprites size is 32x32
  • It only lets you choose a palette for the whole metasprite

Luckily you can overcome these limitations by using your preferred pixel art software and then export your data as a spritesheet

As with gbr sprites a .meta file can be created to pass arguments to png2asset. Contrary to gbr sprites this .meta file won't be created automatically so it is important that you create a it and at least indicate the sprite dimensions (or it will be exported as a single sprite)

-sw 32 -sh 16 

Check the png2asset params here

Creating a new Sprite

The template already comes with a placeholder Sprite but you surely will need to add more. Yo do this by following the next 3 steps:

  1. Create the sprite image data.
  2. Create a new file < YourNewSprite >.c containing this:
#include "Banks/SetAutoBank.h"

void START() {
}

void UPDATE() {
}

void DESTROY() {
}
  1. Register this new Sprite in ZGBMain.h
#define SPRITES \
...
_SPRITE_DMG(<YourNewSprite>, <image>)\
SPRITE_DEF_END

Big maps scroll support

ZGB support maps up to 16384 bytes with a maximum width or height of 255 tiles. The engine will take care of updating the native 32x32 background as the camera moves

gif

Here is how you create a new map and load it into your game:

  • Open Game Boy Tile Designer included in <ZGB_PATH>/env/tools/gbtd22 and create a new tile set
  • Open Game Boy Map Builder included in <ZGB_PATH>/env/tools/gbmb18 and create a new map that uses the previous tile set
  • In the START function of your state you should manually add the sprite that the camera will follow
  • Import your map and Call InitScroll
IMPORT_MAP(map); //This is the name of your map without the extension

void START() {
	scroll_target = SpriteManagerAdd(SpritePlayer, 50, 50);
	InitScroll(BANK(map), &map, 0, 0);
}

As the scroll updates new rows or columns it will call the function GetTileReplacement located in ZGBMain.c The default behaviour of this function is to spawn sprites using sprite_tye = 255 - tile_id, but you can customize it for your custom needs


Metasprites

Metasprites are sprites composed of 8x8 or 8x16 native sprites. The tool png2asset from GBDK is used to create the data that will end up in the final build:

  • duplicated tiles will be only added once
  • mirrored tiles will also count as duplicated
  • empty tiles will be ignored
  • palette info will be included

Sprites modes 8x8 and 8x16

The Game Boy has native support for sprite sizes 8x8 and 8x16. You can use any of them to compose the metasprites in your game.

Choosing 8x8 size will make it easier to duplicate parts of the metasprite and will require less memory to store it but will take longer to render the final metasprite

The default Sprite mode is selected in your makefile

# Default hardware sprites size: SPRITES_8x16(default) or SPRITES_8x8
DEFAULT_SPRITES_SIZE = SPRITES_8x16

Sprite animations

Animations in ZGB are defined by arrays of frames where the first element is the number of frames

const UINT8 anim_walk[] = {4, 0, 1, 2, 1, 0};

Setting the current animation is done with SetSpriteAnim(sprite, animation, speed)

Instead of setting an animation you can Set the current frame manually by calling SetFrame(Sprite, frame_idx)

The Sprite field anim_frame contains the animation index if there is an animation running, or the frame index otherwise


Collisions

All sprites have a rectangle collider that will be used to check collisions. By default it will be defined by the metasprites dimensions but you can adjust it on the sprite .meta file

-px 2 -py 0 -pw 12 -ph 19

gif gif

This rectangle will remain constant when the sprite is flipped

Sprite vs Background

First you need to declare an array (terminated in 0) indicating which tiles are considered collidables

UINT8 collision_tiles[] = {1, 2, 3, 4, 8, 10, 0}; //In this case tiles 1, 2, 3, 4, 8 an 10 will be considered collidables

Then you need to pass this array when you Init the scroll (you can have several arrays depending on the tileset you use)

InitScroll(BANK(map), &map, collision_tiles, 0);

And now, instead of directly modify the X and Y coordinates of your Sprite, you need to call TranslateSprite

TranslateSprite(THIS, -1, 0); //Move the current sprite 1 pixel to the left checking collisions with the background

If the Sprite collides then it won't advance and TranslateSprite will return the collision tile (so you can check if there are spikes or other stuff)

You can also declare an array of collision tiles that will be only checked when the Sprite is moving downwards. This is very useful for platform games where the character can jump into a platform from below

gif

Sprite vs Sprite

To check if two sprites are colliding call the function CheckCollision in "Sprite.h"

if(CheckCollision(THIS, other_sprite))
{
    //Sprites are colliding!
}

Auto Banking

ZGB uses bankpack so you don't need to worry about where to place your code or resources. Just make sure that:

  • #include "Banks/SetAutoBank.h" is added at the beggining of your States and Sprites
  • If you need to call an sprite function from another sprite, declare it BANKED
void HitMe();        //WRONG!!
void HitMe() BANKED; //RIGHT!
  • Check the png created in the Debug/Release folder of your build to get an overview of your banks usage. For a more detailed information you can use RomUsage

Fonts

Fonts in ZGB are gbr files of 45 tiles, with uppercase characters A-Z 0-9 !'()-.:? The ZGB-Template already comes with a default font that you can customize

In order to print some texts in your game

  1. Import the font using
#include "Print.h"
IMPORT_TILES(<font filename>);
  1. Init the font in the START function of your State by calling
INIT_FONT(font, PRINT_BKG); //PRINT_BKG to draw on the background or PRINT_WIN to draw on the Window
  1. Print some text using
PRINT(0, 0, "Hello World"); //print Hello World on 0, 0

You can also use Printf to draw some vars with %d %i &u and %s

You can change the target (background or window) with the var print_target


Music

You can select witch music drive to use gbt-player or hUGETracker in the Makefile

# Music player: HUGETRACKER(default) or GBT_PLAYER
MUSIC_PLAYER = GBT_PLAYER

To play some music in your game

  • Place the .mod or .uge files in the res/music folder
  • Import the music with
DECLARE_MUSIC(<music_filename>)
  • Play it with
PlayMusic(<music_filename>, LOOP)
  • And Stop it with
StopMusic;

Sound Effects

To play an FX Sound you just need to call

void PlayFx(SOUND_CHANNEL channel, UINT8 mute_frames, ...); // Add register data from GBSound

The channel will be occupied during mute_frames and the music player won't be able to use it


Game Boy Color

Because ZGB uses png2asset, palette data will be always included for each sprite allowing ZGB to load the palette automatically when the Sprite is loaded

Just make sure that:

  • The total Sprites loaded don't need more than 8 different palettes (if two sprites have the same palettes, they will share them)
  • The palette colors are ordered from lighter to darker so that the game will also look good on the original GB

Super Game Boy Borders

Follow the next steps to create Super Game Boy borders for your game

  • create the folder res/borders
  • Add a png with these limitations:
    • size must be 256x224
    • there must be a 160x144 transparent rectangle in the center of it
    • maximum number of different tiles is 256
    • each 8x8 tile has a limit of 16 colors
    • there can only be 4 different palettes of 16 colors
    • here is a template you can use
  • In your code (do this before loading any other bg map)
#include "SGB.h"

IMPORT_MAP(<border_filename>);

void START() {
  LOAD_SGB_BORDER(<border_filename>);
  ...
}

Savegame support

In order to have savegames in your game you must include a couple of files named savegame.h and savegame.c with the next content

//savegame.h
#ifndef SAVEGAME_H
#define SAVEGAME_H

#include <gb/gb.h>
#include "SRAM.h"

typedef struct {
	SAVEGAME_HEADER;

  //Whatever content you want to store in external ram

} Savegame;

extern Savegame savegame;

#endif
//savegame.c
#include "savegame.h"
Savegame savegame;

Having a file named savegame.c in your project will automatically compile it using MBC1+RAM+BATTERY (otherwise it will use MBC1)

Then before accesing any content you must enable/disable sram access

ENABLE_RAM;
  //Acess savegame content to read/write
DISABLE_RAM;

VS Code debugging using Emulicious

The ZGB-template is properly configured for C Debugging under Emulicious in Visual Studio Code. If you started your current project with an old version of the template you just need to copy the .vscode folder into the root of your project.

Now ensure that you have either Debug or DebugColor selected as your current configuration and press F5 to start debugging. Emulicious will be launched automatically and breakpoints will be hit. Enjoy!


License

Released under the MIT license

zgb's People

Contributors

aljenci avatar bbbbbr avatar calindro avatar jellelicht avatar josemwarrior avatar joyrider3774 avatar sergeeo avatar untoxa avatar zal0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zgb's Issues

Possible imporvement to FadeStepColor

I believe the FadeStepColor function could be improved by changing the calls to set_bkg_palette and set_sprite_palette to one call each outside the for loop:

https://github.com/Zal0/ZGB/blob/master/common/src/Fade_b.c#L61

void FadeStepColor(UINT8 i) {
	UINT8 pal, c;
	UWORD palette[4];
	UWORD palette_s[4];
	UWORD* col = ZGB_Fading_BPal;
	UWORD* col_s = ZGB_Fading_SPal;

	for(pal = 0; pal < 8; pal ++) {
		for(c = 0; c < 4; ++c, ++col, ++col_s) {
				palette[c] = UpdateColor(i, *col);
				palette_s[c] = UpdateColor(i, *col_s);
		};
	}
	set_bkg_palette(pal, 8, palette);
	set_sprite_palette(pal, 8, palette_s);
	delay(20);
}

This would reduce the number of function calls, and in cases where the for loop takes longer than a single frame would reduce the chances of the palette updates spanning frames (since they occur closer together), thus reducing out-of-sync palette updates.

Occasional Corrupt Map Tiles

I'm not programming using this engine myself, but there's a visual issue I've seen in Super Princess' 2092 Exodus and Luna, so I suspect it's a bug in the engine, and so I thought I would file a ticket.

Sometimes when scrolling the engine appears to incorrectly decode or assign a map tile, resulting in a corrupt appearance. The tile remains in its incorrect state as long as it remains on-screen. If I scroll the tile off-screen and then back on-screen the issue goes away. Unfortunately, I don't have a reliable way to force the issue to happen. It just happens somewhat rarely seemingly at random.

I have attached photos of the bug expressing twice in Luna. Look towards the top-left corner. Again, I saw the issue once or twice in Super Princess' 2092 Exodus, but I lack any screenshots of the issue there.

zgb_1
zgb_2

SGB Borders don't load on PAL Snes / Super GameBoy

Hey,

I have a PAL Snes as well as PAL Super Gameboy and SGB Borders don't load with ZGB on it. I had initially noticed it in my GBDK-2020 game and toxa mentioned there is a timing issue on PAL Systems, added a delay of 4 frames fixed it on my GBDK-2020 game. He also suggested to test ZGB, so i took the latest version (by first grabbing the release and then overwriting with latest github version sources so i also had the environment) and i took the ZGB Template and added a border as per the documentation, but on my PAL SNES / SGB the border did not load. It did work in BGB and it also worked when using the the easy flash junior, but it did not work if i used GBX-RW to flash an empty cartridge. I'm guessing easy flash junior and perhaps everdrive do some other things that don't require the delay or so.

GB Studio used a similar delay https://github.com/chrismaltby/gbvm/blob/master/src/core/core.c#L192-L196 (its what toxa was refering to as well) and we've seen other games incorporating such delays ... (https://sourcegraph.com/github.com/SimonLarsen/tobutobugirl-dx/-/blob/init.c?L125 and https://sourcegraph.com/github.com/SimonLarsen/tobutobugirl-dx/-/blob/main.c?L34:3)

Initially i had put the same delay in the LOAD_SGB_BORDER Function but this still did not work, if i moved that delay to right at the beginning of main it started working also on my PAL SNES / SGB.

So basically (if wait_vbl_done) does not interfere we can either delay 4 frames or at a fixed delay as other examples did. we are guessing interrupts could interfere and the delay has to be set before them or the SGB Border does not load but it's only guessing as i did not really verify this.

I'll create a pull request to add the delay

Add LCD_isr(); function declaration to main header

Just a stupid suggestion, could you add void LCD_isr(); declaration to main.h? in case you want to remove this interruption to have the sprites over the window. It's an easy tweak, but if it's already included in ZGB it's always better.
Thanks in advance!

Compiling issue (__sdcc_call_hl.s)

I'm having an issue compiling any games with this tool, it works fine on my laptop but on my desktop I get an error when it starts on __sdcc_call_hl.s. The error that pops up calls out sdasgb.exe

The text from cmd reads

make: Entering directory c:/ZGB/common/src'
compiling __sdcc_call_hl.s
make: *** [../Release/__sdcc_call_hl.o] Error -1073741502
make: Leaving directory `c:/ZGB/common/src'

C:\Users\digis\Downloads\ZGB-template-master\ZGB-template-master>cd src

C:\Users\digis\Downloads\ZGB-template-master\ZGB-template-master\src>C:\gbdk\bin\make-3.81-bin\bin\make run
compiling resource: ../res/src/font.b3.c
0 [main] sh 16880 sync_with_child: child 13780(0x208) died before initialization with status code 0xC0000142
105 [main] sh 16880 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
make: *** [../Release/res/font.b3.o] Error 128

C:\Users\digis\Downloads\ZGB-template-master\ZGB-template-master\src>cd ..

C:\Users\digis\Downloads\ZGB-template-master\ZGB-template-master>pause
Press any key to continue . . .`

If this isn't where this should be posted, let me know where I should move it.

Thanks

Errors with ZGB-template

I downloaded the latest ZGB-template-master and opened the solution in Visual Studio 2022 Community Edition. Immediately, I am seeing errors in the Error List such as:

E0070 incomplete type is not allowed

image

E0260 explicit type is missing ('int' assumed)

image

E0065 expected a ';'

image

I did install the latest release of ZGB and ran install.bat.

macOS build

Where can I get a macOS build? I don't own a windows maschine.

Missing information in Music section of tutorial

In the music section of the tutorial (https://github.com/Zal0/ZGB/wiki/Music) the part about declaring the music is slightly confusing.

First, the template using HUDTRACKER by default, not GBT_PLAYER. The tutorial doesn't seem to work with HUGETRACKER (linker errors), so it requires that the user editor the Makefile here:

# Music player: HUGETRACKER(default) or GBT_PLAYER MUSIC_PLAYER = GBT_PLAYER

Modify it and save it with a different name. Don't forget to include in what bank the music should be (level1.mod for example).

This talks about setting the bank that the music should live in, but I'm pretty sure that isn't required anymore, as the project using automatic banking.

Additionally, there is a missing step to "include music.h".

Incorrect initialization of hUGEDriver

This line is incorrect; hUGE_init is for initializing to a song descriptor, but 0 isn't one. Up until now, I believe this went unnoticed since hUGE_init doesn't do any unbounded looping, but when I added song decompression to a fork of hUGEDriver, this broke.

Here's a patch which fixes things up :)

diff --git a/common/include/Music.h b/common/include/Music.h
index 8ed475d..e36ae0c 100644
--- a/common/include/Music.h
+++ b/common/include/Music.h
@@ -13,7 +13,7 @@ void MusicCallback() __nonbanked;
 	extern BYTE hUGE_paused;
 	void hUGE_mute(UBYTE mute);
 
-	#define INIT_MUSIC hUGE_init(0)
+	#define INIT_MUSIC
 	#define DECLARE_MUSIC(SONG) extern const void __bank_ ## SONG ## _uge; extern const hUGESong_t SONG ## _uge
 	#define PlayMusic(SONG, LOOP) __PlayMusic(&SONG ## _uge, (uint8_t)&__bank_ ## SONG ## _uge, 0)
 	#define StopMusic hUGE_paused = 1; hUGE_mute(HT_CH_MUTE); last_music = 0

[Request] [Docs] Debian/Ubuntu instructions for compiling in wiki

Description of Changes

I recently have started using this library and first, thank you for all your hard work you put into it. Its very impressive and heavily enriches the community of game boy developers.

I use Ubuntu on desktop and I would like to help refine some instructions for the wiki to help other developers using this repo on linux. I was wondering if we could have a "installation / building" page separate from the Creating a New Project Wiki Page. Ideally this page can lead with the expected installation with windows, but could have a header for linux building instructions with some more specific commands. I read your post in #10 (comment) and believe that the instructions you gave are spot on, and with a little refinement would be a very good start for the wiki page.

Thank you again for your time, and I would love to help with this if I can.

FadeOut() is broken on DMG

The fade functions found in "Fade.h" appear to be broken when running the non-color version of a game. FadeIn() works (fading the screen to pure white, but FadeOut() appears to have no effect. If called after calling FadeIn() the screen stays pure white. If called without first calling FadeOut(), the color does not change.

I wrote a simple example game with this Update:

void UPDATE() {
	if(KEY_TICKED(J_START))
	{
		FadeIn();
	}
	
	if (KEY_TICKED(J_SELECT))
	{
		FadeOut();
	}

These 2 gifs are the same game compiled as Color and Non-Color. In both cases I press START and shortly after I press SELECT. Note that while both versions fade up to white, the DMG version does not fade back down.

gb1_dmg_broken_fade

gb1_color_working_fade

Errors in Enemy Sprite section of tutorial

Save the file into the res/ folder as enemy.gbr (the b3 before the gbr extension indicates that we want to save this sprite on bank 3, notice how all the resources in the template are also stored in bank3 by default)
https://github.com/Zal0/ZGB/wiki/Enemies

This section has 2 errors:

  1. The parts about banks (b3) are no longer relevant.
  2. The file must be saved into res/Sprites/ (not just res). Otherwise, the game will crash.

MoveScroll( ... ) does not support jumping long distances

If you use MoveScroll to jump more than 1 tile at a time, it will not load in tiles for the rows you skip over.

For example, this is the result of scrolling by 16 pixels at a time:

image

The functionality is required for maps the don't start in the top left hand corner of the map.

Check specific tile at specific location ?

Hi !

I was wondering about something. I'm trying to make a game where you get to stick to walls and ceilings and stuff, but I can't figure out how to check the collision tiles at a certain point. I'm mainly wondering what the .... command ? is that the word ?
I'm wondering what the command is for that. I thought "GetScrollTile" might do the trick, but.... Yeah, that's not working.

image

If it doesn't exist already, I was wondering if you could add it ? I've been looking through the include files for anything that could help, but... I couldn't find anything. Maybe I'm blinding on it...

Cannot build on 2021.0

I was on 2020.2 and rom compilation was working fine, but today I installed 2021.0 and compilation doesn't work.

C:\Users\censored\Downloads\ZGB-template-master\ZGB-template-master>cd src

C:\Users\censored\Downloads\ZGB-template-master\ZGB-template-master\src>C:\Users\censored\Downloads\ZGB->2021.0\ZGB\common..\env\make-3.81-bin\bin\make run BUILD_TYPE=ReleaseColor
Linking
Multiple definition of _empty
Multiple definition of _empty
Multiple definition of _empty
Multiple definition of _empty
Multiple definition of _empty
Multiple definition of _empty
Multiple definition of _empty
?ASlink-Warning-Cannot open library module ../ReleaseColor/zgb/.rel
Multiple definition of _empty
make: *** [../bin/ZgbTest.gbc] Erreur 2

C:\Users\censored\Downloads\ZGB-template-master\ZGB-template-master\src>cd ..

C:\Users\censored\Downloads\ZGB-template-master\ZGB-template-master>pause
Appuyez sur une touche pour continuer...

Changing back to 2020.2 wasn't helpful since now it makes a new error when compilling:

C:\Users\censored\Downloads\ZGB-template-master\ZGB-template-master>cd src

C:\Users\censored\Downloads\ZGB-template-master\ZGB-template-master\src>C:\Users\censored\Downloads\ZGB-2020.2\ZGB->2020.2\common..\env\make-3.81-bin\bin\make run BUILD_TYPE=ReleaseColor
Linking
C:/Users/censored/Downloads/ZGB-2020.2/ZGB-2020.2/common/../env/gbdk/bin/lcc -Wl-m -Wl-j -Wl-yt1 -Wl-yo128 -Wl->yp0x143=0xC0 -Wl-g.STACK=0xDEFF -k../ReleaseColor/zgb -lzgb.lib -o ../ReleaseColor/ZgbTest.gbc >../ReleaseColor/res/map.b3.gbm.o ../ReleaseColor/res/enemy.b3.gbr.o ../ReleaseColor/res/font.b3.gbr.o >../ReleaseColor/res/player.b3.gbr.o ../ReleaseColor/res/tiles.b3.gbr.o ../ReleaseColor/SpriteEnemy.o >../ReleaseColor/SpritePlayer.o ../ReleaseColor/StateGame.o ../ReleaseColor/ZGBMain.o
Error: Format(XL3) Only XL2 format is supported
Error: Format(XL3) Only XL2 format is supported
Error: Format(XL3) Only XL2 format is supported
Error: Format(XL3) Only XL2 format is supported
Error: Format(XL3) Only XL2 format is supported
Error: Format(XL3) Only XL2 format is supported
Error: Format(XL3) Only XL2 format is supported
Error: Format(XL3) Only XL2 format is supported
Error: Format(XL3) Only XL2 format is supported
Error: Format(XL3) Only XL2 format is supported
Error: Format(XL3) Only XL2 format is supported
Error: Format(XL3) Only XL2 format is supported
Error: Format(XL3) Only XL2 format is supported
Error: Format(XL3) Only XL2 format is supported
Error: Format(XL3) Only XL2 format is supported
Error: Format(XL3) Only XL2 format is supported
Error: Format(XL3) Only XL2 format is supported
Error: Format(XL3) Only XL2 format is supported

?ASlink-Warning-Undefined Global ___sdcc_bcall_ehl referenced by module Frame
ERROR: address overflow (addr c0a1 >= 8000)
c:\Users\censored\Downloads\ZGB-2020.2\ZGB-2020.2\env\gbdk\bin\lcc.exe: c:\Users\censored\Downloads\ZGB-2020.2\ZGB->2020.2\env\gbdk\bin/link-gbz80: No such file or directory
make: *** [../bin/ZgbTest.gbc] Erreur 1

C:\Users\censored\Downloads\ZGB-template-master\ZGB-template-master\src>cd ..

C:\Users\censored\Downloads\ZGB-template-master\ZGB-template-master>pause
Appuyez sur une touche pour continuer...

Edit: I deleted the Release/Debug/ReleaseColor/DebugColor folder(s) and compilation with 2020.2 worked again, however 2021.0 still doesn't work

Problems with 32x32 Sprites

I'm having problems with 32x32 sprites.
This is how it should appear (in the previous versions of ZGB it was working ok):
image ok
And this is how appears now:
image wrong

As I see, the problem is with the automatically exported file. Here I left an attached a file with the file exported from GBTD (enemy3 (ok).b3.c) and the automatically generated file (enemy3 (wrong).b3.gbr.c). As you can see, the sprite array is not the same.

Thanks in advance!

enemy3.zip

Latest GBDK compatibility

dear @Zal0 , please make ZGB compatible with the latest GBDK-2020 from your repo, i have a conflict with _current_bank definition, thank you

Request to change sprite collisions

Before as the collisions of the sprites were defined, you could change the collisions at any time you wanted, now as it is done through the meta is something that I do not know how it could be done.

SpriteManagerLoad() issue loading multiple color palettes from disparate sprites

I'm observing an issue where the last sprite loaded has its color palette overwrite previous sprites palettes.

Screen Shot 2021-11-22 at 8 08 56 PM

  • a grey box that is supposed to be green. generated from a gbr.
  • a person that appears correct on the right and wrong on the left. generated from a png.
  • a blue hint window that is correct generated from a png.

Screen Shot 2021-11-22 at 8 41 59 PM

I think the strncmp is trying to allow multiple sprites that are sharing colors to share a hardware palette? I don't think it's functioning correctly. Perhaps after filing this issue I'll try to find a more proper fix.

Error when compiling template

When I try compiling I get the following error from the compiler :
ZGB/common/src/main.c:127: warning 112: function 'add_low_priority_TIM' implicit declaration
ZGB/common/src/main.c:127: error 101: too many parameters make: *** [../ReleaseColor/zgb/main.o] Error 1

Add license

Without a license, it isn't legal (at least where I live) for anyone to use this library in their game, because you haven't given them permission (even though the code is right here). I would recommend adding either the MIT license or the zlib license.

  • The MIT license requires that you give the library credit.
  • The zlib license requires that you give credit in your source code, but binaries do not have to.

To add one of these licenses, you can put one of the following texts in a file called LICENSE.txt (or LICENSE.md).

zlib:

zlib License

(C) 2017 Zalo

This software is provided 'as-is', without any express or implied
warranty.  In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
   claim that you wrote the original software. If you use this software
   in a product, an acknowledgment in the product documentation would be
   appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
   misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.

MIT:

MIT License

Copyright (c) 2017 Zalo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Feature Request: Save functions

I'm loving working with ZGB so far, builds fast, reasonably documented, good start up tutorials, etc.

My current project doesn't need saves but it would be great to be able to add them :)

Default SaveGame Values

Often a save file should not be completely zero'd out by default.

It would be nice if the SRAM API allowed for either passing in a "default" savegame struct to copy in the case of CheckSRAMIntegrity needing to clear out the save. Alternatively, some sort of callback that the game could implement would work too.

Failure to use music

I declare the music and use it as indicated in the documentation but I get this error when I save a song .uge in the res/music folder

sus

Problem with Enemies section.

I followed the tutorial for creating enemies. when I define the enemy sprite I get this error.

?ASlink-Warning-Undefined Global '_Start_SpriteEnemy' referenced by module 'ZGBMain_Init'

?ASlink-Warning-Undefined Global '___bank_SpriteEnemy' referenced by module 'ZGBMain_Init'

?ASlink-Warning-Undefined Global '_Update_SpriteEnemy' referenced by module 'ZGBMain_Init'

make: *** [../bin/ZGB_TEMPLATE.gb] Error 2

Issue linking gbt_player when running makefile on macOS

I've been successfully building/running on macOS for a while now using changes very similar to this pull request: https://github.com/Zal0/ZGB/pull/32/files

However I've recently added music to my game, and I'm noticing this issue:

creating zgb.lib
Linking
?ASlink-Warning-Cannot open library module ../DebugColor/zgb/-e gbt_player.o

?ASlink-Warning-Undefined Global '_gbt_stop' referenced by module 'main'

?ASlink-Warning-Undefined Global '_gbt_enable_channels' referenced by module 'main'

?ASlink-Warning-Undefined Global '_gbt_play' referenced by module 'Music'

?ASlink-Warning-Undefined Global '_gbt_loop' referenced by module 'Music'

?ASlink-Warning-Undefined Global '_gbt_update' referenced by module 'Music'

The culprit seems to be some bad string concatenation with macOS make, where -e is in the wrong place: /zgb/-e gbt_player.o

I was able to work around this by removing the link to $(ZGB_PATH_UNIX)/lib/hUGEDriver.obj.o, and adding an explicitly linking $(OBJDIR_ZGB)/gbt_player.o instead. I can keep my copy of ZGB patched and rebase as new changes come out, since I already do this for gbm2c, gbr2c, and gbr2png binaries... But it would be nice if a fix were incorporated upstream since the makefile seems like fertile ground for merge conflicts.

Screen Shot 2021-12-01 at 4 08 56 PM

Screen Shot or a link to one

This isn't a big issue, but could you include a screen shot in your readme.md, i think it could help people want to download it, at least, screenshots influence my decisions on downloading things.

Support for hUGETracker's hUGEDriver

One thing that would make this library perfect would be native support for hUGETracker's hUGEDriver. It's specifically designed to be used with Gameboy development, meaning it is way better than OpenMPT and all the clunkiness with that system.

.gbr needs to be in the same directory as .gbm

Heya, I love this project, it's making GB dev so accessible and the tutorial is great!

I found a small issue when going through the HUD section of the tutorial: I had hud_tiles.gbr in res/sprites (i duplicated the player.gbr sprite so I didn't have to redefine the colour palette) and hud.gbm in res. This resulted in it rendering glitchy tiles:

image

After a while I figured it out, I don't know if this is a bug or just something to be documented.

Cheers!

Glitched animation

I'm not sure if this's a bug but... I'm trying to add a sprite with a simple 4 frames 32x32 animation.

I added this to ZGBMain.h:

_SPRITE_DMG(SPRITE_ENEMY, enemy, 3, FRAME_32x32, 4)\

I have an exported enemy.b3.c file under res/src.

The enemy code is:

#pragma bank 2
#include "main.h"
UINT8 bank_SPRITE_ENEMY = 2;

#include "SpriteManager.h"

const UINT8 anim_enemy_idle[] = {0, 1, 2, 3};

void Start_SPRITE_ENEMY() {
	SetSpriteAnim(THIS, anim_enemy_idle, 15);
}

void Update_SPRITE_ENEMY() {

}

void Destroy_SPRITE_ENEMY() {
}

The result is:
https://www.youtube.com/watch?v=NDc7awTalys

I would appreciate any advice!

Error with ZGB-Template with the latest version

Hello! First of all, thanks for this wonderfull engine.

I've got a problem with the latest version, I've updated engine and game code to work with it, but I cannot compile any of the test i was making before all the changes in the engine were made. I try to redownload all and configure again and with the new template, but the results are the same. If I restore the previous game code and ZGB enviroment, everything is Ok.

There goes an attachement with the result:

imagen

Thanks in advance!

`C:\ZGB\proyectos\ZGB-template-master>cd src

C:\ZGB\proyectos\ZGB-template-master\src>c:/ZGB/common..\env\make-3.81-bin\bin\make run
El sistema no puede encontrar la ruta especificada.
El sistema no puede encontrar la ruta especificada.
El sistema no puede encontrar la ruta especificada.
El sistema no puede encontrar la ruta especificada.
El sistema no puede encontrar la ruta especificada.
El sistema no puede encontrar la ruta especificada.
El sistema no puede encontrar la ruta especificada.
El sistema no puede encontrar la ruta especificada.
El sistema no puede encontrar la ruta especificada.
El sistema no puede encontrar la ruta especificada.
El sistema no puede encontrar la ruta especificada.
El sistema no puede encontrar la ruta especificada.
El sistema no puede encontrar la ruta especificada.
El sistema no puede encontrar la ruta especificada.
El sistema no puede encontrar la ruta especificada.
El sistema no puede encontrar la ruta especificada.
El sistema no puede encontrar la ruta especificada.
El sistema no puede encontrar la ruta especificada.
Creating folder ../res/src
La sintaxis del comando no es correcta.
Error writing fileCreating folder ../Release/zgb
La sintaxis del comando no es correcta.
common..\env\make-3.81-bin\bin\make: *** [../Release/zgb] Error 1

C:\ZGB\proyectos\ZGB-template-master\src>cd ..

C:\ZGB\proyectos\ZGB-template-master>pause
Presione una tecla para continuar . . .`

ZGB path can't have spaces

It is not really and issue of ZGB is an issue of make.
ZGB can't be inside any folder that have spaces. Is the path of the installation of ZGB have spaces then the build don't work.
It seems to be a bug of make http://savannah.gnu.org/bugs/?712

For ZGB I think the better is to point that in the readme and in the wiki tutorial.

Error in Maps section of Tutorial

Open the tiles.bgr with the Game Boy Tile Designer and go to View->Tile Count and set that to 255. Now edit the tile 254 that corresponds to the sprite of type 1 (SPRITE_ENEMY) and create a thumbnail of the enemy

https://github.com/Zal0/ZGB/wiki/Maps

This part of the tutorial assumes that tiles.gbr is setup for 256 tiles, but it only has 128.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.