Code::Blocks - DC Dev R1 *refixed*

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
User avatar
emptythought
DC Developer
DC Developer
Posts: 2015
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Wed Jan 30, 2002 9:14 am
Location: UNITED STATES NRN
Has thanked: 0
Been thanked: 0
Contact:

Code::Blocks - DC Dev R1 *refixed*

Post by emptythought »

Here is the official release of my Dreamcast setup for Code::Blocks. Thanks to starlight for pointing out the SDL issues in my WIP release (they're now working).

About R1:
- upgraded to Code::Blocks svn (1.0 RC2 support dropped)
- no Makefiles needed
- includes Dreamcast sh-elf compiler (GCC 3.4.6)
- building romdisks within the IDE
- project files for most of KOS' Dreamcast examples
- configuration program automatically sets Dreamcast compiler for you
- easy uninstallation

Downloads:
CodeBlocks_DCDev_R1.exe (refixed 12/19/07)
cbdc_dep.zip (fixed 12/19/07) (this is for DC Dev ISO R2 and newer - sets the Dreamcast compiler up in Code::Blocks to use the Dev ISO's path rather than using the compiler in the "independent" installer)
manconf.zip (includes HTML manual-setup instructions for integrating CodeBlocks with Dev ISO R2 and newer, and the Dreamcast script used for the Dreamcast wizard)

Credits:
JMD for bin2odc.exe (used for romdisks)
pnpbios for the original Code::Blocks for DC thread
Last edited by emptythought on Sat Mar 08, 2008 6:56 pm, edited 6 times in total.
User avatar
Covar
DCEmu Mega Fan
DCEmu Mega Fan
Posts: 2990
Joined: Sat Nov 30, 2002 8:06 am
Location: Cary, NC
Has thanked: 0
Been thanked: 0
Contact:

Re: Code::Blocks - DC Dev R1

Post by Covar »

The installer doesn't work. can't seem to actually click the install button, or change the install path.
User avatar
emptythought
DC Developer
DC Developer
Posts: 2015
Joined: Wed Jan 30, 2002 9:14 am
Location: UNITED STATES NRN
Has thanked: 0
Been thanked: 0
Contact:

Re: Code::Blocks - DC Dev R1

Post by emptythought »

I configured the installer to check for codeblocks.exe in the upper path, so make sure you select the folder CodeBlocks is installed in and add \dc. Also make sure the path you select has Code::Blocks svn, not 1.0 RC2.
User avatar
Covar
DCEmu Mega Fan
DCEmu Mega Fan
Posts: 2990
Joined: Sat Nov 30, 2002 8:06 am
Location: Cary, NC
Has thanked: 0
Been thanked: 0
Contact:

Re: Code::Blocks - DC Dev R1

Post by Covar »

ah ok, i got it to install now.

quick question though, to compile i will need to install cygwin?
User avatar
emptythought
DC Developer
DC Developer
Posts: 2015
Joined: Wed Jan 30, 2002 9:14 am
Location: UNITED STATES NRN
Has thanked: 0
Been thanked: 0
Contact:

Re: Code::Blocks - DC Dev R1

Post by emptythought »

Covar wrote:ah ok, i got it to install now.

quick question though, to compile i will need to install cygwin?
Nope! :)
User avatar
Covar
DCEmu Mega Fan
DCEmu Mega Fan
Posts: 2990
Joined: Sat Nov 30, 2002 8:06 am
Location: Cary, NC
Has thanked: 0
Been thanked: 0
Contact:

Re: Code::Blocks - DC Dev R1

Post by Covar »

i didn't think so since you mentioned it, but when i try and compile a dreamcast project it tells me it sh-elf-gcc.exe needs cygwin1.dll to continue.
User avatar
emptythought
DC Developer
DC Developer
Posts: 2015
Joined: Wed Jan 30, 2002 9:14 am
Location: UNITED STATES NRN
Has thanked: 0
Been thanked: 0
Contact:

Re: Code::Blocks - DC Dev R1

Post by emptythought »

I probably forgot to change the additional path under the toolchain executables tab and missed it because I have Cygwin installed. I'm almost 100% sure that's the problem. For now, you can fix it by changing "C:\cygwin\bin" to "C:\Program Files\CodeBlocks\dc\bin"...
User avatar
Covar
DCEmu Mega Fan
DCEmu Mega Fan
Posts: 2990
Joined: Sat Nov 30, 2002 8:06 am
Location: Cary, NC
Has thanked: 0
Been thanked: 0
Contact:

Re: Code::Blocks - DC Dev R1 *fixed*

Post by Covar »

That works much better now. and i must say this is great. by far the fastest i went from installing a toolchain to having a working dc binary.
User avatar
Arqueiro
DCEmu Nutter
DCEmu Nutter
Posts: 785
Joined: Tue Jul 02, 2002 9:29 am
Has thanked: 0
Been thanked: 0
Contact:

Re: Code::Blocks - DC Dev R1 *fixed*

Post by Arqueiro »

thanks for share this with us!
3d graphics and visualization ?
http://www.arquiteturadigital.com
User avatar
Arqueiro
DCEmu Nutter
DCEmu Nutter
Posts: 785
Joined: Tue Jul 02, 2002 9:29 am
Has thanked: 0
Been thanked: 0
Contact:

Re: Code::Blocks - DC Dev R1 *fixed*

Post by Arqueiro »

to use the installer i need first have this Code::Blocks svn installed right ?
3d graphics and visualization ?
http://www.arquiteturadigital.com
User avatar
emptythought
DC Developer
DC Developer
Posts: 2015
Joined: Wed Jan 30, 2002 9:14 am
Location: UNITED STATES NRN
Has thanked: 0
Been thanked: 0
Contact:

Re: Code::Blocks - DC Dev R1 *fixed*

Post by emptythought »

Arqueiro wrote:to use the installer i need first have this Code::Blocks svn installed right ?
Yes. Otherwise the Install button is grayed out. Any current SVN should work, I can't remember what revision I used but anything over 42xx should work.
User avatar
Arqueiro
DCEmu Nutter
DCEmu Nutter
Posts: 785
Joined: Tue Jul 02, 2002 9:29 am
Has thanked: 0
Been thanked: 0
Contact:

Re: Code::Blocks - DC Dev R1 *fixed*

Post by Arqueiro »

this is what is happening with me,

when i use the last version, available on the official site, the installation pack dont work. (codeblocks-1.0rc2)

when i install a old version, (codeblocks-1.0-rc1.1) it goes and install it but i got some errors when start the program (some incompatible pluguins)


which version are you guys working ?
3d graphics and visualization ?
http://www.arquiteturadigital.com
User avatar
emptythought
DC Developer
DC Developer
Posts: 2015
Joined: Wed Jan 30, 2002 9:14 am
Location: UNITED STATES NRN
Has thanked: 0
Been thanked: 0
Contact:

Re: Code::Blocks - DC Dev R1 *fixed*

Post by emptythought »

OK, you're not using a SVN. None of the official releases will work.

Uninstall the release you have installed, create a folder in Program Files call CodeBlocks, download the latest SVN from here and extract it there.
User avatar
Arqueiro
DCEmu Nutter
DCEmu Nutter
Posts: 785
Joined: Tue Jul 02, 2002 9:29 am
Has thanked: 0
Been thanked: 0
Contact:

Re: Code::Blocks - DC Dev R1 *fixed*

Post by Arqueiro »

thanks for you help fackue, im trying to compile a example that come with the KOS:

Code: Select all

/* png example for KOS 1.1.x
 * Jeffrey McBeth / Morphogenesis
 * <mcbeth@morphogenesis.2y.net>
 *
 * Heavily borrowed from from 2-D example
 * AndrewK / Napalm 2001
 * <andrewk@napalm-x.com>
 */

#include <kos.h>
#include <png/png.h>
#include <zlib/zlib.h>

/* font data */
extern char wfont[];

/* textures */
pvr_ptr_t font_tex;
pvr_ptr_t back_tex;
char *data;

/* init background */
void back_init()
{
    back_tex = pvr_mem_malloc(512*512*2);
    png_to_texture("/rd/background.png", back_tex, PNG_NO_ALPHA);
}

/* init font */
void font_init()
{
    int i,x,y,c;
    unsigned short * temp_tex;
    
    font_tex = pvr_mem_malloc(256*256*2);
    temp_tex = (unsigned short *)malloc(256*128*2);
    
    c = 0;
    for(y = 0; y < 128 ; y+=16)
        for(x = 0; x < 256 ; x+=8) {
            for(i = 0; i < 16; i++) {
                temp_tex[x + (y+i) * 256 + 0] = 0xffff * ((wfont[c+i] & 0x80)>>7);
                temp_tex[x + (y+i) * 256 + 1] = 0xffff * ((wfont[c+i] & 0x40)>>6);
                temp_tex[x + (y+i) * 256 + 2] = 0xffff * ((wfont[c+i] & 0x20)>>5);
                temp_tex[x + (y+i) * 256 + 3] = 0xffff * ((wfont[c+i] & 0x10)>>4);
                temp_tex[x + (y+i) * 256 + 4] = 0xffff * ((wfont[c+i] & 0x08)>>3);
                temp_tex[x + (y+i) * 256 + 5] = 0xffff * ((wfont[c+i] & 0x04)>>2);
                temp_tex[x + (y+i) * 256 + 6] = 0xffff * ((wfont[c+i] & 0x02)>>1);
                temp_tex[x + (y+i) * 256 + 7] = 0xffff * (wfont[c+i] & 0x01);
            }
            c+=16;
        }
    pvr_txr_load_ex(temp_tex, font_tex, 256, 256, PVR_TXRLOAD_16BPP);
}

void text_init()
{
  int length = zlib_getlength("/rd/text.gz");
  gzFile f;

  data = (char *)malloc(length+1); // I am not currently freeing it

  f = gzopen("/rd/text.gz", "r");
  gzread(f, data, length);
  data[length] = 0;
  gzclose(f);
    
  printf("length [%d]\n", length);
}

/* draw background */
void draw_back(void)
{
    pvr_poly_cxt_t cxt;
    pvr_poly_hdr_t hdr;
    pvr_vertex_t vert;

    pvr_poly_cxt_txr(&cxt, PVR_LIST_OP_POLY, PVR_TXRFMT_RGB565, 512, 512, back_tex, PVR_FILTER_BILINEAR);
    pvr_poly_compile(&hdr, &cxt);
    pvr_prim(&hdr, sizeof(hdr));

    vert.argb = PVR_PACK_COLOR(1.0f, 1.0f, 1.0f, 1.0f);    
    vert.oargb = 0;
    vert.flags = PVR_CMD_VERTEX;
    
    vert.x = 1;
    vert.y = 1;
    vert.z = 1;
    vert.u = 0.0;
    vert.v = 0.0;
    pvr_prim(&vert, sizeof(vert));
    
    vert.x = 640;
    vert.y = 1;
    vert.z = 1;
    vert.u = 1.0;
    vert.v = 0.0;
    pvr_prim(&vert, sizeof(vert));
    
    vert.x = 1;
    vert.y = 480;
    vert.z = 1;
    vert.u = 0.0;
    vert.v = 1.0;
    pvr_prim(&vert, sizeof(vert));
    
    vert.x = 640;
    vert.y = 480;
    vert.z = 1;
    vert.u = 1.0;
    vert.v = 1.0;
    vert.flags = PVR_CMD_VERTEX_EOL;
    pvr_prim(&vert, sizeof(vert));
}

/* draw one character */
void draw_char(float x1, float y1, float z1, float a, float r, float g, float b, int c, float xs, float ys)
{
    pvr_vertex_t    vert;
    int             ix, iy;
    float           u1, v1, u2, v2;
    
    ix = (c % 32) * 8;
    iy = (c / 32) * 16;
    u1 = (ix + 0.5f) * 1.0f / 256.0f;
    v1 = (iy + 0.5f) * 1.0f / 256.0f;
    u2 = (ix+7.5f) * 1.0f / 256.0f;
    v2 = (iy+15.5f) * 1.0f / 256.0f;
    
    vert.flags = PVR_CMD_VERTEX;
    vert.x = x1;
    vert.y = y1 + 16.0f * ys;
    vert.z = z1;
    vert.u = u1;
    vert.v = v2;
    vert.argb = PVR_PACK_COLOR(a,r,g,b);
    vert.oargb = 0;
    pvr_prim(&vert, sizeof(vert));
    
    vert.x = x1;
    vert.y = y1;
    vert.u = u1;
    vert.v = v1;
    pvr_prim(&vert, sizeof(vert));
    
    vert.x = x1 + 8.0f * xs;
    vert.y = y1 + 16.0f * ys;
    vert.u = u2;
    vert.v = v2;
    pvr_prim(&vert, sizeof(vert));
    
    vert.flags = PVR_CMD_VERTEX_EOL;
    vert.x = x1 + 8.0f * xs;
    vert.y = y1;
    vert.u = u2;
    vert.v = v1;
    pvr_prim(&vert, sizeof(vert));
}

/* draw a string */
void draw_string(float x, float y, float z, float a, float r, float g, float b, char *str, float xs, float ys) {
  pvr_poly_cxt_t cxt;
  pvr_poly_hdr_t hdr;
  float orig_x = x;

  pvr_poly_cxt_txr(&cxt, PVR_LIST_TR_POLY, PVR_TXRFMT_ARGB4444, 256, 256, font_tex, PVR_FILTER_BILINEAR);
  pvr_poly_compile(&hdr, &cxt);
  pvr_prim(&hdr, sizeof(hdr));
  
  while (*str) {
    if (*str == '\n')
    {
      x = orig_x;
      y += 40;
      str++;
      continue;
    }
    draw_char(x, y, z, a, r, g, b, *str++, xs, ys);
	x+=8*xs;
  }
}

/* base y coordinate */
int y = 0;

/* draw one frame */
void draw_frame(void)
{
    pvr_wait_ready();
    pvr_scene_begin();
    
    pvr_list_begin(PVR_LIST_OP_POLY);
    draw_back();
    pvr_list_finish();

    pvr_list_begin(PVR_LIST_TR_POLY);

    /* 1720 and 480 are magic numbers directly related to the text scrolling
     * 1720 is enough room for the whole text to scroll from the bottom of
     * the screen to off the top.  31 lines * 40 pixels + 480 pixel high screen
     * 480 is the height of the screen (starts the text at the bottom)
     */
    draw_string(0, y % 1720 + 440, 3, 1, 1,1,1, data, 2, 2);
    
    pvr_list_finish();
    pvr_scene_finish();

    y--;
}

/* romdisk */
extern uint8 romdisk_boot[];
KOS_INIT_ROMDISK(romdisk_boot);

int main(void)
{
    int done = 0;

    /* init kos  */
    pvr_init_defaults();
    
    /* init font */
    font_init();
    
    /* init background */
    back_init();

    /* init text */
    text_init();
    
    /* keep drawing frames until start is pressed */
    while(!done) {
        MAPLE_FOREACH_BEGIN(MAPLE_FUNC_CONTROLLER, cont_state_t, st)
            if (st->buttons & CONT_START)
                done = 1;
        MAPLE_FOREACH_END()

	draw_frame();
    }

    return 0;
}


and now i got this error:

Code: Select all

Compiling: C:\cygwin\usr\local\dc\kos\kos\examples\dreamcast\png\example.c
Linking console executable: C:\cygwin\usr\local\dc\kos\kos\examples\dreamcast\png\example.exe
/usr/local/dc/sh-elf/lib/gcc/sh-elf/3.4.6/../../../../sh-elf/bin/ld: warning: cannot find entry symbol start; defaulting to 000000008c010000
C:\cygwin\usr\local\dc\kos\kos\examples\dreamcast\png\example.o(.text+0x34): In function `back_init':
C:\cygwin\usr\local\dc\kos\kos\examples\dreamcast\png/example.c:27: undefined reference to `_png_to_texture'
C:\cygwin\usr\local\dc\kos\kos\examples\dreamcast\png\example.o(.text+0x158): In function `font_init':
C:\cygwin\usr\local\dc\kos\kos\examples\dreamcast\png/example.c:54: undefined reference to `_wfont'
C:\cygwin\usr\local\dc\kos\kos\examples\dreamcast\png\example.o(.text+0x1b8): In function `text_init':
C:\cygwin\usr\local\dc\kos\kos\examples\dreamcast\png/example.c:69: undefined reference to `_zlib_getlength'
C:\cygwin\usr\local\dc\kos\kos\examples\dreamcast\png\example.o(.text+0x1c8):C:\cygwin\usr\local\dc\kos\kos\examples\dreamcast\png/example.c:69: undefined reference to `_gzopen'
C:\cygwin\usr\local\dc\kos\kos\examples\dreamcast\png\example.o(.text+0x1d0):C:\cygwin\usr\local\dc\kos\kos\examples\dreamcast\png/example.c:69: undefined reference to `_gzread'
C:\cygwin\usr\local\dc\kos\kos\examples\dreamcast\png\example.o(.text+0x1d4):C:\cygwin\usr\local\dc\kos\kos\examples\dreamcast\png/example.c:69: undefined reference to `_gzclose'
C:\cygwin\usr\local\dc\kos\kos\examples\dreamcast\png\example.o(.data+0x0): In function `back_init':
C:\cygwin\usr\local\dc\kos\kos\examples\dreamcast\png/example.c:24: undefined reference to `_romdisk_boot'
C:\cygwin\usr\local\dc\kos\kos\lib\dreamcast/libkallisti.a(init.o)(.text+0x514): In function `arch_return':
/usr/local/dc/kos/kos/kernel/arch/dreamcast/kernel/init.c:249: undefined reference to `_arch_real_exit'
C:\cygwin\usr\local\dc\kos\kos\lib\dreamcast/libkallisti.a(init.o)(.text+0x6a4): In function `arch_abort':
/usr/local/dc/kos/kos/kernel/arch/dreamcast/kernel/init.c:284: undefined reference to `_arch_real_exit'
C:\cygwin\usr\local\dc\kos\kos\lib\dreamcast/libkallisti.a(exec.o)(.text+0xcc): In function `arch_exec_at':
/usr/local/dc/kos/kos/kernel/arch/dreamcast/kernel/exec.c:40: undefined reference to `__arch_old_stack'
C:\cygwin\usr\local\dc\kos\kos\lib\dreamcast/libkallisti.a(exec.o)(.text+0xd8):/usr/local/dc/kos/kos/kernel/arch/dreamcast/kernel/exec.c:40: undefined reference to `__arch_old_sr'
C:\cygwin\usr\local\dc\kos\kos\lib\dreamcast/libkallisti.a(exec.o)(.text+0xdc):/usr/local/dc/kos/kos/kernel/arch/dreamcast/kernel/exec.c:40: undefined reference to `__arch_old_vbr'
C:\cygwin\usr\local\dc\kos\kos\lib\dreamcast/libkallisti.a(exec.o)(.text+0xe0):/usr/local/dc/kos/kos/kernel/arch/dreamcast/kernel/exec.c:40: undefined reference to `__arch_old_fpscr'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 3 seconds)
14 errors, 0 warnings
 

anyone have idea why this is happening ?


thanks
3d graphics and visualization ?
http://www.arquiteturadigital.com
User avatar
emptythought
DC Developer
DC Developer
Posts: 2015
Joined: Wed Jan 30, 2002 9:14 am
Location: UNITED STATES NRN
Has thanked: 0
Been thanked: 0
Contact:

Re: Code::Blocks - DC Dev R1 *fixed*

Post by emptythought »

anyone have idea why this is happening ?
It has to do with wfont and the romdisk not getting linked but to get wfont linked correctly it needs to be converted to an object file and the program we're using to do this has the romdisk symbols hardcoded. I had some issues compiling the bin2odc's source. I was looking into creating the symbols at runtime. I tried manually changing the symbols and could not get it linking right so even if I did get the source to compile right I was not sure how to set the symbols. If you have to have wfont.o, I compilied the example in Cygwin then copied it to the example in CodeBlocks and linked it and it compiled fine.
User avatar
Neoblast
DC Developer
DC Developer
Posts: 314
Joined: Sat Dec 01, 2007 8:51 am
Has thanked: 3 times
Been thanked: 1 time

Re: Code::Blocks - DC Dev R1 *fixed*

Post by Neoblast »

First of all thank you for all this.
I tried to set up devC++ but it seems the ELF files won't work when making the iso because of the linker order, is there any way to successfully compile in devC++?
Well I can't install CODEBLOCKS dc config I get this error ( I'm using one of the latest codeblocks SVN ) "open and close Codeblocks and then continue" default.conf not found.
Point is that no default.conf is generated and even If I copy that file from the documents and settings/user/programdata/codeblocks it does not recognize it.......
User avatar
emptythought
DC Developer
DC Developer
Posts: 2015
Joined: Wed Jan 30, 2002 9:14 am
Location: UNITED STATES NRN
Has thanked: 0
Been thanked: 0
Contact:

Re: Code::Blocks - DC Dev R1 *fixed*

Post by emptythought »

Neoblast wrote:Well I can't install CODEBLOCKS dc config I get this error ( I'm using one of the latest codeblocks SVN ) "open and close Codeblocks and then continue" default.conf not found.
Point is that no default.conf is generated and even If I copy that file from the documents and settings/user/programdata/codeblocks it does not recognize it.......
It doesn't give me the error with CodeBlocks November 28 svn. Also - you shouldn't have to copy it to anywhere. Once you open CodeBlocks for the first time and close it it creates default.conf. You might have to save the layout if it asks you to but I would of said that before if you needed to.
First of all thank you for all this.
I tried to set up devC++ but it seems the ELF files won't work when making the iso because of the linker order, is there any way to successfully compile in devC++?
There wasn't when I tried it.
User avatar
Neoblast
DC Developer
DC Developer
Posts: 314
Joined: Sat Dec 01, 2007 8:51 am
Has thanked: 3 times
Been thanked: 1 time

Re: Code::Blocks - DC Dev R1 *fixed*

Post by Neoblast »

Well I open it and close it and no default.conf is created, the only default.conf is on
documents and settings/user/programdata/codeblocks/
It is still giving me that error, weird....
BTW I have the latest CODEBLOCKS SVN.

Where can I download a precompiled linux toolchain ( .rpm package or compressed one )?
Since consolevision is down many of the forum downloads are gone
User avatar
emptythought
DC Developer
DC Developer
Posts: 2015
Joined: Wed Jan 30, 2002 9:14 am
Location: UNITED STATES NRN
Has thanked: 0
Been thanked: 0
Contact:

Re: Code::Blocks - DC Dev R1 *fixed*

Post by emptythought »

Neoblast wrote:Well I open it and close it and no default.conf is created, the only default.conf is on
documents and settings/user/programdata/codeblocks/
It is still giving me that error, weird....
BTW I have the latest CODEBLOCKS SVN.
Does it have read-only or hidden flags set?
Where can I download a precompiled linux toolchain ( .rpm package or compressed one )?
Since consolevision is down many of the forum downloads are gone
http://dchelp.dcemulation.org/downloads ... 86.tar.bz2
User avatar
Neoblast
DC Developer
DC Developer
Posts: 314
Joined: Sat Dec 01, 2007 8:51 am
Has thanked: 3 times
Been thanked: 1 time

Re: Code::Blocks - DC Dev R1 *fixed*

Post by Neoblast »

Does it have read-only or hidden flags set?
Nope.
Any tutorial on how to configure it? I'd appreciate, Thanks.
We're starting a project for dc that might see a demo on christmas or january if all goes well.

Now I only have to set the dev environment on linux, I did it manually for windows
(manconf.zip)
Post Reply