/* * $VER DIYreko 2.0 (3.4.95) * * An Arexx script for ImageFX * For creation of .REKO data files compatible with * Reko-Productions Klondike-Deluxe-AGA 1.3 * Klondike II and III (perhaps IV, when it comes out :))) * Written by Tomasz Nidecki (TONID) * Contact: Tomasz.Nidecki@p22.f52.n480.z2.fidonet.org * 2:480/52.22 in FIDOnet * BIG thanx to Paul Hernik (CBM80) for correcting bugs in * the script for use with IFX 2.0, and for tips on * improving this program! * * Certain ideas borrowed from Thomas Krehbiel's Snapshot 1.04.00 * and his JPEG 1.00.00 included in ImageFX Release 1.50 * * Compatible with ImageFX 2.0, NOT COMAPTIBLE with ImageFX 1.50 * * This script lets you automatically build a .REKO file for * Reko-Productions Klondike game out of a series of cropped and/or * scaled images. This script provides scaling, enhancing, framing, * card symbols, also rendering to a correct palette and generating a * .REKO file. * * Feel free to modify this script to your convenience, but please refrain * from spreading your versions of the script. Send them to the author * instead, suggesting changes and enhancements. They might be included in * the next version of the archive. * * This release opens a new class of programs called RecognitionWare. All I * ask from you for using this script is please mention the fact that You * used DIYreko for the creation of your .REKO set somewhere in one of the * cards. Don't forget to mention Reko-Productions, too! * * For detailed description of the use of this script, read the accompanying * .guide file! Without it you might have problems using this program. * * This script is richly commented to your convenience. I'm sorry if it * makes it a bit unclear at first, but when you start reading it, you'll * appreciate the comments. */ OPTIONS RESULTS /* make Arexx return results from various functions */ SIGNAL ON BREAK_C /* allow user to stop the reko creation process */ /* Clean up after previous unsuccessful uses of DIYreko and other commands*/ Redraw Off /* first turn off the redrawing of the image buffer */ ADDRESS COMMAND 'Protect >NIL: RAM:__DIYreko#? ADD d' /* delete all DIYreko temporary files from RAM */ ADDRESS COMMAND 'Delete RAM:__DIYreko#? QUIET' KillBuffer force /* kill all buffers */ Swap KillBuffer force KillBrush force Render close /* kill the render screen */ Redraw On /* Retrieve previous values from the environment */ cardbase = GETCLIP('IFX_DIYreko_CardBase') /* path to the source cards with basename*/ tempdir = GETCLIP('IFX_DIYreko_TempDir') /* directory where DIYreko will store temporary files */ destfile = GETCLIP('IFX_DIYreko_DestFile') /* directory where the created .REKO file will be put */ txtrfile = GETCLIP('IFX_DIYreko_TextureFile') /* texture file from Imagefx:textures */ bgset = GETCLIP('IFX_DIYreko_BGSet') /* colour set (if custom selected, the colors below will be used */ red = GETCLIP('IFX_DIYreko_Red') /* the red component of the background colour */ green = GETCLIP('IFX_DIYreko_Green') /* the green component of the background colour */ blue = GETCLIP('IFX_DIYreko_Blue') /* the blue component of the background colour */ rendermode = GETCLIP('IFX_DIYreko_RenderMode') /* rendering mode */ enhance = GETCLIP('IFX_DIYreko_Enhance') /* flag - enhance pictures using contrast and sharpen? */ useframe = GETCLIP('IFX_DIYreko_UseFrame') /* flag - use frame on cards? */ usepad = GETCLIP('IFX_DIYreko_UsePad') /* flag - use pad under Aces or use given cards */ cutedge = GETCLIP('IFX_DIYreko_CutEdge') /* flag - cut card edges or not */ settype = GETCLIP('IFX_DIYreko_SetType') /* how many cards in the set (55/59/68) */ /* If empty values are returned from the environment, set these to the following: */ IF cardbase = '' THEN cardbase = "ImageFX:Reko/Card" IF tempdir = '' THEN tempdir = "SYS:Trashcan/" IF destfile = '' THEN destfile = "ImageFX:Reko/Card.REKO" IF txtrfile = '' THEN txtrfile = "handmade_paper" IF bgset = '' THEN bgset = 0 IF red = '' THEN red = 154 IF green = '' THEN green = 0 IF blue = '' THEN blue = 48 IF rendermode = '' THEN rendermode = 0 IF enhance = '' THEN enhance = 1 IF useframe = '' THEN useframe = 1 IF usepad = '' THEN usepad = 1 IF cutedge = '' THEN cutedge = 1 IF settype = '' THEN settype = 0 /* Prepare gadgets for the complex requester */ Gadget.1 = 'T/140/20/200/0/Card basename:/'cardbase Gadget.2 = 'T/140/35/200/0/Temporary dir:/'tempdir Gadget.3 = 'T/140/50/200/0/Destination file:/'destfile Gadget.4 = 'T/140/65/200/0/Texture file:/'txtrfile Gadget.5 = 'C/140/80/Background set:/6/REKO Red/REKO Green/REKO Blue/Tonid`s Red/Night Black/Custom/0' Gadget.6 = 'J/140/95/30/Custom BG: R:/'red Gadget.7 = 'J/225/95/30/G:/'green Gadget.8 = 'J/310/95/30/B:/'blue Gadget.9 = 'C/140/110/Render mode:/3/HAM8/256 col./16 col./0' Gadget.10 = 'X/140/125/Enhance pictures?/'enhance Gadget.11 = 'X/140/140/Use frame?/'useframe Gadget.12 = 'X/140/155/Use pad?/'usepad Gadget.13 = 'X/140/170/Cut Edges?/'cutedge Gadget.14 = 'C/140/185/Version:/3/55 Cards/59 Cards/68 Cards/0' /* Enable complex requester using defined gadgets */ ComplexRequest '"DIYreko options:"' 14 Gadget 380 225 IF rc ~= 0 THEN Call BREAK_C /* if anything goes wrong better exit from the macro */ /* Get results from the complex requester and store them in the variables */ cardbase = result.1 tempdir = result.2 destfile = result.3 txtrfile = result.4 bgset = result.5 red = result.6 green = result.7 blue = result.8 rendermode = result.9 enhance = result.10 useframe = result.11 usepad = result.12 cutedge = result.13 settype = result.14 /* process the directory names so they include slashes or colons */ IF (RIGHT(tempdir,1)~='/') & (RIGHT(tempdir,1)~=':') THEN tempdir = tempdir||'/' /* Store the given values in the environment for the next call to DIYreko */ CALL SETCLIP('IFX_DIYreko_CardBase',cardbase) CALL SETCLIP('IFX_DIYreko_TempDir',tempdir) CALL SETCLIP('IFX_DIYreko_DestFile',destfile) CALL SETCLIP('IFX_DIYreko_TextureFile',txtrfile ) CALL SETCLIP('IFX_DIYreko_BGSet',bgset) CALL SETCLIP('IFX_DIYreko_Red',red) CALL SETCLIP('IFX_DIYreko_Green',green) CALL SETCLIP('IFX_DIYreko_Blue',blue) CALL SETCLIP('IFX_DIYreko_RenderMode',rendermode) CALL SETCLIP('IFX_DIYreko_Enhance',enhance) CALL SETCLIP('IFX_DIYreko_UseFrame',useframe) CALL SETCLIP('IFX_DIYreko_UsePad',usepad) CALL SETCLIP('IFX_DIYreko_CutEdge',cutedge) CALL SETCLIP('IFX_DIYreko_SetType',settype) /* Copy frame, symbol and Prefs files to RAM for faster access */ IF useframe THEN DO ADDRESS COMMAND 'Copy >NIL: 'cardbase'Frame TO RAM:__DIYreko_framefile__' IF rc ~= 0 THEN Call BREAK_FrameNotFound END ADDRESS COMMAND 'Copy >NIL: 'cardbase'Symbols TO RAM:__DIYreko_symbolfile__' IF rc ~= 0 THEN Call BREAK_SymbolNotFound IF settype = 2 THEN DO ADDRESS COMMAND 'Copy >NIL: 'cardbase'Prefs TO RAM:__DIYreko_prefsfile__' IF rc ~= 0 THEN Call BREAK_PrefsNotFound END IF useframe THEN Message "Frame and symbols copied to RAM:" ELSE Message "Symbols copied to RAM:" /* Some startup actions */ Undo Off /* save memory by turning undo off - this kills the undo buffer too */ LockInput /* lock the input to prevent the user from messing around with the GUI while the script is working */ /* Prepare colour sets, if colours not custom */ IF bgset = 0 THEN DO /* Standard REKO red cardset */ red = 154 green = 0 blue = 48 END IF bgset = 1 THEN DO /* Standard REKO green cardset */ red = 48 green = 100 blue = 0 END IF bgset = 2 THEN DO /* Standard REKO blue cardset */ red = 28 green = 104 blue = 117 END IF bgset = 3 THEN DO /* My favourite deep-red colour, like in Beauty.REKO */ red = 81 green = 0 blue = 40 END IF bgset = 4 THEN DO /* Night black */ red = 0 green = 0 blue = 0 END /* If colour chosen as custom, no values will be changed */ Blend 100 /* set blending mode to full */ EdgeMode Normal /* no edge operations (like antialiasing) will be performed */ Transparency Include 0 Exclude 0 /* nothing should be considered transparent */ /* Process the card 00 - the only thing we can do with it is scale it */ Message "Phase 1 - Processing Card 00" /* 'message' outputs text to the Arexx bar on ImageFX toolbox screen */ Redraw Off LoadBuffer cardbase||'00' force /* load the card killing the previous buffer */ IF rc ~= 0 THEN Call BREAK_CardNotFound /* jump to a correct subroutine if something goes wrong */ toobig = 0 GetMain /* get some info about the card */ Parse var result name picwidth picheight . /* 'parse' is an Arexx instruction which changes a string into separate variables */ IF (picwidth>88) | (picheight>130) THEN toobig = 1 /* will we need to sharpen the picture? We only do it if it was scaled to be smaller */ IF (picwidth~=88) | (picheight~=130) THEN Scale 88 130 /* if not the right size, scale it */ IF toobig THEN DO IF enhance THEN DO Contrast 10 /* a great tip from snapshot.ifx macro - nicely enhances the small image */ Sharpen 40 /* continuing... */ END END Redraw On SaveBufferAs ILBM tempdir||'__DIYreko_Card00__' force /* save the card overwriting any older versions of it */ IF rc ~= 0 THEN Call BREAK_CannotSaveCard /* Make the card 01 - this is the card showing empty space * we will make it appear recessed into the background by a neat little trick * this card will also have a sign with my alias on it :) * Whatever you do, please do not modify this part - this is the only thing * I would like in return for using this macro by you - recognition for my work * However do not hesitate to put a string like "made using DIYreko by TONID" * somewhere else in the cardset * ATTENTION: The card 01 from the source will be IGNORED. I decided to force * this kind of action, since I saw a couple of sets where someone put a picture * in this place, and it highly confused the player (try StarTrek.reko and you'll * see what I mean) */ Message "Phase 1 - Processing Card 01" CreateBuffer 88 130 force /* make a buffer sized like a standard card */ Redraw Off SetPalette '-1' Red Green Blue /* force the given colour components into the current drawing colour */ FilledBox 0 0 88 130 /* fill the buffer with the active colour */ BoxRegion 1 1 86 128 /* select the whole card */ Brightness (-10) /* darken the whole card a bit */ BoxRegion 0 0 0 128 /* select the left edge of the picture */ Brightness (-40) /* make it darker */ BoxRegion 1 0 87 0 /* select the top edge of the picture */ Brightness (-40) /* make it darker */ BoxRegion 87 1 87 128 /* select the right edge */ Brightness 25 /* make it brighter */ BoxRegion 0 129 87 129 /* and the bottom one */ Brightness 25 /* make it brighter */ Region full /* return to processing of the full image */ GetPixel 0 0 /* what colour is pixel 0 0 */ darkercolour = result /* we save the colour for further use when rendering */ SetPalette '-1' darkercolour /* set drawing colour to the same as the dark edges */ bx = 59 /* set up base x position for the signoff */ by = 121 /* same for y */ Point bx by /* make a trial point */ BoxRegion bx by bx by /* set region to this point only */ Brightness (-30) /* darken it even more - we do this to obtain an even darker colour */ Region full /* full region again */ GetPixel bx by evendarkercolour = result SetPalette '-1' evendarkercolour /* set drawing colour to even darker than the dark edges */ Line bx by (bx+4) by /* start drawing my signoff - horizontal part of t */ Line bx+2 (by+1) (bx+2) (by+4) /* vertical part of t */ Line (bx+4) (by+2) (bx+4) (by+3) /* left edge of o */ Line (bx+6) by (bx+7) by /* top edge of o */ Line (bx+8) (by+1) (bx+8) (by+3) /* right edge of o */ Line (bx+5) (by+4) (bx+7) (by+4) /* bottom edge of o */ Line (bx+10) by (bx+10) (by+4) /* left edge of n */ Line (bx+10) by (bx+13) by /* top edge of n */ Line (bx+14) (by+1) (bx+14) (by+4) /* right edge of n */ Line (bx+16) by (bx+18) by /* top of i */ Line (bx+17) (by+1) (bx+17) (by+3) /* vertical part of i */ Line (bx+16) (by+4) (bx+18) (by+4) /* bottom of i */ Line (bx+20) by (bx+23) by /* top edge of d */ Line (bx+24) (by+1) (bx+24) (by+3) /* right edge of d */ Line (bx+20) (by+4) (bx+23) (by+4) /* bottom edge of d */ Line (bx+20) (by+2) (bx+20) (by+3) /* left edge of d */ GetPixel 87 129 /* similar operation with a light colour */ lightercolour = result SetPalette '-1' lightercolour bx = 60 by = 122 Point bx by BoxRegion bx by bx by Brightness (30) Region full GetPixel bx by evenlightercolour = result SetPalette '-1' evenlightercolour Line bx by (bx+4) by Line bx+2 (by+1) (bx+2) (by+4) Line (bx+4) (by+2) (bx+4) (by+3) Line (bx+6) by (bx+7) by Line (bx+8) (by+1) (bx+8) (by+3) Line (bx+5) (by+4) (bx+7) (by+4) Line (bx+10) by (bx+10) (by+4) Line (bx+10) by (bx+13) by Line (bx+14) (by+1) (bx+14) (by+4) Line (bx+16) by (bx+18) by Line (bx+17) (by+1) (bx+17) (by+3) Line (bx+16) (by+4) (bx+18) (by+4) Line (bx+20) by (bx+23) by Line (bx+24) (by+1) (bx+24) (by+3) Line (bx+20) (by+4) (bx+23) (by+4) Line (bx+20) (by+2) (bx+20) (by+3) Redraw On SaveBufferAs ILBM tempdir||'__DIYreko_Card01__' force IF rc ~= 0 THEN Call BREAK_CannotSaveCard /* And now for the back-card - card 02 */ Message "Phase 1 - Processing Card 02" Redraw Off LoadBuffer cardbase||'02' force IF rc ~= 0 THEN Call BREAK_CardNotFound GetMain Parse var result name picwidth picheight . IF (picwidth~=88) | (picheight~=130) THEN Scale 88 130 IF enhance THEN DO Contrast 10 Sharpen 40 END IF cutedge THEN DO /* let's cut the edges if the user wants to */ SetPalette '-1' Red Green Blue Point 0 0 /* all four corners to background colour */ Point 87 0 Point 0 129 Point 87 129 END Redraw On SaveBufferAs ILBM tempdir||'__DIYreko_Card02__' force IF rc ~= 0 THEN Call BREAK_CannotSaveCard /* And now for the main loop - processing of game cards 02 to 54 */ actualset = 0 actualcard = 0 DO cardnumber = 3 TO 54 Message "Phase 1 - Processing Card "||RIGHT(cardnumber,2,'0') Redraw off LoadBuffer cardbase||RIGHT(cardnumber,2,'0') force /* add a leading 0 to the number */ IF rc ~= 0 THEN Call BREAK_CardNotFound GetMain Parse var result name picwidth picheight . IF (picwidth~=88) | (picheight~=130) THEN Scale 88 130 IF enhance THEN DO Contrast 10 Sharpen 40 END IF useframe THEN DO Swap /* switch to the other buffer */ LoadBuffer 'RAM:__DIYreko_framefile__' force /* load the frame from RAM: to save time */ IF rc ~= 0 THEN Call BREAK_RAMFrameNotFound IF cardnumber = 3 THEN DO /* find the frame colour to set the right render palette later on */ GetPixel 3 3 /* an example pixel from a frame - that's where a symbol will be, so the frame colour should be underneath it */ framecolour = result END Matte 0 0 0 /* put the frame over the card image, treating black (0 0 0) as transparent - now this is your new card image*/ END Swap LoadBuffer 'RAM:__DIYreko_symbolfile__' force /* load the symbols into the buffer from RAM: */ IF rc ~= 0 THEN Call BREAK_RAMSymbolNotFound IF cardnumber = 3 THEN DO /* do it only for the first card, no sense in repeating it 52 times */ GetMain Parse var result name bufwidth bufheight . symbolwidth = (bufwidth % 13) symbolheight = (bufheight % 4) END Scissors /* prepare to cut the brush - this ImageFX instruction makes the next instruction after it act as a scissors for a brush to be cut */ Box (actualcard * symbolwidth) (actualset * symbolheight) symbolwidth symbolheight /* this will cut the brush NOT draw a box */ CreateBuffer 88 130 force /* make a new card buffer in place of the symbols */ BrushHandle 0 0 /* hold the brush by its top-left corner */ Point (87-symbolwidth) 1 /* put the symbols in the corners */ Point 1 (129-symbolheight) KillBrush force Matte 0 0 0 IF cutedge THEN DO SetPalette '-1' Red Green Blue Point 0 0 Point 87 0 Point 0 129 Point 87 129 END Redraw On SaveBufferAs ILBM tempdir||'__DIYreko_Card'||RIGHT(cardnumber,2,'0')||'__' force IF rc ~= 0 THEN Call BREAK_CannotSaveCard actualset = actualset + 1 /* change the symbol positions to be cut the next time we process a card */ IF (actualset > 3) THEN DO actualset = 0 actualcard = actualcard + 1 END END /* If the cardset is of the extended type - with 4 extra cards, process them too */ IF settype > 0 THEN DO IF usepad THEN DO /* if the user selected a pad - a card four times as wide to be used underneath the Aces */ Redraw Off LoadBuffer cardbase||'Pad' force /* load the pad file */ IF rc ~= 0 THEN Call BREAK_CardNotFound GetMain Parse var result name picwidth picheight . IF (picwidth~=352) | (picheight~=130) THEN Scale 352 130 IF enhance THEN DO Contrast 10 Sharpen 40 END Swap CreateBuffer 88 130 force Swap DO i = 0 TO 3 Message "Phase 1 - Processing Card "||RIGHT((55+i),2,'0') Crop (88*i) 0 88 130 ToSwap /* put a part of the picture into the other buffer */ Swap Redraw On SaveBufferAs ILBM tempdir||'__DIYreko_Card'||RIGHT((55+i),2,'0')||'__' force IF rc ~= 0 THEN Call BREAK_CannotSaveCard Redraw Off Swap END END ELSE DO /* if the user would rather process ready-made cards to be put under the Aces */ DO cardnumber = 55 TO 58 Redraw Off Message "Phase 1 - Processing Card "||RIGHT(cardnumber,2,'0') LoadBuffer cardbase||RIGHT(cardnumber,2,'0') force IF rc ~= 0 THEN Call BREAK_CardNotFound GetMain Parse var result name picwidth picheight . IF (picwidth~=88) | (picheight~=130) THEN Scale 88 130 IF enhance THEN DO Contrast 10 Sharpen 40 END Redraw On SaveBufferAs ILBM tempdir||'__DIYreko_Card'||RIGHT(cardnumber,2,'0')||'__' force IF rc ~= 0 THEN Call BREAK_CannotSaveCard END END END /* And if the cardset is of the extra-extended type - process the prefs cards */ IF settype = 2 THEN DO Redraw Off CreateBuffer 88 130 force /* create a buffer for the texture */ SetPalette '-1' red green blue /* force the given colour components into the current drawing colour */ FilledBox 0 0 88 130 /* fill the buffer with the active colour */ texturepath = "ImageFX:textures/"||txtrfile /* take one of the ImageFX 2.0 textures and apply to the prepared buffer */ Hook ApplyTexture texturepath 0 200 Shiny IF rc ~= 0 THEN Call BREAK_TextureNotFound GetMain Parse var result name picwidth picheight . IF (picwidth~=88) | (picheight~=130) THEN Scale 88 130 Swap DO i = 0 TO 8 Redraw Off Message "Phase 1 - Processing Card "||RIGHT((i+59),2,'0') LoadBuffer "RAM:__DIYreko_prefsfile__" force /* load the prefs file */ IF rc ~= 0 THEN Call BREAK_RAMPrefsNotFound Crop (88*i) 0 88 130 /* cut out the correct prefs frame */ Matte 0 0 0 /* put the texture under the frame */ IF cutedge THEN DO SetPalette '-1' Red Green Blue Point 0 0 Point 87 0 Point 0 129 Point 87 129 END Redraw On SaveBufferAs ILBM tempdir||'__DIYreko_Card'||RIGHT((i+59),2,'0')||'__' force IF rc ~= 0 THEN Call BREAK_CannotSaveCard END END /* Clean up, because we need as much memory as possible */ Redraw Off KillBuffer force swap KillBuffer force KillBrush force Render close ADDRESS COMMAND 'Protect >NIL: RAM:__DIYreko#?__ ADD d' ADDRESS COMMAND 'Delete RAM:__DIYreko#?__ QUIET' ADDRESS COMMAND 'Which >T:__DIYreko_flushfound__ Flush#?' /* find a flush command - I use one and it sometimes saves me some memory, so if the user has it, use it! */ ADDRESS COMMAND 'Execute T:__DIYreko_flushfound__' /* if found, execute it */ ADDRESS COMMAND 'Delete T:__DIYreko#?__ QUIET' Redraw On /* Prepare a buffer for rendering the palette */ Redraw Off CreateBuffer (7 * 88) (4 * 130) force /* Load images into the buffer side by side * unfortunately, due to memory limitations, we can only * load about 30 images, but it should be enough to get * the correct palette, as long as we select the ones that matter: * the first three, and if it's an extended cardset, also numbers 55 to 58 * and at least one of the prefs cards in order to get the colours from the * prefs texture - best use cards 62 and 67 - select card and about card, * since they contain the most elements which could matter for the * base colours selection. * * If you are one of the lucky people with 10 MB ram or something like that * feel free to change this part to consider all cards (should be easy enough). * However, this will only lengthen the processing time and will do little good for * the quality of the cardset, unless every card is completely different when it * comes to colours */ xp = 0 /* current x position */ yp = 0 /* current y position */ Message "Phase 2 - Preparing palette" chosenend = 27 /* choose how many standard cards we can take */ IF settype = 1 THEN chosenend = 23 IF settype = 2 THEN chosenend = 21 DO i = 0 TO chosenend LoadBrush tempdir||'__DIYreko_Card'||RIGHT(i,2,'0')||'__' force IF rc ~= 0 THEN Call BREAK_TempFileNotFound BrushHandle 0 0 Point (xp * 88) (yp * 130) xp = xp + 1 IF (xp > 6) THEN DO xp = 0 yp = yp + 1 END END IF settype > 0 THEN DO DO i = 55 TO 58 LoadBrush tempdir||'__DIYreko_Card'||RIGHT(i,2,'0')||'__' force IF rc ~= 0 THEN Call BREAK_TempFileNotFound BrushHandle 0 0 Point (xp * 88) (yp * 130) xp = xp + 1 IF (xp > 6) THEN DO xp = 0 yp = yp + 1 END END END IF settype = 2 THEN DO DO i = 62 TO 67 BY 5 LoadBrush tempdir||'__DIYreko_Card'||RIGHT(i,2,'0')||'__' force IF rc ~= 0 THEN Call BREAK_TempFileNotFound BrushHandle 0 0 Point (xp * 88) (yp * 130) xp = xp + 1 IF (xp > 6) THEN DO xp = 0 yp = yp + 1 END END END KillBrush force /* Prepare rendering module */ SetRender 'Amiga' IF rendermode = 0 THEN DO Render Mode PAL HIRES HAM LACE Render Colors 64 /* max number of base colours in HAM8 */ Render Dither 0 0 0 /* no dithering needed in HAM8 */ END IF rendermode = 1 THEN DO Render Mode PAL HIRES LACE Render Colors 256 /* 256-colour mode */ Render Dither 2 2 3 /* Floyd, ZigZag, High Error limiting */ END IF rendermode = 2 THEN DO Render Mode PAL HIRES LACE Render Colors 16 /* 16-colour mode */ Render Dither 2 2 3 /* Floyd, ZigZag, High Error limiting */ END /* Render the big buffer to obtain the best palette, adjust and lock it */ LockRange 0 off /* unlock the palette - it might have been locked before */ Palette 8 /* we switch to the render palette */ IF rendermode = 0 THEN VisibleColors 64 /* show 64 colors on screen - needed to use HAM base colors for rendering */ IF rendermode = 1 THEN VisibleColors 256 /* show 256 colors on screen */ IF rendermode = 2 THEN VisibleColors 16 /* show 16 colors on screen */ RenderPalette /* render a palette */ SortPalette Up /* sort it - darkest to lightest */ SetPalette 0 red green blue /* set the background colour */ GetPalette 20 /* move the colours 20 and 24 to the first locations which don't matter too much */ temppalette = result SetPalette 1 temppalette GetPalette 24 temppalette = result SetPalette 2 temppalette SetPalette 20 darkercolour /* set the now free colours 20 and 24 for the sprites selecting the cards in the game */ SetPalette 24 lightercolour IF useframe THEN SetPalette 5 framecolour SetPalette 3 255 0 0 /* red - used for symbols */ SetPalette 4 0 0 1 /* almost black - used for symbols */ SetPalette 5 evendaarkercolour /* these are necessary so that the TONID logo appears sharp :) */ SetPalette 6 evenlightercolour LockRange 0 on /* lock the render palette so no loaded image can change it and all will use the same one */ VisibleColors 32 KillBuffer force Redraw On /* Now reload all the pictures and render them into the correct colours */ Redraw Off lastcard = 54 /* establish the correct last card number */ IF settype = 1 THEN lastcard = 58 IF settype = 2 THEN lastcard = 67 DO cardnumber = 0 TO lastcard Message "Phase 3 - Rendering Card "||RIGHT(cardnumber,2,'0') LoadBuffer tempdir||'__DIYreko_Card'||RIGHT(cardnumber,2,'0')||'__' force IF rc ~= 0 THEN Call BREAK_TempFileNotFound Render Go SaveRenderedAs ILBM tempdir||'__DIYreko_Rendered'||RIGHT(cardnumber,2,'0') force IF rc ~= 0 THEN Call BREAK_CannotSaveCard ADDRESS COMMAND 'Delete 'tempdir'__DIYreko_Card'||RIGHT(cardnumber,2,'0')||'__ QUIET' Render Close END /* Clean up to save as much RAM as possible */ KillBuffer force swap KillBuffer force KillBrush force Render close ADDRESS COMMAND 'Which >T:__DIYreko_flushfound__ Flush#?' ADDRESS COMMAND 'Execute T:__DIYreko_flushfound__' ADDRESS COMMAND 'Delete T:__DIYreko#?__ QUIET' /* Generate the .REKO file in RAM: */ Message "Phase 4 - Generating .REKO datafile" ADDRESS COMMAND 'cd 'tempdir /* In KlondikeIII the Card.REKO is made in the current directory, not in RAM: !!! */ IF settype = 0 THEN ADDRESS COMMAND 'Reko 'tempdir'__DIYreko_Rendered00 55' IF settype = 1 THEN ADDRESS COMMAND 'Reko 'tempdir'__DIYreko_Rendered00 59' IF settype = 2 THEN ADDRESS COMMAND 'Reko 'tempdir'__DIYreko_Rendered00 68' /* And move the freshly created REKO file to your destination directory */ ADDRESS COMMAND 'Copy FROM ImageFX:card.reko TO 'destfile' QUIET BUF=64' /* needed if using Klondike III REKO command */ ADDRESS COMMAND 'Copy FROM RAM:card.reko TO 'destfile' QUIET BUF=64' /* small copy buffer due to little memory available */ /* Finally - delete the temporary files */ ADDRESS COMMAND 'Protect >NIL: 'tempdir'__DIYreko#? ADD d' ADDRESS COMMAND 'Delete 'tempdir'__DIYreko#? QUIET' ADDRESS COMMAND 'Delete RAM:card.reko QUIET' ADDRESS COMMAND 'Delete ImageFX:card.reko QUIET' RequestNotify 'Operation Completed Successfully.' /* show a requester with an OK button */ Undo On UnlockInput /* restore input so that a user can use the GUI again */ EXIT /* here the execution ends */ /* Exceptions, executed only if a call was made to one of them: */ BREAK_FrameNotFound: RequestNotify 'Frame file cannot be accessed - check path and files' Call BREAK_C /* all exceptions end in the same way as if we pressed the close button on the Arexx titlebar */ BREAK_SymbolNotFound: RequestNotify 'Symbol file cannot be accessed - check path and files' Call BREAK_C BREAK_PrefsNotFound: RequestNotify 'Prefs file cannot be accessed - check path and files' Call BREAK_C BREAK_TextureNotFound: RequestNotify 'Texture file cannot be accessed - check path and files' Call BREAK_C BREAK_RAMFrameNotFound: RequestNotify 'Frame file in RAM cannot be accessed' Call BREAK_C BREAK_RAMSymbolNotFound: RequestNotify 'Symbol file in RAM cannot be accessed' Call BREAK_C BREAK_RAMPrefsNotFound: RequestNotify 'Prefs file in RAM cannot be accessed' Call BREAK_C BREAK_CardNotFound: RequestNotify 'Card file cannot be accessed - check path and files' Call BREAK_C BREAK_CannotSaveCard: RequestNotify 'Cannot save file - check path, protection bits and free disk space' Call BREAK_C BREAK_TempFileNotFound: RequestNotify 'Cannot find temp file' Call BREAK_C /* In case of a break signalled */ BREAK_C: Message "Exiting DIYreko" UnlockInput KillBuffer force swap KillBuffer force KillBrush force Render close Undo On Redraw On ADDRESS COMMAND 'Protect >NIL: RAM:__DIYreko#?__ ADD d' ADDRESS COMMAND 'Delete RAM:__DIYreko#?__ QUIET' ADDRESS COMMAND 'Protect >NIL: 'tempdir'__DIYreko#?__ ADD d' ADDRESS COMMAND 'Delete 'tempdir'__DIYreko#?__ QUIET' EXIT