Dark Bit Factory & Gravity
GENERAL => Challenges & Competitions => Topic started by: spitfire on October 24, 2008
-
I'm not done yet but this is my entry. I want to get this done today so I'll be complaining here about my issues and then maybe someone can help :)
http://bitworld.bitfellas.org/demo.php?id=3240
(http://kestra.exotica.org.uk/files/screenies/2000/2213.PNG)
-
Here I'll document all the stupid shit I've done. Hopefully I will learn from these if I write them down :P
1) Frigging linking errors.
I've encountered this error like 1000 times and I just never learn. In visual c++, project -> Linker "additional library diectories" must point to where the libs are, but in addition to that each lib to be used must be specified in project ->Linker -> Input "additional dependancies".
Why isn't giving the directory enough information?? The compiler can see what I use or don't use in the code can't it?
2) Sound
First I made a directx wav player, using the sample source for wav playing that comes with the DirectX sdk, DXUTSound.h/cpp which you can find in your directx directory, \Samples\C++\Common.
Then I realised the song is a mod file, so I used fmod.
FSOUND_Init(44100, 32, 0);
FMUSIC_MODULE * sawng = FMUSIC_LoadSong("8.mod");
FMUSIC_PlaySong(sawng);But the pitch was all wrong, shockwave helped me with that here.
http://dbfinteractive.com/forum/index.php?topic=3596.0 (http://dbfinteractive.com/forum/index.php?topic=3596.0)
Then I realised I was using the wrong song! (don't ask :P)
The actual song is a "future composer" file which fmod can't play. No problem, I went to the resources section and used the tiny fc replayer. It didn't play at all till I moved the "play" function call before ptc_open. No idea why.
But of course one of the rules is that all files must be part of the exe, but this lib only loads stuff from the hard drive.
So I got this updated lib from the same guy on the net, which can play from memory. http://www.vectronixhq.de/?page_id=26 (http://www.vectronixhq.de/?page_id=26)
May I suggest we replace the tiny fc player with it?
This is how I loaded song as a resource FYI
BYTE *data;
//IDR_SONG1 is just a unique integer to identify the resource. "song" is the type that I made
//when I imported the data. I think you could just say RC_DATA instead for any binary stuff.
HRSRC handle = FindResource(NULL, MAKEINTRESOURCE(IDR_SONG1), TEXT("song"));
if ( handle != NULL )
{
HGLOBAL ptr = LoadResource(NULL, handle);
if ( ptr != NULL)
{
data = (BYTE*)LockResource(ptr);
}
}
int size = sizeof(data); //doesnt work
//had to manually specify size of the song in bytes
playOSMEMusicMem(data, 19980,1);
3) Bitmaps
I was using Freeimage (http://freeimage.sourceforge.net/ (http://freeimage.sourceforge.net/)) originally to load the jpgs I had ripped from the demo. But freeimage cant be linked statically AFAICT. So I had to convert the stuff to bitmap resources and load them using WINAPI. But they were pretty huge so I changed them to 8 bit paletted. Here is the code to load paletted bitmaps as a resource. I had some trouble getting them to display right, but it was an issue of using the pitch instead of the width and multiplying by the number of bytes per pixel in some areas.
HBITMAP LoadResourceBitmap(HINSTANCE hInstance, LPSTR lpString, HPALETTE FAR* lphPalette);
HPALETTE CreateDIBPalette (LPBITMAPINFO lpbmi, LPINT lpiNumColors);
int main();
HBITMAP LoadResourceBitmap(HINSTANCE hInstance, LPSTR lpString,
HPALETTE FAR* lphPalette)
{
HRSRC hRsrc;
HGLOBAL hGlobal;
HBITMAP hBitmapFinal = NULL;
LPBITMAPINFOHEADER lpbi;
HDC hdc;
int iNumColors;
if (hRsrc = FindResource(hInstance, lpString, RT_BITMAP))
{
hGlobal = LoadResource(hInstance, hRsrc);
lpbi = (LPBITMAPINFOHEADER)LockResource(hGlobal);
hdc = GetDC(NULL);
*lphPalette = CreateDIBPalette ((LPBITMAPINFO)lpbi, &iNumColors);
if (*lphPalette)
{
SelectPalette(hdc,*lphPalette,FALSE);
RealizePalette(hdc);
}
hBitmapFinal = CreateDIBitmap(hdc,
(LPBITMAPINFOHEADER)lpbi,
(LONG)CBM_INIT,
(LPSTR)lpbi + lpbi->biSize + iNumColors * sizeof(RGBQUAD),
(LPBITMAPINFO)lpbi,
DIB_RGB_COLORS );
ReleaseDC(NULL,hdc);
UnlockResource(hGlobal);
FreeResource(hGlobal);
}
return (hBitmapFinal);
}
HPALETTE CreateDIBPalette (LPBITMAPINFO lpbmi, LPINT lpiNumColors)
{
LPBITMAPINFOHEADER lpbi;
LPLOGPALETTE lpPal;
HANDLE hLogPal;
HPALETTE hPal = NULL;
int i;
lpbi = (LPBITMAPINFOHEADER)lpbmi;
if (lpbi->biBitCount <= 8)
*lpiNumColors = (1 << lpbi->biBitCount);
else
*lpiNumColors = 0; // No palette needed for 24 BPP DIB
if (lpbi->biClrUsed > 0)
*lpiNumColors = lpbi->biClrUsed; // Use biClrUsed
if (*lpiNumColors)
{
hLogPal = GlobalAlloc (GHND, sizeof (LOGPALETTE) +
sizeof (PALETTEENTRY) * (*lpiNumColors));
lpPal = (LPLOGPALETTE) GlobalLock (hLogPal);
lpPal->palVersion = 0x300;
lpPal->palNumEntries = *lpiNumColors;
for (i = 0; i < *lpiNumColors; i++)
{
lpPal->palPalEntry[i].peRed = lpbmi->bmiColors[i].rgbRed;
lpPal->palPalEntry[i].peGreen = lpbmi->bmiColors[i].rgbGreen;
lpPal->palPalEntry[i].peBlue = lpbmi->bmiColors[i].rgbBlue;
lpPal->palPalEntry[i].peFlags = 0;
}
hPal = CreatePalette (lpPal);
GlobalUnlock (hLogPal);
GlobalFree (hLogPal);
}
return hPal;
}
int main()
{
HPALETTE hPalette;
HBITMAP file = LoadResourceBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP1), &hPalette);
BITMAP bmp;
GetObject( file, sizeof(bmp), &bmp);
width = bmp.bmWidth;
height = bmp.bmHeight;
bpp = bmp.bmBitsPixel;
pitch = bmp.bmWidthBytes/ (bpp/8);
if ( data != NULL) delete data;
data = new unsigned int[ height*pitch];
GetBitmapBits( file, height * pitch * 4, data );
DeleteObject( file );
// data is the 32 bit image array now ready for blitting
}
4) resolution
This is what I'm about to do, the original is 320x200 (I think). The rules specified 640x480 as the minimum so Ill just draw each pixel as 4 blocks and adjust a bit here and there. Also have to code a fullscreen thingy.
5) Font. Gonna have to build up a font image by copy pasting each character from screenshots. Getting the text will b easy though as explained in the help thread.
6) Demo
and here I get to actually start coding the demo. Not much to it though. Just got to get the sine pattern right and make the text transition effect.
-
TinyFC can replay from memory... you can replace it with the OSME engine or the SC68 engine (if you have the song ripped and packed with its replay routine).
However, regarding the graphics... what you do seem over-complicated to me. Why not just save your image as RAW data?? you can do it with free tools such as XnView. Otherwise Photoshop or Paintshop Pro can handle that as well. Then convert your RAW file as an array of bytes in your source code and load it from there into your bitmap objects/textures/etc...
sorry, I hate the whole resource management available in the Win32 API...
-
BTW, this demo/intro uses the full PAL resolution (720x568).
Using a 640x480 resolution will crop parts of the screen. It's better to use a 800x600 resolution here in order to have the full image displayed
-
Stormbringer has given you good advice about this one, the intro you are remaking is a really good one Spitfire, there are no Addonic intros at Retro-Remakes and this will be a fine addition when it's one-filed.
As for loading graphics, 8 bit pictures resourced into your exe will pack down nicely. :)
-
TinyFC can replay from memory
fcuk! I thought it couldn't, for some reason I now notice the inMem parameters :<. Maybe I should change back to tinyfc for size, but I'm too time constrained now.
sorry, I hate the whole resource management available in the Win32 API...
Trust me you are not alone in this regard :)
Ok so yesterday something came up so I didn't make any progress. Today is the day!
Todo:
1) font. The scroller text is nowhere in memroy or the exe, its probably compressed or encrypted somehow but my archivers wont open it. I'll have to type it all out :(
2) Okay so I have to go to 800x600 then :/ Still have to sort out the update in fullscreen function.
3) Rerip the gfx cuz I didnt do it properly first time.
4) make some alpha blending thing for the edges of the logo. Texture map the rotating background. Make the random pixels text fading thingy.
-
the text is a little bit modified ;)
original text address : $23a3c
text routine :
lea $23a3c,a3
move.b (a3)+,d4
not.b d4
do the same thing with the text :
move.b (a3),d0
not.b d0
move.b d0,(a3)
tabchar :
abcdefghijklmnopqrstuvwxyz1234567890-.:+^,!?><()
here is the text :
a d d o n i c p r e s e n t s
their newest intro.........
contact addonic :
addonic
postfach 291
4125 riehen 1 switzerland
----------------------------------------
or,
(no name)
plk 049830-c
w-7858 weil am rhein
united germany
----------------------------------------
(no name)
plk 172929-e
w-7800 freiburg
united germany
----------------------------------------
call soon our board...
crashpoint bbs
sysop: devil (!!!)
----------------------------------------
greets to our worshipped contacts..
abandon
alcatraz
amaze
anarchy
analog
aofcf
arcane
axis
cinefex design
cristal
cryptoburners
cytax
d-tect
dexion
elite inc.
euphoria
flash productions
frantic
fraxion
image
l.s.d.
legend
level four
magnatic fields
moses / ex-setrox
mystix
next
possessed
razor 1911
rebels
savage
s.i.c.a.
spreadpoint
synergy
tristar
ufo
vertigo
visitech
zero defects
------------------------------------
-
gfx (original size and colors) :
background : 640x384 8 colors (the second half start at line 12)
logo : 320x92 32 colors
credits : 320x6 4 colors
font : 400x15 4 colors
-
thanks hellsangel! have some Karma here ;)
-
Yep :)
-
Gah just after I had typed it all out :P But thanks anyway yours is probably more accurate.
How did you get the font?
So the text bits were inverted? How did you find that out, and the memory address of the text?
-
! courageous to retype all the text :xmas:
for all the questions, I disassembled the program after unpacked : I use megamon, a desassembler/debugger. When I have all addresses of gfx, text,... I can rip them with megamon and my fav gfx ripper 3rdday, and for the text, I "coded" directly in memory the "decrypter".
the text is just at the start of the program:
"bra StartIntro
dc.b '...' ; text
...
StartIntro:
... ; code
"
for the whole program, I disassemble it with IDA (Interactive Disassembler) under Windows. (shame on me, I dont use ReSource on Amiga :whack: )
-
Okay well I've missed the deadline, but I worked too hard to not submit it :P
I still have some innacuracies to sort out but please let me know if it crashes.
-
work fine (XP and Vista) !
great (I missed to rip the pattern for the random pixels text fading, but not needed !)
LMB to exit missing
-
Good remake!
Quality is fine here. :)
Sorry that you missed the deadline, but thank you for supporting Retro Remakes. It's really nice to have another group to add to the list!
-
Works fine here, no crashes or weirdness.
Very smooth :)
-
works very fine here as well. It would be good to add the left mouse button to exit... and I guess it can be uploaded to the collection.
Sorry that you missed the deadline, but the result is really accurate as far as I can see.
I just hope that you will work on more remakes in the near future ;)
-
Ok I made some minor tweaks to things that were bugging me. Theres still some stuff thats not right but I think its pointless to continue:
I added lmb close and fixed the text fading.
Timing of text and sine movement still isn't accurate but close enough.
One thing I'm confused about, is that there is this funny chinese character in one of the demo groups names (Moses # ex-setrox), but the fontmap that hellsangel ripped didnt have it in ( added it of course). Does that mean he made that font bitmap manually and just missed the character? I thought it was taken directly from memory.
-
A Valliant effort there Spitfire dude, like the pixel tranisition on the text.
-
Good remake!
Quality is fine here. :)
Sorry that you missed the deadline, but thank you for supporting Retro Remakes. It's really nice to have another group to add to the list!
I agree what is essentially being done here is conversion to a new format so these demos may be enjoyed. Thanks for the nice addition.
-
One thing I'm confused about, is that there is this funny chinese character in one of the demo groups names (Moses # ex-setrox), but the fontmap that hellsangel ripped didnt have it in ( added it of course). Does that mean he made that font bitmap manually and just missed the character? I thought it was taken directly from memory.
no, this character is not in the original font (not made manually! the font is like that in memory), no more in the Characters Table : "abcdefghijklmnopqrstuvwxyz1234567890-.:+^,!?><() "
the text is "Moses / ex-setrox". The "/" is missing.
I'll take a look at the source to see what the program do with the "/"
Edit : so, it's not a "funny chinese character" but a funny bug ^^
no test is done if a char is not in the table => the char address is the second bitplan of the font bitmap (char "A").
see the screenshot of the font in memory
-
OIC, interesting - well at least I'm true to the original without crashing the system.
I should probably learn to use that utility :P
-
Very sweet prod spitfire. Awesome catchy music too! Razor sounds always good, wow :)
Btw, crashes when it is about to exit. Memleaks there?
-
ja mousedown implemented in a dodgy way.. shouldnt happen if u push esc. try?
-
You are right it doesn't happen when you exit using esc!
EDIT: it just crashes when I don't do anything and the music stops
-
ok will have a look into it sometime, but its exam time now :(
-
Yop, sounds like a memory leak.