1
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Quote
No, I'm right. It writes ecx dwords not ecx bytes.
Jim
Code: [Select]mov eax,dword ptr[TC]This says
mov ecx, [slice]
mov edi, [PP]
rep stosd
move the colour into register eax
move the number of pixels into ecx
move the address of the first pixel to fill into edi
do it - copy eax to edi for ecx times.
It's equivalent to the C codeCode: [Select]for (int i = 0; i < ecx; i++)
*edi++ = eax;
Jim

Hum... I've made the changes. And it's running at same speed!
But I've cleaned the code -> I was still using StartDrawing() and StopDrawing() before each call of linerout, coz I was testing the speed between my rout and LineXY()...
Damn it runs now at 60FPS on my PC!!!
Global s$
; Constantes
#WINTITLE = "E-Swat - Replicants Remake"
#WINHEIGHT = 480 ; Impossible de faire du 320x200, résolution minimale 640x480
#WINWIDTH = 640
#BPP = 32
#SPRH = 16
#SPRW = 16
;Declaration procedure
Declare PrintTransparentSprite(IdSprite, x, y , r, g, b)
Declare getLetterPos(caractere$)
Declare getFonts(IdSprite, x, y, w, h, num, r, g, b)
Declare ErrorWindowCreation()
Declare Anim(fullscreen.b)
Declare PrintTextWindows(text$)
;Include text
;XIncludeFile "Payload.pbi" ; crack message
;
; 8x8
; DC.B ' ---------------- '
; DC.B ' -THE REPLICANTS- '
; DC.B ' ---------------- ',$00
; DC.B ' PRESENTS: - ESWAT + - '
; DC.B ' '
; DC.B 'GREETZ TO : AVB,NEXT,AUTOMATION,TMB '
; DC.B 'THE POMPEY PIRATES,PHALANX,ALLIANCE,BB, '
; DC.B 'DELIGHT,FOF,TLB,TDI,QUARTET,HTL,MCA, '
; DC.B 'THOR,MAD VISION,INNER CIRCLE,TSG... ',$00
; DC.B ' '
; DC.B 'MEGA THANX TO THE BWK FOR DIS LOGO... ',$00
; DC.B ' BASH ',$27,'T',$27,' FOR TRAINER ',$FF
;
s$ = " ---------------- " + Chr(10) + Chr(13)
s$ = s$ + " -THE REPLICANTS- " + Chr(10) + Chr(13)
s$ = s$ + " ---------------- " + Chr(10) + Chr(13) + Chr(10) + Chr(13)
s$ = s$ + " PRESENTS: - ESWAT + - " + Chr(10) + Chr(13) + Chr(10) + Chr(13)
s$ = s$ + "GREETZ TO : AVB,NEXT,AUTOMATION,TMB " + Chr(10) + Chr(13)
s$ = s$ + "THE POMPEY PIRATES,PHALANX,ALLIANCE,BB, " + Chr(10) + Chr(13)
s$ = s$ + "DELIGHT,FOF,TLB,TDI,QUARTET,HTL,MCA, " + Chr(10) + Chr(13)
s$ = s$ + "THOR,MAD VISION,INNER CIRCLE,TSG... " + Chr(10) + Chr(13) + Chr(10) + Chr(13)
s$ = s$ + "MEGA THANX TO THE BWK FOR DIS LOGO... " + Chr(10) + Chr(13) + Chr(10) + Chr(13)
s$ = s$ + " BASH 'T' FOR TRAINER " + Chr(10) + Chr(13)
; print a sprites
Procedure PrintTransparentSprite(IdSprite, x, y, r, g, b)
TransparentSpriteColor(IdSprite, RGB(r,g,b))
DisplayTransparentSprite(IdSprite, x, y)
EndProcedure
; give the position of caractere$ in alpha variable.
; parameters:
; In :
; - caractere$ : a char to find in a array which synchronized with letter on a bitmap fonts
; Out :
; - an integer which returns the good position if the char exist else 0 but here 0 is space.
Procedure getLetterPos(caractere$)
alpha$ = " !" + Chr(34) + " '()*+,-. 0123456789:; = ? ABCDEFG"
alpha$ = alpha$ + "HIJKLMNOPQRSTUVWXYZ"
length = Len(alpha$);
i = 1;
While (Mid(alpha$, i, 1) <> Mid(caractere$, 1, 1) And i <= length)
i = i + 1
Wend
If i > length
ProcedureReturn 0
EndIf
ProcedureReturn i;
EndProcedure
; take the good bitmap char in a sprite picture. Before num computed by getLetterPos
; parameters :
; In :
; - IdSprite : sprite handle which contains bitmap fonts
; - x,y : letter position in pixel in a pic
; - w,h : width, height in pixel for a letter
; - num : logic letter position in a pic
; - r,g,b : transparency color for sprite
; Out:
;
Procedure getFonts(IdSprite, x, y, w, h, num, r, g, b)
fontsW = SpriteWidth(IdSprite) ; [!] Just take with sprite width
; ClipSprite(IdSprite, #PB_Default, #PB_Default, #PB_Default, #PB_Default)
; reinit original sprite size after clipping
posX = (num-1) % ((fontsW / w))
posY = (num-1) / ((fontsW / w))
srcX = (posX) * w
srcY = (posY) * h
srcH = h
srcW = w
ClipSprite(IdSprite, srcX, srcY, srcW, srcH)
PrintTransparentSprite(IdSprite, x, y, r, g, b)
ClipSprite(IdSprite, #PB_Default, #PB_Default, #PB_Default, #PB_Default)
EndProcedure
; Generic Error function.
Procedure ErrorWindowCreation()
MessageRequester("Error", "This is fucked up, I can't create the window", 0)
End
EndProcedure
; Animatation routine
; In:
; - fullscreen.b : create an animation in fullscreen mode or not. Two state: 0/false -> windowed mode, 1/true -> fullscreen
: Out:
;
Procedure Anim(fullscreen.b)
;Init subsystem and the windows with fullscreen or not
InitSprite()
InitKeyboard()
If fullscreen
If OpenScreen(#WINWIDTH, #WINHEIGHT, #BPP, #WINTITLE) = 0
ErrorWindowCreation()
EndIf
Else
If OpenWindow(1337,0,0,#WINWIDTH, #WINHEIGHT, #WINTITLE, #PB_Window_BorderLess | #PB_Window_ScreenCentered)
If Not OpenWindowedScreen(WindowID(1337), 0, 0, #WINWIDTH, #WINHEIGHT, 1, 0, 0)
ErrorWindowCreation()
EndIf
Else
ErrorWindowCreation()
EndIf
EndIf
;Animation
Result = CatchSprite(0, ?fontsReps, #PB_Sprite_Texture)
Result = CatchSprite(1, ?logoReps, #PB_Sprite_Texture)
Result = CreateImage(12, #WINWIDTH, #WINHEIGHT,#BPP)
ClearScreen(0)
Repeat
xpad = 0
ypad = 0
StartDrawing(ImageOutput(12))
For i = 1 To Len(s$) Step 1
car$ = Mid(s$, i , 1)
Select car$
Case Chr(10)
ypad = ypad + #SPRH
Case Chr(13)
xpad = 0
Default
getFonts(0,xpad, ypad+156, #SPRW, #SPRH, getLetterPos(car$), 0, 0, 0)
xpad = xpad + #SPRW
EndSelect
Next i
PrintTransparentSprite(1, 0, 0, 0, 0, 0)
StopDrawing()
; ClearScreen(0)
StartDrawing(ScreenOutput())
DrawImage(ImageID(12),0,100,640,480) ; On my pb linux version this code print at x = 0, y = 0, image height = 100 but !!! On the doc, it's drawimage(Id, x, y, w, h) so x = 0, y = 100 and image height= 480 and width = 640....
StopDrawing() ; It's really obvious !!!! :'(
FlipBuffers()
If fullscreen = 0
Event = WaitWindowEvent(0)
EndIf
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape) Or KeyboardPushed(#PB_Key_Space) Or KeyboardPushed(#PB_Key_T)
EndProcedure
; Init the question for fullscreen or windowed mode. After selection the button, the animation will be in a good screen mode
; In :
; - text$ : Is the message for MessageBox
; Out :
;
Procedure PrintTextWindows(text$)
Result = MessageRequester(#WINTITLE, text$,#PB_MessageRequester_YesNoCancel)
Select Result
Case #PB_MessageRequester_Yes
Anim(#True)
Case #PB_MessageRequester_No
Anim(#False)
EndSelect
EndProcedure
;!!!!! Begin !!!!!
PrintTextWindows("Credits : Jace, Padman, StormBringer !!! and you ;o)"+ Chr(10) + Chr(13) + "Do you want Fullscreen ? :)")
End ; va!n advice
;!!!!! End !!!!!
DataSection
fontsReps: IncludeBinary("eswatfonts.bmp")
logoReps: IncludeBinary("eswatlogo.bmp")
EndDataSection
; IDE Options = PureBasic 4.51 (Linux - x86)
; CursorPosition = 196
; FirstLine = 158
; Folding = -
; EnableXP
...
; ClearScreen(0)
StartDrawing(ScreenOutput())
DrawImage(ImageID(12),0,100,640,480) ; On my pb linux version this code print at x = 0, y = 0, image height = 100 but !!! On the doc, it's drawimage(Id, x, y, w, h) so x = 0, y = 100 and image height= 480 and width = 640....
StopDrawing() ; It's really obvious !!!! :'(
FlipBuffers()
If fullscreen = 0
Event = WaitWindowEvent(0)
EndIf
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape) Or KeyboardPushed(#PB_Key_Space) Or KeyboardPushed(#PB_Key_T)
...
Global s$
; Constants
#WINTITLE = "E-Swat - Replicants Remake"
#WINHEIGHT = 480
#WINWIDTH = 640
#BPP = 32
#SPRH = 16 ; sprite height
#SPRW = 16; " " width
;Declaration procedure
Declare PrintTransparentSprite(IdSprite, x, y , r, g, b)
Declare getLetterPos(caractere$)
Declare getFonts(IdSprite, x, y, w, h, num, r, g, b)
Declare ErrorWindowCreation()
Declare Anim(fullscreen.b)
Declare PrintTextWindows(text$)
;
; 8x8
; DC.B ' ---------------- '
; DC.B ' -THE REPLICANTS- '
; DC.B ' ---------------- ',$00
; DC.B ' PRESENTS: - ESWAT + - '
; DC.B ' '
; DC.B 'GREETZ TO : AVB,NEXT,AUTOMATION,TMB '
; DC.B 'THE POMPEY PIRATES,PHALANX,ALLIANCE,BB, '
; DC.B 'DELIGHT,FOF,TLB,TDI,QUARTET,HTL,MCA, '
; DC.B 'THOR,MAD VISION,INNER CIRCLE,TSG... ',$00
; DC.B ' '
; DC.B 'MEGA THANX TO THE BWK FOR DIS LOGO... ',$00
; DC.B ' BASH ',$27,'T',$27,' FOR TRAINER ',$FF
;
s$ = " ---------------- " + Chr(10) + Chr(13)
s$ = s$ + " -THE REPLICANTS- " + Chr(10) + Chr(13)
s$ = s$ + " ---------------- " + Chr(10) + Chr(13) + Chr(10) + Chr(13)
s$ = s$ + " PRESENTS: - ESWAT + - " + Chr(10) + Chr(13) + Chr(10) + Chr(13)
s$ = s$ + "GREETZ TO : AVB,NEXT,AUTOMATION,TMB " + Chr(10) + Chr(13)
s$ = s$ + "THE POMPEY PIRATES,PHALANX,ALLIANCE,BB, " + Chr(10) + Chr(13)
s$ = s$ + "DELIGHT,FOF,TLB,TDI,QUARTET,HTL,MCA, " + Chr(10) + Chr(13)
s$ = s$ + "THOR,MAD VISION,INNER CIRCLE,TSG... " + Chr(10) + Chr(13) + Chr(10) + Chr(13)
s$ = s$ + "MEGA THANX TO THE BWK FOR DIS LOGO... " + Chr(10) + Chr(13) + Chr(10) + Chr(13)
s$ = s$ + " BASH 'T' FOR TRAINER " + Chr(10) + Chr(13)
; print a sprites
Procedure PrintTransparentSprite(IdSprite, x, y, r, g, b)
TransparentSpriteColor(IdSprite, RGB(r,g,b))
DisplayTransparentSprite(IdSprite, x, y)
EndProcedure
; give the position of caractere$ in alpha variable.
; parameters:
; In :
; - caractere$ : a char to find in a array which synchronized with letter on a bitmap fonts
; Out :
; - an integer which returns the good position if the char exist else 0 but here 0 is space.
Procedure getLetterPos(caractere$)
alpha$ = " !" + Chr(34) + " '()*+,-. 0123456789:; = ? ABCDEFG"
alpha$ = alpha$ + "HIJKLMNOPQRSTUVWXYZ"
length = Len(alpha$);
i = 1;
While (Mid(alpha$, i, 1) <> Mid(caractere$, 1, 1) And i <= length)
i = i + 1
Wend
If i > length
ProcedureReturn 0
EndIf
ProcedureReturn i;
EndProcedure
; take the good bitmap char in a sprite picture. Before num computed by getLetterPos
; parameters :
; In :
; - IdSprite : sprite handle which contains bitmap fonts
; - x,y : letter position in pixel in a pic
; - w,h : width, height in pixel for a letter
; - num : logic letter position in a pic
; - r,g,b : transparency color for sprite
; Out:
;
Procedure getFonts(IdSprite, x, y, w, h, num, r, g, b)
fontsW = SpriteWidth(IdSprite) ; [!] Just take with sprite width
; ClipSprite(IdSprite, #PB_Default, #PB_Default, #PB_Default, #PB_Default)
; reinit original sprite size after clipping
posX = (num-1) % ((fontsW / w))
posY = (num-1) / ((fontsW / w))
srcX = (posX) * w
srcY = (posY) * h
srcH = h
srcW = w
ClipSprite(IdSprite, srcX, srcY, srcW, srcH)
PrintTransparentSprite(IdSprite, x, y, r, g, b)
ClipSprite(IdSprite, #PB_Default, #PB_Default, #PB_Default, #PB_Default)
EndProcedure
; Generic Error function.
Procedure ErrorWindowCreation()
MessageRequester("Error", "This is fucked up, I can't create the window", 0)
End
EndProcedure
; Animatation routine
; In:
; - fullscreen.b : create an animation in fullscreen mode or not. Two state: 0/false -> windowed mode, 1/true -> fullscreen
: Out:
;
Procedure Anim(fullscreen.b)
;Init subsystem and the windows with fullscreen or not
InitSprite()
InitKeyboard()
If fullscreen
If OpenScreen(#WINWIDTH, #WINHEIGHT, #BPP, #WINTITLE) = 0
ErrorWindowCreation()
EndIf
Else
If OpenWindow(1337,0,0,#WINWIDTH, #WINHEIGHT, #WINTITLE, #PB_Window_BorderLess | #PB_Window_ScreenCentered)
If Not OpenWindowedScreen(WindowID(1337), 0, 0, #WINWIDTH, #WINHEIGHT, 1, 0, 0)
ErrorWindowCreation()
EndIf
Else
ErrorWindowCreation()
EndIf
EndIf
;Animation
Result = CatchSprite(0, ?fontsReps, #PB_Sprite_Texture)
Result = CatchSprite(1, ?logoReps, #PB_Sprite_Texture)
Result = CreateImage(12, #WINWIDTH, #WINHEIGHT,#BPP)
ClearScreen(0)
Repeat
xpad = 0
ypad = 0
StartDrawing(ImageOutput(12))
For i = 1 To Len(s$) Step 1
car$ = Mid(s$, i , 1)
Select car$
Case Chr(10)
ypad = ypad + #SPRH
Case Chr(13)
xpad = 0
Default
getFonts(0,xpad, ypad+156, #SPRW, #SPRH, getLetterPos(car$), 0, 0, 0)
xpad = xpad + #SPRW
EndSelect
Next i
PrintTransparentSprite(1, 0, 0, 0, 0, 0)
StopDrawing()
ClearScreen(0)
StartDrawing(ScreenOutput())
DrawImage(ImageID(12),0,100) ; Here, if i removed ImageID the program segfault.
StopDrawing() ; In all case nothing are print. But it's backbuffer -> frontbuffer right ?
FlipBuffers()
If fullscreen = 0
Event = WaitWindowEvent(0)
EndIf
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape) Or KeyboardPushed(#PB_Key_Space) Or KeyboardPushed(#PB_Key_T)
EndProcedure
; Init the question for fullscreen or windowed mode. After selection the button, the animation will be in a good screen mode
; In :
; - text$ : Is the message for MessageBox
; Out :
;
Procedure PrintTextWindows(text$)
Result = MessageRequester(#WINTITLE, text$,#PB_MessageRequester_YesNoCancel)
Select Result
Case #PB_MessageRequester_Yes
Anim(#True)
Case #PB_MessageRequester_No
Anim(#False)
EndSelect
EndProcedure
;!!!!! Begin !!!!!
PrintTextWindows("Credits : Jace, Padman, StormBringer !!! and you ;o)"+ Chr(10) + Chr(13) + "Do you want Fullscreen ? :)")
End ; va!n advice
;!!!!! End !!!!!
DataSection
fontsReps: IncludeBinary("eswatfonts.bmp")
logoReps: IncludeBinary("eswatlogo.bmp")
EndDataSection
; IDE Options = PureBasic 4.51 (Linux - x86)
; CursorPosition = 196
; FirstLine = 158
; Folding = -
Ok, I could be terribly wrong here (I'm just a lousy BASIC coder), but you are basically creating a front/backbuffer on your own, flipping those two then right? (Btw is SDL OpenGL based or is it DirectX?) PB uses an inbuilt double buffering method. I think you should just go away from converting your SDL stuff 1:1 to PB (it's not gonna work) and not complicate things. Try the easy approaches shown above.
Any other opinions/ideas/explanations on this are very welcome! Come on guys!
It's just for illustrate my talk. 
(Here, it's just SDL mechanism but with DirectX (DirectDraw is same). Yeah, i would like to follow your advice but i'm lost because i haven't these pb reflex.
To say true, i coded in "c/sdl version very quickly" but not in pb. I taked some effort for worse result in my case.My Dear Maracuja,
I don't understand why you say Purebasic is different of SDL?!? You are using exactly the "same" things with it!
SDL_BlitSurface(fonts, &src, screen, &dst); -> DisplaySprite(0, sco+cco, 320)
SDL_FillRect(finalScreen, NULL, 0); -> Clearscreen(0)
SDL_BlitSurface(prefinalScreen, NULL, finalScreen, &dst); // Here I print the logos/fonts at dst.y position until 0.
SDL_BlitSurface(finalScreen, NULL, screen, NULL); // Here i copy the finalbuffer on the screen
SDL_Flip(screen); // flipbuffers() like
-> Flipbuffers() yep, the switch between logical and physical screen are completely transparent!
So you just have to work onto the logical screen (ScreenOutput()) and display it after all jobs....
But to be back at your question, I think you want to know how to make a scoll text in a buffer to display it everywhere onto screen.
I've sent you the STCS remake code! It is using a "pre-buffered" sprite like you want! I create a sprite first, then I display all the font needed inside, and then i display the sprite everywhere on the screen - I must admit - using DisplayTransparentSprite or Peek & Poke (Hi PadMan!)
The trick is: you can't sprite into a sprite! So you have 3 options:
1- using images, and DrawImage() and displaying them into the sprite.
2- using your self-sprite rout with Peek & Poke and working in byte mode in the sprite (see STCS remake)!
3- display onto the screen at start of frame, grabbing the part of the screen in a sprite, clearing the screen, displaying all the other effect, and then displaying the sprite you created at first onto the rest!!! and at the end flipbuffers()!
Here is the version using the third technique (based on the last version of Padman):
... code cut ...
As you can see, you are using a buffer![]()
![]()
Next post, the first way!
QuoteSo the "for loop" doesn't useful for your update, right ?
Yours is still responsible for the static text. You can probably even use your version for displaying a scrolltext.QuoteThe clipSprite are used just to pick the good letter in fonts bitmap buffer which is (handle = 0) ? and displaysprite pointed by handle = 0 fo rendering your letter on the final screen ?
Yes, it clips a 8*8 rectangle of the larger font picture and displays that.QuoteTo conclude, what's the interest to use screendrawing/stopdrawing if you can render without them ?
StartDrawing()/StopDrawing() is only necessary for drawing Images or for PB internal drawing commands. For Sprites it's not needed, yes. Maybe you should have a look at the PB Help File and the Examples to understand the differences between Sprites and Images.QuoteDo you think if it possible to create a pre-rendered buffer which have all fonts/logos and after i will play with this buffer ?
If you want, i will made a sample in c/sdl to show the result ?
To be honest with you I don't exactly understand why you would want a pre-rendered buffer and what exactly you mean by that? I mean it's easy the way it's done now and it's not like you want to do a ton of gfx effects, where direct buffer drawing comes to mind. An example might help. I have to warn you though, I haven't got much experience with C, leave alone SDL.

#include <stdio.h>
#include <stdlib.h>
#if _MSC_VER || _WIN32
#include <windows.h>
#endif
#if _MSC_VER || _WIN32 || __APPLE__
#include <eswatFonts.h>
#include <eswatLogo.h>
#else
#include "eswatFonts.h"
#include "eswatLogo.h"
#endif
#include <assert.h>
#if !_MSC_VER
#include <SDL/SDL.h>
#else
#include <SDL.h>
#endif
#define WIN_HEIGHT 640
#define WIN_WIDTH 480
#define FONT_HEIGHT 8
#define FONT_WIDTH 8
#define WIN_BPP 24
#define INTRONAME "E-Swat Replicants cracktro"
#if !defined(FALSE)
#define FALSE 0
#endif
#if !defined(TRUE)
#define TRUE 1
#endif
static int fin_prg = FALSE;
static int fin_anim = FALSE;
static int fin_scene1 = FALSE;
static void getFonts(SDL_Surface *fonts, SDL_Surface *screen, int x, int y, int w, int h, int num)
{
int posX;
int posY;
SDL_Rect src;
SDL_Rect dst;
posX = (num-1) % ((fonts->w / w));
posY = (num-1) / ((fonts->w / w));
src.x = (posX) * w;
src.y = (posY) * h;
src.h = h;
src.w = w;
dst.x = x;
dst.y = y;
dst.h = src.h;
dst.w = src.w;
SDL_BlitSurface(fonts, &src, screen, &dst);
}
static int getLetterPos(char c)
{
size_t i;
size_t length;
char alpha[] = {
" !\" '()*+,-. 0123456789:; = ? ABCDEFG" \
"HIJKLMNOPQRSTUVWXYZ"
};
length = strlen(alpha);
i = (size_t)0;
while (alpha[i++] != c && i < length);
if (i > length)
return 0;
return /*((int)c) - ((int) 'a' - (int)'A')*/ (int)(i);
}
static void printText(SDL_Surface *screen, SDL_Surface *fonts, const char *s, int x, int y)
{
size_t sLength;
size_t i;
sLength = strlen(s);
for (i = 0; i < sLength ; i++)
{
getFonts(fonts, screen, (x+((int)i*8)), y, 8, 8, getLetterPos(s[i]));
}
}
static void PrintPayload(SDL_Surface *screen, SDL_Surface *fonts)
{
//liner
size_t i;
size_t length;
int ypad;
int xpad;
/*
* 8x8
* DC.B ' ---------------- '
* DC.B ' -THE REPLICANTS- '
* DC.B ' ---------------- ',$00
* DC.B ' PRESENTS: - ESWAT + - '
* DC.B ' '
* DC.B 'GREETZ TO : AVB,NEXT,AUTOMATION,TMB '
* DC.B 'THE POMPEY PIRATES,PHALANX,ALLIANCE,BB, '
* DC.B 'DELIGHT,FOF,TLB,TDI,QUARTET,HTL,MCA, '
* DC.B 'THOR,MAD VISION,INNER CIRCLE,TSG... ',$00
* DC.B ' '
* DC.B 'MEGA THANX TO THE BWK FOR DIS LOGO... ',$00
* DC.B ' BASH ',$27,'T',$27,' FOR TRAINER ',$FF
*/
char scrollText[] = {
" ---------------- \n\r" \
" -THE REPLICANTS- \n\r" \
" ---------------- \n\r\n\r" \
" PRESENTS: - ESWAT + - \n\r\n\r" \
"GREETZ TO : AVB,NEXT,AUTOMATION,TMB \n\r" \
"THE POMPEY PIRATES,PHALANX,ALLIANCE,BB, \n\r" \
"DELIGHT,FOF,TLB,TDI,QUARTET,HTL,MCA, \n\r" \
"THOR,MAD VISION,INNER CIRCLE,TSG... \n\r\n\r" \
"MEGA THANX TO THE BWK FOR DIS LOGO... \n\r\n\r" \
" BASH 'T' FOR TRAINER \n\r" \
};
xpad = 0;
ypad = 0;
//getFonts(fonts, screen, 0, 0, 8, 8, 320, 200, 89);
length = strlen(scrollText);
for (i = 0 ; i < length ; i++)
{
char c = scrollText[i];
if (c == '\n')
{
ypad+=8;
continue;
}
if (c == '\r')
{
xpad = 0;
continue;
}
xpad +=8;
getFonts(fonts, screen, xpad, ypad+68, 8, 8, getLetterPos(c));
}
#if TEST
getFonts(fonts, screen, 0 , 0, 8, 8, getLetterPos('¸'));
getFonts(fonts, screen, 0 , 8, 8, 8, getLetterPos('‰'));
#endif
}
static SDL_Surface *ChangeVideoMode(int w, int h, int bpp, int flags)
{
return SDL_SetVideoMode(w, h, bpp, flags);
}
static void HandleEvent(SDL_Event *event)
{
switch(event->type)
{
case SDL_KEYDOWN:
{
if ( event->key.keysym.sym == SDLK_ESCAPE )
fin_prg = TRUE;
if ( (event->key.keysym.sym == SDLK_SPACE || event->key.keysym.sym == SDLK_t) && fin_scene1)
fin_anim = TRUE;
break;
}
case SDL_QUIT:
{
fin_prg = TRUE;
break;
}
}
}
int main(int argc, char *argv[])
{
SDL_Event event;
SDL_Surface *screen;
SDL_Surface *fonts;
SDL_RWops *fontsRW;
SDL_Surface *logo;
SDL_RWops *logoRW;
SDL_Surface *prefinalScreen; /* pre render buffer */
SDL_Surface *finalScreen; /* buffer before display screen */
SDL_Rect dst;
Uint32 ticksOld;
Uint32 ticks;
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
printf("Unable to init SDL : %s\n", SDL_GetError());
return -1;
}
atexit(SDL_Quit);
#if defined(_MSC_VER) || defined(_WIN32)
FullScreen = MessageBox((HWND)NULL, TEXT("Fullscreen ?"), TEXT("Full or Not ? :=)"), MB_YESNO);
screen = ChangeVideoMode(WIN_HEIGHT, WIN_WIDTH, WIN_BPP,
(FullScreen == IDYES) ? SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_FULLSCREEN:
SDL_DOUBLEBUF | SDL_HWSURFACE);
if (screen == (SDL_Surface *)NULL)
#else
screen = ChangeVideoMode(WIN_HEIGHT, WIN_WIDTH, WIN_BPP, SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_FULLSCREEN);
if (screen == (SDL_Surface *)NULL)
#endif
{
printf("Unable to open video mode : %s\n",SDL_GetError());
exit(EXIT_FAILURE);
}
SDL_WM_SetCaption(INTRONAME, (const char *)NULL);
SDL_ShowCursor(SDL_DISABLE);
fontsRW = SDL_RWFromMem(eswatFonts, sizeof(eswatFonts)/sizeof(eswatFonts[0]));
fonts = SDL_LoadBMP_RW(fontsRW, 1);
assert(fonts != (SDL_Surface *) NULL);
logoRW = SDL_RWFromMem(eswatLogo, sizeof(eswatLogo)/sizeof(eswatLogo[0]));
logo = SDL_LoadBMP_RW(logoRW, 1);
/* create the last buffer which used before display screen */
finalScreen = SDL_CreateRGBSurface(0, WIN_WIDTH, WIN_HEIGHT, WIN_BPP, 0, 0, 0, 0);
/* pre render buffer */
prefinalScreen = SDL_CreateRGBaSurface(0, WIN_WIDTH, WIN_HEIGHT, WIN_BPP, 0, 0, 0, 0);
/* print logo on pre render buffer */
SDL_BlitSurface(logo, NULL, prefinalScreen, NULL);
/* same thing for fonts */
PrintPayload(prefinalScreen, fonts);
/* dst represent fonts blitting rectangle x,y,w,h*/
dst.x = 0;
dst.y = WIN_HEIGHT;
dst.w = WIN_WIDTH;
dst.h = WIN_HEIGHT;
ticksOld = SDL_GetTicks();
while (!fin_prg)
{
/* update/render Anim opengl */
while (SDL_PollEvent(&event))
{
HandleEvent(&event);
}
ticks = SDL_GetTicks();
if (ticks - ticksOld > (1/60))
{
ticksOld = ticks;
SDL_FillRect(finalScreen, NULL, 0); /* reset background buffer before display with black color */
if (!fin_anim) {
if (dst.y > 0) {
dst.y -= 4; /* move the pre render buffer y axis of -4 pixels*/
} else {
fin_scene1 = TRUE;
}
} else {
if (dst.y <= WIN_HEIGHT) {
dst.y += 4;
} else {
fin_prg = TRUE;
}
}
}
SDL_BlitSurface(prefinalScreen, NULL, finalScreen, &dst); // Here I print the logos/fonts at dst.y position until 0.
SDL_BlitSurface(finalScreen, NULL, screen, NULL); // Here i copy the finalbuffer on the screen
SDL_Flip(screen); // flipbuffers() like
}
SDL_FreeSurface(fonts);
SDL_FreeSurface(prefinalScreen);
SDL_FreeSurface(finalScreen);
SDL_FreeSurface(screen);
SDL_ShowCursor(SDL_ENABLE);
SDL_Quit();
return 0;
}
