I 've made some progress on the cracktro but I need some help/clarifications for the final touches before releasing it:
1) Is it possible to crossfade between 2 music files? Instead of StopMusic / PlayMusic which cuts off music in a sudden manner?
2) Is is possible to move images on an inactive display that resides in the bakground?
If not, the TTF font, when installed by Font manager creates a .font and .otag file. How these files should be treated/linked?
4) I added a quit function. Although it works as supposed via RA+Q hotkey or choosing Quit from Menu, when pressing ESC it loops me back on line 384. Can't figure out why.
5) 360x284, from original cracktro code, is way too tiny for modern resolutions. Tried to manipulate the routines for 800x600 and managed to fill up correctly the star field but could't move rest of the graphics to appropriate positions. Can anybody help on this regard? Is there any other alternative rather than messing directly with the pixel positions one by one? Tried some scaling options but none did the trick.
6) My second biggest concern after point 5, is the Desktop Display 1 which doesn't work on Win as stated from post 3 already. This prohibits the craktro working on Windows. How can we re-create the tint/gray effect? I mean, this code:
Here below follows the code. Sources can be downloaded from
. Script includes combined code from several Hollywood examples such as: menu creation, object transition fx, blanker, Zoom Text, multi displays, cracktro and some more. I 'll comment most of the functions and release full sources. Do you think that the code could be cleaned up and/or re-structured in a better way?
Code: Select all
/*
** Important! Check if the used Hollywood version is at least
** version 6.0!
*/
@VERSION 6,0
@APPTITLE "RP18 CrakTr0"
@APPVERSION "$VER: RP18 CrakTr0 Alpha (0.6 - 27.01.18)"
@APPICON {DefaultIcon="64x64", Ic64x64 = "RP186464.png",Ic64x64s = "186464.png"}
@OPTIONS {RegisterApplication = True}
@BRUSH 4, "font_big.png", {Transparency = #BLACK}
@BRUSH 5, "font_small.png", {Transparency = #BLACK}
@BRUSH 8, "dan.png"
@BRUSH 9, "logo.png", {Transparency = #BLACK}
@BRUSH 10, "RP18cover.jpg"
@ANIM 1, "stefanim.gif", {LoadTransparency = True}
@FONT 1, "sys:fonts/_ttf/TERMINAT.TTF", 20, {Engine = #FONTENGINE_INBUILT}
@MUSIC 1, "blaizer.mod"
@MUSIC 2, "GameOver.mp3"
@DISPLAY 1, {Desktop = True, DisableBlanker = True}
w = GetAttribute(#BGPIC, 1, #ATTRWIDTH)
h = GetAttribute(#BGPIC, 1, #ATTRHEIGHT)
BGPicToBrush(1, 2)
BrushToGray(2)
DisplayBrush(2, 0, 0)
For k = 10 To 100 Step 20
CopyBrush(2, 3)
TintBrush(3, #BLACK, k)
DisplayBrush(3, 0, 0)
Next
mx = w - bw
my = h - bh
Function p_Zoomit(t$)
Local sx, sy, trans = 1, 1, 0
TextOut(#CENTER, #CENTER, t$, {AnchorX = 0.5, AnchorY = 0.5})
StartTimer(1)
For Local k = 1 To 20
sx = sx + 0.2
sy = sy + 0.2
trans = trans + (255 / 20)
SetLayerStyle(1, {ScaleX = sx, ScaleY = sy, Transparency = trans})
WaitTimer(1, 1000\35)
Next
EndFunction
EnableLayers
;Some old code: SetFont(#MONOSPACE, 40)
UseFont(1)
SetFontColor(#WHITE)
p_ZoomIt("CrackTr0")
RemoveLayer(1)
p_ZoomIt("is")
RemoveLayer(1)
p_ZoomIt("loading...")
RemoveLayer(1)
;MoveBrush(9, #RIGHTOUT, #BOTTOM, #LEFTOUT, #BOTTOM, {TYPE = #SINE, Speed = #NORMALSPEED})
CreateDisplay(2, {BORDERLESS=True, SCALEMODE=true, Menu = 1, Title="RP Issue 18 CrackTr0", ScreenTitle="RP #18 CrackTr0 by Cool_amigaN", SmoothScale=True, Sizeable = True, Width = 360, Height = 284})
width = GetAttribute(#DISPLAY, 0, #ATTRWIDTH)
height = GetAttribute(#DISPLAY, 0, #ATTRHEIGHT)
OpenDisplay(2)
ActivateDisplay(2)
@MENU 1, {
{"About", {
{"Fullscreen", ID = "fullscreen", Hotkey = "F"},
{"FPS counter", ID = "fps", Flags = #MENUITEM_TOGGLE, Hotkey = "P"},
{""},
{"Credits", ID = "credits", Hotkey = "C"},
{"Visit for more...", {
{"Website...", ID = "www"},
{"Forum...", ID = "forum"}}},
{""},
{"Quit", ID = "quit", Hotkey = "Q"}}},
}
/*
** Event callback that handles menu selections
*/
Function p_MenuFunc(msg)
Switch msg.action
Case "OnMenuSelect":
Local r$ = ""
Local doreq = True
Switch msg.item
Case "fullscreen"
If GetAttribute(#DISPLAY,2,#ATTRMODE)=#DISPMODE_WINDOWED
ChangeDisplayMode(#DISPMODE_FULLSCREEN)
Else
ChangeDisplayMode(#DISPMODE_WINDOWED)
EndIf
Case "credits":
SystemRequest("", "\27c\27bCredits\27n\nCode by Dan of Anarchy - Skidrow\nMusic by Blaizer of Horizon\nPorted by Mr. X of Barracuda\nAdditional code by jPV\nModed & compiled by Cool_amigaN", "OK", #REQICON_INFORMATION)
doreq = False
Case "www" OpenURL ("https://goo.gl/P1eFXE")
Case "forum" OpenURL ("http://amigacomet.boards.net/thread/112/retro-planet-18")
Case "toggle":
SystemRequest("", "Toggle state: " .. IsMenuItemSelected(1, msg.item), "OK", #REQICON_INFORMATION)
doreq = False
Case "quit": p_PrepareExit()
End
Default:
r$ = msg.item
EndSwitch
EndSwitch
EndFunction
; listen to "OnMenuSelect" event handler
InstallEventHandler({OnMenuSelect = p_MenuFunc})
/* prepare the background gradient and the color bars */
Function p_CreateBG()
; this is the gradient effect for the sine scroller
CreateBrush(6, 360, 132)
SelectBrush(6)
SetFillStyle(#FILLGRADIENT, #LINEAR, #RED, #YELLOW)
Box(0, 0, 360, 50)
SetFillStyle(#FILLGRADIENT, #LINEAR, #YELLOW, #WHITE)
Box(0, 50, 360, 16)
SetFillStyle(#FILLGRADIENT, #LINEAR, #WHITE, #YELLOW)
Box(0, 66, 360, 16)
SetFillStyle(#FILLGRADIENT, #LINEAR, #YELLOW, #RED)
Box(0, 82, 360, 50)
EndSelect
; the color bars will cycle through these colors
cols = {$F70000, $F72000, $F74100, $F76100, $F78200, $F7A200, $F7C300, $F7E300, $F7F300, $E7F300,
$C6F300, $A5F300, $84F300, $63F300, $42F300, $21F300, $00F300, $00F321, $00F342, $00F363,
$00F384, $00F3A5, $00F3A5, $00F3C6, $00F3E7, $00F3F7, $00E3F7, $00C3F7, $00A2F7, $0082F7,
$0061F7, $0041F7, $0020F7, $0000F7, $2100F7, $4200F7, $6300F7, $8400F7, $A500F7, $C600F7,
$E700F7, $F700F7, $F700E7, $F700C6}
collength = ListItems(cols)
start2 = collength - 1
EndFunction
/* prepare the text writer */
Function p_InitWriter()
Local i, c
Local textcols = {$840000, $844100, $848200, 0, $008200, 0, $004184, $000084, $420084, $840084} ; base colors for gradient
Local f$ = " !\"§$%&'()*+,-./0123456789:;<=>?#ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; format of font_small.iff
Local x, y
chars_s = {}
; create our lookup table chars_s{}
For y = 0 To 1
For x = 0 To 39
chars_s[Asc(MidStr(f$, y * 40 + x, 1))] = {x = x * 8, y = y * 8}
Next
Next
wc=0 ; Reset writer position for new init
; Let's have several texts. You can have one t$[0], or many 1, 2, 3...
Local t$={}
t$[0] =
" * RETROPLANET * " ..
" PROUDLY PRESENTS " ..
" ANOTHER LIGHTSPEED RELEASE " ..
" " ..
" ISSUE NO. 18 " ..
" " ..
" SINCE 2013, 52 FULL COLOR PAGES OF RETRO " ..
" GREETINGS TO: DONY, NGANAG, VULTURE " ..
" DINOHATZI, SPYROS, KEROPI, TSAK " ..
" VISIT: RETROPLANET.GR / MOOBUNNY.GR "
t$[1] =
" * RETROPLANET * " ..
" PROUDLY PRESENTS " ..
" ANOTHER LIGHTSPEED RELEASE " ..
" " ..
" ISSUE NO. 18 " ..
" " ..
" SINCE 2013, 52 FULL COLOR PAGES OF RETRO " ..
" GREETINGS TO: JPV, FIK, TINA, MIKE " ..
" WALKERO, VAGGI6128, MASTERGR " ..
" VISIT: RETROPLANET.GR / MOOBUNNY.GR "
writertextlen = StrLen(t$[wt])
writertext = StrToArray(t$[wt])
If HaveItem(t$,wt+1) Then wt=wt+1 Else wt=0 ; Switch to the next text
; this brush contains the copper effect for the writer text
CreateBrush(7, 360, 80)
SelectBrush(7)
For k = 0 To 79
If k % 8 = 1
c = textcols[i]
i = i + 1
EndIf
Line(0, k, 359, k, c)
If k % 8 < 4
c = c + $212021
Else
c = c - $212021
EndIf
Next
EndSelect
; clear its mask
SelectMask(7)
SetMaskMode(#MASKINVISIBLE)
Cls
EndSelect
; all future renderings are now in "visible" mode
SetMaskMode(#MASKVISIBLE)
cx = 0
cy = 29
EndFunction
/* init the sine scroller */
Function p_InitScroll()
Local f$ = " !\"§$%&'()*+,-./0123456789:;<=>?#ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; format of font_big.iff
Local x, y
chars = {}
; create lookup table chars{}
For y = 0 To 2
For x = 0 To 19
chars[Asc(MidStr(f$, y * 20 + x, 1))] = {x = x * 16, y = y * 16}
Next
Next
Local t$ = " - THE LEADING FORCE - IS BACK WITH:" ..
" * ISSUE 18 * " ..
"READ ALL ABOUT: " ..
"AMIGA32 SHOW REPORT BY: WALKERO " ..
"8/16BITS REVIEWS FOR AMSTRAD CPC, C=64, ZX SPECTRUM, ATARI ST - " ..
" HC508 VS. ACA500+ ALL BY: DONY " ..
"BENCHMARKING VAMPIRE 600 V2 BY: VULTURE " ..
"INCUBATION: TIME IS RUNNING OUT REVIEW BY: COOL AMIGAN " ..
"FLIGHT OF THE AMAZON QUEEN REVIEW BY: PHANTOM " ..
"WINGS OF DESTINY FROM JUDAS PRIEST BY: VULTURE " ..
"AND MUCH - MUCH MORE... " ..
"PLACE YOUR ORDER WHILE STOCKS LAST! " ..
"SEE YOU AT AMICAMP 6, 27-28/01/18 AT FOUNDATION - BE THERE! "..
" ... SCROLL RESTARTS ..."
scrolltextlen = StrLen(t$)
scrolltext = StrToArray(t$)
EndFunction
/* create our sine lookup table */
Function p_MakeSine()
Local i, s = 0, 2 * #PI / 500
sine = {}
sinelen = 500
For Local k = 0 to sinelen - 1
sine[k] = Sin(i) * 55 + 55
i = i + s
Next
EndFunction
/* prepare starfield */
Function p_InitStars()
stars = {}
For Local i = 0 To 199
stars[i] = {
x = Rnd(360),
y = Rnd(238) + 24,
speed = Rnd(4) + 1,
color = (Rnd(11) + 4) * 0x111111}
Next
EndFunction
/* this function is called 50 times a second */
Function p_MainLoop()
DisableLineHook()
Local charpos_tmp, scrollpos_tmp, sinepos_tmp = charpos, scrollpos, sinepos
Local char = scrolltext[scrollpos_tmp]
Local i, k
; advance to next positions
charpos = charpos + 2
If charpos >= 16
charpos = 0
scrollpos = scrollpos + 1
If scrollpos >= scrolltextlen Then scrollpos = 0
EndIf
sinepos = sinepos + 4
If sinepos >= sinelen Then sinepos = sinepos - sinelen
; flip the back buffer into view and make the front buffer the back buffer,
; so we can render the next frame!
Flip
; now draw the next frame to the back buffer!
Cls
DisplayBrush(8, 284, 265) ; display "DAN OF ANARCHY"
If frame<frames Then frame=frame+1 Else frame=1
DisplayAnimFrame(1, MouseX(), MouseY(), frame)
; draw starfield
For i = 0 To 199
If stars[i].x >= 360 Then stars[i].x = stars[i].x - 360
Plot(stars[i].x, stars[i].y, stars[i].color)
stars[i].x = stars[i].x + stars[i].speed
Next
; display upper color bar
i = start1
For k = 0 To collength - 2
Line(k * 8, 22, k * 8 + 7, 22, cols[i])
i = i + 1
If i = collength Then i = 0
Next
Line(k * 8, 22, 359, 22, cols[i])
start1 = start1 + 1
If start1 = collength Then start1 = 0
; display lower color bar (reverse direction!)
i = start2
For k = collength To 1 Step -1
Line(k * 8 + 7, 262, k * 8, 262, cols[i])
i = i - 1
If i = -1 Then i = collength - 1
Next
Line(9, 262, 0, 262, cols[i])
start2 = start2 - 1
If start2 = -1 Then start2 = collength - 1
; now render the sine scroller intro the gradient's mask
SelectMask(6)
SetMaskMode(#MASKINVISIBLE)
Cls
SetMaskMode(#MASKVISIBLE)
For Local x = 0 To 360 Step 16
For Local k = 0 To 15
charpos_tmp = charpos_tmp + 1
if charpos_tmp >= 16
charpos_tmp = 0
scrollpos_tmp = scrollpos_tmp + 1
If scrollpos_tmp >= scrolltextlen Then scrollpos_tmp = 0
char = scrolltext[scrollpos_tmp]
EndIf
DisplayBrushPart(4, chars[char].x + charpos_tmp, chars[char].y, x + k, sine[sinepos_tmp], 1, 16)
sinepos_tmp = sinepos_tmp + 1
if sinepos_tmp >= sinelen Then sinepos_tmp = 0
Next
Next
EndSelect
DisplayBrush(6, 0, 132) ; render the masked gradient to it
; writer not finished yet?
If wc < writertextlen
; render its characters to our prepare copper brush's mask
char = writertext[wc]
If char <> ' ' And high = 1
SelectMask(7)
DisplayBrushPart(5, chars_s[char].x, chars_s[char].y, cx, cy - 29, 8, 8)
EndSelect
EndIf
DisplayBrush(7, 0, 29)
; highlight it first!
If char <> ' ' And high = 0
DisplayBrushPart(5, chars_s[char].x, chars_s[char].y, cx, cy, 8, 8)
EndIf
; advance to next character
If high = 1
cx = cx + 8
wc = wc + 1
If cx = 352
cx = 0
cy = cy + 8
EndIf
EndIf
high = 1 - high
Else
; simply display the brush now because the writer is done
DisplayBrush(7, 0, 29)
EndIf
EnableLineHook()
If fps_counter=60
fps_result=Round(60000/GetTimer(2))
fps_counter=1
StartTimer(2)
Else
fps_counter=fps_counter+1
EndIf
If IsMenuItemSelected(2, "fps") Then TextOut(#RIGHT,#TOP,"fps: "..fps_result)
InstallEventHandler ({OnMouseDown = ActivateDisplay(2),
OnMouseUp = ActivateDisplay(2),
OnRightMouseDown = ActivateDisplay(2),
OnRightMouseUp = ActivateDisplay(2),
CloseWindow = p_PrepareExit,
OnKeyDown = p_CheckKey})
EndFunction
Function p_PrepareExit()
If exit = True Then Return
SelectDisplay(1)
FreeDisplay(2)
StopMusic (1)
PlayMusic (2)
EnableLayers
DisplayBrushFX(10, #CENTER, #CENTER, {Type = #CROSSFADE, Speed = 20})
Wait(100)
UndoFX(#BRUSH, 10,#PIXELZOOM1, #NORMALSPEED)
Wait(50)
DisplayBrushFX(9, #CENTER, #CENTER, {Type = #CROSSFADE, Speed = 20})
Wait(50)
UndoFX(#BRUSH, 9,#WATER1, #NORMALSPEED)
EndFunction
/* check if ESC was pressed */
Function p_CheckKey(msg)
If msg.key = "ESC" Then p_PrepareExit()
EndFunction
p_CreateBG()
p_InitScroll()
p_InitWriter()
p_InitStars()
p_MakeSine()
frame=0
frames=GetAttribute(#ANIM,1,#ATTRNUMFRAMES)
SetInterval(1, p_MainLoop, 500/60) ; 60 fps
SetInterval(3, p_InitWriter, 30000) ; init writer every 30 seconds
StartTimer(2) ; timer for fps counting
fps_counter=1
fps_result=60
UseFont (1)
SetFontColor(ARGB(128, #GRAY))
;SetFont(#BITMAP_DEFAULT,8)
PlayMusic(1)
; begin double buffered output
BeginDoubleBuffer(True)
Repeat
WaitEvent
Forever