Graphics Replacement in DSB

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Graphics Replacement in DSB

Post by Sophia »

Responding to a question that came up in chat but was too long to explain there...

In DSB, there are actually two ways to replace most graphics:
  1. Have a bitmap of the same name as an existing graphic
  2. Load something different to its entry in the gfx table.
For example, in this line:

Code: Select all

gfx.alcove_vi_front = dsb_get_bitmap("VI_FRONT")
The Vi alcove's front image can be replaced by placing a new vi_front.bmp (or .png, .pcx, etc.) image in the dungeon's folder. The first method works because DSB searches loose images in the dungeon folder, then that dungeon's graphics.dsb, and only searches the base graphics.dat last. You can also replace images by writing a new line of code to load a different image to gfx.alcove_vi_front, such as:

Code: Select all

gfx.alcove_vi_front = dsb_get_bitmap("NEW_VI_FRONT")
However, there are some images whose names are "Hardcoded" in the engine. They aren't loaded by the Lua code at all because they are drawn by the system. This means they cannot be replaced using the second method, however, they can still be replaced by placing an image of the proper name in the dungeon's folder. These images are the following:

:arrow: CONTROL_BACKGROUND = the background for the brown GUI boxes (for saving and loading etc.)
:arrow: CONTROL_LONG = a long GUI button
:arrow: CONTROL_SHORT = a short GUI button
:arrow: PTRARROW = the yellow arrow mouse pointer
:arrow: PTRHAND = the mouse "hand" pointer
:arrow: OPTION_RES = a 232x146 image offering resurrection (only)
:arrow: OPTION_REI = a 232x146 image offering reincarnation (only)
:arrow: OPTION_RES_REI = a 232x146 image offering resurrection and reincarnation
:arrow: REI_NAMEENTRY = a 240x146 image where you enter the name of your reincarnated champion

EDIT: Formerly hardcoded images that can now be changed by the normal Lua means
:!: BAR_DAMAGE = an 86x42 image, consisting of three 86x14 sections (gfx.damage_bar)
:!: FULL_DAMAGE = an 64x174 image, consisting of three 64x58 sections (gfx.damage_full)
:!: BOX_BOOST = a 36x36 green outline box (gfx.box_boost)
:!: BOX_HURT = a 36x36 red outline box (gfx.box_hurt)
:!: BOX_SEL = a 36x36 cyan outline box (gfx.box_sel)
:!: DAMAGE = a 176x90 jagged cyan explosion showing weapon damage (gfx.monster_damage)
:!: INVENTORY = the inventory background image (gfx.inventory_background)
:!: TOP_HANDS = the 134x58 image for the top of the screen showing the champion's hands (gfx.top_hands)
:!: TOP_PORT = the 134x58 background image where a champion's portrait goes (gfx.top_port)
:!: TOP_DEAD = the 134x58 skull and crossbones image when a champion is dead (gfx.top_dead)

So, for example, to replace the yellow mouse pointer with the Atari ST's cyan pointer, simply place an image of the cyan pointer (with a power pink background) in the dungeon's folder as ptrarrow.bmp (or .png, .pcx, etc.) and DSB will automatically load the image.

All of these images can be extracted by opening graphics.dat in the Allegro grabber, in case anyone is interested.
User avatar
Qwerty
Apprentice
Posts: 55
Joined: Sun Aug 30, 2009 6:21 am

Re: Graphics Replacement in DSB

Post by Qwerty »

Thank you the answer ,Sophia!!
It is very useful.But I have not understood the usage of Allegro yet. :(
Therefore, I will get and study the usage of Allegro.
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Graphics Replacement in DSB

Post by Sophia »

Qwerty wrote:But I have not understood the usage of Allegro yet. :(
Therefore, I will get and study the usage of Allegro.
You don't really have to understand Allegro, as such, just the Grabber, which is a program used by (and comes with) Allegro to construct data files in a format Allegro can use. It has a rather ugly interface, but it suffices for most things. :)
User avatar
Qwerty
Apprentice
Posts: 55
Joined: Sun Aug 30, 2009 6:21 am

Re: Graphics Replacement in DSB

Post by Qwerty »

I've replaced most of vanila images and sounds by your first way.
However, when I try to compiling,
"segmentation_fault" is sometimes happened.

This is the LOG.TXT.

Code: Select all

INIT: Parsing configuration file
INIT: Using gamedir C:\DSB37b\SNES (base:0)
INIT: Using color depth of 32
INIT: Starting FMOD
INIT: Triple buffering unavailable or disabled.
LUA: Lua initialized
Parsing base/global.lua
Parsing base/graphics.lua
Parsing base/inventory_info.lua
Parsing base/util.lua
Parsing base/triggers.lua
Parsing base/conditions.lua
Parsing base/monster.lua
Parsing base/monster_ai.lua
Parsing base/methods.lua
Parsing base/damage.lua
Parsing base/xp.lua
Parsing base/magic.lua
Parsing base/msg_handlers.lua
Parsing base/hooks.lua
Parsing base/system.lua
Parsing base/render.lua
Parsing base/startup.lua
Parsing C:\DSB37b\SNES/startup.lua
Parsing base/objects.lua
OBJ: 401 system archs
Parsing C:\DSB37b\SNES/objects.lua
OBJ: 403 total archs
DUNGEON: Attempting to compile
Parsing C:\DSB37b\SNES/dungeon.lua
PROGRAM CRASH!
Location: 0 1 3
Reason: Segmentation Fault
Stack Dump:
DSBmain
write_dsbgraphics
compile_dsbgraphics
write_file(PTRHAND)
write_bin
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Graphics Replacement in DSB

Post by Sophia »

The crash happens when DSB tries to save your new PTRHAND image into graphics.dsb. I've tested things and I've been able to do that successfully, so now it's a bit mysterious what is wrong.

Here is a new version of the program exe. Please use this exe instead of the DSB.exe that was in 0.37b; it may fix the problem. If not, it will at least output more debugging information, so maybe we can figure out what's wrong:
http://www.ojnk.net/dm/dsb/DSBdebug3727.zip
User avatar
Qwerty
Apprentice
Posts: 55
Joined: Sun Aug 30, 2009 6:21 am

Re: Graphics Replacement in DSB

Post by Qwerty »

I've tested the compile by using "DSBdebug3272".
unfortunately, the same problem has occurred. :cry:
I'll report it.

Code: Select all

@@@ DEBUG VERSION 0.37.27
INIT: Parsing configuration file
INIT: Using gamedir C:\DSB37b\SNES (base:0)
INIT: Using color depth of 32
INIT: Starting FMOD
INIT: Triple buffering unavailable or disabled.
LUA: Lua initialized
Parsing base/global.lua
Parsing base/graphics.lua
Parsing base/inventory_info.lua
Parsing base/util.lua
Parsing base/triggers.lua
Parsing base/conditions.lua
Parsing base/monster.lua
Parsing base/monster_ai.lua
Parsing base/methods.lua
Parsing base/damage.lua
Parsing base/xp.lua
Parsing base/magic.lua
Parsing base/msg_handlers.lua
Parsing base/hooks.lua
Parsing base/system.lua
Parsing base/render.lua
Parsing base/startup.lua
Parsing C:\DSB37b\SNES/startup.lua
Parsing base/objects.lua
OBJ: 401 system archs
Parsing C:\DSB37b\SNES/objects.lua
OBJ: 403 total archs
DUNGEON: Attempting to compile
Parsing C:\DSB37b\SNES/dungeon.lua
PROGRAM CRASH!
Location: 0 1 3
Reason: Segmentation Fault
Stack Dump:
DSBmain
write_dsbgraphics
compile_dsbgraphics
write_file(DAMAGE)
write_bin(C:\DSB37b\SNES/DAMAGE.pcx)
write_bin_data(8ffcf20, 5188, 0)
this "segmentation-falut" problem is to be occured by not only my data but also your "test_dungeon" data.
Additionally, This problem is not without fail, and occasionally occured.

I think that it's a very mysterious thing of this.
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Graphics Replacement in DSB

Post by Sophia »

When DSB compiles a graphics.dsb, it creates and uses some temporary files. From your debugging information I have been able to figure out that this error is caused by DSB being unable to open the needed temporary files. So, I think the problem may not be with DSB, but something with your computer. I think this especially because the test_dungeon also has problems. So, I wonder, is your hard drive or temporary file folder very full, or do you have a lot of files open, or something else that could be creating this problem? Unfortunately, there isn't much I can do in DSB other than make it fail more gracefully, which I will do...
User avatar
Qwerty
Apprentice
Posts: 55
Joined: Sun Aug 30, 2009 6:21 am

Re: Graphics Replacement in DSB

Post by Qwerty »

Ooh, I am ashamed though my computer has the cause. :oops:
Thank you for your cooperation.
User avatar
Adamo
Italodance spammer
Posts: 1534
Joined: Fri Apr 22, 2005 11:59 am
Location: Poland
Contact:

Re: Graphics Replacement in DSB

Post by Adamo »

What is the password to "graphics2.dat"?
Spoiler
(\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/)
Spoiler
(@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@)
Spoiler
(>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<)
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Graphics Replacement in DSB

Post by Sophia »

There is no password.
For some reason, the Allegro grabber just has a problem recognizing it. :(
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Graphics Replacement in DSB

Post by Gambit37 »

Can I install this Grabber as a standalone tool, or do I need to install Allegro? When can I find it? I found some odd tool called Grabber, but it's dated 2005 and doesn't let you export things all in one go, or even with the right palette. Is this the right tool? Seems highly clunky!

What's in "graphics2.dat"?
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Graphics Replacement in DSB

Post by Sophia »

It is highly clunky.
Rather than messing around with extracting the images, just download and use this file.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Graphics Replacement in DSB

Post by Gambit37 »

I tried replacing PTRARROW with a 32-bit PNG -- the alpha channel is not respected and instead I get junk drawn around it.
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Graphics Replacement in DSB

Post by Sophia »

Oops. I'll fix this. :)
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Graphics Replacement in DSB

Post by Gambit37 »

Thanks. OK, some more graphics replacement questions:

1) How can I draw a fullscreen bitmap behind the interface that stays there all the time? IE, a background image.
2) How do I change the health/stamina/mana bars to use bitmaps?
3) Can I override the inventory panel displayed when you put an item in hand or click it on the eye? I'd like for some items to display a special bitmap in that food/water panel area instead of the normal description/icon.
4) How can I make the food/water bars draw parts of a specially designed bitmap instead of just coloured bars?
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Graphics Replacement in DSB

Post by Sophia »

Gambit37 wrote:How can I draw a fullscreen bitmap behind the interface that stays there all the time? IE, a background image.
At present, you can't, really. This would be a good thing to add!
Gambit37 wrote:How do I change the health/stamina/mana bars to use bitmaps?
Another one that at present is not possible. If I'm doing this I probably should just go ahead and include support for an RTC-style player color bitmap, too.
Gambit37 wrote:Can I override the inventory panel displayed when you put an item in hand or click it on the eye? I'd like for some items to display a special bitmap in that food/water panel area instead of the normal description/icon.
Yes, you can use a subrenderer. See the wiki for documentation, or check out the examples provided in the test_dungeon, especially the money box. The base code's implementation of chests and scrolls may also help you.
Gambit37 wrote:How can I make the food/water bars draw parts of a specially designed bitmap instead of just coloured bars?
You can just override sys_render_mainsub and pass the drawing functions a bitmap instead of a color. See this thread:
http://www.dungeon-master.com/forum/vie ... 53&t=29164
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Graphics Replacement in DSB

Post by Gambit37 »

Aw, bum, I was hoping to fully port my RTC interface over. I can wait though :D

Sub-renderers sound fun, I need to check me out some of that wiki goodness ;-)
Mon Ful Ir
Adept
Posts: 221
Joined: Sat Jan 07, 2006 1:54 am
Location: Britain

Re: Graphics Replacement in DSB

Post by Mon Ful Ir »

You'll find an example of a custom sub-renderer in my code library too.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Graphics Replacement in DSB

Post by Gambit37 »

Oooh, thanks. Where's your code library? Is it in your dungeon with all the monsters in it?
Mon Ful Ir
Adept
Posts: 221
Joined: Sat Jan 07, 2006 1:54 am
Location: Britain

Re: Graphics Replacement in DSB

Post by Mon Ful Ir »

Aye. There's a DM2-style bag in it.

In mfi_dungeon, go to objects.lua and scroll down past all the monsters. Starting at line 2375 there's a list of "things", and the bag's the first one. I'll put the code here for you:-

Code: Select all

obj.bag = clone_arch(obj.chest, {
	name="BAG",
	mass=35,
	icon=gfx.thing_icon_bag_closed,
	alt_icon=gfx.thing_icon_bag_open,
	dungeon=gfx.thing_dungeon_bag,
	inside_gfx=gfx.thing_subrenderer_bag
} )
You have to get the image size right or it doesn't work. I had to work out the correct subrenderer size by trial and error; it seems to be 246 x 146.

Err, Gambit37 will probably be able to follow that, but for anyone who might read this while learning DSB, the sizes are as follows:- THING_DUNGEON_BAG.png is 96 x 54. The two icons must be 32 x 32, and THING_SUBRENDERER_BAG is 246 x 146.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Graphics Replacement in DSB

Post by Gambit37 »

Finally getting around to porting my RTC interface over to DSB. A few differences and problems, I think I worked out how to handle most of them, but this one is puzzling:

* GUY_ICONS (party order guys) does not seem overridable? I put a PNG version in the root of my dungeon folder, but nothing changed. I noticed it's not listed above in your hard-coded list? Is it possible to override this? (I got the name of it from the DSB graphics zip you supplied)
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Graphics Replacement in DSB

Post by Sophia »

I misnamed it in the zip. It's called HERO_ICONS.
A png should work, but note that it must be a 256 color PNG: color index 0 is used as the mask for coloring the characters. The background should be power pink as normal, and the color index doesn't matter.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Graphics Replacement in DSB

Post by Gambit37 »

Hmm, this doesn't seem to work. A PNG (with the correct 8-bit palette you described) displays in the wrong colours or entirely as black. I can however get a PCX to display in the right palette, but it has some junk drawn over the last rotated icon? (IE, the one that points left) Doesn't matter which colour is pointing left, it will have junk over it)

EDIT: I can confirm that the PCX works correctly IF you don't use custom champion colours. When I activate the custom champion colour bitmaps, there is junk drawn over the PCX, see here:

Image
User avatar
zoom
Grand Master
Posts: 1819
Joined: Tue Sep 23, 2003 1:27 am
Location: far away but close enough

Re: Graphics Replacement in DSB

Post by zoom »

Sidenote:Can DSB display animated gif´s? (or use some other form of animations)
(I read sth. about monster animations for DM2??, but can´t remember too good, really.)

if "yes":

dm2-items ency

--> Image

there is however this - well.. - ongoing repetition. :shock:




DSB could take one animation out of a pool of animations and play it, then pick another one out of the pool
A pool for the green potion could contain three animations:
strong shaking(9 Frames), medium shaking(4 Frames) and almost no shaking (5 frames)
total randomness would break the animation

Effectively alternating the graphics used - on the fly -


some thoughts :
(too much item-animation is disturbing; although animated items is quite cool!
--> maybe slow it down? decrease frequency?)

Probably is one gif with all these alternations incorporated doing enough change? Would bloat up file size, however.
-------------------------------------------------------
-------------------------------------------------------


super cool would be to have the potions kind of animate while they are fresh,like effervescents and turn to a static picture after time (or if they aren´t put somewhere else.)

else: nevermind ;)
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Graphics Replacement in DSB

Post by Gambit37 »

DSB can animate anything, super smoothly, at high speed, totally independently of the game clock. You can do whatever you want :-)
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Graphics Replacement in DSB

Post by Sophia »

Gambit37 wrote:Hmm, this doesn't seem to work. A PNG (with the correct 8-bit palette you described) displays in the wrong colours or entirely as black. I can however get a PCX to display in the right palette, but it has some junk drawn over the last rotated icon? (IE, the one that points left) Doesn't matter which colour is pointing left, it will have junk over it)
I didn't write the code to load PNG images in DSB, so I'm not really sure why it doesn't work.
However, since you found a method that actually works, I'm not going to bother digging into it.

I will, however, fix the glitchiness with the images. :)
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Graphics Replacement in DSB

Post by Gambit37 »

Cool, thanks :-) Only the final result is important, so I don't mind too much how I get there :-)
User avatar
zoom
Grand Master
Posts: 1819
Joined: Tue Sep 23, 2003 1:27 am
Location: far away but close enough

Re: Graphics Replacement in DSB

Post by zoom »

alright, thanks! :O
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Graphics Replacement in DSB

Post by Gambit37 »

Just started trying out a replacement ICONGRID.PNG using 24-bit + Alpha. The alpha is not respected, all items are drawn with a white background. And when recoloured (such as a weapon in hand shown all black), you just see a black square. This is a pretty major problem for me, can it be fixed?
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Graphics Replacement in DSB

Post by Sophia »

That's not what's supposed to happen, obviously.
Please email me your icongrid and I should be able to sort it out. :)
Post Reply