struggling with loading bitmap

SGDK only sub forum

Moderator: Stef

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Fri Feb 07, 2014 5:26 pm

You've removed the need to load the palette and tiles now too?!?
Yeah as the Bitmap or Image object contains all needed information so a single method can do everything for you (but this is less flexible than using low level method).

About the doc folder, it contains a doxygen documentation which give you doc for each methods :)

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Mon Feb 10, 2014 6:57 pm

Still no joy

Code: Select all

Launching tool 'Make': C:\Dev\md\sdk\bin\make  -f C:\Dev\md\sdk\makefile.gen (in C:\Users\Matt\DevWork\md\TheGame)
stdout> C:/Dev/md/sdk/bin/mkdir -p out
stdout> C:/Dev/md/sdk/bin/mkdir -p out/src
stdout> C:/Dev/md/sdk/bin/mkdir -p out/res
stdout> C:/Dev/md/sdk/bin/gcc  -m68000 -Wall -O1 -fomit-frame-pointer -fno-builtin-memset -fno-builtin-memcpy -Iinc -Isrc -Ires -IC:/Dev/md/sdk/inc -IC:/Dev/md/sdk/res -BC:/Dev/md/sdk/bin -c main.c -o out/main.o
stderr> In file included from C:/Dev/md/sdk/inc/genesis.h:14,
stderr>                  from main.c:1:
stderr> C:/Dev/md/sdk/inc/font.h:19:20: libres.h: No such file or directory
stderr> main.c: In function `main':
stderr> main.c:21: warning: passing arg 1 of `VDP_loadBMPTileData' from incompatible pointer type
stderr> make: *** [out/main.o] Error 1
Tool execution terminated with status 2

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Mon Feb 10, 2014 10:26 pm

Verify that the file C:/Dev/md/sdk/res/libres.h exists, if not then recompile the library by using the makelib.gen makefile.
The file should appears and your problem be fixed !

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Mon Feb 10, 2014 11:14 pm

Stef wrote:Verify that the file C:/Dev/md/sdk/res/libres.h exists, if not then recompile the library by using the makelib.gen makefile.
The file should appears and your problem be fixed !
There is a res file but no h extension file! :D Shouldn't this be in the zip file for the SDK?

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Mon Feb 10, 2014 11:38 pm

Ran the makelib.gen and almost have it working!

I really appreciate your patience with me Stef :)

Code: Select all

Launching tool 'Make': C:\Dev\md\sdk\bin\make  -f C:\Dev\md\sdk\makefile.gen (in C:\Users\Matt\DevWork\md\TheGame)
stdout> C:/Dev/md/sdk/bin/mkdir -p out
stdout> C:/Dev/md/sdk/bin/mkdir -p out/src
stdout> C:/Dev/md/sdk/bin/mkdir -p out/res
stdout> C:/Dev/md/sdk/bin/gcc  -m68000 -Wall -O1 -fomit-frame-pointer -fno-builtin-memset -fno-builtin-memcpy -Iinc -Isrc -Ires -IC:/Dev/md/sdk/inc -IC:/Dev/md/sdk/res -BC:/Dev/md/sdk/bin -c main.c -o out/main.o
stderr> main.c: In function `main':
stderr> main.c:21: warning: passing arg 1 of `VDP_loadBMPTileData' from incompatible pointer type
stdout> echo "out/main.o" > out/cmd_
stdout> C:/Dev/md/sdk/bin/gcc -BC:/Dev/md/sdk/bin -n -T C:/Dev/md/sdk/md.ld -nostdlib out/sega.o @out/cmd_ C:/Dev/md/sdk/lib/libmd.a C:/Dev/md/sdk/lib/libgcc.a -o out/rom.out
stderr> out/main.o: In function `main':
stderr> main.c:(.text+0x4): undefined reference to `car'
stderr> main.c:(.text+0x18): undefined reference to `car'
stderr> main.c:(.text+0x2a): undefined reference to `car'
stderr> main.c:(.text+0x4a): undefined reference to `car'
stderr> make: *** [out/rom.out] Error 1
Tool execution terminated with status 2
Launching tool 'Run Rom': C:\Dev\md\emulator\gens.exe C:\Users\Matt\DevWork\md\TheGame\\out\rom.out (in C:\Users\Matt\DevWork\md\TheGame)

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Tue Feb 11, 2014 8:44 am

Is car your image resource ?
I though you already got that part working.
Can you tell me how you declared you car resource ? it should be located in a .res file located in the res folder of your project. Check the "sprite" sample provided in SGDK to see a bit more about the .res file, you can also read the rescomp.txt file (in bin directory).

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Tue Feb 11, 2014 9:53 am

Stef wrote:Is car your image resource ?
I though you already got that part working.
Can you tell me how you declared you car resource ? it should be located in a .res file located in the res folder of your project. Check the "sprite" sample provided in SGDK to see a bit more about the .res file, you can also read the rescomp.txt file (in bin directory).
Yes I have the file in the res directory of the project. I'll double check things tonight. If i can't see the problem I'll zip up the project and upload it to this thread tonight to be 100% certain.

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Tue Feb 11, 2014 10:32 am

Ok well, maybe an mistake in the res definition, anyway i will see the problem when zip will be uploaded !

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Tue Feb 11, 2014 6:44 pm

Tried to create the project again and still no joy

Code: Select all

Launching tool 'Make': C:\Dev\md\sdk\bin\make  -f C:\Dev\md\sdk\makefile.gen (in C:\Users\Matt\DevWork\md\GraphicDemo)
stdout> C:/Dev/md/sdk/bin/gcc -BC:/Dev/md/sdk/bin -n -T C:/Dev/md/sdk/md.ld -nostdlib out/sega.o @out/cmd_ C:/Dev/md/sdk/lib/libmd.a C:/Dev/md/sdk/lib/libgcc.a -o out/rom.out
stderr> out/sega.o: In function `registersDump':
stderr> (.text+0x2a4): undefined reference to `registerState'
stderr> out/sega.o: In function `registersDump':
stderr> (.text+0x2aa): undefined reference to `registerState'
stderr> out/sega.o: In function `registersDump':
stderr> (.text+0x2b0): undefined reference to `registerState'
stderr> out/sega.o: In function `registersDump':
stderr> (.text+0x2b6): undefined reference to `registerState'
stderr> out/sega.o: In function `registersDump':
stderr> (.text+0
stderr> x2bc): undefined reference to `registerState'
stderr> out/sega.o:(.text+0x2c2): more undefined references to `registerState' follow
stderr> out/sega.o: In function `busAddressErrorDump':
stderr> (.text+0x308): undefined reference to `ext1State'
stderr> out/sega.o: In function `busAddressErrorDump':
stderr> (.text+0x310): undefined reference to `addrState'
stderr> out/sega.o: In function `busAddressErrorDump':
stderr> (.text+0x318): undefined reference to `ext2State'
stderr> out/sega.o: In function `busAddressErrorDump':
stderr> (.text+0x320): undefined reference to `srState'
stderr> out/sega.o: In function `busAddressErrorDump':
stderr> (.text+0x328): undefined reference to `pcState'
stderr> out/sega.o: In function `exception4WDump':
stderr> (.text+0x334): undefined reference to `srState'
stderr> out/sega.o: In function `exception4WDump':
stderr> (.text+0x33c): undefined reference to `pcState'
stderr> out/sega.o: In function `exception4WDump':
stderr> (.text+0x344): undefined reference to `ext1State'
stderr> out/sega.o: In function `exceptionDump':
stderr> (.text+0x350): undefined reference to `srState'
stderr> out/sega.o: In function `exceptionDump':
stderr> (.text+0x358): undefined reference to `pcState'
stderr> out/main.o: In function `main':
stderr> main.c:(.text+0x4): undefined reference to `car'
stderr> main.c:(.text+0x18): undefined reference to `car'
stderr> main.c:(.text+0x2a): undefined reference to `car'
stderr> main.c:(.text+0x4a): undefined reference to `car'
stderr> make: *** [out/rom.out] Error 1
Tool execution terminated with status 2
Here is the link to the project

http://www.filedropper.com/graphicdemo

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Tue Feb 11, 2014 7:25 pm

ok I didn't full understand that I needed to write my res file! I have placed one in my project containing the following line:

IMAGE car "car.bmp" -1

Code: Select all

Launching tool 'Make': C:\Dev\md\sdk\bin\make  -f C:\Dev\md\sdk\makefile.gen (in C:\Users\Matt\DevWork\md\GraphicDemo)
stdout> C:/Dev/md/sdk/bin/rescomp res/gfx.res res/gfx.s
stdout> ===============================================================================
stdout> aPLib example                   Copyright (c) 1998-2009 by Joergen Ibsen / Jibz
stdout>                                                             All Rights Reserved
stdout> 
stdout>                                                   http://www.ibsensoftware.com/
stdout> ===============================================================================
stdout> 
stdout> 
stdout> compressed 256 -> 162 bytes (100% done)
stdout> compressed 256 -> 162 bytes (63%) in 0.00 seconds
stdout> ===============================================================================
stdout> aPLib example                   Copyright (c) 1998-2009 by Joergen Ibsen / Jibz
stdout>                                                             All Rights Reserved
stdout> 
stdout>                                                   http://www.ibsensoftware.com/
stdout> ===============================================================================
stdout> 
stdout> 
stdout> compressed 16 -> 17 bytes (100% done)
stdout> compressed 16 -> 17 bytes (106%) in 0.00 seconds
stdout> rescomp v1.1
stdout> 
stdout> Resource: IMAGE car "car.bmp" -1
stdout> 
stdout> --> executing plugin IMAGE...
stdout> Executing C:\Dev\md\sdk\bin\appack c "pack.in" "pack1.out"
stdout> Packed with APLIB, original size = 256 compressed to 162 (63.2813 %)
stdout> Executing C:\Dev\md\sdk\bin\appack c "pack.in" "pack1.out"
stdout> Could not pack, original data remain (size = 16)
stdout> C:/Dev/md/sdk/bin/mkdir -p out
stdout> C:/Dev/md/sdk/bin/mkdir -p out/src
stdout> C:/Dev/md/sdk/bin/mkdir -p out/res
stdout> C:/Dev/md/sdk/bin/gcc  -m68000 -Wall -O1 -fomit-frame-pointer -fno-builtin-memset -fno-builtin-memcpy -Iinc -Isrc -Ires -IC:/Dev/md/sdk/inc -IC:/Dev/md/sdk/res -BC:/Dev/md/sdk/bin -c res/gfx.s -o out/res/gfx.o
stdout> C:/Dev/md/sdk/bin/mkdir -p out
stdout> C:/Dev/md/sdk/bin/mkdir -p out/src
stdout> C:/Dev/md/sdk/bin/mkdir -p out/res
stdout> C:/Dev/md/sdk/bin/gcc  -m68000 -Wall -O1 -fomit-frame-pointer -fno-builtin-memset -fno-builtin-memcpy -Iinc -Isrc -Ires -IC:/Dev/md/sdk/inc -IC:/Dev/md/sdk/res -BC:/Dev/md/sdk/bin -c src/main.c -o out/src/main.o
stderr> src/main.c: In function `main':
stderr> src/main.c:7: error: structure has no member named `image'
stderr> src/main.c:7: error: structure has no member named `w'
stderr> src/main.c:7: error: structure has no member named `h'
stderr> src/main.c:7: error: structure has no member named `w'
stderr> make: *** [out/src/main.o] Error 1
stdout> rm res/gfx.s
Tool execution terminated with status 2
ToDoList: Warning: No to-do types or comment symbols selected to search for, nothing to do.

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Tue Feb 11, 2014 8:36 pm

I hadn't realised I could open up the cbp files as they're pretty much just a XML project configuration file :D

I've replicated the configuration in the Sprites cbp file into my GraphicsDemo cbp file. I've got the Code:Blocks compiler working now so I no longer have to run a custom "Tools" option :D

Still getting an error however :/

Code: Select all

-------------- Build: default in GraphicDemo (compiler: Sega Genesis Compiler)---------------

Running command: make.exe -f C:\Dev\md\sdk\makefile.gen
C:/Dev/md/sdk/bin/mkdir -p out
C:/Dev/md/sdk/bin/mkdir -p out/src
C:/Dev/md/sdk/bin/mkdir -p out/res
C:/Dev/md/sdk/bin/gcc  -m68000 -Wall -O1 -fomit-frame-pointer -fno-builtin-memset -fno-builtin-memcpy -Iinc -Isrc -Ires -IC:/Dev/md/sdk/inc -IC:/Dev/md/sdk/res -BC:/Dev/md/sdk/bin -c src/main.c -o out/src/main.o
src/main.c: In function `main':
src/main.c:7: error: structure has no member named `image'
src/main.c:7: error: structure has no member named `w'
src/main.c:7: error: structure has no member named `h'
src/main.c:7: error: structure has no member named `w'
make: *** [out/src/main.o] Error 1
Process terminated with status 2 (0 minute(s), 0 second(s))
4 error(s), 0 warning(s) (0 minute(s), 0 second(s))

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Tue Feb 11, 2014 10:18 pm

Just declare your car resource as :

Code: Select all

BITMAP car "car.bmp" -1
as you are using the bitmap methods.
IMAGE type resource is for use with others methods.

Don't forget you also have these methods:

Code: Select all

u16 VDP_drawBitmap(u16 plan, const Bitmap *bitmap, u16 x, u16 y);
to directly draw your BITMAP in one shot.
Same for IMAGE with :

Code: Select all

u16 VDP_drawImage(u16 plan, const Image *image, u16 x, u16 y);

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Tue Feb 11, 2014 10:55 pm

Stef wrote:Just declare your car resource as :

Code: Select all

BITMAP car "car.bmp" -1
as you are using the bitmap methods.
IMAGE type resource is for use with others methods.

Don't forget you also have these methods:

Code: Select all

u16 VDP_drawBitmap(u16 plan, const Bitmap *bitmap, u16 x, u16 y);
to directly draw your BITMAP in one shot.
Same for IMAGE with :

Code: Select all

u16 VDP_drawImage(u16 plan, const Image *image, u16 x, u16 y);
do x and y now represent the tile position ? or the width and height?

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Tue Feb 11, 2014 11:06 pm

Digging through the .h files now and solved my own question :)

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Tue Feb 11, 2014 11:11 pm

I get a screen briefly flickering full of pixels but no image :( in a image struct what is the attribute I should be passing? I know in a bitmap it should be .image

Code: Select all

#include <genesis.h>

#include "gfx.h"
#include "music.h"

int main()
{
        // start music
        //SND_startPlay_VGM(roadrash_music);
        VDP_drawBitmap(VDP_PLAN_A, car.image, 3, 3);
        while(1)
        {
                VDP_waitVSync();
        }
        return 0;
}

Post Reply