andreasjhkarlsson / gbdk-n Goto Github PK
View Code? Open in Web Editor NEWgbdk libraries updated for newer versions of sdcc
gbdk libraries updated for newer versions of sdcc
There exists an alternative linker for sdcc that could maybe be used to overcome banked code problems.
http://www.tensi.eu/thomas/programming/asxxx-linker/asxxxlinker.html
It seems like gotoxy()
isn't working.
I compile this:
#include <stdio.h>
#include <gb/gb.h>
#include <gb/console.h>
// clear the screen
void cls (void) NONBANKED;
void main () {
DISPLAY_ON;
cls();
gotoxy(11, 8);
printf("O HAI!");
}
with this:
BIN=/opt/gbdk/bin
OBJ=./obj
build:
mkdir -p $(OBJ)
$(BIN)/gbdk-n-compile.sh demo.c -o $(OBJ)/demo.rel
$(BIN)/gbdk-n-link.sh $(OBJ)/demo.rel -o $(OBJ)/demo.ihx
$(BIN)/gbdk-n-make-rom.sh $(OBJ)/demo.ihx demo.gb
clean:
rm -rf $(OBJ)
rm -f demo.gb
and I get this:
Am I doing it wrong?
Info:
I'm running in this docker environment.
Debian GNU/Linux 10 (buster)
SDCC : 3.8.0 #10562 (Linux)
I've packaged gbdk-n for nix ( see NixOS/nixpkgs#61709 ) , but i'd like few minors improvements : add a license file at project root, and please make a release, that would be easier to distribute.
2$:
LD (HL-),A
DEC B
JR NZ,2$
;; Clear from 0xFF80 to 0xFFFF
LD HL,#0xFFFF
LD B,#0x80
in libc/crt0.s
In ROMs this is placed at 0x0169
When I try to handle interrupts using the add_JOY
, add_VBL
etc. functions, the emulator (BGB) hangs after the handler is called for the first time. The code I used for test:
#include <gb/gb.h>
#include <gb/rand.h>
UINT8 tiles[64], i, jp;
void joypad_irq() {
jp = joypad();
set_bkg_tiles(0, 0, 1, 1, &jp);
}
void main() {
disable_interrupts();
DISPLAY_OFF;
for(i=0; i<64; i++)
tiles[i] = _rand();
set_bkg_data(0, 128, tiles);
SHOW_BKG;
DISPLAY_ON;
/* this hangs */
add_JOY(joypad_irq);
enable_interrupts();
set_interrupts(JOY_IFLAG);
while(1) { }
/* this works */
//enable_interrupts();
//while(1) { joypad_irq(); }
}
Just to mention the errors message I get. Nevertheless, I can compile the examples and run on bgb.
Compiling: digits.c
libc\digits.c:1: warning 115: unknown or unsupported #pragma directive 'bank=BASE'
Compiling: gprint.c
Compiling: gprintf.c
Compiling: gprintln.c
Compiling: gprintn.c
libc\gprintn.c:11: warning 94: comparison is always false due to limited range of data type
libc\gprintn.c:11: warning 126: unreachable code
libc\gprintn.c:12: warning 126: unreachable code
libc\gprintn.c:12: warning 126: unreachable code
libc\gprintn.c:13: warning 126: unreachable code
libc\gprintn.c:13: warning 126: unreachable code
Assembling: arand.s
Assembling: cgb.s
Assembling: cpy_data.s
Assembling: crt0.s
Assembling: delay.s
Assembling: drawing.s
Assembling: font.s
Assembling: f_ibm_sh.s
Assembling: f_italic.s
Assembling: f_min.s
Assembling: f_spect.s
Assembling: get_bk_t.s
Assembling: get_data.s
Assembling: get_prop.s
Assembling: get_spr.s
Assembling: get_wi_t.s
Assembling: get_xy_t.s
Assembling: global.s
Assembling: hiramcpy.s
Assembling: ibmfixed.s
Assembling: init_tt.s
Assembling: input.s
Assembling: mv_bkg.s
Assembling: mv_spr.s
Assembling: mv_win.s
Assembling: pad.s
Assembling: rand.s
Assembling: sample.s
Assembling: scroll_b.s
Assembling: scroll_s.s
Assembling: scroll_w.s
Assembling: serial.s
Assembling: set_bk_t.s
Assembling: set_data.s
Assembling: set_prop.s
Assembling: set_spr.s
Assembling: set_wi_t.s
Assembling: set_xy_t.s
Assembling: sfr.s
Assembling: sgb.s
1 fichier(s) copié(s).
Adding: obj\arand.rel
Adding: obj\cgb.rel
Adding: obj\cpy_data.rel
Adding: obj\crt0.rel
Adding: obj\delay.rel
Adding: obj\digits.rel
Adding: obj\drawing.rel
Adding: obj\font.rel
Adding: obj\f_ibm_sh.rel
Adding: obj\f_italic.rel
Adding: obj\f_min.rel
Adding: obj\f_spect.rel
ERROR: Couldn't create temporary file 'lib\gb.__L'
Adding: obj\get_bk_t.rel
Adding: obj\get_data.rel
Adding: obj\get_prop.rel
Adding: obj\get_spr.rel
Adding: obj\get_wi_t.rel
Adding: obj\get_xy_t.rel
Adding: obj\global.rel
Adding: obj\gprint.rel
Adding: obj\gprintf.rel
Adding: obj\gprintln.rel
Adding: obj\gprintn.rel
Adding: obj\hiramcpy.rel
Adding: obj\ibmfixed.rel
Adding: obj\init_tt.rel
Adding: obj\input.rel
Adding: obj\mv_bkg.rel
Adding: obj\mv_spr.rel
Adding: obj\mv_win.rel
Adding: obj\pad.rel
ERROR: Couldn't create temporary file 'lib\gb.__I'
Adding: obj\rand.rel
Adding: obj\sample.rel
Adding: obj\scroll_b.rel
Adding: obj\scroll_s.rel
Adding: obj\scroll_w.rel
Adding: obj\serial.rel
Adding: obj\set_bk_t.rel
Adding: obj\set_data.rel
Adding: obj\set_prop.rel
Adding: obj\set_spr.rel
Adding: obj\set_wi_t.rel
Adding: obj\set_xy_t.rel
Adding: obj\sfr.rel
Adding: obj\sgb.rel
Build succeeded!
Then, compiling Space example:
?ASlink-Warning-Undefined Global '.jpad' referenced by module 'Space'
But, as I said, the .gb is done and working.
multi bank support?
windows support?
Quick heads-up that the sdcclib tool that's being used in this project has been removed in sdcc version 3.8.6.Apparently sdar should be used instead according to the docs.
http://sdcc.sourceforge.net/doc/sdccman.pdf
So I assume 3.8.0 is the way to go for now?
More examples are needed as part of documented the available functions and showcase how to do stuff and how to build them. New and current examples needs to be checked for correctness as well as old gbdk used 8 bit-ints (not standard compliant).
So I've been playing around with this for a bit and banked code seems to be a major problem with gbdk-n currently. And it's not necessarily that the gbdk-n code is bad but there's definitely issues compiling code that results in multi bank roms.
After a bunch of digging I think I've pinned this to the SDCC linker not allowing for an extended address space > 64kb.
Before I go and file a bug over there, do you have any examples of working multi bank code (specifically generating a rom > 64kb)?
The gbz80 runtime (crt0) included in sdcc is currently disabled and replaced with the old runtime shipped with the original gbdk. This is probably bad.
Most (all) modules depend heavily on the old runtime so the appropriate functionality needs to be broken out into modules.
Hello,
Is it possible to play background music and sound effect sfx with this SDK ?
3$:
LDH A,(.STAT)
AND #0x02
JR NZ,3$
LD A,(BC) ; Copy W tiles
LD (HL+),A;<<<<<
INC BC
DEC D
JR NZ,3$
Since sdcc 3.9.0+, the binary sdcclib
was removed. It is replaced by sdar
.
sdar -qv
This library is very helpful when starting out with gameboy development, but the lack of documentation makes it a pain to use efficiently, e.g. the entire section about gb/console.h
is just blah
.
There are currently overlaps & incompatibilities between the runtime (crt) and standard libraries (stdlib) included in gbdk-n and the ones included in SDCC.
Currently, the included crt in SDCC is disabled in favor of the gbdk-n. This is because gbdk-n breaks with SDCC runtime. This is done by passing --no-std-crt0 to sdcc.
For the standard library, both the gbdk-n library and sdcc library are used because there are functions in both libraries that are needed for successful builds. The problem is when the libraries overlap, resulting in failing builds (multiple symbols defined when linking). An example is the rand() function that is defined in both gbdk-n and sdcc.
Lddc supports setting the -Wl-yp0x143=0x80
flag to set things as Gameboy Color compatible. Is there an equivalent way for doing this with gbdk-n / sdcc?
Hi, I stumbled onto your project while looking for an updated GBDK using the latest SDCC.
I've built with SDCC HEAD (3.5.4 #9304 as of Aug 24 2015) and cannot get a binary created with makebin
, getting error: size of the buffer is too small.
My program, test.c
, looks like:
#include <gb/gb.h>
#include <gb/console.h>
#include <stdio.h>
void main()
{
printf(" \nTest\n");
}
And I execute the following:
$ ./gbdk-n-compile.sh test.c
+ sdcc -mgbz80 --no-std-crt0 -I /gbdk-n/bin/../include -I /gbdk-n/bin/../include/asm -c test.c
$ ./gbdk-n-link.sh test.c
+ sdcc -mgbz80 --no-std-crt0 -I /gbdk-n/bin/../include -I /gbdk-n/bin/../include/asm -L /gbdk-n/bin/../lib /gbdk-n/bin/../lib/crt0.rel -l gb.lib -o a.ihx test.c
$ makebin -Z a.ihx test.gb
error: size of the buffer is too small.
Is this correct or have I done something wrong?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.