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 2020-04-16 02:08:45

Zalo
Member
From: Spain
Registered: 2016-07-26
Posts: 103
Website

GBDK 3.0 - updated to latest SDCC and bank support

I think it's time we leave the old gbdk behind and update it to the latest version of everything

We already knew that it is posible to use the latest SDCC and the old linker but no one has updated the tools. I tried to do it the last weekend. You can find it here
Contrary to gbdk-n this keeps all the original functionallity and files and just updates the tools (including lcc)

It's been fully tested on Windows, macOS and Linux, and finally we have all the changes in all the platforms (2.96 has been never available in windows for some reason) There are still some issues with some of the examples but I have tested it with all the games I made on ZGB and everything is working

Feel free to report bugs and fixes (and please test them before making any pr)

Last edited by Zalo (2020-04-16 04:22:35)

Offline

 

#2 2020-04-16 04:45:26

toxa
Member
Registered: 2020-02-13
Posts: 309

Re: GBDK 3.0 - updated to latest SDCC and bank support

I think it is a proper moment to apply some patches to the library too. Well-known issues, such as: https://gbdev.gg8.se/forums/viewtopic.php?id=214 for example.

Offline

 

#3 2020-04-16 05:07:07

toxa
Member
Registered: 2020-02-13
Posts: 309

Re: GBDK 3.0 - updated to latest SDCC and bank support

i also noticed, that there are two libraries in the release:
from sdcc: bin\SDCC\lib\gbz80\
from gbdk: lib\small\asxxxx\
it's a bit confusing. why not to unite them (or simply throw away one)?

Offline

 

#4 2020-04-16 07:40:56

Zalo
Member
From: Spain
Registered: 2016-07-26
Posts: 103
Website

Re: GBDK 3.0 - updated to latest SDCC and bank support

Yes, the library that comes with SDCC will be removed in the next release (actually in the Linux version it's been removed already)

About making patches, I agree. I was just asking you all to do it via pull requests and ensuring they have been properly tested. I can't just accept any changes in the library that breaks some other stuff. I hope you guys understand it

Offline

 

#5 2020-04-16 20:02:26

bbbbbr
Member
Registered: 2019-03-04
Posts: 127

Re: GBDK 3.0 - updated to latest SDCC and bank support

Nice work, thanks for putting this together!

It will hopefully save people some trouble and effort.

Offline

 

#6 2020-04-17 11:52:57

toxa
Member
Registered: 2020-02-13
Posts: 309

Re: GBDK 3.0 - updated to latest SDCC and bank support

one more improvement:
in order make headers compile with -DUSE_SFR_FOR_REG compiler option with sdcc4, modification of gb/hardware.h is needed:
#define __REG    extern volatile __sfr /* was: sfr UINT8 */
smaller and faster code is generated. i tested it, it's ok.

Offline

 

#7 2020-04-17 18:13:25

Zalo
Member
From: Spain
Registered: 2016-07-26
Posts: 103
Website

Re: GBDK 3.0 - updated to latest SDCC and bank support

pr please

Offline

 

#8 2020-04-20 09:45:48

Zalo
Member
From: Spain
Registered: 2016-07-26
Posts: 103
Website

Re: GBDK 3.0 - updated to latest SDCC and bank support

Hi Toxa... in the docs it says that SFR is experimental https://github.com/Zal0/gbdk-2020/blob/ … /ChangeLog
and then in 2.96a a pragma directive in hardware is added "#error SFR is unteseted and disabled in 2.96"

I can't find where __sfr is defined in order to understand how this works

Offline

 

#9 2020-04-20 10:09:36

toxa
Member
Registered: 2020-02-13
Posts: 309

Re: GBDK 3.0 - updated to latest SDCC and bank support

__sfr is defined by a compiler. please look the documentation:  http://sdcc.sourceforge.net/doc/sdccman.pdf chapter "3.5.1.7 __sfr / __sfr16 / __sfr32 / __sbit". i don't know why it is "experimental", maybe it was, when gbdk 2.96 was developed, but to me this sounds strange, because in microcontroller world Special Function Registers (SFR) are quite common. it is not something special for gbz80. i tested it, sdcc4 seems to produce the correct code. i made a test and my game also runs fine.
ps: the goal is to generate:

ldh (n8), A

instead of:

ld (r16), A

that is how it looks in generated code with __sfr:

;src\mushroompie.c:471: NR52_REG = 0x80; // Enables sound, always set this first
    ld    a, #0x80
    ldh    (_NR52_REG+0),a

without:

;src\mushroompie.c:471: NR52_REG = 0x80; // Enables sound, always set this first
    ld    hl, #0xff26
    ld    (hl), #0x80

Last edited by toxa (2020-04-20 15:00:37)

Offline

 

#10 2020-05-16 06:59:31

Zalo
Member
From: Spain
Registered: 2016-07-26
Posts: 103
Website

Re: GBDK 3.0 - updated to latest SDCC and bank support

Offline

 

#11 2020-05-30 16:32:21

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

Re: GBDK 3.0 - updated to latest SDCC and bank support

Thanks for the update!

I still have games programmed with the older version of ZGB, they compiled ok with gbdk 3.1. But the sprites have some issues, they behave as if they are skipping 1 frame when being moved.

I tried to compile the zgb sample using the new ZGB, but I had no luck.
The issue might be caused by the old ZGB, but I didn't find any difference in the sprite translate function, so I don't really know.

EDIT: yeah the issue is related to the old ZGB, I could compile the sample with the new ZGB and everything OK smile.

Last edited by Mills (2020-05-30 16:53:47)

Offline

 

#12 2020-05-31 03:39:22

Zalo
Member
From: Spain
Registered: 2016-07-26
Posts: 103
Website

Re: GBDK 3.0 - updated to latest SDCC and bank support

I've got all the games I made with ZGB compiled with the latest GBDK smile
Also in the latest releases I already included gbdk 2020 in the env package

Offline

 

#13 2020-07-10 07:53:45

0x7f
Member
Registered: 2019-11-24
Posts: 65

Re: GBDK 3.0 - updated to latest SDCC and bank support

Hi, I am using gbdk 2020 but I failed when writing to the wave pattern register for sound channel 3. Can someboy help and give an example? Thanks!

Offline

 

#14 2020-07-10 14:01:43

toxa
Member
Registered: 2020-02-13
Posts: 309

Re: GBDK 3.0 - updated to latest SDCC and bank support

hm... there is a samptest.c example which is functional.
what is the exact problem? if you want to define those registers, you may declare something like this:

Code:

volatile unsigned char __at (0xFF30) wave[16];

Last edited by toxa (2020-07-10 14:07:50)

Offline

 

#15 2020-07-11 03:39:38

0x7f
Member
Registered: 2019-11-24
Posts: 65

Re: GBDK 3.0 - updated to latest SDCC and bank support

Hi toxa, thanks that fixed it!

Offline

 

#16 2020-07-17 20:10:55

foxyblue
New member
Registered: 2020-07-17
Posts: 1

Re: GBDK 3.0 - updated to latest SDCC and bank support

Hi Zalo,

I am using this library for the first time, what's the best way to install it and compile?

I think I am being thrown off by the broken links in the original doc: http://gbdk.sourceforge.net/doc/html/c01.html#I(USING-GBDK)C(1,SECT1)

Offline

 

#17 2020-07-19 19:16:33

bbbbbr
Member
Registered: 2019-03-04
Posts: 127

Re: GBDK 3.0 - updated to latest SDCC and bank support

foxyblue- Which OS are you using, Windows or Linux?

Offline

 

#18 2020-10-01 08:59:46

toxa
Member
Registered: 2020-02-13
Posts: 309

Re: GBDK 3.0 - updated to latest SDCC and bank support

GBDK-2020 v4.0 is released: https://github.com/Zal0/gbdk-2020/releases

- GBDK now requires SDCC 4.0.3 or higher, that has fully working toolchain. Old link-gbz80 linker is not used anymore, sdldgb and makebin are used to link objects and produce binary roms; maccer tool is no longer needed either
  - SDCC 4.0.3 has much better code generator which produces smaller and faster code. Code is twice faster
  - SOURCE LEVEL DEBUGGING is possible now! Native toolchain produces *.CDB files that contain detailed debug info. Look for EMULICIOUS extension for vs.code. It supports breakpoints, watches, inspection of local variables, and more!
  - SDCC 4.0.4 has fixed RGBDS support; library is not updated to support that in full yet, but it is possible to assemble and link code emitted by SDCC with RGBDS
  - New banked trampolines are used, they are faster and smaller
  - New (old) initialization for non-constant arrays do NOT require 5 times larger rom space than initialized array itself, SDCC even tries to compress the data
- Library was improved
  - itoa/ltoa functions were rewritten, div/mod is not required now which is about 10 times faster
  - sprite functions are inline now, which is faster up to 12 times and produces the same or smaller code; .OAM symbol is renamed into _shadow_OAM that allows accessing shadow OAM directly from C code
  - interrupt handling was revised, it is now possible to make dedicated ISR's, that is important for time-sensitive handlers such as HBlank.
  - printf/sprintf were rewritten and splitted, print functions are twice faster now and also requre less rom space if you use sprintf() only, say, in bgb_emu.h
  - crash_handler.h - crash handler that allows to detect problems with ROMs after they are being released (adapted handler, originally written by ISSOtm)
  - improved and fixed string.h
  - many other improvements and fixes - thanks to all contributors!
- Revised examples
- Improved linux support
- Lcc has been updated
  - it works with the latest version of sdcc
  - quoted paths with spaces are working now

Last edited by toxa (2020-10-01 09:02:15)

Offline

 

#19 2020-10-01 09:20:15

Zalo
Member
From: Spain
Registered: 2016-07-26
Posts: 103
Website

Re: GBDK 3.0 - updated to latest SDCC and bank support

smile
You were faster than me

Offline

 

#20 2020-10-03 20:53:16

bbbbbr
Member
Registered: 2019-03-04
Posts: 127

Re: GBDK 3.0 - updated to latest SDCC and bank support

These look like great updates.

There seems to be a problem with calling initarand() and arand(). I opened an issue on github.

Offline

 

#21 2020-11-14 15:33:32

toxa
Member
Registered: 2020-02-13
Posts: 309

Re: GBDK 3.0 - updated to latest SDCC and bank support

GBDK-2020 v4.0.1 is released: https://github.com/Zal0/gbdk-2020/releases

    - Updated documentation, now online: https://zal0.github.io/gbdk-2020/api/
    - IHX is checked for correctness before the makebin stage. That allows to warn about overwriting the same ROM addresses (SDCC toolchain does not check this anymore).
    - Library was improved
        - set_*_tiles() now wrap maps around horizontal and vertical boundaries correctly
        - new fill_*_rect() functions to clear rectangle areas
        - runtime initialization code now does not initialize whole WRAM with zeros anymore, that allows BGB to raise exceptions when code tries to read WRAM that was not written before.
        - enhanced SGB support
            - joypad_init()/joypad_ex() support for multiple joypads
            - SGB border example
        - _current_bank variable is updated when use bank switching macros
    - Reorganized examples: each example is in separate folder now, that simplifies understanding.
    - Lcc improvements

Last edited by toxa (2020-11-14 16:35:37)

Offline

 

#22 2021-01-21 01:43:28

bbbbbr
Member
Registered: 2019-03-04
Posts: 127

Re: GBDK 3.0 - updated to latest SDCC and bank support

GBDK-2020 4.0.2 has been released::
https://github.com/Zal0/gbdk-2020/releases/tag/4.0.2

- Updated documentation
- Library was improved
  - Linking with stdio.h does not require that much rom now
  - Default font is changed to the smaller one (102 characters), that leaves space for user tiles
  - Fixed broken support for multiplying longs
  - Multiple minor improvements
- New bankpack feature, allows automatic bank allocation for data and code, see banks_autobank example, feature is in beta state, use with care
- Lcc improvements
  - Including fixed overriding of default shadow_oam, stack, etc. locations
- Added BGB debug example project

There is now also a GBDK and ZGB specific Discord server.
Link is on the GBDK-2020 github front page: https://github.com/Zal0/gbdk-2020/

Last edited by bbbbbr (2021-01-21 01:44:19)

Offline

 

#23 2021-01-21 03:07:22

toxa
Member
Registered: 2020-02-13
Posts: 309

Re: GBDK 3.0 - updated to latest SDCC and bank support

Oh, forgot about this topic, thank you, @bbbbbr!

Last edited by toxa (2021-01-21 03:08:01)

Offline

 

#24 2021-03-26 19:12:09

bbbbbr
Member
Registered: 2019-03-04
Posts: 127

Re: GBDK 3.0 - updated to latest SDCC and bank support

GBDK-2020 4.0.3 has been released::
https://github.com/gbdk-2020/gbdk-2020/ … /tag/4.0.3

- Updated documentation, including the PDF version:
  https://gbdk-2020.github.io/gbdk-2020/d … index.html
  https://gbdk-2020.github.io/gbdk-2020/d … manual.pdf
- Library was improved
    - Metasprites support (see example)
    - GBCompress decompressor included (see example)
    - Large map scrolling helper functions (see example)
    - Multiple minor improvements
- New tools
    - png2mtspr converts png images into metasprite structs
    - gbcompress compression utility, compatible with GBTD/GBMB


Detailed changelog:
https://gbdk-2020.github.io/gbdk-2020/d … otoc_md121

(edit, point links to changed repo location)

Last edited by bbbbbr (2021-04-04 02:04:44)

Offline

 

#25 2021-03-27 03:51:26

M2m
Member
Registered: 2021-02-18
Posts: 27

Re: GBDK 3.0 - updated to latest SDCC and bank support

@bbbbbr

Really appreciate everyone's effort put into GBDK-2020 !

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson