Dingoonity.org

GCW Zero => Development => Topic started by: zx-81 on February 10, 2013, 10:40:57 am

Title: Any sample / example for a simple SDL app on gcw0 ?
Post by: zx-81 on February 10, 2013, 10:40:57 am
Hi All,

May be one day i will join the gcw0 community, so i would like to know if there are any source code examples + makefile of a simple SDL app for gcw0 ? Is there any wiki ?

I've seen that there were many ported apps (or simply cross compiled) available as opk file (on google drive) but not any source code with a valid makefile. Is there any place where i can find the source code of those apps ?
That would help me to understand on how to port any SDL apps on gcw0.

Btw I haven't seen any description of the default.gcw0.desktop file which is mandatory to get a proper opk running on gcw0 ? Is it the same as a320 apps ?

Finally another last question, is there any difference on SDL keycode used by the Dingoo and the gcw0 for keypads ?

Thanks for your help :)



Title: Re: Any sample / example for a simple SDL app on gcw0 ?
Post by: dmitry_smagin on February 10, 2013, 11:09:35 am
In general, programming for gcw0 is the same as for a320; Makefiles are mostly the same too, except the use of -fhard-float instead of -fsoft-float flag (you can omit it completely).

Some info about opk desktop files is here: https://github.com/gcwnow/buildroot/wiki/Package-file-format

SDL keycodes are the same, but gcw0 has X and Y caps swapped. Gcw0 Y behaves as a320 X etc.

For example, I used this Makefile to compile dingux-colem:
Quote
#
# Colem port on DINGUX
#
# Copyright (C) 2009 Ludovic Jacomme ([email protected])
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
COLEM_VERSION=1.1.0

TARGET = dingux-colem.dge

OBJS = gp2x_psp.o \
cpudingux.o \
Coleco.o \
ColEm.o \
Debug.o \
SN76489.o \
Unix.o \
LibPsp.o \
Z80.o \
psp_main.o \
psp_sdl.o \
psp_sound.o \
psp_kbd.o \
psp_font.o \
psp_menu.o \
psp_joy.o \
psp_danzeff.o \
psp_menu_set.o \
psp_menu_help.o \
psp_menu_joy.o \
psp_menu_kbd.o \
psp_menu_cheat.o \
psp_menu_list.o \
psp_editor.o \
miniunz.o \
unzip.o \
psp_fmgr.o

CC=mipsel-linux-gcc
STRIP=mipsel-linux-strip

DEFAULT_CFLAGS = $(shell sdl-config --cflags)

MORE_CFLAGS = -I.  \
-DENABLE_THREADS -mips32 -O3 -fstrength-reduce -fthread-jumps -fexpensive-optimizations \
-fomit-frame-pointer -frename-registers -pipe -G 0 -D_GNU_SOURCE=1 -D_REENTRANT -DIS_LITTLE_ENDIAN -D_DEBUG \
-DMPU_JZ4740 -ffast-math \
-DUNIX -DBPP16 -DLSB_FIRST -DSOUND  -DNO_STDIO_REDIRECT  -DCOLEM_VERSION=\"$(COLEM_VERSION)\" \
-DDINGUX_MODE

CFLAGS = $(DEFAULT_CFLAGS) $(MORE_CFLAGS)
LDFLAGS = -s

LIBS += -lSDL -lSDL_image -lpng -lz -lm -lpthread -ldl

.c.o:
   $(CC) $(CFLAGS) -c $< -o [email protected]

$(TARGET): $(OBJS)
   $(CC) $(LDFLAGS) $(CFLAGS) $(OBJS) $(LIBS) -o $(TARGET) && $(STRIP) $(TARGET)

install: $(TARGET)
   cp $< /media/dinguxdisk/game/dingux-colem/

clean:
   rm -f $(OBJS) $(TARGET)

ctags:
   ctags *[ch]
[/quote[
Title: Re: Any sample / example for a simple SDL app on gcw0 ?
Post by: zx-81 on February 10, 2013, 01:17:52 pm
Many thanks for your help. It would be then really easy to back port all my dingux stuff to gcw0 (if it has not been done already, like dingux-colem).

I should be able to port all caanoo versions of my emulator ports and games  (with enhancement and bug fix) in no time :).
Title: Re: Any sample / example for a simple SDL app on gcw0 ?
Post by: BAFelton on February 10, 2013, 02:19:01 pm
Great to see you here Zx ;)
Title: Re: Any sample / example for a simple SDL app on gcw0 ?
Post by: zx-81 on February 10, 2013, 02:29:14 pm
glad to see you too Baf !
Title: Re: Any sample / example for a simple SDL app on gcw0 ?
Post by: ruffnutts on February 10, 2013, 04:21:36 pm
Wow zx on board would be great ;)
Title: Re: Any sample / example for a simple SDL app on gcw0 ?
Post by: clach04 on April 04, 2013, 05:58:24 am
I know this is kinda late but there is an example in the native dingoo sdk http://code.google.com/p/dingoo-sdk/source/browse/trunk/dingoo_sdk/samples/sdl_hello_world/ which can be built for native, OpenDingux or OD for the GCW0 (this should work for pretty much any platform with an appropriate makefile).

RE key codes, it depends what you mean. Some of your original projects uses raw codes which vary on every platform (rather than SDL key press defines, SDLK_* http://code.google.com/p/dingoo-sdk/wiki/DingooSDL the SDLK_ defines are the same and consistent). I've got some of those raw codes documented at https://bitbucket.org/clach04/dingoo_hugo/commits/8631a278d78e15566a1e0760dab1c589db341775 as they were needed for HuGo. There are a few minor tweaks/improvements in that repo so you may want to check them out.
Title: Re: Any sample / example for a simple SDL app on gcw0 ?
Post by: pcercuei on April 04, 2013, 11:58:36 pm
Beware, we will move very soon to a joystick driver for the buttons of the GCW0; that means that the buttons won't be mapped to keyboard anymore. Consider adding support for joysticks.
Title: Re: Any sample / example for a simple SDL app on gcw0 ?
Post by: Optimus on October 13, 2013, 10:52:09 pm
HELP NEEDED!

I tried to compile something, anything, in various ways and can't make a sense of what I am doing wrong. It always goes back to the menu.

I compile and get a dge which I try to run from file explorer in GCW. It just returns me back to the menu.
Is it ok to just run the executable or should I make it into an OPK or something else?
I tried to enable disable various things in makefile flags. I don't understand most of the flags there.
Tried also C and C++ version.

This is my makefile:

Quote
OBJS = main.o

TARGET = test.dge

TOOLCHAINDIR = /opt/gcw0-toolchain/usr
BINPATH = $(TOOLCHAINDIR)/bin

ARCH = mipsel-gcw0-linux-uclibc-
CC   =$(BINPATH)/$(ARCH)gcc
CXX   =$(BINPATH)/$(ARCH)g++
STRIP=$(BINPATH)/$(ARCH)strip

DEFAULT_CFLAGS = $(shell sdl-config --cflags)

MORE_CFLAGS = -I.  \
-DENABLE_THREADS -mips32 -O3 -fstrength-reduce -fthread-jumps -fexpensive-optimizations \
-fomit-frame-pointer -frename-registers -pipe -G 0 -D_GNU_SOURCE=1 -D_REENTRANT -DIS_LITTLE_ENDIAN -D_DEBUG \
-DMPU_JZ4740 -ffast-math \
-DUNIX -DBPP16 -DLSB_FIRST -DSOUND  -DNO_STDIO_REDIRECT \
-DDINGUX_MODE

LIB_PATH  = $(TOOLCHAINDIR)/lib

CFLAGS = $(DEFAULT_CFLAGS) $(MORE_CFLAGS)
CXXFLAGS = $(CFLAGS)
LDFLAGS = -s -L$(LIB_PATH)

LIBS += -lSDL -lSDL_image -lpng -lz -lm -lpthread -ldl

.c.o:
   $(CXX) $(CXXFLAGS) -c $< -o [email protected]

$(TARGET): $(OBJS)
   $(CXX) $(LDFLAGS) $(CFLAGS) $(OBJS) $(LIBS) -o $(TARGET) && $(STRIP) $(TARGET)

clean:
   rm -f $(OBJS) $(TARGET)

ctags:
   ctags *[ch]

So what?

p.s. Maybe if there is a very elementary program, a helloworld with a proper makefile to run with this toolchain, that we know it works. And I can try it here. I have the toolchain in cygwin, extracted it from within cygwin. Seems fine.
Title: Re: Any sample / example for a simple SDL app on gcw0 ?
Post by: pcercuei on October 13, 2013, 11:00:42 pm
p.s. Maybe if there is a very elementary program, a helloworld with a proper makefile to run with this toolchain, that we know it works. And I can try it here. I have the toolchain in cygwin, extracted it from within cygwin. Seems fine.
Where did you get that? We didn't release any toolchain for cygwin...
Title: Re: Any sample / example for a simple SDL app on gcw0 ?
Post by: Optimus on October 13, 2013, 11:13:32 pm
Where did you get that? We didn't release any toolchain for cygwin...

It was the toolchain I acquired from here http://boards.dingoonity.org/gcw-development/dev-toolchain (http://boards.dingoonity.org/gcw-development/dev-toolchain)
I know it's supposed to be a dingoo toolchain that might work with GCW.
There could be a possibility I mistakenly think I am compiling for GCW and running dingoo executable on GCW instead, without knowing what I am doing.

Although yesterday I tried the official SDK in Ubuntu on a VirtualBox (very slow, don't like to work there) and got somehow an executable which also throws me back to menu. Same result.

Maybe I am not allowed to run directly an executable and I have to pack to OPK to test?
Title: Re: Any sample / example for a simple SDL app on gcw0 ?
Post by: hi-ban on October 13, 2013, 11:15:43 pm
You have to chmod +x, or pack them into an OPK.
Title: Re: Any sample / example for a simple SDL app on gcw0 ?
Post by: pcercuei on October 13, 2013, 11:17:11 pm
Prior to execute the binary from the Zero, you have to set the execution flag.
Telnet to the console, and type 'chmod +x my_binary.dge' (assuming you transfered the binary in the home folder and not anywhere else).
Title: Re: Any sample / example for a simple SDL app on gcw0 ?
Post by: Optimus on October 13, 2013, 11:49:34 pm
Prior to execute the binary from the Zero, you have to set the execution flag.
Telnet to the console, and type 'chmod +x my_binary.dge' (assuming you transfered the binary in the home folder and not anywhere else).

Well, thanks! Finally that worked for me! I guess I am still very clueless about linux :P
Also, it's the first time I telnet on a handheld and test my code this way. That seems fun!
Title: Re: Any sample / example for a simple SDL app on gcw0 ?
Post by: robert2098 on October 14, 2013, 09:00:45 pm
Although yesterday I tried the official SDK in Ubuntu on a VirtualBox (very slow, don't like to work there).

Instead of VirtualBox, you can also try the free version of VMware Player (https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/6_0). Maybe that works better for you than VirtualBox.

Robert
Title: Re: Any sample / example for a simple SDL app on gcw0 ?
Post by: Optimus on October 17, 2013, 01:42:13 pm
Although yesterday I tried the official SDK in Ubuntu on a VirtualBox (very slow, don't like to work there).

Instead of VirtualBox, you can also try the free version of VMware Player (https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/6_0). Maybe that works better for you than VirtualBox.

Robert

I might try that too, hope it's free.
Got a fast new desktop PC though, so maybe virtualbox is much faster now.
But I had this other problem, couldn't recognize USB so that I can ftp and telnet to the GCW.
I had to use dropbox to send my compiled version, then go to real desktop to get it from there and transfer. Very slow process.
Title: Re: Any sample / example for a simple SDL app on gcw0 ?
Post by: johnnyonflame on October 17, 2013, 04:18:40 pm
As far as I've read about, VirtualBox's only drawback is the slightly slower IO.
I've been working with it for a while using an Athlon x2 without much trouble. Of course my current rig does it best, but still.

Although yesterday I tried the official SDK in Ubuntu on a VirtualBox (very slow, don't like to work there).

Instead of VirtualBox, you can also try the free version of VMware Player (https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/6_0). Maybe that works better for you than VirtualBox.

Robert

I might try that too, hope it's free.
Got a fast new desktop PC though, so maybe virtualbox is much faster now.
But I had this other problem, couldn't recognize USB so that I can ftp and telnet to the GCW.
I had to use dropbox to send my compiled version, then go to real desktop to get it from there and transfer. Very slow process.

Try configuring the GCW Zero for auto-detection, or Pause the VM, plug zero, connect using the menu, unpause the VM.
Title: Re: Any sample / example for a simple SDL app on gcw0 ?
Post by: mth on October 23, 2013, 01:25:45 am
Going back to the original question, here (https://github.com/gcwnow/tests/) is example code for a super simple SDL application, including a Makefile to build it.
Title: Re: Any sample / example for a simple SDL app on gcw0 ?
Post by: theweirdn8 on November 10, 2013, 01:35:24 am
I reccomend using CodeBlocks and attatch toolchain. Easiest port ever for me!