diff --git a/sources/BG_BLUE.zip b/sources/BG_BLUE.zip deleted file mode 100644 index 7815850..0000000 Binary files a/sources/BG_BLUE.zip and /dev/null differ diff --git a/sources/bg_blue/1024x768.jpg b/sources/bg_blue/1024x768.jpg new file mode 100644 index 0000000..1fd6d04 Binary files /dev/null and b/sources/bg_blue/1024x768.jpg differ diff --git a/sources/bg_blue/12801024v.jpg b/sources/bg_blue/12801024v.jpg new file mode 100644 index 0000000..7fdda0c Binary files /dev/null and b/sources/bg_blue/12801024v.jpg differ diff --git a/sources/bg_blue/1280x1024.jpg b/sources/bg_blue/1280x1024.jpg new file mode 100644 index 0000000..b24492c Binary files /dev/null and b/sources/bg_blue/1280x1024.jpg differ diff --git a/sources/bg_blue/16to10.jpg b/sources/bg_blue/16to10.jpg new file mode 100644 index 0000000..abe85d0 Binary files /dev/null and b/sources/bg_blue/16to10.jpg differ diff --git a/sources/bg_blue/16to9.jpg b/sources/bg_blue/16to9.jpg new file mode 100644 index 0000000..b439f0b Binary files /dev/null and b/sources/bg_blue/16to9.jpg differ diff --git a/sources/bg_blue/4to3.jpg b/sources/bg_blue/4to3.jpg new file mode 100644 index 0000000..25ba598 Binary files /dev/null and b/sources/bg_blue/4to3.jpg differ diff --git a/sources/bg_blue/licence.txt b/sources/bg_blue/licence.txt new file mode 100644 index 0000000..e43de6e --- /dev/null +++ b/sources/bg_blue/licence.txt @@ -0,0 +1 @@ +Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License (CC BY-NC-SA 4.0) By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. Section 1 - Definitions. a.Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. b.Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. c.BY-NC-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License. d.Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. e.Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. f.Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. g.License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution, NonCommercial, and ShareAlike. h.Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. i.Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. j.Licensor means the individual(s) or entity(ies) granting rights under this Public License. k.NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange. l.Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. m.Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. n.You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. Section 2 - Scope. a.License grant. 1.Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: A.reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and B.produce, reproduce, and Share Adapted Material for NonCommercial purposes only. 2.Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. 3.Term. The term of this Public License is specified in Section 6(a). 4.Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. 5.Downstream recipients. A.Offer from the Licensor - Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. B.Additional offer from the Licensor - Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter's License You apply. C.No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. 6.No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). b.Other rights. 1.Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. 2.Patent and trademark rights are not licensed under this Public License. 3.To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes. Section 3 - License Conditions. Your exercise of the Licensed Rights is expressly made subject to the following conditions. a.Attribution. 1.If You Share the Licensed Material (including in modified form), You must: A.retain the following if it is supplied by the Licensor with the Licensed Material: i.identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); ii.a copyright notice; iii.a notice that refers to this Public License; iv.a notice that refers to the disclaimer of warranties; v.a URI or hyperlink to the Licensed Material to the extent reasonably practicable; B.indicate if You modified the Licensed Material and retain an indication of any previous modifications; and C.indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. 2.You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. 3.If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. b.ShareAlike. In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply. 1.The Adapter's License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-NC-SA Compatible License. 2.You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material. 3.You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply. Section 4 - Sui Generis Database Rights. Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: a.for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only; b.if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and c.You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. Section 5 - Disclaimer of Warranties and Limitation of Liability. a.Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You. b.To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You. c.The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. Section 6 - Term and Termination. a.This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. b.Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: 1.automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or 2.upon express reinstatement by the Licensor. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. c.For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. d.Sections 1, 5, 6, 7, and 8 survive termination of this Public License. Section 7 - Other Terms and Conditions. a.The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. b.Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. Section 8 - Interpretation. a.For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. b.To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. c.No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. d.Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the -Licensor.- The text of the Creative Commons public licenses is dedicated to the public domain under the CC0 Public Domain Dedication. Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark -Creative Commons- or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. Creative Commons may be contacted at creativecommons.org. \ No newline at end of file diff --git a/sources/bg_blue/readme.txt b/sources/bg_blue/readme.txt new file mode 100644 index 0000000..ef4abf5 --- /dev/null +++ b/sources/bg_blue/readme.txt @@ -0,0 +1,151 @@ + BG_BLUE_STRUCTURE - Background Images for the FireBee Computer + -------------------------------------------------------------- + + +Introduction +------------ +Thank you for downloading the BG_BLUE_STRUCTURE set of background images +for the FireBee computer. The supplied images can be used as background +image in the FreeMiNT/XaAES or the FreeMiNT/MyAES environments. The +following sizes are available: 4x3 (1600x1200), 16x9 (1920x1080), 16x10 +(1920x1200), 1024x768, 1280x1024. + +Authors +---------- +FireBee Logo idea: Friederike Dreyer (& Mathias Wittau) +FireBee Logo artwork: Jean-Pierre Feicht +BG concept & design: Mathias Wittau +The ACP Team + +LICENSE: CC BY-NC-SA 4.0 + +Version: 1.0 +Release date: 2015/09/10 + + +DISCLAIMER +---------- +This archive is PROVIDED AS IT IS, and the authors DISCLAIM ALL +RESPONSIBILITY FOR ANY LOSS OR DAMAGE resulting from the use of this pack +of backgrounds, no matter how it is caused. + + +How to set a BG image +--------------------- + +FreeMiNT/XaAES +-------------- +XaAES is capable of displaying a wallpaper in all colour depths and +resolutions. However, *setting* a wallpaper is not straightforward, but +it is done by pressing a keys combination which takes a snapshot of the +current screen and set it as the desktop background. As you probably +don't want your GEM desktop as wallpaper, you need a program capable of +displaying a picture in fullscreen, and then set the desktop background. + +1.Open the picture of your choice in zView, the image viewer available + in your FireBee setup. It's recommended to use the same proportions of + your current screen res. + +2.Press 'F10' to display the picture in zView fullscreen mode. + +3.Press the following keyboard combination: + +CONTROL+ALT+":" + +You might have to press Shift to get the ":", e.g. Shift+".". In this +case, the keyboard combination will be Control+Alt+Shift+".". Now XaAES +saves this picture as background in: + +c:/mint/1-19-cur/xaaes//xa_form.mfd + +4.Close zView. The picture formerly displayed in fullscreen by zView is +now your desktop background. + +Please note that this background will be used in your current colour +depth and screenres only. If you switch to another resolution and you +want to keep the same wallpaper, you will have to repeat the steps +above. The generated backgrounds will be available at every resolution +change. + +FreeMiNT MyAES +-------------- +In MyAES, the BG image is always named desk.jpg and by default is +located inside the skin=C:\gemsys\myaes\skins\ folder. This path +is set in the myaes configuration file and can be changed. + +Be aware that the skin\ folder contains all the images for the +window's theme in use, and modifying the contents other than the +desk.jpg image, will affect the overall look. + +Setting up a BG image +---------------------- +1. Select the source BG image matching your preferred screenres; +2. Rename or Copy/Rename it into desk.jpg; +3. Move or Rename or Delete the current BG image, by default: + (C:\gemsys\myaes\skins\\desk.jpg); +4. Copy/move the new desk.img to the skin/ folder; +5. Reboot. + +The selected desk.img image will be used in all screenres as MyAES +will automatically tile the background images smaller than current +screenres and crop the right/bottom edges of those bigger. + + +System Requirements +------------------- +- A poweful TOS platform with TC screen depth; +- A Multitasking OS (such as FreeMiNT/XaAES or FreeMiNT/MyAES) and a + desktop; +- the OS extension NVDI or the NVDI palette is recommanded (required to + display correctly the 256 colors icon sets for the fireBee). + + +Licence +------- +This background images set is licensed by the Authors listed in the +"Authors" section of this readme file, under a: + +CREATIVE COMMONS ATTIBUTION-NONCOMMERCIAL-SHAREALIKE 4.0 INTERNATIONAL +(CC BY-NC-SA 4.0) + +https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode + +Under this licence, you are free to: + +Share - copy and redistribute the material in any medium or format +Adapt - remix, transform, and build upon the material + +The licensor cannot revoke these freedoms as long as you follow the +license terms. + +Under the following terms: + +Attribution - You must give appropriate credit, provide a link to the +license, and indicate if changes were made. You may do so in any +reasonable manner, but not in any way that suggests the licensor +endorses you or your use. + +NonCommercial - You may not use the material for commercial purposes. + +ShareAlike - If you remix, transform, or build upon the material, you +must distribute your contributions under the same license as the +original. + +No additional restrictions - You may not apply legal terms or +technological measures that legally restrict others from doing anything +the license permits. + + +Notices: +You do not have to comply with the license for elements of the material +in the public domain or where your use is permitted by an applicable +exception or limitation. + +No warranties are given. The license may not give you all of the +permissions necessary for your intended use. For example, other rights +such as publicity, privacy, or moral rights may limit how you use the +material. + +For the full text of the licence see the LICENSE.TXT document. + + diff --git a/sources/bg_blue/summary.txt b/sources/bg_blue/summary.txt new file mode 100644 index 0000000..1c563a2 --- /dev/null +++ b/sources/bg_blue/summary.txt @@ -0,0 +1 @@ +Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) This is a human-readable summary of (and not a substitute for) the license You are free to: Share - copy and redistribute the material in any medium or format; Adapt - remix, transform, and build upon the material. The licensor cannot revoke these freedoms as long as you follow the license terms. Under the following terms: Attribution - You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. NonCommercial - You may not use the material for commercial purposes. ShareAlike - If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. No additional restrictions - You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. Notices: You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation. No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material. \ No newline at end of file diff --git a/sources/fb_hyps.zip b/sources/fb_hyps.zip deleted file mode 100644 index 1d2488e..0000000 Binary files a/sources/fb_hyps.zip and /dev/null differ diff --git a/sources/fb_hyps/FB_LOG16.IMG b/sources/fb_hyps/FB_LOG16.IMG new file mode 100644 index 0000000..c5c2b43 Binary files /dev/null and b/sources/fb_hyps/FB_LOG16.IMG differ diff --git a/sources/fb_hyps/catalog.cfg b/sources/fb_hyps/catalog.cfg new file mode 100644 index 0000000..3e8095e --- /dev/null +++ b/sources/fb_hyps/catalog.cfg @@ -0,0 +1,37 @@ +-COMPILE +>System +Basic system software/Setup tools +>Tools +The software you need +>Internet +and Network +>Development tools +Programmieren... +>Others +Unsorted documentations +# +.welcome.hyp +System +.firebee.hyp +System +.TERADESK.HYP +System +.THING.HYP +System +.THINGICN.HYP +System +.cops.hyp +System +.xaaes.hyp +# +./DE/RSM.HYP +Development tools +.BGH.HYP +Development tools +.BGH2RSM.HYP +Development tools +.OVERLAY.HYP +Development tools +.rsm2cs.hyp +Development tools +# diff --git a/sources/fb_hyps/catalog.hyp b/sources/fb_hyps/catalog.hyp new file mode 100644 index 0000000..b08eb6c Binary files /dev/null and b/sources/fb_hyps/catalog.hyp differ diff --git a/sources/fb_hyps/catalog.ref b/sources/fb_hyps/catalog.ref new file mode 100644 index 0000000..41224fb Binary files /dev/null and b/sources/fb_hyps/catalog.ref differ diff --git a/sources/fb_hyps/catalog.stg b/sources/fb_hyps/catalog.stg new file mode 100644 index 0000000..c623988 --- /dev/null +++ b/sources/fb_hyps/catalog.stg @@ -0,0 +1,280 @@ +@database "Hypertext of Hypertexts" +@options "-ains" +@author "ACP" +@$VER: Catalog (@:"__DATE__") + +@subject "TOP" +@node "Main" "Available Hypertexts" +@{0U}Available Hypertexts FireBee@{0} + + EN @{"DE" LINK "DE"} @{"FR" LINK "FR"} @{"RU" LINK "RU"} @{"NL" LINK "NL"} + +@line 1 59 0 + + + @{"System" link "System"} + Basic system software/Setup tools + + @{"Tools" link "Tools"} + The software you need + + @{"Network" link "Network"} + Connection to other computers + + @{"Development tools" link "Development tools"} + Compiler, Resource editor... + + @{"Others" link "Others"} + Unsorted documentations + +@endnode + + +@node "System" +@toc "Main" +@{0U}System FireBee@{0} + + @{"Welcome to the FireBee" link welcome.hyp} + Version: 1.0 + + @{"FireBee/FireTOS documentation" link firebee.hyp} + Program: March 16 2014 Doc: July 25 2011 + + @{"TeraDesk" link TERADESK.HYP} + Version: 4.08 (July 2019) + + @{"Thing! Desktop" link THING.HYP} + Version: 1.27 (23/8/1998) + + @{"ThingIcon" link THINGICN.HYP} + Version: 1.10 + + @{"XaAES" link XAAES.HYP} + Version: 1.6.4beta + + @{"COntrolPanel Server" LINK cops.hyp} + Version: 1.07 (15. July 1997) + + @{"FlashTool" LINK C:\flasher\readme.txt} + Version: 2.01 + + @{"TosWin2" link C:\guides\DE\toswin2.hyp} (only german) + Version: 2.7 + +@endnode + + +@node "Tools" +@toc "Main" +@{0U}Tools FireBee@{0} + + @{"68k Emulator" link C:\tools\68kemu\README.txt} + Version: (17/03/2012) + + @{"lzip" LINK C:\tools\lzip\lzip.txt} + Version: 1.0 + + @{"QED Texteditor" link C:\guides\qed.hyp} + Version: 5.0.5 + + @{"Qextract" LINK C:\tools\qextract\qextract.txt} + Version: 0.7 + + @{"Simple Boot Manager" LINK C:\tools\sboot-03\readme.txt} + Version: 0.3 + + @{"ST-Guide+Tools EN" LINK "stg_en"} + + @{"Synctime" SYSTEM "C:\tools\synctime\doc\synctime.htm"} + Version: 1.3 + + @{"zView Guide" link ZVIEW.HYP} + Version: BETA7a (25/12/05) + +@endnode + + +@node "stg_en" "ST-Guide+Tools EN" +@{0U}ST-Guide+Tools EN FireBee@{0} + + @{"ST-Guide" LINK st-guide.hyp} + Version: 1.5e (1997) + + @{"HCP Hypertext compiler" LINK hcp.hyp} + Version: 2.0e (1997) + + @{"RefLink" LINK reflink.hyp} + Version: 1.02 (1997) + + @{"STool" LINK stool.hyp} + Version: 1.00e (1997) + +@endnode + + +@node "Network" +@toc "Main" +@{0U}Network FireBee@{0} + +## @{"NFS Client lmount" LINK lmount.hyp} +## Version: 1.0 (2019) + +@endnode + + +@node "Development tools" +@toc "Main" +@{0U}Development tools FireBee@{0} + + @{"ResourceMaster EN" link rsm.hyp} + Version: 3.6 + + @{"AHCC" link ahcc.hyp} + Version: 5.6 + + @{"DIGGER" link digger.hyp} + Version: 8.1 + + @{"GFA Basic Editor" LINK "GBE"} + Version: 1.71 + + @{"TOS - The Operating System" link TOS.HYP} + Version: December 19, 2008 + +@endnode + + +@node "GBE" "GFA Basic Editor" +@toc "Development tools" +@{0U}GFA Basic Editor FireBee@{0} + + @{"GBE" link gbe.hyp} + Version: 1.71 + + @{"GBE libraries" link gbe_lib.hyp} + + @{"Devpac 3" link devpac3.hyp} + + @{"GFA Basic" link gfabacic.hyp} + (original Atari version) + + @{"Atari Compendium" link compend.hyp} + Version: 1.25 + +@endnode + + +@node "Others" +@toc "Main" +@{0U}Others FireBee@{0} + + +@endnode + + +@node "DE" "German Hypertexts" +@toc "Main" +@{0U}German Hypertexts FireBee@{0} + + @{"TeraDesk" link C:\guides\DE\TERADESK.HYP} + Version: 4.08 (July 2019) + + @{"Thing! Desktop" link C:\guides\DE\THING.HYP} + Version: 1.27D (23/8/1998) + + @{"ThingIcon" link C:\guides\DE\THINGICN.HYP} + Version: 1.10D + + @{"COntrolPanel Server" LINK C:\guides\DE\cops.hyp} + Version: 1.08D + + @{"QED Texteditor" link C:\guides\DE\qed.hyp} + Version: 5.0.5 + + @{"ResourceMaster DE" link "rsm_de"} + + @{"ST-Guide+Tools DE" LINK "stg_de"} + + @{"TOS - Das Betriebssystem" link C:\guides\DE\TOS_HYP.HYP} + Version: M„rz 28, 2016 + + @{"TosWin2" link C:\guides\DE\toswin2.hyp} + Version: 2.7 + +@endnode + + +@node "rsm_de" "ResourceMaster DE" +@toc "DE" +@{0U}ResourceMaster DE FireBee@{0} + + @{"ResourceMaster" link C:\guides\DE\RSM.HYP} + Version: 3.65 + + @{"BGH" link C:\guides\DE\BGH.HYP} + Version: 1.4 + + @{"BGH to RSM" link C:\guides\DE\BGH2RSM.HYP} + Version: 1.2 + + @{"ResourceMaster-Overlays" link C:\guides\DE\OVERLAY.HYP} + Version: ? + + @{"RSM to C-Source" link C:\guides\DE\rsm2cs.hyp} + Version: 1.03 + + @{"SRSCSIZE" link C:\guides\DE\srscsize.txt} + Version: Mai 9, 2000 + +@endnode + + +@node "stg_de" "ST-Guide+Tools DE" +@toc "DE" +@{0U}ST-Guide+Tools DE FireBee@{0} + + @{"ST-Guide" LINK C:\guides\DE\st-guide.hyp} + Version: 1.5d (1997) + + @{"HCP Hypertext compiler" LINK C:\guides\DE\hcp.hyp} + Version: 2.0d (1997) + + @{"RefLink" LINK C:\guides\DE\reflink.hyp} + Version: 1.02 (1997) + + @{"STool" LINK C:\guides\DE\stool.hyp} + Version: 1.00d (1997) + +@endnode + + +@node "FR" "French Hypertexts" +@toc "Main" +@{0U}French Hypertexts FireBee@{0} + + @{"Thing! Desktop" link C:\guides\FR\THING.TXT} + Version: 1.27E (23/8/1998) + + @{"ThingIcon" link C:\guides\THINGICN.TXT} + Version: 1.10E + +@endnode + + +@node "RU" "Russian Hypertexts" +@toc "Main" +@{0U}Russian Hypertexts FireBee@{0} + + @{"TeraDesk" link C:\guides\RU\TERADESK.HYP} + Version: 4.08 (July 2019) + +@endnode + + +@node "NL" " Dutch Hypertexts" +@{0U}Dutch Hypertexts FireBee@{0} + + @{"QED Texteditor" link C:\guides\NL\qed.hyp} + Program: 5.0.5 Doc: 5.0.2 + +@endnode diff --git a/sources/fb_hyps/catalog.txt b/sources/fb_hyps/catalog.txt new file mode 100644 index 0000000..cf091d6 --- /dev/null +++ b/sources/fb_hyps/catalog.txt @@ -0,0 +1,16 @@ +Notes for creating HypViews catalog.hyp file on FireBee: + +- Please do NOT use ST-Guides "stool.tos" for creating a catalog.hyp file! + It works, but stool.tos don't accept pathnames in the catalog.cfg configuration + file and so the "multi-language structure" of FireBees /guides/ folder is + not working sufficiently. + So please see the the included "catalog.cfg" only as an example. + +- If you want to add categories, .hyp files or "external" (.txt) files to your + catalog, edit file "catalog.stg" with texteditor QED. Just copy and paste + a "neighbour entry" link, edit name and path to your needs and save the file. + + After that, drag and drop the file "catalog.stg" on compiler c:/tools/stgui15/st-guide/hcp.ttp + and the new catalog will be created. + +If you have problems with that, please send me an email: latzmaster@gmx.de diff --git a/sources/fb_hyps/clock.img b/sources/fb_hyps/clock.img new file mode 100644 index 0000000..786309b Binary files /dev/null and b/sources/fb_hyps/clock.img differ diff --git a/sources/fb_hyps/desktop.img b/sources/fb_hyps/desktop.img new file mode 100644 index 0000000..c8719dd Binary files /dev/null and b/sources/fb_hyps/desktop.img differ diff --git a/sources/fb_hyps/doc_dir.img b/sources/fb_hyps/doc_dir.img new file mode 100644 index 0000000..d847cc4 Binary files /dev/null and b/sources/fb_hyps/doc_dir.img differ diff --git a/sources/fb_hyps/keyboard.img b/sources/fb_hyps/keyboard.img new file mode 100644 index 0000000..f23d495 Binary files /dev/null and b/sources/fb_hyps/keyboard.img differ diff --git a/sources/fb_hyps/language.img b/sources/fb_hyps/language.img new file mode 100644 index 0000000..47dbb09 Binary files /dev/null and b/sources/fb_hyps/language.img differ diff --git a/sources/fb_hyps/network.img b/sources/fb_hyps/network.img new file mode 100644 index 0000000..30e2dfa Binary files /dev/null and b/sources/fb_hyps/network.img differ diff --git a/sources/fb_hyps/screens.img b/sources/fb_hyps/screens.img new file mode 100644 index 0000000..e3ada41 Binary files /dev/null and b/sources/fb_hyps/screens.img differ diff --git a/sources/fb_hyps/weblink.img b/sources/fb_hyps/weblink.img new file mode 100644 index 0000000..a90c92e Binary files /dev/null and b/sources/fb_hyps/weblink.img differ diff --git a/sources/fb_hyps/welcome.hyp b/sources/fb_hyps/welcome.hyp new file mode 100644 index 0000000..776de5e Binary files /dev/null and b/sources/fb_hyps/welcome.hyp differ diff --git a/sources/fb_hyps/welcome.stg b/sources/fb_hyps/welcome.stg new file mode 100644 index 0000000..4443450 --- /dev/null +++ b/sources/fb_hyps/welcome.stg @@ -0,0 +1,2139 @@ +@database "Welcome to the FireBee" +@options "-i" +@author "ACP" +@$VER: Version 1.0 (@:"__DATE__") +@subject "System" +@width 75 + +@node "Main" "Welcome to FireBee" +@{0U}Welcome FireBee@{0} + + EN @{"DE" LINK "DE1"} @{"FR" LINK "FR1"} @{"IT" LINK "IT1"} @{"ES" LINK "ES1"} @{"RU" LINK "RU1"} + +@line 25 26 0 + + +@limage FB_LOG16.IMG 0 + + @{0B}Congratulations on your new FireBee!@{0} + +Before you start using your FireBee you'll probably want to change some +basic settings. The tools described in this document can be found in +the folder c:\mint\setup\. + + +@{0B}REALLY IMPORTANT:@{0} All the software included in your FireBee FreeMiNT-Setup +is provided "@{0B}as is@{0}". Means that if you have problems/suggestions or just +questions about a particular software, @{0U}please read its documentation first@{0} +and, if your issue is not solved, contact the author/developer @{0U}directly or +post in a forum@{0} (see "Weblinks"). +On the firebee.org @{"support pages" system "http://firebee.org/fb-bin/support?lng=EN"} you also will find many information +about the FireBee hardware and software. + +All the installed programs are tested by several users and work good. +But please understand that the ACP project @{0B}can not maintain/support@{0} all +this "third party" software! + + Thank you - the ACP team. + + + @{"First steps" LINK "Usage"} + + @{"The FireBee FreeMiNT file/folder structure" LINK "fstruct"} + + @{"Installed software" link "softnotes"} + + +The weblinks in this document are opened in NetSurf browser with +a left click. +Linked local files will be opened with left click in the current window. + +This helpviewer "HypView" is autostarted by the desktop. If you don't like +this, please deactivate the Autostart-function for "hyp_view.app" in the +desktops "Set Applications" dialog. + +@endnode + + +@node "Usage" "First steps" +@{0U}First steps FireBee@{0} + +@image desktop.img 2 + + + @{0U}Choose which desktop to use:@{0} + +With the tool @{0B}sel_desk.prg@{0} you can select which desktop to use with +FreeMiNT on your FireBee. It comes with a selection of three desktops - +@{"TeraDesk" LINK "teradesk.hyp"}, @{"Thing! v1.27" LINK "thing.hyp"} and Thing! v1.29. +Please note that Thing! v1.29 is a betaversion and has a few minor bugs. + +sel_desk.prg is automatically started the first time you boot your Bee. +If you want to switch to an other desktop later on, you can easily do so +with this tool. + +Your desktop selection is saved in the configuration file +c:\mint\desktop.cnf. + + +@image screens.img 2 + + + @{0U}Change screen mode:@{0} + +Your FireBee boots by default into a standard VGA resolution. This means +640 by 480 pixels in 65536 colours. You probably want to select a mode +more appropriate to your monitor. +The tool @{0B}modes.prg@{0} presents a list of all available screenmodes for you +to choose between. If your monitor supports EDID, its native resolution is +easily available as the "Best" screenmode, which is selected by default. + +See @{"Wikipedia/EDID" system "https://en.wikipedia.org/wiki/Extended_display_identification_data"} for more informations. + +@{0B}Important! Please test the screenmode before you use it!@{0} If the test +doesn't display a proper picture (correct vertical colour (or b/w) lines, +no "flickering"), don't use this screenmode. + +The screenmode is saved in the configuration file c:\mint\xa_video.cnf. +If you by accident save a screenmode that your monitor doesn't support, +you can boot to FireTOS or EmuTOS and delete this file. The next time you +boot FreeMiNT/XaAES, the video mode used by TOS will be used. You can now +use modes.prg to select a new screenmode again. + + +@image network.img 2 + + + @{0U}Modify the network settings:@{0} + +The network settings in your FireBee is preconfigured to automatically +connect to your network using the DHCP protocol. If your network is using +this mode (most do), then you don't have to change anything. + +If your network doesn't use DHCP, or you for some reason want to assign +your FireBee a fixed address, you can launch the tool @{0B}netconf.prg@{0}. +This will allow you to choose between automatic (DHCP) and manual network +configuration. If you use manual configuration, the tool will not let you +save the settings until all required fields are filled out and validated. + +Note! The Firebee ethernet driver's device name is @{0B}eth0@{0}. + +Your network settings are saved in c:\mint\network.cnf. +If you don't use networking at all, you can safely delete this file. + + +@image keyboard.img 2 + + + @{0U}Select keyboard layout:@{0} + +FreeMiNT offers a lot of keyboard layouts for different languages. You can +assign one (or more) of these @{manually LINK C:\mint\1-19-2c5\keyboard\ReadMe} or you can create a +different keyboard layout with the GEM tool @{KeyEdit LINK keyedit.hyp}. + + +@image language.img 2 + + + @{0U}Choose your preferred language:@{0} + +FreeMiNT/XaAES is available in eight languages. XaAES sets the language +automatically if a translation is present, according the AKP-cookie (which +contain the system language/keyboard settings). +You can easily set your preferred language with the tool @{0B}language.prg@{0}. + +For the desktops @{0B}TeraDesk@{0} and @{0B}Thing!@{0} (and many other programs), +translations in several languages are available within the respective +(sub-)directories. Simply rename the programs resource file +(e.g. "desktop.rsc" for TeraDesk) to .rsx and then copy the .rsc file from +"your" language subfolder here. + +Some (mostly newer) programs also set their language automatically. + + +@image clock.img 2 + + + @{0U}System time and date:@{0} + +If you are connected to the internet, your FireBee's system time and date +is automatically updated at start by the program @{0B}Synctime@{0} in folder +c:\tools\synctime\. +Please set your local timezone and DST (Daylight saving time). +The default NTP timeserver is globally available, but you can improve the +performance by setting a more local timeserver like e.g. +"0.de.pool.ntp.org" for Germany. Searching the web for "ntp timeserver" +gives you more info. + + +@image doc_dir.img 2 + + + @{0U}Further readings:@{0} + +@{"How to set up NVDI 5.03 on the FireBee." LINK C:\nvdi\readme.txt} +@{"Use a desktop wallpaper." LINK C:\mint\wallp\readme.txt} +@{"SpareMinT Wiki" system "http://wiki.sparemint.org/"} + +Please take a look in the folder c:\guides\ as well. There you will +find documentations for many of the programs delivered with your FireBee. +Or just open @{"HypViews catalog" LINK "catalog.hyp"} :-) + + +@image weblink.img 2 + + + @{0U}Weblinks, news and support:@{0} + +News, updates and software downloads can be find on @{"FireBee website" system "http://firebee.org"}. + +For assistance, discussions etc please visit: + +- @{"The FireBee Forum" system "http://atari-forum.com/viewforum.php?f=92"} +- @{"The german FireBee Forum" system "https://forum.atari-home.de/index.php?board=35.0"} +- You can also join the @{"FireBee Mailing list" system "mailto:acplist-subscribe@firebee.org"}. + +As well our @{"development blog" system "http://acp.atari.org"} may be an interresting +resource for you. + +@line 1 74 0 + +Your FireBee comes with @{0B}2 years warranty@{0} that is granted by our hardware +producer @{"Medusa Computer Systems" system "http://medusacomputer.com/"}. + +You can as well contact us at any time at our +main mailaddress @{0B}acpinfo@atari.org@{0}. + +@endnode + + +@node "fstruct" "File/folder structure" +@{0U}The file/folder structure FireBee@{0} + +@{0U}The root directory, partition c:/:@{0} + +CLIPBRD --> Copy/paste "scrap.*" is saved here +Downloads --> Default download folder for browser, ftp, ... +THING --> Desktops Thing! v1.27 and v1.29 +Uploads --> Default upload folder +auto --> The AUTO folder +cpx --> Control panel modules (*.cpx) @{0B}used with TOS only!@{0} +devtools --> Developer tools +firebee --> Informations about FireBee hardware +gemsys --> System-wide used files/libraries (fonts, ...) +guides --> *.hyp and *.ref helpfiles from all programs go here +home --> Software configuration files are saved here +mint --> The FreeMint system directory +nvdi --> Patch program for NVDI5 on the FireBee +sources --> Archives of included software/FreeMinT binaries +teradesk --> The desktop "TeraDesk" +tools --> Default folder for GEM programs +zipped --> ZIP archives of "third party software" +CONTROL.INF --> Configuration file for FBXCTRL*.ACC +FBXCTRL*.ACC --> Controlpanel server @{0B}used with TOS only!@{0} + + +@{0U}The FreeMinT system directory c:/mint/:@{0} + +1-19-* --> FreeMinT "kernel" folder, "*" is the release version +DESKTOP.CNF --> Your desktop selection (created by sel_desk.prg) +mint_acc --> Accessories @{0B}used with FreeMinT only!@{0} +mint_cpx --> Control panels @{0B}used with FreeMinT only!@{0} +network.cnf --> Your network configuration, created by netconf.prg +setup --> FreeMinT setup tools described in "Welcome..." helptext +slb --> Shared libraries for system-wide usage +sys --> FreeMinT "advanced" binaries and files +sys.cnf --> System symbolic links +tools --> GEM tools for FreeMinT +wallp --> A nice set of FireBee desktop background images + + +@{0U}The FreeMinT kernel folder c:/mint/1-19-*/:@{0} + +doc --> Documentations +ext2.xfs --> Filesystem driver for ext2 partitions +firebee --> FireBee ethernet driver +fonts --> FreeMinT system fonts for other languages +inet4.xdd --> Network device driver +keyboard --> Keyboard tables for many languages +lp.xdd --> Driver for local printer +minix.xfx --> Filesystem driver for minix (deactivated) +mint.cnf --> @{"The FreeMinT configuration file" LINK c:\mint\1-19-2c5\mint.cnf} +mint.ini --> (Boot-) Initialization file (don't edit by hand!) +mintv4e.prg --> FreeMinT kernel +nfs.xfs --> Driver for network file system +xaaes --> XaAES (Application Environment System) +xconout2.xdd --> Device driver for console output + + +@{0U}The XaAES folder c:/mint/1-19-*/xaaes/:@{0} + +640480.16 --> Background image for 640x480, 65536 colours +gradient --> Gradient styles for window frame (titlebar, buttons, ...) +img --> Colour images for window frame +moose.adi | +moose_w.adi |-> Mouse drivers +pal --> Different colour palettes (GEM, NVDI) +widgets --> Different window button styles +xa_help.cs | +xa_help.de | +xa_help.es | +xa_help.fr | +xa_help.hu | +xa_help.it | +xa_help.ru | +xa_help.txt |-> Language versions for XaAES help/keyboard hotkeys +xa_xtobj.rsc --> Default extended resource objects +xaaes.cnf --> @{"The XaAES configuration file" LINK c:\mint\1-19-2c5\xaaes\xaaes.cnf} +xaaes.km --> XaAES kernel module +xaaes016.rsc --> XaAES resource +xaaes016.rsl --> Language translation file for XaAES +xaaeswdg.rsc --> Default window button style +xaloader.prg --> Loads the XaAES kernel module +xobj --> Different styles for extended resource objects + +@endnode + + +@node "softnotes" "Installed software" +@{0U}Installed software FireBee@{0} + +The installed programs are located in separate directories, organized to +get a "logic" division between user software, FreeMiNT-related software +and programs for development. +Only the Desktops are located in their own directories, C:\teradesk\ +and C:\thing\. + + +@{0U}The Desktops:@{0} + +- TeraDesk: Light weight, TOS-like desktop with a modern style. Works + perfect with FireTOS and FreeMiNT. + +- Thing: Desktop with more functions, but also with a few small issues. + + * Thing 1.27: + - Displays only 16 color icons. + - Problems with very long filenames. + + * Thing 1.29: + - Needs NVDI for displaying 256 colour icons. + + * Both versions: + - In 256 colour mode (with or without NVDI), desktop and window + icons are black. + - The icon assignment program "thingicn.app" displays only the + 16 colour icons (but 256 colour icons are assigned correct + for the Thing 1.29 desktop). + + +@{0U}Folder C:\tools\: User software@{0} + +- 68kemu: Emulator for 68k programs which don't run directly on FireBee. + +- DracFTP: Draconis FTP client. + +- HypView: The help system, displaying .HYP helpfiles. + +- lzip: Easy compressing file/folder (.zip). + +- mxplay: Music player for MP3 and other formats. + +- NetSurf: Web browser, supporting https://. Find many links to other + useful programs in its hotlist! + NetSurf works correct only in TC modes (65k or 16M colours), + best in 16M colour mode. + +- PH Clock: A desktop clock with selectable clockfaces, serving also as + a drag and drop sample player for many uncompressed + sound formats. + +- ProCalc: A calculator. + +- qed: Text editor. + +- Qextract: Extracting tool for many compressed archive formats. + +- SBoot boot manager: + + SBoot is a startup manager for the FireBee and other TOS compatibles. + It is configurable (up to 10 sets) and able to change the startup order + of AUTO folder programs. + In our 2019 setup, SBOOT is preinstalled in the AUTO folder, but + disabled by default. To activate SBOOT, rename it to SBOOT.PRG, then + disable MiNT (rename mint-xxx.prg to mint-xxx.prx) and reboot. + Now when SBOOT main screen appears, select SBOOT.PRG with the UP/DOWN + arrows, move it to the first position with Shift+A (Move file up) or + Shift+Y (Move file down). Activate back MiNT with the RETURN key and + exit SBOOT with the " Q " key. The system will perform the start + sequence now and boot MiNT. + + As a basic rule for reordering AUTO folder programs, SBOOT always must + boot @{0B}first@{0} while MINT always boots @{0B}last@{0}. If you install other programs + in AUTO (for instance NVDI5), remember to move MINT to the + last position! + Additional informations are available in the SBOOT folder. + +- ST-Guide: Helpsystem (old), but including programs to compile + .hyp helpfiles. + +- Synctime: Sets your system time/date from NTP server. Please set your + timezone and DST. + +- Vision: Image painting program. + +- zView: PDF viewer, image browser and -viewer. + + +@{0U}Folder C:\devtools\: Development programs@{0} + +- AHCC: Pure C compatible compiler for Atari + +- Digger: Debugger + +- GBE: GFA Basic editor. At first start of the program the editor detects + the CPU type and configures its libraries accordingly. + +- RSM: ResourceMaster, an editor for GEM resource files. + + +@{0U}Folder C:\mint\tools\: Tools for FreeMiNT only@{0} + +- fsetter: Control the filesystem settings (enable long filenames, ...). + +- gluestik: STik/STinG to MinTNet gateway, needed by some net tools. + +- mgw: MagiCNet to MinTNet gateway. + +- TosWin2: FreeMiNT console window and "frontend" for commandline shell. + + +@{0U}Folder C:\mint\setup\: FreeMiNT setup tools@{0} + +See @{"First steps" link Usage}. + + +Again: All the software included in our FireBee FreeMiNT-Setup is provided +"@{0B}as is@{0}". The notes are only a small collection of hints and known +issues, please read the documentations of the software! + +The programs TeraDesk, QED, AHCC, Digger, HypView, Synctime, Qextract, +lzip and CoPS are native ColdFire-compiled. + +@endnode + + +@node "DE1" "Willkommen" +@{0U}Wilkommen FireBee@{0} + + @{"EN" LINK "Main"} DE @{"FR" LINK "FR1"} @{"IT" LINK "IT1"} @{"ES" LINK "ES1"} @{"RU" LINK "RU1"} + +@line 25 26 0 + + +@limage FB_LOG16.IMG 0 + + @{0B}Gratulation zur neuen FireBee!@{0} + +Beim ersten Start der neuen FireBee willst Du wahrscheinlich ein paar +grundlegende Einstellungen „ndern. Die hier beschriebenen Tools dazu +finden sich alle im Ordner c:\mint\setup\. + + +@{0B}WIRKLICH WICHTIG:@{0} Die Software in diesem FireBee FreeMiNT-Setup wird von +uns "@{0B}so wie sie ist@{0}" angeboten. Das heižt wenn Ihr Probleme/Verbesserungs- +vorschl„ge oder auch nur eine Frage zu einer bestimmten Software habt, +@{0U}bitte lest zuerst dessen Dokumentation@{0}. Und dann, wenn das Problem dadurch +nicht gel”st wird, kontaktiert den Autor/Entwickler @{0U}pers”nlich oder +schreibt eine Nachricht in einem Forum@{0} (siehe "Internetadressen"). +Alle installierten Programme wurden von mehreren Benutzern getestet und +funktionieren gut. +Aber bitte versteht daž das ACP-Projekt all diese "Drittanbieter"-Software +@{0B}weder untersttzen kann noch an deren (Weiter-)Entwicklung beteiligt ist@{0}! + + Vielen Dank - das ACP-Team. + + + @{"Erste Schritte" LINK "DE2"} + + @{"Die FireBee FreeMiNT Datei/Ordner-Struktur" link "fstruct_DE"} + + @{"Informationen zu installierter Software" link "DE3"} + + +Die Weblinks in diesem Dokument werden durch einen Linksklick im NetSurf- +Browser ge”ffnet. +Verlinkte lokale Dateien ”ffnen sich mit Linksklick im momentanen Fenster. + +Dieser Hilfe-Viewer "HypView" wird automatisch vom Desktop gestartet. +Falls das nicht gewnscht ist, deaktiviert bitte die Autostart-Funktion +fr "hyp_view.app" im Desktop-"Anwendungen anmelden" Dialog. + +@endnode + + +@node "DE2" "Erste Schritte" +@toc "DE1" +@{0U}Erste Schritte FireBee@{0} + +@image desktop.img 2 + + + @{0U}Den Desktop w„hlen:@{0} + +Mit dem Tool @{0B}sel_desk.prg@{0} kann man den - mit FreeMiNT - zu verwendenden +Desktop ausw„hlen. Es stehen drei Desktops zur Auswahl: +@{"TeraDesk" LINK C:\guides\DE\teradesk.hyp}, @{"Thing! v1.27" LINK C:\guides\DE\thing.hyp} und Thing! v1.29. +Bitte beachten: Thing! v1.29 ist eine Beta-Version und hat ein paar +kleine Fehler. + +sel_desk.prg wird nur beim ersten Start der FireBee automatisch gestartet. +Wenn man sp„ter zu einem anderen Desktop wechseln m”chte kann man das +natrlich durch manuellen Start dieses Tools tun. + +Die Auswahl des Desktops wird in der Datei c:\mint\desktop.cnf +gespeichert. + + +@image screens.img 2 + + + @{0U}Bildschirmaufl”sung „ndern:@{0} + +Die FireBee bootet voreingestellt in einer Standard-VGA Aufl”sung, das +heižt 640 x 480 Pixel in 65536 Farben. Ihr wollt aber wahrscheinlich eine +h”here Aufl”sung verwenden, m”glichst die Beste die der Monitor anbietet: + +Das Tool @{0B}modes.prg@{0} bietet eine Auswahlliste aller verfgbarer Bildschirm- +Aufl”sungen. Wenn der Monitor EDID untersttzt ist seine native Aufl”sung +bereits bei der Option "Best" eingetragen (dieser Modus ist als +Standard ausgew„hlt). + +Siehe @{"Wikipedia/EDID" system "https://en.wikipedia.org/wiki/Extended_display_identification_data"} fr mehr Informationen. + +@{0B}Wichtig! Bitte testet die gew„hlte Aufl”sung bevor ihr sie verwendet!@{0} +Wenn der Test kein sauberes Bild zeigt (vertikale bunte (o. s/w) Streifen, +kein Flimmern oder Flackern), bitte diese Aufl”sung nicht verwenden. + +Die Bildschirmaufl”sung wird in der Datei c:\mint\xa_video.cnf +gespeichert. Wenn man aus Versehen eine Aufl”sung gespeichert hat die der +Monitor nicht untersttzt, kann man FireTOS oder EmuTOS booten und diese +Datei l”schen. +Beim n„chsten Start mit FreeMiNT/XaAES wird dann der Standard-Videomodus +vom TOS verwendet. Nun kann man mit modes.prg erneut eine passende +Aufl”sung ausw„hlen. + + +@image network.img 2 + + + @{0U}Netzwerkeinstellungen „ndern:@{0} + +Die Netzwerkeinstellungen der FireBee sind zur automatischen Verbindung +per @{0B}DHCP-Protokoll@{0} vorkonfiguriert. Wenn dein Netzwerk/Router dies +untersttzt (bei den meisten Routern ist das der Standard) muž man hier +nichts ver„ndern. + +Wenn das Netzwerk kein DHCP verwendet oder man aus einem anderen Grund der +FireBee eine feste IP-Adresse zuweisen m”chte benutzt man das +Programm @{0B}netconf.prg@{0}. +Hiermit kann man zwischen automatischer (DHCP) und manueller Netzwerk- +konfiguration w„hlen. +Bei der manuellen Konfiguration muž man alle verlangten Eingaben machen, +erst danach kann man die Einstellungen speichern. + +Info: Der Firebee Ethernettreiber-Ger„tename ist @{0B}eth0@{0}. + +Die Netzwerkeinstellungen werden in der Datei c:\mint\network.cnf +gespeichert. Wenn man kein Netzwerk verwendet kann man diese Datei ohne +Probleme l”schen. + + +@image keyboard.img 2 + + + @{0U}Tastaturlayout ausw„hlen:@{0} + +FreeMiNT bietet eine Menge Tastaturlayouts fr die verschiedenen Sprachen. +Man kann ein (oder auch mehrere) Layouts @{"manuell" LINK C:\mint\1-19-2c5\keyboard\ReadMe} installieren oder +man verwendet das GEM-Tool @{"KeyEdit" LINK keyedit.hyp} zum Erstellen eines neuen (eigenen) +Tastaturlayouts. + + +@image language.img 2 + + + @{0U}Die bevorzugte Sprache einstellen:@{0} + +FreeMiNT/XaAES ist in acht Sprachen verfgbar. XaAES setzt die Sprache, +wenn eine entsprechende šbersetzung vorhanden ist, automatisch nach dem +Wert im AKP-Cookie (dies enth„lt die System-Sprache und Tastatur- +einstellung). +Zum Einstellen der bevorzugten Sprache verwendet man einfach das +Setup-Tool @{0B}language.prg@{0}. + +Bei den Desktops @{0B}TeraDesk@{0} und @{0B}Thing!@{0} (und vielen anderen Programmen) sind +in entsprechenden Unterordnern verschiedene šbersetzungen verfgbar. Man +benennt einfach die Resource-Datei des jeweiligen Programms +(z.B. "desktop.rsc" fr TeraDesk) in .rsx um und kopiert dann die .rsc- +Datei aus dem entsprechenden Unterordner in den Programmordner. + +Manche (meist neuere) Programme setzen ihre Sprache ebenfalls automatisch. + + +@image clock.img 2 + + + @{0U}System Zeit und Datum:@{0} + +Wenn die FireBee mit dem Internet verbunden ist werden beim Start System- +Zeit und -Datum automatisch durch das Programm @{0B}Synctime@{0} im Ordner +c:\tools\ gesetzt. +Bitte w„hlt hier Eure lokale Zeitzone und die Sommerzeit-Einstellung. +Der Standard NTP-Zeitserver ist weltweit verfgbar; es empfiehlt sich +jedoch einen n„heren Server zu w„hlen, z.B. "0.de.pool.ntp.org" fr +Deutschland. +Eine Internetsuche nach "ntp zeitserver" gibt Euch weitere Infos. + + +@image doc_dir.img 2 + + + @{0U}Weitere Informationen:@{0} + +- @{"Wie man NVDI 5.03 auf der FireBee installiert." LINK C:\nvdi\readme.txt} +- @{"Einen Bildschirm-Hintergrund einrichten." LINK C:\mint\wallp\readme.txt} +- @{"SpareMinT Wiki" system "http://wiki.sparemint.org/"} + +Bitte schaut auch mal in den Ordner c:\guides\. Dort finden sich +Anleitungen und Dokumentationen zu vielen der auf der FireBee +installierten Programme. +Oder benutzt einfach die @{"Katalog-Funktion" LINK "catalog.hyp"} von HypView :-) + + +@image weblink.img 2 + + + @{0U}Internetadressen, Neuigkeiten und Support:@{0} + +Neuigkeiten, Updates und Software-Downloads gibt es auf der +@{"FireBee Webseite" system "http://firebee.org"}. + +Untersttzung, Diskussionen usw. findet Ihr + +- im @{"englischen FireBee-Forum" system "http://atari-forum.com/viewforum.php?f=92"} +- im @{"deutschen FireBee-Forum" system "https://forum.atari-home.de/index.php?board=35.0"} +- Ihr k”nnt Euch auch in die @{"FireBee Mailing-Liste" system "mailto:acplist-subscribe@firebee.org"} eintragen. + +Unser @{"Entwickler-Blog" system "http://acp.atari.org"} k”nnte auch eine interessante Lektre +fr Euch sein. + +@line 1 74 0 + +Die FireBee wird mit @{0B}2 Jahren Garantie@{0} von unserem Hardware-Produzenten +@{"Medusa Computer Systems" system "http://medusacomputer.com/"} ausgeliefert. + +Ihr k”nnt uns ebenfalls jederzeit ber unsere EMailadresse +@{0B}acpinfo@atari.org@{0} kontaktieren. + +@endnode + + +@node "fstruct_DE" "Datei/Ordner-Struktur" +@toc "DE1" +@{0U}Die Datei/Ordner-Struktur FireBee@{0} + +@{0U}Das Wurzelverzeichnis, Partition c:/:@{0} + +CLIPBRD --> Copy/paste "scrap.*" Dateien werden hier gespeichert +Downloads --> Standard Download-Ordner fr Browser, ftp, ... +THING --> Die Desktops Thing! v1.27 und v1.29 +Uploads --> Standard Upload-Ordner +auto --> Der AUTO-Ordner +cpx --> Kontrollfeld-Module (*.cpx) @{0B}nur fr TOS!@{0} +devtools --> Entwickler-Programme +firebee --> Informationen ber die FireBee Hardware +gemsys --> Systemweit verwendete Dateien/Bibliotheken (Fonts, ...) +guides --> *.hyp und *.ref Hilfedateien von Programmen +home --> Programm-Konfigurationsdateien werden hier gespeichert +mint --> Das FreeMint System-Verzeichnis +nvdi --> Patch-Programm fr NVDI5 auf der FireBee +sources --> Archive der enthaltenen Software/FreeMinT Binaries +teradesk --> Der Desktop "TeraDesk" +tools --> Standard-Ordner fr GEM-Programme +zipped --> ZIP-Archive der "Drittanbieter-Software" +CONTROL.INF --> Konfigurationsdatei fr FBXCTRL*.ACC +FBXCTRL*.ACC --> Kontrollfeld-Server @{0B}nur fr TOS!@{0} + + +@{0U}Das FreeMinT System-Verzeichnis c:/mint/:@{0} + +1-19-* --> FreeMinT "Kernel" Ordner, "*" ist die Versionsnummer +DESKTOP.CNF --> Deine Desktop-Auswahl (erzeugt von sel_desk.prg) +mint_acc --> Accessories @{0B}nur fr FreeMinT!@{0} +mint_cpx --> Kontrollfelder @{0B}nur fr FreeMinT!@{0} +network.cnf --> Deine Netzwerk-Konfiguration, erzeugt von netconf.prg +setup --> FreeMinT Setup Tools, erkl„rt in "Welcome..." Hilfetext +slb --> Shared libraries fr systemweite Verwendung +sys --> FreeMinT "erweiterte" Binaries und Dateien +sys.cnf --> Systemweite symbolische Links +tools --> GEM-Tools fr FreeMinT +wallp --> Ein paar hbsche FireBee Desktop-Hintergrundbilder + + +@{0U}Der FreeMinT Kernel Ordner c:/mint/1-19-*/:@{0} + +doc --> Dokumentationen +ext2.xfs --> Dateisystem-Treiber fr ext2 Partitionen +firebee --> FireBee Ethernet Treiber +fonts --> FreeMinT System-Fonts fr andere Sprachen +inet4.xdd --> Netzwerk Ger„tetreiber +keyboard --> Tastaturlayouts (Tabellen) fr viele Sprachen +lp.xdd --> Treiber fr den lokalen Drucker +minix.xfx --> Dateisystem-Treiber fr minix (deaktiviert) +mint.cnf --> @{"Die FreeMinT Konfigurationsdatei" LINK c:\mint\1-19-2c5\mint.cnf} +mint.ini --> (Boot-) Initialisierungsdatei (nicht von Hand „ndern!) +mintv4e.prg --> FreeMinT Kernel +nfs.xfs --> Treiber fr NFS (network file system) +xaaes --> XaAES (Application Environment System) +xconout2.xdd --> Ger„tetreiber fr Konsolenausgabe + + +@{0U}Der XaAES Ordner c:/mint/1-19-*/xaaes/:@{0} + +640480.16 --> Hintergrundbild fr 640x480, 65536 Farben +gradient --> Gradient-Stile fr Fensterelemente (Titel, Buttons) +img --> Farben-Stile fr Fensterelemente +moose.adi | +moose_w.adi |-> Maustreiber +pal --> Verschiedene Farbpaletten (GEM, NVDI) +widgets --> Verschiedene Fensterbutton-Stile +xa_help.cs | +xa_help.de | +xa_help.es | +xa_help.fr | +xa_help.hu | +xa_help.it | +xa_help.ru | +xa_help.txt |-> Sprachen-Versionen der XaAES-Hilfe/Tastaturkrzel +xa_xtobj.rsc --> Standard erweiterte Resource-Objekte +xaaes.cnf --> @{"Die XaAES Konfigurationsdatei" LINK c:\mint\1-19-2c5\xaaes\xaaes.cnf} +xaaes.km --> XaAES Kernel-Modul +xaaes016.rsc --> XaAES Resource-Datei +xaaes016.rsl --> Sprachen (šbersetzungs)-Datei fr XaAES +xaaeswdg.rsc --> Standard Fensterbutton-Stil +xaloader.prg --> L„dt das XaAES Kernel-Modul +xobj --> Verschiedene Stile fr die erweiterten Resource-Objekte + +@endnode + + +@node "DE3" "Installierte Software" +@toc "DE1" +@{0U}Informationen zu installierter Software FireBee@{0} + +Die installierten Programme befinden sich in verschiedenen Verzeichnissen +um eine m”glichst logische Trennung zwischen "User"-Software, FreeMiNT- +(System-) Programmen und Entwickler-Software zu bieten. +Nur die Desktops befinden sich in ihren eigenen Ordnern, C:\teradesk\ und +C:\thing\. + + +@{0U}Die Desktops:@{0} + +- TeraDesk: Ein leichter, TOS-„hnlicher Desktop mit modernem Stil. + Arbeitet perfekt mit FireTOS und FreeMiNT. + +- Thing: Zwei Desktops mit mehr Funktionen, aber auch ein paar + kleinen Problemen. + + * Thing 1.27: + - Zeigt nur Icons in 16 Farben. + - Probleme mit sehr langen Dateinamen. + + * Thing 1.29: + - Ben”tigt NVDI zur Darstellung von 256-Farbicons. + + * Beide Versionen: + - Bei Bildschirmaufl”sungen mit 256 Farben (mit oder ohne NVDI) + sind die Desktop- und Fenstericons schwarz. + - Das Programm "thingicn.app" fr die Icon-Zuweisungen zeigt + immer nur die 16-Farbicons an (die 256-Farbicons werden aber + bei Thing 1.29 korrekt zugewiesen). + +@{0U}Ordner C:\tools\: User Software@{0} + +- 68kemu: Emulator fr 68k-Programme die nicht direkt auf der + FireBee laufen. + +- DracFTP: Draconis FTP-Client. + +- HypView: Das Hilfesystem zum Anzeigen von .HYP Hilfedateien. + +- lzip: Einfaches Komprimieren von Dateien/Ordnern (.zip). + +- mxplay: Musikprogramm (Player) fr MP3 und andere Formate. + +- NetSurf: Internet-Browser, untersttzt auch https://. In der "Hotlist" + findet Ihr viele Links zu Atari-Programmen! + NetSurf funktioniert nur in Truecolour-Bildschirmaufl”sungen + (65k oder 16M Farben). + +- ProCalc: Ein (Taschen-)Rechner. + +- qed: Texteditor. + +- Qextract: Entpacker-Tool fr viele komprimierte Formate. + +- SBoot Bootmanager: + + SBoot ist ein Start-Manager fr die FireBee und andere TOS-kompatible, + frei konfigurierbar mit bis zu 10 verschiedenen Setups. Man kann auch + die Reihenfolge der AUTO-Ordner Programme damit „ndern. + In unserem 2019 Setup ist SBOOT im AUTO-Ordner vorinstalliert, aber + standardm„žig de-aktiviert. Will man SBOOT verwenden, so muž man es erst + in SBOOT.PRG umbenennen, dann MiNT de-aktivieren (mint-xxx.prg in + mint-xxx.prx umbenennen) und danach die FireBee neustarten. + + Beim Erscheinen des SBOOT Hauptbildschirms selektiert man jetzt + SBOOT.PRG mit den PFEIL HOCH/RUNTER Tasten, dann bewegt man den Eintrag + mit SHIFT+A (hoch) oder SHIFT+Y (runter) an die @{0B}oberste@{0} Position. + Nun reaktiviert man MiNT (ausw„hlen und RETURN) und beendet danach + SBOOT mit der Taste " Q ". + Das System startet jetzt normal weiter und bootet MiNT. + + Als generelle Regel fr die Programmsortierung im AUTO-Ordner gilt: + SBOOT muž immer das @{0B}erste@{0} Programm sein und MINT immer das @{0B}letzte@{0}. + Wenn Ihr andere Programme im AUTO-Ordner (z.B. NVDI5) installiert, denkt + daran MiNT danach wieder an die letzte Position zu setzen! + Weitere Informationen zu SBOOT findet Ihr im SBOOT-Programmordner. + +- ST-Guide: Hilfesystem (alt), enth„lt aber Programme zum Kompilieren von + .hyp Hilfedateien. + +- Synctime: Setzt die FireBee System-Zeit/Datum von einem NTP-Server. + Bitte stellt Eure Zeitzone und Sommerzeiteinstellung im + Programm ein. + +- Vision: Bildbearbeitungsprogramm. + +- zView: PDF-Viewer, Bilder-Browser und -Anzeiger. + + +@{0U}Ordner C:\devtools\: Entwickler-Software@{0} + +- AHCC: Pure C kompatibler Compiler fr Atari + +- Digger: Debugger + +- GBE: GFA Basic Editor. Beim ersten Start des Programms erkennt der + Editor den CPU-Typ automatisch und konfiguriert dementsprechend + die Bibliotheken. + +- RSM: ResourceMaster, ein Editor fr GEM Resource-Dateien. + + +@{0U}Ordner C:\mint\tools\: Tools nur fr FreeMiNT@{0} + +- fsetter: Žndern der Dateisystem-Einstellungen (lange Dateinamen, ...). + +- gluestik: STik/STinG zu MinTNet-Gateway, von manchen Net-Tools ben”tigt. + +- mgw: MagiCNet zu MinTNet-Gateway. + +- TosWin2: FreeMiNT Konsolen-Fenster und "Frontend" fr die + Kommandozeilen-Shell. + + +@{0U}Ordner C:\mint\setup\: FreeMiNT Setup Tools@{0} + +Siehe @{"Erste Schritte" link DE2}. + + +Noch einmal: Die Software in diesem FireBee FreeMiNT-Setup wird von uns +"@{0B}so wie sie ist@{0}" angeboten. Die Informationen sind nur eine kleine +Sammlung von Hinweisen und bekannten Problem(ch)en; bitte lest die +jeweiligen Programm-Dokumentationen! + +Die Programme TeraDesk, QED, AHCC, Digger, HypView, Synctime, Qextract, +lzip und CoPS sind native ColdFire-kompiliert. + +@endnode + + +@node "FR1" "Bienvenu" +@{0U}Bienvenu FireBee@{0} + + @{"EN" LINK "Main"} @{"DE" LINK "DE1"} FR @{"IT" LINK "IT1"} @{"ES" LINK "ES1"} @{"RU" LINK "RU1"} + +@line 25 26 0 + + +@limage FB_LOG16.IMG 0 + + @{0B}F‚licitations pour votre nouveau FireBee!@{0} + +Avant de commencer … utiliser votre FireBee vous voudrez certainement +changer les paramŠtres de base. Les outils d‚crits dans ce document sont +disponibles dans le dossier c:\mint\setup\. + + +@{0B}TRES IMPORTANT:@{0} Tous les logiciels contenus dans votre FreeMiNT-Setup pour +le FireBee est fourni "@{0B}tel quel@{0}", ce qui signifie que pour tout problŠme +suggestion et autre question sur un logiciel en particulier, @{0U}veuillez dans +un premier temps vous r‚f‚rer … sa documentation@{0} et si votre problŠme +persiste, contactez @{0U}directement@{0} l'auteur ou le d‚veloppeur ou encore +@{0U}postez votre requette sur un forum@{0} (voir "Liens web"). +Tous les programmes install‚s sont test‚s par plusieurs utilisateurs et +fonctionnent correctement. Vous comprenez ais‚ment que le projet ACP +@{0B}ne peut maintenir ou supporter@{0} tous ces logiciels "tiers"! + + Merci - l'‚quipe ACP. + + + @{"Premiers pas" LINK "FR2"} + + @{"La structure des fichiers/dossiers FireBee FreeMiNT" LINK fstruct_FR} + + @{"Les logiciels install‚s" LINK "FR3"} + + +Les liens Web de ce document s'ouvrent dans le navigateur NetSurf par un +clic gauche. Les fichiers locaux li‚s seront ouverts avec un clic gauche +dans la fenˆtre courante. + +Ce Help-viewer est lanc‚ automatiquement par le bureau. Si vous n'etes pas +interess‚ par celui ci, vous pouvez d‚sactiver la fonction Autostart pour +"hyp_view.app" dans le menu "Set Applications" du bureau. + +@endnode + + +@node "FR2" "Premiers pas" +@toc "FR1" +@{0U}Premiers pas FireBee@{0} + +@image desktop.img 2 + + + @{0U}Choix du bureau … utiliser:@{0} + +Avec l'outil @{0B}sel_desk.prg@{0} vous pouvez s‚lectionner votre bureau qui sera +utilis‚ sous FreeMinT sur votre FireBee. Une selection parmis trois +bureaux vous est propos‚e: @{"TeraDesk" LINK "teradesk.hyp"}, @{"Thing! v1.27" LINK C:\guides\FR\thing.hyp} et Thing! v1.29. + +A noter que Thing! v1.29 est une version b‚ta et peut pr‚senter quelques +bugs mineurs. + +sel_desk.prg est automatiquement lanc‚ au premier d‚marrage de votre +FireBee. Grace … cet outil, vous pouvez, … tout moment et trŠs facilement +changer de bureau. + +La s‚lection du bureau est sauvegard‚e dans le fichier de configuration: +c:\mint\desktop.cnf. + + +@image screens.img 2 + + + @{0U}Changer la r‚solution graphique:@{0} + +Votre FireBee d‚marre par d‚faut avec une r‚solution VGA standard, soit, +640 x 480 pixels en 65536 couleurs, mais vous aurez trŠs certainement … +coeur d'utiliser un mode d'‚cran plus appropri‚ … votre moniteur. + +L'outil @{0B}modes.prg@{0} vous propose de choisir un mode graphique parmis une +liste de r‚solutions disponibles. Si votre moniteur supporte le protocole +EDID, sa r‚solution native sera alors d‚tect‚e et sera mentionn‚e en tant +que "meilleur" mode d'‚cran. Ce mode est s‚lectionn‚ par d‚faut. + +Voir @{"Wikipedia / EDID" system "https://en.wikipedia.org/wiki/Extended_display_identification_data"} pour plus d'informations. + +@{0B}ATTENTION: Veuillez tester la r‚solution d'‚cran avant de l'utiliser!@{0} +Eviter tout mode dont l'image pr‚senterait des lignes verticales +incorrectes et/ou du scintillement (que ce soit en mode N/B ou couleur). + +Le mode graphique est sauvegard‚ dans le fichier de configuration +c:\mint\xa_video.cnf. + +Si par accident, vous sauvegardez une r‚solution non support‚e par votre +moniteur, vous pourrez d‚marrer votre FireBee sous FireTOS ou EmuTOS et +supprimer ce fichier. Au prochain red‚marage sous FreeMint/XaAES, le mode +graphique TOS par d‚faut sera utilis‚ et vous pourrez utiliser de nouveau +modes.prg pour choisir une nouvelle r‚solution d'‚cran. + + +@image network.img 2 + + + @{0U}Modifier les paramŠtres r‚seau:@{0} + +Les paramŠtres r‚seau de votre FireBee sont pr‚configur‚s pour se +connecter automatiquement … votre r‚seau domestique en utilisant le +protocole DHCP. +Si votre r‚seau utilise ce mode, ce qui est la majorit‚ des cas, alors +vous n'aurez rien … modifier. + +Si toute fois votre r‚seau n'utilise pas le protocole DHCP ou si, pour une +raison quelconque, vous souhaitez attribuer … votre FireBee une adresse +fixe, vous pouvez lancer l'outil @{0B}netconf.prg@{0}. Cela vous permettra de +choisir entre une configuration automatique (via DHCP) ou bien manuelle. +Si vous optez pour une configuration manuelle, la sauvegarde sera autoris‚ +uniquement lorsque tous les champs obligatoires auront ‚t‚ compl‚t‚s +et valid‚s. + +Note! The nom du driver ethernet du Firebee est @{0B}eth0@{0}. + +Les paramŠtres r‚seau sont enregistr‚s sous c:\mint\network.cnf. +Si vous ne souhaitez pas relier votre ordinateur au r‚seau, le fichier +peut, alors, ˆtre supprim‚ en toute s‚curit‚. + + +@image keyboard.img 2 + + + @{0U}S‚lectionner la configuration du clavier:@{0} + +FreeMiNT propose de nombreuses configurations clavier pour s'adapter … la +langue s‚lectionn‚e. +Vous pouvez, toutefois, en attribuer une ou plusieurs @{manuellement LINK C:\mint\1-19-2c5\keyboard\ReadMe} ou mˆme +en cr‚er une nouvelle en fonction de vos besoins avec l'outil GEM @{KeyEdit LINK keyedit.hyp}. + + +@image language.img 2 + + + @{0U}Choisir sa langue pr‚f‚r‚e:@{0} + +FreeMiNT/XaAES est disponible en huit langues. XaAES d‚finit la langue +automatiquement en cas de traduction, selon le cookie AKP, qui contient +les paramŠtres de langue/clavier du systŠme). Vous pouvez facilement +d‚finir votre langue pr‚f‚r‚e avec l'outil @{0B}language.prg@{0}. + +Pour les bureaux @{0B}TeraDesk@{0} et @{0B}Thing!@{0} ainsi que de nombreux autres +programmes, des versions en differentes langues sont disponibles dans +leurs sous-dossiers respectifs. +Il suffit simplement de renommer le fichier de ressource de programmes +"*.rsc" en "*.rsx" puis recopier, ici, le "*.rsc" d‚sir‚ contenu dans le +sous-dossier de language. + +A noter que certains des programmes les plus r‚cents, adaptent leur +language automatiquement. + + +@image clock.img 2 + + + @{0U}Heure et date du systŠme:@{0} + +Si vous ˆtes connect‚ … Internet, l'heure et la date du systŠme de votre +FireBee sont automatiquement mises … jour au d‚marrage par le programme +@{0B}Synctime@{0} contenu dans le dossier c:\tools\synctime\. +Veuillez d‚finir votre fuseau horaire local et votre heure d'‚t‚ (DST). +Le serveur de temps NTP par d‚faut est globalement disponible, mais si +vous le souhaitez, vous pouvez en am‚liorer la pr‚cision en d‚finissant +un serveur de temps plus local comme par exemple "0.fr.pool.ntp.org" +pour la France. + +Pour un compl‚ment d'informations sur le sujet, vous pouvez effectuer une +recherche sur le net en indiquant "net timeserver" sur un +moteur de recherche. + + +@image doc_dir.img 2 + + + @{0U}Lectures complementaires:@{0} + +@{"Comment configurer NVDI 5.03 sur FireBee." LINK C:\nvdi\readme.txt} +@{"Utiliser un fond d'‚cran." LINK C:\mint\wallp\readme.txt} +@{"Wiki SpareMinT" system "http://wiki.sparemint.org/"} + +Prenez un instant pour aller voir le dossier c:\guides\, vous y +retrouverez les documentations pour de nombreux programmes fournis avec +votre FireBee. +Ou simplement pour ouvrir le @{"catalogue Hypviews" LINK "catalog.hyp"} :-) + + +@image weblink.img 2 + + + @{0U}Liens, actualit‚s et support:@{0} + +Actualit‚s, mises … jour et t‚l‚chargement de logiciels sont disponibles +sur le @{"site web du FireBee" system "http://firebee.org"}. + +Pour obtenir de l'aide, des discussions, etc... veuillez visiter: + +- @{"le forum FireBee" system "http://atari-forum.com/viewforum.php?f=92"} +- @{"le forum FireBee allemand" system "https://forum.atari-home.de/index.php?board=35.0"} +- @{"la liste de diffusion FireBee" system "mailto:acplist-subscribe@firebee.org"}. + +De plus, notre @{"blog sur le developpement" system "http://acp.atari.org"} pourait peut ˆtre +vous interresser. + +@line 1 74 0 + +Votre FireBee est livr‚ avec une @{0B}garantie de 2 ans couverte@{0} par notre +concepteur hardware @{"Medusa Computer Systems" system "http://medusacomputer.com/"}. + +Vous pouvez ‚galement nous contacter … tout moment par … notre +adresse mail: @{0B}acpinfo@atari.org@{0}. + +@endnode + + +@node "fstruct_FR" "La structure des fichiers/dossiers" +@toc FR1 +@{0U}La structure des fichiers/dossiers FireBee@{0} + +@{0U}Le r‚pertoire racine, partition c:/:@{0} + +CLIPBRD --> Copier/coller "scrap.*" est sauvegard‚ ici +Downloads --> Dossier de t‚l‚chargement par d‚faut pour navigateur, + ftp, ... +THING --> Les bureaux "Thing!" v1.27 et v1.29 +Uploads --> R‚pertoire de publication/Upload par d‚faut +auto --> R‚pertoire AUTO +cpx --> Modules de panneau de contr“le(*.cpx), + @{0B}utilisable uniquement sous TOS!@{0} +devtools --> Outils de d‚veloppement +firebee --> Informations sur le hardware du FireBee +gemsys --> Fichiers/librairies systŠme (polices, ...) +guides --> Fichiers d'aide *.hyp et *.ref +home --> R‚pertoire de sauvegarde des fichiers de + configuration logicielle +mint --> R‚pertoiren du systŠme FreeMint +nvdi --> Programme de patch pour NVDI5 sur le FireBee +sources --> Archive des binaires des logiciels et de + FreeMinT fournis +teradesk --> Le bureau "TeraDesk" +tools --> R‚pertoire par d‚faut des programmes GEM +zipped --> Archives ZIP des logiciels "tiers" +CONTROL.INF --> Fichier de configuration pour FBXCTRL*.ACC +FBXCTRL*.ACC --> Serveur de panneau de contr“le, + @{0B}utilisable uniquement sous TOS!@{0} + + +@{0U}Le r‚pertoire du systŠme FreeMinT c:/mint/:@{0} + +1-19-* --> R‚pertoire du noyau FreeMinT, "*" est le num‚ro de + la r‚vision +DESKTOP.CNF --> Votre s‚lection du bureau (g‚n‚r‚ par sel_desk.prg) +mint_acc --> Accessoires, @{0B}utilisable uniquement sous FreeMinT!@{0} +mint_cpx --> Panneau de contr“le, @{0B}utilisable uniquement + sous FreeMinT!@{0} +network.cnf --> Votre configuration r‚seau, g‚n‚r‚e par netconf.prg +setup --> Outils de configuration de FreeMinT d‚crit dans le + fichier d'aide "Welcome..." +slb --> Libraries partag‚es pour des usages du systŠme +sys --> Binaires et fichiers "avanc‚s" de FreeMinT +sys.cnf --> Liens symboliques du systŠme +tools --> Outils GEM pour FreeMinT +wallp --> Un joli ensemble d'image de fond pour le FireBee + + +@{0U}Le r‚pertoire du noyau de FreeMinT c:/mint/1-19-*/:@{0} + +doc --> Documentations +ext2.xfs --> Driver du systŠme de fichier pour les partitions ext2 +firebee --> Driver ethernet du FireBee +fonts --> Polices systŠmes et autres languages de FreeMinT +inet4.xdd --> Driver de dispositifs r‚seaux +keyboard --> Matrices claviers pour de nombreuses langues +lp.xdd --> Driver d'imprimante locale +minix.xfx --> Driver de systŠme de fichier pour minix (d‚sactivat‚) +mint.cnf --> @{"Le fichier de configuration de FreeMinT" LINK c:\mint\1-19-2c5\mint.cnf} +mint.ini --> (Boot-) Fichier d'initialisation (A ne pas + ‚diter manuellement!) +mintv4e.prg --> Noyau FreeMinT +nfs.xfs --> Driver pour le systŠme de fichiers r‚seaux +xaaes --> XaAES (Application Environment System) +xconout2.xdd --> Driver de sortie console + + +@{0U}Le r‚pertoire XaAES c:/mint/1-19-*/xaaes/:@{0} + +640480.16 --> Image de fond en 640x480, 65536 couleurs +gradient --> Gradient de styles pour les contours de fenˆtre + (barre de titre , boutons, ...) +img --> Images de couleurs pour les contours de fenˆtre +moose.adi | +moose_w.adi |-> Drivers souris +pal --> Differentes palettes de couleurs (GEM, NVDI) +widgets --> Differents styles de boutons de fenˆtre +xa_help.cs | +xa_help.de | +xa_help.es | +xa_help.fr | +xa_help.hu | +xa_help.it | +xa_help.ru | +xa_help.txt |-> Versions des raccoucris clavier/aide pour XaAES en + differentes langues +xa_xtobj.rsc --> Objets ressources ‚tendus par d‚faut +xaaes.cnf --> @{"Le fichier de configuration XaAES" LINK c:\mint\1-19-2c5\xaaes\xaaes.cnf} +xaaes.km --> Module du noyau XaAES +xaaes016.rsc --> Ressources XaAES +xaaes016.rsl --> Fichier de traduction linguistique pour XaAES +xaaeswdg.rsc --> Style de bouton de fenˆtre par d‚faut +xaloader.prg --> Charge les modules du noyau XaAES +xobj --> Diff‚rents styles pour les objets de ressource ‚tendue + +@endnode + + +@node "FR3" "Les logiciels install‚s" +@toc "FR1" +@{0U}Tools FireBee@{0} + + +@endnode + + +@node "IT1" "Benvenuto" +@{0U}Benvenuto FireBee@{0} + + @{"EN" LINK "Main"} @{"DE" LINK "DE1"} @{"FR" LINK "FR1"} IT @{"ES" LINK "ES1"} @{"RU" LINK "RU1"} + +@line 25 26 0 + + +@limage FB_LOG16.IMG 0 + + @{0B}Congratulazioni per il tuo nuovo FireBee!@{0} + +Prima di iniziare a utilizzare il tuo FireBee, probabilmente vorrai +cambiare alcune impostazioni di base. Gli strumenti descritti in questo +documento sono disponibili nella cartella c:\mint\setup\. + + +@{0B}DAVVERO IMPORTANTE:@{0} tutto il software incluso nella setup FreeMiNT del +FireBee Š fornito "@{0B}cos com'Š@{0}". Significa che se hai problemi/suggerimenti +o semplicemente domande su un software specifico, @{0U}leggi prima la sua +documentazione@{0} e, se il problema non Š risolto, @{0U}contatta direttamente +l'autore/sviluppatore o domanda su un forum Atari@{0} (vedi "Link Web"). +Tutti i programmi installati sono stati testati da pi— utenti e funzionano +correttamente. Ma devi comprendere che il progetto ACP @{0B}non ha i mezzi +per mantenere/supportare@{0} tutto questo software "di terze parti"! + + Grazie - il team ACP. + + + @{"Primi passi" LINK "IT2"} + + @{"La struttura di file/cartelle di FreeMiNT per FireBee" LINK "fstruct_IT"} + + @{"Software installato" LINK "IT3"} + + +I collegamenti Web presenti in questo documento vengono aperti nel browser +NetSurf con un clic sinistro. I file locali collegati verranno aperti con +un clic sinistro nella finestra corrente. + +Il visualizzatore di documenti "HypView" viene avviato automaticamente dal +desktop. Se non Š di tuo gradimento, puoi disattivare la funzione di avvio +automatico di "hyp_view.app" dalla finestra di dialogo +"Imposta applicazioni". + +@endnode + + +@node "IT2" "Primi passi" +@toc "IT1" +@{0U}Primi passi FireBee@{0} + +@image desktop.img 2 + + + @{0U}Scelta del desktop da utilizzare:@{0} + +Con lo strumento @{0B}sel_desk.prg@{0} puoi selezionare il desktop da utilizzare +con FreeMiNT sul tuo FireBee. Viene fornita una scelta di tre desktop: +@{"TeraDesk" LINK "teradesk.hyp"}, @{"Thing! v1.27" LINK "thing.hyp"} e Thing! v1.29. +Si prega di notare che Thing! v1.29 Š una versione beta e presenta alcuni +bug minori. + +sel_desk.prg viene avviato automaticamente al primo avvio del FireBee. +Se vuoi passare ad un altro desktop in un secondo momento, puoi farlo +facilmente sempre con questo strumento. + +Il desktop selezionato viene salvato nel file di configurazione +c:\mint\desktop.cnf. + + +@image screens.img 2 + + + @{0U}Cambia la modalit… schermo:@{0} + +FireBee si avvia per impostazione predefinita in una risoluzione VGA +standard. Questo significa 640 per 480 pixel in 65536 colori. +Probabilmente vorrai selezionare una modalit… video pi— appropriata per il +tuo monitor. Lo strumento @{0B}modes.prg@{0} presenta un elenco di tutte le +modalit… schermo disponibili tra cui scegliere. Se il tuo monitor supporta +EDID, la sua risoluzione nativa Š facilmente disponibile come modalit… +schermo "Best". +Questa modalit… Š selezionata come impostazione predefinita. + +Vedi @{"Wikipedia/EDID" system "https://en.wikipedia.org/wiki/Extended_display_identification_data"} per maggiori informazioni. + +@{0B}Importante! Si prega di testare la modalit… schermo prima di usarla!@{0} +Se il test non visualizza un'immagine corretta (linee colorate verticali +corrette (o b/n), nessun "sfarfallio"), non utilizzare questa modalit…. + +La modalit… schermo viene salvata nel file di configurazione +c:\mint\xa_video.cnf. +Se per sbaglio salvi una modalit… schermo non supportata dal tuo monitor, +puoi effettuare il boot su FireTOS o EmuTOS ed eliminare questo file. +All'avvio successivo di FreeMiNT/XaAES, verr… utilizzata la modalit… video +del TOS. A questo punto potrai usare modes.prg per selezionare una nuova +modalit… schermo. + + +@image network.img 2 + + + @{0U}Modifica le impostazioni di rete:@{0} + +Le impostazioni di rete in FireBee sono preconfigurate per una connessione +automatica alla rete usando il protocollo DHCP. Se la tua rete utilizza +questa modalit… (molte lo fanno), non devi cambiare nulla. + +Se la tua rete non utilizza DHCP, o per qualche motivo vuoi assegnare al +tuo FireBee un indirizzo fisso, Š possibile avviare lo strumento +@{0B}netconf.prg@{0}. +Questo strumento consente di scegliere tra la configurazione di rete +automatica (DHCP) e manuale. Se si utilizza la configurazione manuale, lo +strumento non consente di salvare le impostazioni fino a quando tutti i +campi richiesti non vengono compilati e convalidati. + +Nota! Il nome del dispositivo del driver Ethernet FireBee Š @{0B}eth0@{0}. + +Le impostazioni di rete vengono salvate in c:\mint\network.cnf. +Se non si utilizza la rete, Š possibile eliminare in sicurezza +questo file. + + +@image keyboard.img 2 + + + @{0U}Seleziona layout tastiera:@{0} + +FreeMiNT offre molti layout di tastiera per diverse lingue. Puoi +assegnarne uno (o di pi—) @{"manualmente" LINK C:\mint\1-19-2c5\keyboard\ReadMe} oppure Š possibile creare un +diverso layout di tastiera con lo strumento GEM @{"KeyEdit" LINK keyedit.hyp}. + + +@image language.img 2 + + + @{0U}Scegli la tua lingua preferita:@{0} + +FreeMiNT/XaAES Š disponibile in otto lingue. XaAES imposta la lingua +automaticamente se Š presente una traduzione, in base al cookie AKP (che +contiene le impostazioni di lingua/tastiera del sistema). +Puoi facilmente impostare la tua lingua preferita con lo strumento +@{0B}language.prg@{0}. + +Per i desktop @{0B}TeraDesk@{0} e @{0B}Thing!@{0} (e molti altri programmi), le traduzioni +in diverse lingue sono disponibili nelle rispettive sotto-cartelle. +E sufficente rinominare il file RSC del programma (ad esempio +"desktop.rsc" per TeraDesk) in .rsx e quindi copiare il file .rsc dalla +sottocartella della "tua" lingua. + +Alcuni programmi (per lo pi— nuovi) impostano automaticamente la lingua. + + +@image clock.img 2 + + + @{0U}Ora e data del sistema:@{0} + +Se sei connesso ad Internet, l'ora e la data del sistema FireBee viene +automaticamente aggiornata all'avvio dal programma @{0B}Synctime@{0} presente nella +cartella c:\tools\synctime\. +Si prega di impostare il fuso orario locale e l'ora legale (ora legale). +Il timeserver NTP predefinito Š disponibile a livello globale, ma Š +possibile migliorare le prestazioni impostando un timeserver pi— vicino, +come "0.it.pool.ntp.org" per la Italia. Una ricerca in rete di un +"ntp timeserver" ti fornir… maggiori informazioni. + + +@image doc_dir.img 2 + + + @{0U}Ulteriori letture:@{0} + +@{"Come configurare NVDI 5.03 su FireBee." LINK C:\nvdi\readme.txt} +@{"Usa uno sfondo del desktop." LINK C:\mint\wallp\readme.txt} +@{"Wiki SpareMinT" system "http://wiki.sparemint.org/"} + +Dai un'occhiata anche alla cartella c:\guides\ . Al suo interno troverai +la documentazione di molti dei programmi forniti con FireBee. +O semplicemente apri il @{"catalogo HypViews" LINK "catalog.hyp"} :-) + + +@image weblink.img 2 + + + @{0U}Link Web, notizie e supporto:@{0} + +Notizie, aggiornamenti e download di software sono disponibili sul +@{"sito Web FireBee" system "http://firebee.org"}. + +Per assistenza, discussioni ecc., Visitate: + +- @{"Il forum FireBee" system "http://atari-forum.com/viewforum.php?f=92"} +- @{"Il forum tedesco FireBee" system "https://forum.atari-home.de/index.php?board=35.0"} +- Puoi anche unirti alla @{"mailing list di FireBee" system "mailto:acplist-subscribe@firebee.org"}. + +Inoltre, il nostro @{"blog di sviluppo" system "http://acp.atari.org"} potrebbe essere una +interessante risorsa. + +@line 1 74 0 + +Il FireBee Š coperto da una @{0B}garanzia di 2 anni@{0} fornita dal nostro +produttore hardware @{"Medusa Computer Systems" system "http://medusacomputer.com/"}. + +Puoi contattarci in qualsiasi momento al nostro +indirizzo di posta principale @{0B}acpinfo@atari.org@{0}. + +@endnode + + +@node "fstruct_IT" "La struttura di file/cartelle" +@toc "IT1" +@{0U}La struttura di file/cartelle FireBee@{0} + +@{0U}La root directory, partizione c:/:@{0} + +CLIPBRD --> "scrap.*" di Copia/Incolla Š salvato qui +Downloads --> Cartella di download predefinita per browser, ftp, ... +THING --> Desktop Thing! v1.27 e v1.29 +Uploads --> Cartella di upload predefinita +auto --> La cartella AUTO +cpx --> Moduli del Pannello di controllo (*.cpx) + @{0B}usato solo con TOS!@{0} +devtools --> Strumenti di sviluppo +firebee --> Informazioni sull'hardware FireBee +gemsys --> File/librerie utilizzate a livello di sistema + (caratteri, ...) +guides --> I file aiuto *.hyp e *.ref di tutti i programmi + vanno qui +home --> I file di configurazione del software vengono + salvati qui +mint --> La directory di sistema FreeMint +nvdi --> Programma patch per NVDI5 su FireBee +sources --> Archivi del software incluso/file binari FreeMint +teradesk --> Il desktop "TeraDesk" +tools --> Cartella predefinita dei programmi GEM +zipped --> Archivi ZIP del "software di terze parti" +CONTROL.INF --> File di configurazione di FBXCTRL*.ACC +FBXCTRL*.ACC --> Server del Pannello di controllo @{0B}usato solo con TOS!@{0} + + +@{0U}La directory di sistema FreeMint c:/mint/:@{0} + +1-19-* --> Cartella "kernel" di FreeMint, "*" Š la versione + di rilascio +DESKTOP.CNF --> Il desktop selezionato (creato da sel_desk.prg) +mint_acc --> Accessori @{0B}usati solo con FreeMint!@{0} +mint_cpx --> Pannello di controllo @{0B}usato solo con FreeMint!@{0} +network.cnf --> La configurazione di rete, creata da netconf.prg +setup --> Strumenti di configurazione FreeMint descritti + in "Welcome..." +slb --> Librerie condivise per l'uso a livello di sistema +sys --> File binari e file "avanzati" di FreeMint +sys.cnf --> Link simbolici di sistema +tools --> Strumenti GEM di FreeMint +wallp --> Una bella raccolta di sfondi per il desktop FireBee + + +@{0U}La cartella kernel di FreeMint c:/mint/1-19-*/:@{0} + +doc --> Documenti +ext2.xfs --> Driver filesystem per partizioni ext2 +firebee --> Driver ethernet FireBee +fonts --> Caratteri di sistema FreeMint per altre lingue +inet4.xdd --> Driver del dispositivo di rete +keyboard --> Tabelle di tastiera per molte lingue +lp.xdd --> Driver per stampante locale +minix.xfx --> Driver Filesystem per minix (disattivato) +mint.cnf --> @{"Il file di configurazione di FreeMint" LINK c:\mint\1-19-2c5\mint.cnf} +mint.ini --> (Boot-) File di inizializzazione (non modificare + a mano!) +mintv4e.prg --> Kernel FreeMint +nfs.xfs --> Driver del file system di rete +xaaes --> XaAES (Application Environment System) +xconout2.xdd --> Driver del dispositivo di output su console + + +@{0U}La cartella XaAES c:/mint/1-19-*/xaaes/:@{0} + +640480.16 --> Immagine di sfondo per 640x480, 65536 colori +gradient --> Stili gradiente per la cornice della finestra + (Titolo, pulsanti, ...) +img --> Immagini a colori per la cornice della finestra +moose.adi | +moose_w.adi |-> Driver del mouse +pal --> Varie Tavolozze colori (GEM, NVDI) +widgets --> Diversi stili di pulsanti della finestra +xa_help.cs | +xa_help.de | +xa_help.es | +xa_help.fr | +xa_help.hu | +xa_help.it | +xa_help.ru | +xa_help.txt |-> Versioni in varie lingue dell'aiuto/scorciatoie + tastiera di XaAES +xa_xtobj.rsc --> Oggetti risorsa estesa predefiniti +xaaes.cnf --> @{"Il file di configurazione XaAES" LINK c:\mint\1-19-2c5\xaaes\xaaes.cnf} +xaaes.km --> Modulo kernel XaAES +xaaes016.rsc --> Risorsa XaAES +xaaes016.rsl --> File di traduzione della lingua per XaAES +xaaeswdg.rsc --> Stile pulsante finestra predefinito +xaloader.prg --> Carica il modulo kernel XaAES kernel +xobj --> Vari stili per gli oggetti risorsa estesa + +@endnode + + +@node "IT3" "Software installato" +@toc "IT1" +@{0U}Software installato FireBee@{0} + +@endnode + + + +@node "ES1" "Bienvenido" +@{0U}Bienvenido FireBee@{0} + + @{"EN" LINK "Main"} @{"DE" LINK "DE1"} @{"FR" LINK "FR1"} @{"IT" LINK "IT1"} ES @{"RU" LINK "RU1"} + +@line 25 26 0 + + +@limage FB_LOG16.IMG 0 + + @{0B}­Felicitaciones por tu nuevo FireBee!@{0} + +Antes de que empieces a ocupar tu FireBee, lo m s probable es que quieras +cambiar algunas de las configuraciones por defecto. Las herramientas +descritas en este documento pueden ser encontradas en el directorio +c:\mint\setup\. + +@{0B}MUY IMPORTANTE:@{0} Todos los programas incluidos en tu Configuraci¢n-FreeMiNT +para FireBee es prove¡da "@{0B}tal cual@{0}". Esto significa que si tienes +problemas, sugerencias o simplemente preguntas sobre un programa en +particular, @{0U}por favor, primero lee su documentaci¢n@{0} y, si tu asunto no es +abordado ah¡, entonces contacta al autor/desarrollador @{0U}directamente o +publica en uno de los foros@{0} (revisa "Enlaces en el Web"). +Todos los programas instalados han sido probados por muchos usuarios y +funcionan bien. ­Pero, por favor, entiende que el proyecto ACP @{0B}no puede +mantener y/o proveer soporte@{0} a todos estos programas de terceras personas! + + Muchas Gracias - el equipo ACP. + + + @{"Los primeros pasos" LINK "ES2"} + + @{"La estructura de archivos y directorios del FireBee FreeMiNT" LINK "fstruct_ES"} + + @{"Programas instalados" LINK "ES3"} + + +Los enlaces de web en este documento se abren en el navegador NetSurf, +presionando el bot¢n izquierdo del rat¢n. +Los enlaces a archivos locales se abren en la ventana actual, presionando +el bot¢n izquierdo del rat¢n. + +Esta visualizaci¢n de ayuda "HypView" es iniciada autom ticamente por el +escritorio. Si esto no te gusta, desactiva la funci¢n de autoinicio +para "hyp_view.app", en la ventana "Set Applications" del escritorio. + +@endnode + + +@node "ES2" "Los primeros pasos" +@toc "ES1" +@{0U}Los primeros pasos FireBee@{0} + +@image desktop.img 2 + + + @{0U}Selecciona el escritorio a ocupar:@{0} + +Con la herramienta @{0B}sel_desk.prg@{0} puedes seleccionar que escritorio ocupar s +con FreeMiNT en tu FireBee. Viene con una selecci¢n de tres escritorios: +@{"TeraDesk" LINK "teradesk.hyp"}, @{"Thing! v1.27" LINK "thing.hyp"} y Thing! v1.29. +Por favor, nota que Thing! v1.29 es una versi¢n beta, y tiene algunos +problemas menores. + +sel_desk.prg se inicia autom ticamente la primera vez que inicias tu Bee. +Si, posteriormente, quieres cambiarte a usar otro escritorio, puedes +hacerlo f cilmente usando esta herramienta. + +La selecci¢n del escritorio es guardada en el archivo de configuraci¢n +c:\mint\desktop.cnf. + + +@image screens.img 2 + + + @{0U}Cambiar el modo de la pantalla:@{0} + +Tu FireBee se inicia, por defecto, en la resoluci¢n VGA estandar. Esto +significa 640 por 480 pixeles con 65536 colores. Probablemente querr s +seleccionar un modo m s apropiado para tu monitor. +La herramienta @{0B}modes.prg@{0} muestra una lista de todos los modos de pantalla +disponibles, para que puedas elegir. Si tu monitor soporta EDID, su +resoluci¢n nativa est  disponible como el "mejor" modo de pantalla, que +es seleccionada por defecto. + +Lee @{"Wikipedia/EDID" system "https://en.wikipedia.org/wiki/Extended_display_identification_data"} para m s informaci¢n. + +@{0B}­Importante! Por favor, prueba el modo de pantalla antes de usarlo.@{0} +Si la prueba no muestra una imagen correcta (lineas verticales de color, +o blanco y negro, correctas, y sin parpadeos), no uses ese modo. + +El modo de pantalla es grabado en el archivo de configuraci¢n +c:\mint\xa_video.cnf. Si, por error, grabas un modo que no es soportado +por tu pantalla, puedes iniciar en FireTOS o EmuTOS y borrar ese archivo. +La pr¢xima vez que inicies FreeMiNT/XaAES, el modo de video usado por TOS +sera seleccionado. En ese momento podras usar modes.prg para seleccionar +un nuevo modo de pantalla. + + +@image network.img 2 + + + @{0U}Modificar la configuraci¢n de red:@{0} + +La configuraci¢n de red en tu FireBee viene preseteada para conectarse +autom ticamente usando el protocolo DHCP. Si tu red usa este modo +(la mayor¡a de las redes la ocupan), entonces no tienes necesidad de +cambiarla. + +Si tu red no ocupa DHCP, o si por cualquier motivo quieres asignar una +direcci¢n fija a tu FireBee, puedes usar la herramienta @{0B}netconf.prg.@{0} +Esto te permitir  elegir entre la configuraci¢n de red autom tica (DHCP) +y manual. Si seleccionas configuraci¢n manual, la herramienta no te +permitir  grabar la configuraci¢n hasta que todos los campos hayan sido +llenados y validados. + +­Nota que el nombre del dispositivo ethernet del FireBee es @{0B}eth0@{0}! + +Tu configuraci¢n de red es grabada en el archivo c:\mint\network.cnf. +Si no ocupas red, entonces puedes borrar este archivo sin problema. + + +@image keyboard.img 2 + + + @{0U}Seleccionar la distribuci¢n del teclado:@{0} + +FreeMiNT ofrece muchas distribuciones de teclado, para diferentes idiomas. +Puedes elegir uno (o m s) de estas distribuciones @{manualmente LINK C:\mint\1-19-2c5\keyboard\ReadMe}, o puedes +crear una distribuci¢n de teclado diferente usando la herramienta de GEM +@{KeyEdit LINK keyedit.hyp}. + + +@image language.img 2 + + + @{0U}Elegir su idioma preferido:@{0} + +FreeMiNT/XaAWS est  disponible en ocho idiomas. XaAES configura el idioma +autom ticamente si hay una traducci¢n presente, de acuerdo al AKP-cookie +(que contiene la configuraci¢n del idioma del sistema y teclado). +Puedes configurar tu idioma preferido usando la herramienta @{0B}language.prg@{0}. + +Para los escritorios @{0B}TeraDesk@{0} y @{0B}Thing!@{0} (y muchos otros programas), +las traducciones a diferentes idiomas estan disponibles dentro de los +sub-directorios respectivos. Simplemente renombra el archivo de recursos +del programa (por ejemplo, "desktop.rsc" en TeraDesk) a .rsx y luego +copia el archivo .rsc desde "tu" directorio del idioma en el mismo lugar. + +Algunos programas (en su mayoria nuevos) configuran su +idioma autom ticamente. + + +@image clock.img 2 + + + @{0U}Fecha y hora del sistema:@{0} + +Si estas conectado a internet, la fecha y hora de tu FireBee ser  +actualizada automaticamente al inicio por el programa @{0B}Synctime@{0}, localizado +en el directorio c:\tools\synctime\. +Por favor, configura tu huso horario y horario de verano. +El servidor de tiempo NTP por defecto est  disponible desde cualquier +lugar del mundo, pero puedes mejorar el desempe¤o configurando un +servidor m s local como, por ejemplo, "0.de.pool.ntp.org" para Alemania. +Buscando en el web por "ntp timeserver" te dara m s informaci¢n. + + +@image doc_dir.img 2 + + + @{0U}Otros documentos interesantes:@{0} + +@{"Como configurar NVDI 5.03 en el FireBee." LINK C:\nvdi\readme.txt} +@{"Usando un fondo de pantalla." LINK C:\mint\wallp\readme.txt} +@{"SpareMinT Wiki." system "http://wiki.sparemint.org/"} + +Por favor, revisa tambi‚n el directorio c:\guides\; hay encontrar s +documentos sobre muchos de los programas incluidos en tu FireBee. +O simplemente abre el @{"catalogo HypViews" LINK "catalog.hyp"} :-) + + +@image weblink.img 2 + + + @{0U}Enlaces web, noticias y soporte:@{0} + +Noticias, actualizaciones y descarga de programas pueden ser encontradas +en el @{"sitio web de FireBee" system "http://firebee.org"}. + +Para asistencia, discusiones, etc, por favor visita: + +- @{"El Foro de FireBee" system "http://atari-forum.com/viewforum.php?f=92"} +- @{"El Foro Alem n de FireBee" system "https://forum.atari-home.de/index.php?board=35.0"} +- Tambi‚n puedes inscribirte en la @{"lista de correo de FireBee" system "mailto:acplist-subscribe@firebee.org"}. + +Adem s, nuestro @{"blog de desarrollo" system "http://acp.atari.org"} puede ser un recurso interesante. + +@line 1 74 0 + +Tu FireBee viene con @{0B}2 a¤os de garant¡a@{0}, que es proveido por la f brica +del hardware, @{"Medusa Computer Systems" system "http://medusacomputer.com/"}. + +Tambi‚n nos puedes contactar, en cualquier momento, a nuestro +correo electr¢nico @{0B}acpinfo@atari.org@{0}. + +@endnode + + +@node "fstruct_ES" "La estructura" +@toc "ES1" +@{0U}La estructura de archivos y directorios FireBee@{0} + +El directorio raiz, partici¢n c:/: + +CLIPBRD --> "scrap.*", de copiado/pegado, son grabados ac  +Downloads --> Directorio, por defecto, de descarga del navegador, + ftp, ... +THING --> Escritorios Thing! v1.27 and v1.29 +Uploads --> Directorio, por defecto, para subida de archivos +auto --> El directorio AUTO +cpx --> M¢dulos del panel de control (*.cpx) @{0B}usados solamente + con TOS@{0} +devtools --> Herramientas de desarrollo +firebee --> Informaci¢n sobre el hardware del FireBee +gemsys --> Bibliotecas y archivos usados por todo el sistema + (fuentes, ...) +guides --> Archivos de ayuda *.hyp y *.ref, de todos los + programas, van ac  +home --> Los archivos de configuraci¢n de los programas son + grabado ac  +mint --> Directorio del sistema FreeMint +nvdi --> Programa parche para NVDI5 en el FireBee +sources --> Archivos de programas y binarios incluidos + para FreeMinT +teradesk --> El escritorio "TeraDesk" +tools --> Directorio, por defecto, para los programas de GEM +zipped --> Archivos ZIP de "programas de terceros" +CONTROL.INF --> Archivo de configuraci¢n para FBXCTRL*.ACC +FBXCTRL*.ACC --> Servidor del panel de control @{0B}usado solamente con TOS@{0} + + +El directorio del sistema FreeMiNT c:/mint/: + +1-19-* --> Directorio del "kernel" de FreeMinT, "*" es la versi¢n +DESKTOP.CNF --> Tu elecci¢n de escritorio (creado por sel_desk.prg) +mint_acc --> Accesorios @{0B}usados solamente con FreeMinT@{0} +mint_cpx --> Paneles de control @{0B}solamente usados con FreeMinT@{0} +network.cnf --> Tu configuraci¢n de red, creada por netconf.prg +setup --> Las herramientas de configuraci¢n para FreeMinT + descritas en el texto de ayuda "Bienvenido..." +slb --> Bibliotecas compartidas usadas por todo el sistema +sys --> Archivos y binarios "avanzados" de FreeMinT +sys.cnf --> Enlaces simb¢licos del sistema +tools --> Herramientas GEM para FreeMinT +wallp --> Un bonito conjunto de fondos de pantalla para + el FireBee + + +El directorio del kernel de FreeMiNT c:/mint/1-19-*/: + +doc --> Documentaci¢n +ext2.xfs --> Manejador del sistema de archivos ext2 +firebee --> Manejador ethernet del FireBee +fonts --> Fuentes del sistema, en otros idiomas, para FreeMinT +inet4.xdd --> Manejador del dispositivo de red +keyboard --> Tablas de teclado para variados idiomas +lp.xdd --> Manejador para la impresora local +minix.xfx --> Manejador del sistema de archivos minix (desactivado) +mint.cnf --> @{"El archivo de configuraci¢n de FreeMinT" LINK c:\mint\1-19-2c5\mint.cnf} +mint.ini --> Archivo de inicializaci¢n (­no lo edite a mano!) +mintv4e.prg --> Kernel del FreeMinT +nfs.xfs --> Manejador para el sistema de archivos por red (NFS) +xaaes --> XaAES (Sistema de medioambiente para aplicaciones) +xconout2.xdd --> Manejador de dispositivo para la salida en consola + + +El directorio XaAES c:/mint/1-19-*/xaaes/: + +640480.16 --> Imagen de fondo de 640x480, 65536 colores +gradient --> Estilos de gradiente para los marcos de ventana + (t¡tulo, botones, ...) +img --> Imagenes en colores para los marcos de ventana +moose.adi | +moose_w.adi |-> Manejadores para el mouse +pal --> Diferentes paletas de colores (GEM, NVDI) +widgets --> Diferentes estilos de botones de ventanas +xa_help.cs | +xa_help.de | +xa_help.es | +xa_help.fr | +xa_help.hu | +xa_help.it | +xa_help.ru | +xa_help.txt |-> Versiones para diferentes idiomas de la ayuda y atajos + de teclado para XaAES +xa_xtobj.rsc --> Objetos, por defecto, de recursos extendidos +xaaes.cnf --> @{"El archivo de configuraci¢n de XaAES" LINK c:\mint\1-19-2c5\xaaes/xaaes.cnf} +xaaes.km --> Modulo de kernel de XaAES +xaaes016.rsc --> Recursos de XaAES +xaaes016.rsl --> Archivo de traducci¢n de idioma para XaAES +xaaeswdg.rsc --> Estilo de bot¢n, para ventana, por defecto +xaloader.prg --> Carga el m¢dulo de kernel de XaAES +xobj --> Diferentes estilos para objetos de recursos extendidos + +@endnode + + +@node "ES3" "Programas instalados" +@toc "ES1" +@{0U}Programas instalados FireBee@{0} + +@endnode + + +@node "RU1" "Äîáðî ïîæàëîâàòü" +@{0U}Äîáðî ïîæàëîâàòü FireBee@{0} + + @{"EN" LINK "Main"} @{"DE" LINK "DE1"} @{"FR" LINK "FR1"} @{"IT" LINK "IT1"} @{"ES" LINK "ES1"} RU + +@line 25 26 0 + + +@limage FB_LOG16.IMG 0 + + @{0B}Ïîçäðàâëÿåì ñ âàøèì íîâûì êîìïüþòåðîì FireBee!@{0} + +Ïåðåä íà÷àëîì èñïîëüçîâàíèÿ FireBee âû, âîçìîæíî, çàõîòèòå èçìåíèòü +íåêîòîðûå åãî áàçîâûå íàñòðîéêè. Óòèëèòû, îïèñàííûå â ýòîì äîêóìåíòå, +ìîæíî íàéòè â ïàïêå c:\mint\setup\. + +@{0B}ÄÅÉÑÒÂÈÒÅËÜÍÎ ÂÀÆÍÎ:@{0} Âñå ïðîãðàììû, âêëþ÷åííûå â óñòàíîâî÷íûé FreeMiNT- +ïàêåò âàøåãî FireBee, ïðåäîñòàâëÿþòñÿ "@{0B}êàê åñòü@{0}". Ýòî îçíà÷àåò, ÷òî â +ñëó÷àå, åñëè ó âàñ ïîÿâÿòñÿ êàêèå-ëèáî ïðîáëåìû/ïðåäëîæåíèÿ èëè ïðîñòî +âîïðîñû, @{0U}â ïåðâóþ î÷åðåäü ïîæàëóéñòà ïðî÷èòàéòå ñîîòâåòñòâóþùóþ +äîêóìåíòàöèþ@{0} ýòèõ ïðîãðàìì, à åñëè âàøà ïðîáëåìà íå ðåøèòñÿ, òî @{0U}ñâÿæèòåñü +ñ àâòîðîì/ðàçðàáîò÷èêîì íàïðÿìóþ@{0} èëè @{0U}íàïèøèòå â ñîîòâåòñòâóþùèé ôîðóì@{0} +(ñì. "Ññûëêè, íîâîñòè è ïîääåðæêà"). +Âñå óñòàíîâëåííûå ïðîãðàììû áûëè ïðîòåñòèðîâàíû íåñêîëüêèìè ïîëüçîâàòåëÿìè +è ðàáîòàþò õîðîøî. Íî, ïîéìèòå ïîæàëóéñòà, ÷òî ACP-ïðîåêò @{0B}íå ìîæåò +îñóùåñòâëÿòü ïîääåðæêó@{0} âñåõ "ñòîðîííèõ" ïðîãðàìì! + + Áëàãîäàðèì âàñ - êîìàíäà ACP. + + + @{"Ïåðâûå øàãè" LINK "RU2"} + + @{"Ñòðóêòóðà ôàéëîâ/ïàïîê óñòàíîâî÷íîãî ïàêåòà FireBee FreeMiNT" LINK "fstruct_RU"} + + @{"Óñòàíîâëåííûå ïðîãðàììû" LINK "RU3"} + + +Ëèíêè íà âíåøíèå ôàéëû èç ýòîãî äîêóìåíòà îòêðûâàþòñÿ ñ ïîìîùüþ êëèêà +ëåâîé êëàâèøè ìûøêè â áðîóçåðå NetSurf. Ëèíêè íà ëîêàëüíûå ôàéëû îòêðîþòñÿ +ñ ïîìîùüþ êëèêà ëåâîé êëàâèøè ìûøêè â òåêóùåì îêíå. + +Ïðîñìîòðîâùèê ôàéëîâ ïîìîùè "HypView" àâòîìàòè÷åñêè çàãðóæàåòñÿ ñ ðàáî÷èì +ñòîëîì. Åñëè âû ýòîãî íå õîòèòå, ïîæàëóéñòà äåêàòèâèðóéòå ôóíêöèþ +Autostart äëÿ ïðîãðàììû "hyp_view.app" â äèàëîãå äåñêòîïà +"Óñòàíîâêà ïðèëîæåíèé". + +@endnode + + +@node "RU2" "Ïåðâûå øàãè" +@toc "RU1" +@{0U}Ïåðâûå øàãè FireBee@{0} + +@image desktop.img 2 + + + @{0U}Âûáîð äåñêòîïà äëÿ èñïîëüçîâàíèÿ:@{0} + +Ñ ïîìîùüþ óòèëèòû @{0B}sel_desk.prg@{0} âû ìîæåòå âûáðàòü êàêîé èìåííî äåñêòîï +èñïîëüçîâàòü â FreeMiNT íà âàøåì FireBee. Ìû ïîñòàâëÿåì íà âûáîð òðè +äåñêòîïà - @{"TeraDesk" LINK C:\guides\RU\teradesk.hyp}, @{"Thing! v1.27" LINK "thing.hyp"} è Thing! v1.29. +Ïîæàëóéñòà, îáðàòèòå âíèìàíèå, ÷òî Thing! v1.29 - ýòî áåòàâåðñèÿ è +ñîäåðæèò íåêîòîðûå íåçíà÷èòåëüíûå áàãè. + +Ïðîãðàììà sel_desk.prg àâòîìàòè÷åñêè ñòàðòóåò ïðè ïåðâîé çàãðóçêå âàøåãî +FireBee. Åñëè ïîçæå âû çàõîòèòå ïåðåêëþ÷èòü äåñêòîï íà äðóãîé, âû ìîæåòå +ëåãêî ñäåëàòü ýòî ñ ïîìîùüþ äàííîé óòèëèòû. + +Èíôîðìàöèÿ î âûáðàííîì âàìè äåñêòîïå ñîõðàíèòñÿ â êîíöèãóðàöèîííîì ôàéëå +c:\mint\desktop.cnf. + + +@image screens.img 2 + + + @{0U}Èçìåíåíèå ðåæèìà ýêðàíà:@{0} + +î óìëî÷àíèþ âàø FireBee çàãðóæàåòñÿ â ñòàíäàðòíîì ðàçðåøåíèè äèñïëåÿ - +VGA. Ýòî îçíà÷àåò 640 íà 480 ïèêñåëåé è 65536 öâåòîâ. Íî, âîçìîæíî, âû +çàõîäèòå âûáðàòü ðåæèì, êîòîðûé áîëüøå ïîäõîäèò äëÿ âàøåãî ìîíèòîðà. +Óòèëèòà @{0B}modes.prg@{0} ïðåäëàãàåò âàì äëÿ âûáîðà áîëüøîå ÷èñëî âîçìîæíûõ +ðåæèìîâ ýêðàíà. Åñëè âàø ìîíèòîð ïîääåðæèâàåò EDID, åãî íàòèâíîå +ðàçðåøåíèå ìîæíî ëåãêî âûáðàòü êàê "Best" ðåæèì. Ýòîò ðåæèì âûáðàí +ïî óìîë÷àíèþ. + +Äëÿ ïîäðîáíîñòåé ïðî EDID ñìîòðèòå @{"Âèêèïåäèþ" system "https://en.wikipedia.org/wiki/Extended_display_identification_data"}. + +@{0B}Âàæíî! Ïîæàëóéñòà ïðîòåñòèðóéòå ðåæèì æêðàíà ïåðåä åãî èñïîëüçâàíèåì!@{0} +Åñëè ïðè òåñòèðîâàíèè äèñïëåé íå ïîêàçûâåò ïðàâèëüíóþ êàðòèíêó (ïðàâèëüíûå +âåðòèêàëüíûå öâåòíûå (èëè ÷/á) ëèíèè, áåç "ìåðöàíèé"), òî íå èñïîëüçóéòå +ýòîò ðåæèì. + +Ðåæèì ýêðàíà ñîõðàíÿåòñÿ â êîíöèãóðàöèîííîì ôàéëå c:\mint\xa_video.cnf. +Åñëè âû ñëó÷àéíî ñîõðàíèëè ðåæèì ýêðàíà, êîòîðûé âàø ìîíèòîð íå +ïîääåðæèâàåò, âû ìîæåòå çàãðóçèòüñÿ â FireTOS èëè EmuTOS è óäàëèòü ýòîò +ôàéë. Âî âðåìÿ ñëåäóþùåé çàãðóçêè ïðè ñòàðòå FreeMiNT/XaAES, áóäåò +çàäåðéñòâîâàí ðåæèì ýêðàíà, îïðåäåëÿåìûé TOS. È òåïåðü âû ñíîâà ìîæåòå +âûáðàòü íîâûé ðåæèì ñ ïîìîùüþ óòèëèòû modes.prg. + + +@image network.img 2 + + + @{0U}Èçìåíåíèå ñåòåâûõ íàñòðîåê:@{0} + +Ñåòåâûå íàñòðîéêè âàøåãî FireBee ïðåäâàðèòåëüíî ñêîíôèãóðèðîâàíû äëÿ +àâòîìàòè÷åñêîãî ïîäêëþ÷åíèÿ ê âàøåé ñåòè ñ ïîìîùüþ DHCP-ïðîòîêîëà. Åñëè +âàøà ñåòü ïîääåðæèâàåò ýòîò ðåæèì (à áîëüøèíñòâî ñåòåé ïîääåðæèâàþò), òî +âàì íå íàäî íè÷åãî áîëüøå ìåíÿòü. + +Åñëè âûøà ñåòü íå èñïîëüçóåò DHCP, èëè ïî êàêîé-ëèáî ïðè÷èíå âû õîòèòå +ïðèñâîèòü âàøåìó FireBee ôèêñèðîâàííûé àäðåñ, âû ìîæåòå çàïóñòèòü óòèëèòó +@{0B}netconf.prg@{0}. Ýòî ïîçâîëèò âàì âûáðàòü ìåæäó àâòîìàòè÷åñêîé (DHCP) +è ðó÷íîé íàñòðîéêîé ñåòåâûõ ïàðàìåòðîâ. Åñëè âû èñïîëüçóåòå ðó÷íóþ +íàñòðîéêó, óòèëèòà íå ïîçâîëèò âàì ñîõðàíèòü êîðíôèãóðàöèþ äî òåõ ïîð, +ïîêà âñå íåîáõîäèìûå ïîëÿ íå áóäóò çàïîëíåíû è ïðîâåðåíû. + +Ïðèìå÷àíèå! Èìÿ óñòðîéñòâà Ethernet-äðàéâåðà Firebee - @{0B}eth0@{0}. + +Âàøè ñåòåâûå íàñòðîéêè ñîõðàíÿþòñÿ â ôàéëå c:\mint\network.cnf. +Åñëè âû âîîáùå íå èñïîëüçóåòå ñåòü, âû ìîæåòå ñïîêîéíî óäàëèòü ýòîò ôàéë. + + +@image keyboard.img 2 + + + @{0U}Âûáîð ðàñêëàäêè êëàâèàòóðû:@{0} + +FreeMiNT ïðåäëàãàåò áîëüøîå êîëè÷åñòâî ðàñêëàäîê êëàâèàòóðû äëÿ ðàçëè÷íûõ +ÿçûêîâ. Âû ìîæåòå íàçíà÷èòü îäíó (èëè íåñêîëüêî) èç íèõ @{"âðó÷íóþ" LINK C:\mint\1-19-2c5\keyboard\ReadMe} èëè âû +ìîæåòå ñîçäàòü ñâîþ ñîáñòâåííóþ ðàñêëàäêó ñ ïîìîùüþ GEM-óòèëèòû @{KeyEdit LINK keyedit.hyp}. + + +@image language.img 2 + + + @{0U}Âûáîð ïðåäïî÷èòàåìîãî ÿçûêà:@{0} + +FreeMiNT/XaAES äîñòóïåí íà âîñüìè ÿçûêàõ. XaAES àâòîìàòè÷åñêè âûáèðàåò +ÿçûê, åñëè ñóùåñòâóåò ôàéë ëîêàëèçàöèè, íà îñíîâàíèè AKP-êóêè (êîòîðûå +ñîäåðæàò óñòàíîâêè ÿçûêà ñèñòåìû/êëàâèàòóðû). +Âû ìîæåòå ëåãêî âûáðàòü ïðåäïî÷èòàåìûé ÿçûê ñ ïîìîùüþ óëèòèòû +@{0B}language.prg@{0}. + +Äëÿ äåñêòîïîâ @{0B}TeraDesk@{0} è @{0B}Thing!@{0} (è ìíîãèõ äðóãèõ ïðîãðàìì), â +ñîîòâåòñòâóþùèõ (ïîä-)ïàïêàõ äîñòóïíû ïåðåâîäû íà íåêîòîðûå ÿçûêè. Ïðîñòî +ïåðåèìåíóéòå ôàéëû ðåñóðñîâ (íàïðèìåð "desktop.rsc" äëÿ TeraDesk) â .rsx +è çàòåì ñêîïèðóéòå ñþäà íóæíûé ôàéë .rsc èç ïîäïàïêè ñ "âàøèì" ÿçûêîì. + +Íåêîòîðûå (â îñíîâíîì íîâûå) ïðîãðàììû ìîãóò âûáèðàòü ñâîé ÿçûê +àâòîìàòè÷åñêè. + + +@image clock.img 2 + + + @{0U}Äàòà è âðåìÿ ñèñòåìû:@{0} + +Åñëè âàø êîìïüþòåð ïîäêëþ÷åí ê èíòåðíåòó, òî ñèñòåìíûå äàòà è âðåìÿ âàøåãî +FireBee áóäóò àâòîìàòè÷åñêè îáíîâëÿòüñÿ ïðè çàïóñêå ïðîãðàììîé @{0B}Synctime@{0} +â ïàïêå c:\tools\synctime\. +Ïîæàëóéñòà, óñòàíîâèòå âàø ìåñòíûé ÷àñîâîé ïîÿñ è óêàæèòå, îñóùåñòâëÿåòñÿ +ëè ïåðåõîä íà "ëåòíåå" âðåìÿ - DST (Daylight saving time). +Ãëîáàëüíûé ñåðâåð âðåìåíè ïî óìîë÷àíèþ NTP äîñòóïåí âåçäå, íî âû ìîæåòå +óëó÷øèòü ïðîèçâîäèòåëüíîñòü, åñëè âûáåðåòå ëîêàëüíûé ñåðâåð âðåìåíè - +íàïðèìåð "0.de.pool.ntp.org" äëÿ Ãåðìàíèè. Äëÿ äîïîëíèòåëüíûõ ïîäðîáíîñòåé +ïîèùèòå â èíòåðíåòå "ntp ñåðâåð âðåìåíè". + + +@image doc_dir.img 2 + + + @{0U}Äîïîëíèòåëüíàÿ èíôîðìàöèÿ:@{0} + +@{"Êàê ñêîíôèãóðèðîâàòü NVDI 5.03 íà âàø FireBee." LINK C:\nvdi\readme.txt} +@{"Èñïîëüçîâàíèå ôîíîâîãî ðèñóíêà äåêñòîïà." LINK C:\mint\wallp\readme.txt} +@{"SpareMinT Wiki" system "http://wiki.sparemint.org/"} + +Ïîæàëóéñòà çàãëÿíèòå â ïàïêó c:\guides\. Òàì âû íàéäåòå äîêóìåíòàöèþ î +ìíîãèõ ïðîãðàììàõ, ïðåäóñòàíîâëåííûõ íà âàøåì FireBee. +Èëè ïðîñòî îòêðîéòå @{"êàòàëîã HypViews" LINK "catalog.hyp"} :-) + + +@image weblink.img 2 + + + @{0U}Ññûëêè, íîâîñòè è ïîääåðæêà:@{0} + +Íîâîñòè, îáíîâëåíèÿ ïðîãðàìì è ññûëêè íà èõ çàãðóçêó ìîæíî íàéòè íà +@{"ñàéòå FireBee" system "http://firebee.org"}. + +Äëÿ ïîëó÷åíèÿ ïîìîùè, äèñêóññèé è òàê äàëåå, ïîæàëóéñòà ïîñåòèòå: + +- @{"Ôîðóì FireBee" system "http://atari-forum.com/viewforum.php?f=92"} +- @{"Íåìåöêèé ôîðóì FireBee" system "https://forum.atari-home.de/index.php?board=35.0"} +- Âû ìîæåòå ïîäïèñàòüñÿ íà @{"ðàññûëêó FireBee" system "mailto:acplist-subscribe@firebee.org"}. + +Òàêæå èíòåðåñíûì ðåñóðñîì äëÿ âàñ ìîæåò îêàçàòüñÿ @{"áëîã ðàçðàáîò÷èêîâ" system "http://acp.atari.org"}. + +@line 1 74 0 + +Âàø FireBee ïîñòàâëÿåòñÿ ñ @{0B}äâóõãîäè÷íîé ãàðàíòèåé@{0}, îáåñïå÷èâàåìîé íàøèì +ïðîèçâîäèòåëåì õàðäà - êîìïàíèåé @{"Medusa Computer Systems" system "http://medusacomputer.com/"}. + +Òàêæå â ëþáîå âðåìÿ âû ìîæåòå ñâÿçàòüñÿ ñ íàìè, íàïèñàâ íàì íà íàø +îñíîâíîé àäðåñ å-ìýéë: @{0B}acpinfo@atari.org.@{0} + +@endnode + + +@node "fstruct_RU" "Ñòðóêòóðà ôàéëîâ/ïàïîê" +@toc "RU1" +@{0U}Ñòðóêòóðà ôàéëîâ/ïàïîê FireBee@{0} + +@{0U}Êîðíåâàÿ äèðåêòîðèÿ, ïàðòèøåí c:/:@{0} + +CLIPBRD --> Çäåñòü õðàíÿòñÿ ôàéëû "ìóñîð.*" ïðè îïåðàöèè + êîïèðîâàíèÿ/âñòàâêè +Downloads --> Ïàïêà ïî óìîë÷àíèþ äëÿ çàãðóçîê áðîóçåðà, ftp, ... +THING --> Äåêñòîïû Thing! v1.27 è v1.29 +Uploads --> Ïàïêà ïî óìîë÷àíèþ äëÿ àïëîàäà +auto --> Ïàïêà AUTO +cpx --> Ìîäóëè ïàíåëè óïðàâëåíèÿ (*.cpx), + @{0B}èñïîëüçóåìûå òîëüêî â TOS!@{0} +devtools --> Ñðåäñòâà ðàçðàáîò÷èêîâ +firebee --> Èíôîðìàöèÿ î æåëåçå FireBee +gemsys --> Ôàéëû/áèáëèîòåêè, èñïîëüçóåìûå ñèñòåìîé (fonts, ...) +guides --> Ñþäà ïîïàäàþò ôàéëû ïîìîùè *.hyp è *.ref îò + âñåõ ïðîãðàìì +home --> Çäåñü õðàíÿòñÿ ôàéëû êîíôèãóðàöèè ïðîãðàìì +mint --> Ñèñòåìíàÿ ïàïêà FreeMint +nvdi --> Ïðîãðàììà ïàò÷à NVDI5 äëÿ FireBee +sources --> Àðõèâ âêëþ÷åííûõ áèíàðíèêîâ ïðîãðàìì/FreeMinT +teradesk --> Äåñêòîï "TeraDesk" +tools --> Ïàïêà ïî óìîë÷àíèþ äëÿ GEM-ïðîãðàìì +zipped --> ZIP-àðõèâû "ñòîðîííèõ ïðîãðàìì" +CONTROL.INF --> Ôàéë êîíôèãóðàöèè äëÿ FBXCTRL*.ACC +FBXCTRL*.ACC --> Ñåðâåð ïàíåëè óïðàâëåíèÿ @{0B}èñïîëüçóåòñÿ òîëüêî â TOS!@{0} + + +@{0U}Ñèñòåìíàÿ ïàïêà FreeMinT c:/mint/:@{0} + +1-19-* --> Ïàïêà "ÿäðà" FreeMinT, "*" - ýòî íîìåð âåðñèè ðåëèçà +DESKTOP.CNF --> Âûáðàííûé âàìè äåêñòîï (ñ ïîìîùüþ + ïðîãðàììû sel_desk.prg) +mint_acc --> Ðåçèäåíòíûå (àêñåññîðíûå) ïðîãðàììû, + @{0B}èñïîëüçóþòñÿ òîëüêî â FreeMinT!@{0} +mint_cpx --> Ïàíåëü óïðàâëåíèÿ @{0B}èñïîëüçóþòñÿ òîëüêî â FreeMinT!@{0} +network.cnf --> Âàøè íàñòðîéêè ñåòè, ñîçäàííûå ñ ïîìîùüþ + ïðîãðàììû netconf.prg +setup --> Óòèëèòû óñòàíîâêè FreeMinT, îïèñàííûå â ðàçäåëå ïîìîùè + "Äîáðî ïîæàëîâàòü..." +slb --> Ðàñøàðåííûå ñèñòåìíûå áèáëèîòåêè +sys --> "Äîïîëíèòåëüíûå" áèíàðíèêè è ôàéëû FreeMinT +sys.cnf --> Ñèñòåìíûå ÿðëûêè +tools --> GEM-óòèëèòû äëÿ FreeMinT +wallp --> Õîðîøèé íàáîð îáîåâ äëÿ äåêñòîïà FireBee + + +@{0U}Ïàïêà ÿäðà FreeMinT c:/mint/1-19-*/:@{0} + +doc --> Äîêóìåíòàöèÿ +ext2.xfs --> Ôàéëîâûé äðàéâåð äëÿ ext2-ïàðòèøåíîâ +firebee --> Ñåòåâîé äðàéâåð FireBee +fonts --> Ñèñòåìíûå ôîíòû FreeMinT äëÿ ðàçëè÷íûõ ÿçûêîâ +inet4.xdd --> Äðàéâåð ñåòåâîãî óñòðîéñòâà +keyboard --> Òàáëèöû ðàñêëàäêè êëàâèàòóðû äëÿ ðàçëè÷íûõ ÿçûêîâ +lp.xdd --> Äðàéâåð äëÿ ìåñòíîãî ïðèíòåðà +minix.xfx --> Äðàéâåð ôàéëîâîé ñèñòåìû äëÿ minix (äåàêòèâèðîâàí) +mint.cnf --> @{"Êîíöèãóðàöèîííûé ôàéë FreeMinT" LINK c:\mint\1-19-2c5\mint.cnf} +mint.ini --> Ôàéë (çàãðóçêè-) èíèöèàëèçàöèè (íå + ðåäàêòèðóéòå âðó÷íóþ!) +mintv4e.prg --> ßäðî FreeMinT +nfs.xfs --> Äðàéâåð äëÿ ñåòåâîé ôàéëîâîé ñèñòåìû +xaaes --> XaAES (Application Environment System) +xconout2.xdd --> Äðàéâåð óñòðîéñòâà äëÿ êîíñîëüíîãî âûõîäà + + +@{0U}Ïàïêà XaAES c:/mint/1-19-*/xaaes/:@{0} + +640480.16 --> Ðèñóíîê ðàáî÷åãî ñòîëà - 640x480, 65536 öâåòîâ +gradient --> Ãðàäèåíòíûå ñòèëè äëÿ îêîí (ïóíêòû ìåíþ, êíîïêè, ...) +img --> Öâåòíûå îáðàçû äëÿ îêîí +moose.adi | +moose_w.adi |-> Äðàéâåðû ìûøè +pal --> Ðàçëè÷íûå öâåòîâûå ïàëèòðû (GEM, NVDI) +widgets --> Ðàçëè÷íûå ñòèëè êíîïîê îêíà +xa_help.cs | +xa_help.de | +xa_help.es | +xa_help.fr | +xa_help.hu | +xa_help.it | +xa_help.ru | +xa_help.txt |-> Âåðñèè íà ðàçëè÷íûõ ÿçûêàõ ãîðÿ÷èõ êëàâèø ïîìîùè/ + ïåðåêëþ÷åíèÿ êëàâèàòóðû XaAES +xa_xtobj.rsc --> Ôàéë äîïîëíèòåëüíûõ îáúåêòîâ ðåñóðñîâ ïî óìîë÷àíèþ +xaaes.cnf --> @{"Êîíôèãóðàöèîííûé ôàéë XaAES" LINK c:\mint\1-19-2c5\xaaes\xaaes.cnf} +xaaes.km --> Ìîäóëü ÿäðà XaAES +xaaes016.rsc --> Ôàéë ðåñóðñîâ XaAES +xaaes016.rsl --> Ôàéë ïåðåâîäà íà äðóãèå ÿçûêè XaAES +xaaeswdg.rsc --> Ñòèëü êíîïîê îêíà ïî óìîë÷àíèþ +xaloader.prg --> Çàãðóæàåò ìîäóëü ÿäðà XaAES +xobj --> Ðàçëè÷íûå ñòèëè äëÿ äîïîëíèòåëüíûõ îáúåêòîâ ðåñóðñîâ + +@endnode + + +@node "RU3" "Óñòàíîâëåííûå ïðîãðàììû" +@toc "RU1" +@{0U}Óñòàíîâëåííûå ïðîãðàììû FireBee@{0} + + +@endnode diff --git a/sources/firehyp.zip b/sources/firehyp.zip deleted file mode 100644 index 1707846..0000000 Binary files a/sources/firehyp.zip and /dev/null differ diff --git a/sources/firehyp/firebee.hyp b/sources/firehyp/firebee.hyp new file mode 100644 index 0000000..124ceb9 Binary files /dev/null and b/sources/firehyp/firebee.hyp differ diff --git a/sources/firehyp/firebee.ref b/sources/firehyp/firebee.ref new file mode 100644 index 0000000..9ea0d5c Binary files /dev/null and b/sources/firehyp/firebee.ref differ diff --git a/sources/firehyp/firebee.stg b/sources/firehyp/firebee.stg new file mode 100644 index 0000000..e541d6c --- /dev/null +++ b/sources/firehyp/firebee.stg @@ -0,0 +1,1513 @@ +@subject "Documentation" +@author "Didier MEQUIGNON" +@database "Documentation of the FIREBEE - FIRETOS" +@$VER: Version Boot 2.01, Drivers 1.01 (July 25, 2011) + +@node "Title" +@{U}Title FIREBEE - FIRETOS@{u} + + +@autorefoff + Documentation of the + + +@limage G:\tos060\doc\firebee\english\..\img\firebee.img 31 + Version Boot 2.01, Drivers 1.01 + July 25, 2011 + + by + + Didier MEQUIGNON + + aniplay@@wanadoo.fr +@autorefon + + + Contents +@endnode + + +@node Main "Contents" +@symbol "Contents" +@toc "Title" +@{U}Contents FIREBEE - FIRETOS@{u} + + + 1 Presentation + 1.1 Coldfire V4e + 1.2 TOS 4.04 + + 2 TOS in Flash + 2.1 Start TOS + 2.2 Drivers + 2.3 Technical (boot) + 2.4 Boot menu + 2.4.1 Original boot menu (TOS started) + 2.4.2 Firebee boot menu (after board init) + + 3 Flash Tool + 3.1 Use Flash Tool + + 4 Configuration + 4.1 Introduction + 4.2 Average load + 4.3 Temperature + 4.4 Memory / uP + 4.5 Boot + 4.6 Stop/Misc + 4.7 Langage + 4.8 Video + 4.9 CT60TEMP.APP + 4.10 BubbleGEM + + 5 Cache + 5.1 The Coldfire's V4e caches + 5.2 GENERAL6.CPX + 5.3 XCONTROL, ZCONTROL, COPS, and SDRAM in copyback + 5.4 PARX.SYS modules and the copyback + 5.5 TSR programs who crashes in the AUTO folder + 5.6 Programs packed by Ice + + 6 Compatibility + 6.1 Crashes + 6.1.1 Crashes with the Coldfire + 6.1.2 Crashes with caches + 6.2 Solutions + + 7 Annexes + 7.1 TOS Keyboard shortcuts + 7.2 Load TOS with dBUG + 7.3 DBUG task + 7.4 Firebee MMU mapping + 7.5 LWIP socket cookie 'SOCK' + + 8 Contacts +@endnode + + +@node "Presentation" +@toc "Main" +@{U}1 Presentation FIREBEE - FIRETOS@{u} + +The Firebee use a Coldfire V4e at 266 MHz (MCF5475) and an FPGA for +emulate obsolete Atari devices and add new features (DSP ?) in the +future. Today for new FPGA feature, there are just a DVI-I port +connected to him (Videl ACP extended modes without hardware +acceleration). + + +@limage G:\tos060\doc\firebee\english\..\img\schema.img 1 + + +Some new devices are connected to the Coldfire : + + ù USB controller on his PCI bus. + + ù AC97 audio codec on his AC-LINK interface. + + ù EDID from monitor to his I2C interface. + + ù Ethernet 10/100. + + 1.1 Coldfire V4e + 1.2 TOS 4.04 + +@endnode + + +@node "Coldfire V4e" +@toc "Presentation" +@{U}1.1 Coldfire V4e FIREBEE - FIRETOS@{u} + +This coldfire like all the members of his familly is a +microcontroller, there are : + + ù Two Fast Ethernet Controllers (FEC 10/100), but only the first + is used on the Firebee. + + ù Four Programmable Serial Controllers (PSC), the first port is + the highspeed serial port, the third port is for the AC97 audio + codec. + + ù A PCI controller connnected to an USB host controller, the PCI + configured at 33MHz on the Firebee. + + ù An USB slave device not used on the Firebee. + + ù A Flexbus connected to the FPGA and 8 MB of Flash memory + (multiplexd bus, same frequency than the PCI). + + ù A Memory Controller connected to 512MB of SDRAM memory. + + ù An I2C interface connected to the DVI-I port. + + ù An DSPI interface connected to the SD-Card socket. + + ù A multichannel DMA (used for example for the AC97). + + ù 6 Timers. + + +@limage G:\tos060\doc\firebee\english\..\img\v4e.img 1 + + +@endnode + + +@node "TOS 4.04" +@toc "Presentation" +@{U}1.2 TOS 4.04 FIREBEE - FIRETOS@{u} + +The TOS404 for FIREBEE use the CF68KLIB (68060 emulation) and use : + + ù Timers and MFP (FPGA emulation). + + ù Serial ports (MFP FPGA emulation and PSC0 from Coldfire). + + ù Serial port for IKBD with Eiffel. + + ù ACIA for original IKBD (FPGA emulation). + + ù ACIA for MIDI (FPGA emulation). + + ù Ethernet 10/100. + + ù PCI: USB / Radeon (USB support mouse & keyboard, and mass + storage) with plug & play feature. + + ù CompactFlash (FPGA emulation). + + ù SD-Card (using DSPI). + + ù Atari Falcon IDE / SCSI (FPGA emulation, SCSI not implemented). + + ù Coldfire DMA. + + ù MMU. + + ù PSG (YAMAHA - FPGA emulation) + + ù Atari Floppy (FPGA emulation, only reading works) + + ù RTC (PIC & FPGA emulation) + + ù Videl ACP extended modes with EDID probing (monitor detection) + + ù AC97 Sound. + +The TOS has four parts : + + ù The original TOS 4.04. + + ù The boot who can start from reset, initialize the board, start + the CF68KLIB, apply the patches to the TOS, add some XBIOS and + boot disk parts rewrited, and start the PCI BIOS. + + ù The CF68KLIB for a 68060 emulation. + + ù The driver part (AC97, Radeon, DMA, USB, Video ACP, rewrited + VDI, TCP/IP stack, etc ...). + +@endnode + + +@node "TOS in Flash" +@toc "Main" +@{U}2 TOS in Flash FIREBEE - FIRETOS@{u} + + 2.1 Start TOS + 2.2 Drivers + 2.3 Technical (boot) + 2.4 Boot menu + 2.4.1 Original boot menu (TOS started) + 2.4.2 Firebee boot menu (after board init) + +@endnode + + +@node "Start TOS" +@toc "TOS in Flash" +@{U}2.1 Start TOS FIREBEE - FIRETOS@{u} + +The TOS located at 0xE0400000 need an FPGA init before start. There +are 3 solutions for start the TOS from reset (from 0xE0000000) : + + ù dBUG who has Ethernet support (TOS easy to update without risk, + see 'Load TOS with dBUG') + + ù BAS the original solution of Fredi (but sound not works under + TOS). + + ù The TOS himself with the rescue TOS who initialize the FPGA. + +NOTE: Only the 2 latest solutions can also start EMUTOS. + +@endnode + + +@node "Drivers" +@toc "TOS in Flash" +@{U}2.2 Drivers FIREBEE - FIRETOS@{u} + +The drivers part on the Firebee add features to TOS : + + ù AC97 driver. + + ù Videl ACP externded modes driver (256 /65K / 16M colors) with + EDID monitor detection. + + ù USB driver. + + ù SD-Card driver (thanks to Fredi). + + ù DMA driver. + + ù Flash driver. + + ù Fast Ethernet Controller (FEC) driver. + + ù Ethernet PHY driver (tranceiver). + + ù VDI/fVDI replacement. + + ù X86 emulator (for a graphic card initialization). + + ù ATI Radeon driver. + + ù XBIOS GSXB driver. + + ù BDOS (GEMDOS replacement). + + ù TCP/IP stack (LwIP/FreeRTOS) with TFTP, FTP, Telnet, HTTP + servers (you can see screen like a VNC server). + + ù GlueSTiK and socket interfaces (from cookies 'STiK' and 'SOCK'). + + ù Real time OS (FreeRTOS) with DBUG task. + + ù 68K/Coldfire disassembler. + +@endnode + + +@node "Technical (boot)" +@toc "TOS in Flash" +@{U}2.3 Technical (boot) FIREBEE - FIRETOS@{u} + +This is a TOS 4.04 patched by the boot (2.0+), in this order there +are : + + ù Board initialization (Coldfire and ACP registers). + + ù The copy of the TOS in SDRAM after apply the patches. + + ù The initialization of the MMU. All the ST-RAM is in writethrough + and the SDRAM declaration in copyback. + + ù Start the CF68KLIB, TOS is a task for FreeRTOS (driver part). + + ù The installation of the cookies '_CPU', '_FPU', '_CF_'. + + ù The patchs for cache, MMU, address in 0x00FFxxxx, and the + instructions movep replaced. + + ù The bombs inside exceptions displayed with texts in clear of a + crash. + + ù The XBIOS function 0xC60A to 0xC60D (temperature, parameters in + Flash, cache...), and the DSP (functions with handshake). + + ù The needful patchs for the blitter, the system fonts and the + Atari logo copied at the top of the ST-RAM. + + ù The replacement of the XBIOS Bconout routine (display texts). + + ù Check and fix the modecode get from NVM. + + ù Start the PCI BIOS and the drivers. + + ù The display of the V4e's type (revision, mask and frequency). + + ù The declaration of the SDRAM to the TOS. + + ù The initialization of the SDRAM, and the MB/s during writing + displayed. + + ù The fastram buffer created and his cookie '_FRB'. + + ù The extended fastram buffer created and his cookie 'XFRB'. + + ù The patch for the boot order of the drives IDE and SCSI (8 + choices). + + ù Extra boot features : + + - Add SCSIDRV and XHDI protocols. + + - Add identify device procedure for SCSI and IDE drives, the + boot wait if a removable drive is not ready. + + - Add IDE slave support. + + - Add CompactFlash support. + + - Add combined MSDOS/TOS root and partition support, this + feature support byte swapping needed by MSDOS format and + search a *.SYS for load the disk driver. + + - Add speed test for bootables devices. + + - Start internal hard disk driver if no bootable disk as an + external driver. + + ù The patch for the boot menu. + + ù The displays redirection of the AUTO programs to a file + boot.log. + + ù The patch for the Pexec function for the copyback (cpush after + the relocation). + + ù The blitter patchs of the VDI functions, vro_cpyfm, vr_trnfm, + and vrt_cpyfm for work in SDRAM (an intermediate buffer inside + ST-RAM is used). + + ù The AES patchs for change the Newdesk buffer of 4 KB to 32 KB. + + ù Scan-codes used with the Eiffel card : + + - PAGE UP/DOWN. + + - PRINT SCREEN. + + - POWER (set 2 only, Eiffel 1.0.5). + + - VOLUME UP/DOWN (set 2 only, Eiffel 1.0.5). + +@endnode + + +@node "Boot menu" +@toc "TOS in Flash" +@{U}2.4 Boot menu FIREBEE - FIRETOS@{u} + +There are two boot menu on the Firebee : + + ù The original use the NVRAM OS setting, the TOS is started. + + ù The second can start EMUTOS in native mode or a TOS to test + after board initialization. Switches or TOS source area (normal + or rescue) change the content of this menu. + + 2.4.1 Original boot menu (TOS started) + 2.4.2 Firebee boot menu (after board init) + +@endnode + + +@node "Original boot menu (TOS started)" +@toc "Boot menu" +@{U}2.4.1 Original boot menu (TOS started) FIREBEE - FIRETOS@{u} + +The TOS can replace magxboot (MagiC) in the AUTO folder for a fast +boot (no programs inside the AUTO folder to start). You can enable a +boot menu with the configuration CPX. This menu arrives if the entry +of the favourite OS inside is <> '-'. + +You can select TOS, or MagiC, value is stored inside the NVM. + +With MagiC, the TOS try to found MAGIC.RAM inside the main directory +of the boot folder. + +Sure you can always use MAGXBOOT.PRG or ATABOOT.PRG inside the AUTO +folder. + +@{B} IMPORTANT MOTE : In the current status of emulation, MagiC can't run +on Firebee. @{b} + +@endnode + + +@node "Firebee boot menu (after board init)" +@toc "Boot menu" +@{U}2.4.2 Firebee boot menu (after board init) FIREBEE - FIRETOS@{u} + +Boot menu and rescue features context is the result of the switches. +SW6 and SW5 are inside the cookie '_SWI': + + ù B7: (1) SW6 DOWN, (0) SW6 UP. + + ù B6: (1) SW5 DOWN, (0) SW5 UP. + + ù B0: (1) rescue TOS started from 0xE0000000 (replace BAS or + dBUG). + +SW6 up is the normal usage. + +SW6 down allows to TOS to start FTP (build option), HTTP, TFTP +servers and create a Ram-Disk actually in B (this feature is also +possible with dBUG at 0xE0000000). + +SW5 up is the normal usage for start the TOS at 0xE0400000 (same +usage inside BAS or dBUG at 0xE0000000) and a boot menu has 2 choices +TOS or EMUTOS (TOS by default). + +SW5 down is the rescue mode, TOS at 0xE0000000 continue to run and a +boot menu displays 3 choices : + + ù TOS404 (at 0xE0000000 - boot) => TOS rescue (default choice) + + ù EMUTOS (at 0xE0600000) + + ù TOS404 (at 0xE0400000 - normal) => TOS to test + +@{B} IT'S IMPORTANT TO FLASH ONLY AT 0xE0000000 AN OFFICIAL STABLE +RELEASE OF THE TOS (rescuetos.hex) OR CONTINUE TO USE DBUG OR BAS AT +0xE0000000. @{b} + +NOTES : + + ù If BAS used for start the TOS, SW5 and SW6 must be up, else you + start EMUTOS or nothing. + + ù If dBUG used for start the TOS, SW5 must be up, else you must + use the command 'go E0400000'. + +@endnode + + +@node "Flash Tool" +@toc "Main" +@{U}3 Flash Tool FIREBEE - FIRETOS@{u} + + 3.1 Use Flash Tool + +@endnode + + +@node "Use Flash Tool" +@toc "Flash Tool" +@{U}3.1 Use Flash Tool FIREBEE - FIRETOS@{u} + + +@limage G:\tos060\doc\firebee\english\..\img\flash1.img 18 + + +The main task of this program is to put TOS binary (.BIN) or Srecord +files (.HEX) inside the flash. + +Since the BOOT v2.0, it's possible to load separate files for the +TOS404, the BOOT and the PCI drivers: + + ù FIRETOS.HEX: contains BOOT + TOS404 + Atari Diagnostics (must + disappear). + + ù BOOT_FIREBEE.HEX: contains the BOOT (must arrive). + + ù DRIVERS_FIREBEE.HEX: contains the PCI drivers (GPL licence, not + in this archive). + + ù TOS404.BIN (not in the archive): just for put the TOS in flash, + in the case of FIRETOS.HEX isn't used. + +NOTE : A binary file (.BIN) has a target address fixed at 0xE0400000. + +@endnode + + +@node "Configuration" +@toc "Main" +@{U}4 Configuration FIREBEE - FIRETOS@{u} + + 4.1 Introduction + 4.2 Average load + 4.3 Temperature + 4.4 Memory / uP + 4.5 Boot + 4.6 Stop/Misc + 4.7 Langage + 4.8 Video + 4.9 CT60TEMP.APP + 4.10 BubbleGEM + +@endnode + + +@node "Introduction" +@toc "Configuration" +@{U}4.1 Introduction FIREBEE - FIRETOS@{u} + +The Firebee's configuration is set with a CPX, used normally with +XCONTROL, ZCONTROL, or COPS. + +This CPX allows to : + + ù Configure the Non Volatile Memory. + + ù Configure the boot in Flash Eprom. + + ù Measure MIPS. + + ù See the load of the system (MiNT or MagiC only). + + ù See the Firebee temperature (need and Eiffel card inside the + same box). + + ù Blank the monitor after a delay. + + +@limage G:\tos060\doc\firebee\english\..\img\cpx3.img 20 + + +There are five common buttons on this CPX : + + ù Save : Button for save adjustments on the disk. + + ù Load : Button for load adjustments saved on the disk. + + ù OK : Button for validate the values changed into the non + volatile ram and the flash parameters. + + ù Cancel : Button for not change values to the configuration. + + ù i : Button for display informations (authors). + +For check get a CPU average load, blank the screen, or get the +temperature (with Eiffel) the CPX : + + ù Under TOS create a desk-accessory CT60TEMP.ACC (sorry for the + name ;-) ) and ask to reboot. + + ù Under MiNT create the program CT60TEMP.APP and start this + program. + + ù Under MagiC start a thread. + +@endnode + + +@node "Average load" +@toc "Configuration" +@{U}4.2 Average load FIREBEE - FIRETOS@{u} + + +@limage G:\tos060\doc\firebee\english\..\img\cpx1.img 19 + + +At this page you can see for MiNT and MagiC : + + ù The current value of CPU average load. + + ù The level of CPU average load. + + ù The curve of CPU average load during the last hour. Without MiNT + 1.11 or more, this curve is very approximate. + +@endnode + + +@node "Temperature" +@toc "Configuration" +@{U}4.3 Temperature FIREBEE - FIRETOS@{u} + + +@limage G:\tos060\doc\firebee\english\..\img\cpx2.img 20 + + +At this page you can see the Firebee's temperature during the last +hour if you have an Eiffel card (with the cookie 'Temp'). This curve +is normally in blue and change to magenta if the fan works (set to on +by the Effeil card). + +The green curve, the 68060 temperature value, and the trigger level +are not used because there are no sensor on the Coldfire (it's a +68060 feature). + +@endnode + + +@node "Memory / uP" +@toc "Configuration" +@{U}4.4 Memory / uP FIREBEE - FIRETOS@{u} + + +@limage G:\tos060\doc\firebee\english\..\img\cpx3.img 20 + + +At this page you can : + + ù See the total capacity of the ST-Ram. + + ù See the total capacity of the Fast-Ram. + + ù See the number of free bytes for the ST-Ram. + + ù See the number of free bytes for the Fast-Ram. + + ù See the number of millions instructions by second worked out by + the microprocessor (BogoMips). + + ù Select with/without FPU. + +@endnode + + +@node "Boot" +@toc "Configuration" +@{U}4.5 Boot FIREBEE - FIRETOS@{u} + + +@limage G:\tos060\doc\firebee\english\..\img\cpx4.img 20 + + + At this page you can : + + - Select the boot order on the IDE and SCSI drives (8 + choices). + + - Select at boot the operating system by default. + + - Select at boot the SCSI arbitration. + + - Select at boot the SCSI identificator (0 to 7). + + - Set the delay at boot in seconds (used for timeout with the + boot menu). + + - Set the default speed of the highspeed serial port used + also for debug. + + - Under TOS, remove the caches during 5 seconds when a + program is started or remove the copyback alert box. + + - Redirect displays of the AUTO folder's programs to a file + boot.log. + + - Get a debug file video.log. + + - Swap the two IDE ports (CompactFlash and IDE). + + NOTES : + + - Theses settings are writed inside the NVRAM or flash + parameters with the 'OK' button. + + - If you use the CompactFlash as drive or want use the + internal driver, please use only new boot (the old boot is + the original boot of the TOS 4.04). + +@endnode + + +@node "Stop/Misc" +@toc "Configuration" +@{U}4.6 Stop/Misc FIREBEE - FIRETOS@{u} + + +@limage G:\tos060\doc\firebee\english\..\img\cpx5.img 20 + + + At this page you can : + + - Set a delay for blank monitor (disabled if set to 0). + + - Set 3 last bytes of MAC address, begin is 00:CF:54. + + - Set board IP address. + + - Set host IP address (for TFTP). + + NOTES : + + - The delay is saved inside the CPX with the 'Save' button + (and not in NVRAM or flash parameters). It's + CT60TEMP.ACC/APP features. + + - The ethernet parameters are writed in the flash parameters + with the 'OK' button. If the valuse are 255/FF or 0, dBUG + setting are used. + + - The default gateway address is 0.0.0.0. + + - The default path/filename for TFTP is /home/firebee.hex. + +@endnode + + +@node "Langage" +@toc "Configuration" +@{U}4.7 Langage FIREBEE - FIRETOS@{u} + + +@limage G:\tos060\doc\firebee\english\..\img\cpx6.img 20 + + + At this page you can : + + - Select at boot the language by default. + + - Select at boot the keyboard type. + + - Select at boot the date format. + + - Select at boot the time format 12 or 24 hours. + + - Select at boot the date separator. + + NOTE : Theses settings are writed inside the NVRAM with the 'OK' + button. + +@endnode + + +@node "Video" +@toc "Configuration" +@{U}4.8 Video FIREBEE - FIRETOS@{u} + + +@limage G:\tos060\doc\firebee\english\..\img\cpx7.img 19 + + + With the default TOS404 (Videl/Blitter) modes you can : + + - Select at boot the monitor type. + + - Select at boot the display's mode : NTSC = 60 Hz, PAL = 50 + Hz. + + - Select at boot the screen resolution. + + - Select at boot the numbers of colors. + + - Select at boot the ST compatibility mode. + + - Select at boot the overscan mode on TV. + + - Replace the NVRAM reading by TOS values saved in the Flash + and use the IKBD clock instead of the RTC. This feature is + for fix NVM problems caused by a battery failure. + + NOTES : + + - Theses settings are writed inside the NVRAM with the 'OK' + button + + - Because there are no blitter actually inside the FPGA + emulation you can't see/use theses settings. + + +@limage G:\tos060\doc\firebee\english\..\img\cpx7_acp.img 20 + + + If the video display use the Radeon or extended ACP modes + (screen above 0x01000000) you can : + + - Select at boot the screen resolution, if the prefered video + mode is found on the monitor, the mode added to the list. + + - Select at boot the numbers of colors (256/65K/16M). + + - Select at boot the monitor layout on the Radeon board + (MON.1,MON.2) : + + * DEFAULT (automatic mode) + + * CRT,NONE + + * CRT,CRT + + * CRT,TMDS + + * TMDS,CRT + + * TMDS,TMDS + + - Select using DMA for boost display (this feature is used + only for the Radeon board, because the Flexbus has troubles + sometimes with ACP video). + + - Replace the NVRAM reading by TOS values saved in the Flash + and use the IKBD clock instead of the RTC. + + NOTE : The Radeon/ACP mode not overwrite the Videl mode, the + mode is writed inside a flash parameter with the 'OK' button. + +@endnode + + +@node "CT60TEMP.APP" +@toc "Configuration" +@{U}4.9 CT60TEMP.APP FIREBEE - FIRETOS@{u} + + This program is created by the CPX. For get a CPU average load, + blank the screen, or get the temperature (with Eiffel) the CPX : + + - Under TOS create a desk-accessory CT60TEMP.ACC and ask to + reboot. + + - Under MiNT create the program CT60TEMP.APP and start this + program. + + - Under MagiC start a thread. + + Some is the solution used (thead, accessory or application), + it's possible to use the multimedia keys features of the Eiffel + PS/2 interface (http://eiffel3.atari.org), especially with the + set number 2 PS/2. The @{B} POWER @{b} key start a stop after a shutdown + procedure. + + If CT60TEMP.APP is used under MagiC or MiNT (for MagiC boot + under TOS and copy CT60TEMP.ACC to CT60TEMP.APP), by using + environment variables, it's possible to use others multimedia + keys of the Eiffel PS/2 interface : + + - @{B} WWW HOME : @{b} Start the internet navigator with the + environment variable BROWSER. + + - @{B} E-MAIL : @{b} Start the email program with the environment + variable MAILER. + + - @{B} WWW SEARCH : @{b} Start the internet navigator with the + environment variable BROWSER with the home page of Google. + + - @{B} MY COMPUTER : @{b} Start the hypertexte viewer with the + environment variable HELPVIEWER with the documentation of + the CT60. + + You must install the program E_TEMP.PRG inside the AUTO folder + (the 'Eiff' cookie is used). + +@endnode + + +@node "BubbleGEM" +@toc "Configuration" +@{U}4.10 BubbleGEM FIREBEE - FIRETOS@{u} + + Under a multitasking operating system (for example MagiC, + MultiTOS, Geneva etc) BubbleGEM can be placed in the auto start + folder where it will be automatically started as a GEM program + on booting the system. + + Under single TOS BubbleGEM can be run as a desk accessory by + renaming BUBBLE.APP to BUBBLE.ACC and copying it to the root + directory of your boot partition, then rebooting. + + BubbleGEM-aware programs send a message and pass a character + string to BubbleGEM if the user clicks with the right mouse + button on an icon, button or window area. BubbleGEM then + displays the character string, formatted in a cute speech bubble + which remains displayed until the user moves the mouse pointer + to another window area, or until the user clicks again to burst + the bubble. + + Optionally bubbles can be displayed by clicking and holding down + the right mouse button; in this case the bubble bursts as soon + as the button is released again. + + While a bubble is open two keyboard shortcuts are active: + + : The content of the bubble is copied to the clipboard and + the bubble remains open. + : The content of the bubble is copied to the clipboard and + the bubble is closed. + + The author of BubbleGEM is Thomas Much; his email address is: + + Thomas.Much@@stud.uni-karlsruhe.de + +@endnode + + +@node "Cache" +@toc "Main" +@{U}5 Cache FIREBEE - FIRETOS@{u} + + 5.1 The Coldfire's V4e caches + 5.2 GENERAL6.CPX + 5.3 XCONTROL, ZCONTROL, COPS, and SDRAM in copyback + 5.4 PARX.SYS modules and the copyback + 5.5 TSR programs who crashes in the AUTO folder + 5.6 Programs packed by Ice + +@endnode + + +@node "The Coldfire's V4e caches" +@toc "Cache" +@{U}5.1 The Coldfire's V4e caches FIREBEE - FIRETOS@{u} + + There are two caches of 32KB inside the Coldfire V4e, data and + instruction. + + The ST-RAM is in writethrough, at each time than the Coldfire + write to the RAM, he write in the same time than the data cache. + + The TT-RAM is in copyback, the Coldfire write always inside his + data cache, he write in the memory the old data of his cache for + found some place for the new data. + + The Coldfire has also an instruction cache, witch the direct + link with the data cache is only the memory. The result is than + it's possible to obtain incoherency between the data cache and + the instruction cache. The example is the excecution of a + relocated program, without precaution and without system call + this is a crash. + +@endnode + + +@node "GENERAL6.CPX" +@toc "Cache" +@{U}5.2 GENERAL6.CPX FIREBEE - FIRETOS@{u} + + This CPX is a patched version of the Falcon GENERAL.CPX for the + TOS 060. The cache on/off selection now uses XBIOS calls. + +@endnode + + +@node "XCONTROL, ZCONTROL, COPS, and SDRAM in copyback" +@toc "Cache" +@{U}5.3 XCONTROL, ZCONTROL, COPS, and SDRAM in copyback FIREBEE - FIRETOS@{u} + + - COPS only flush caches after load the CPX and works fine. + + - ZCONTROL works under MiNT 1.16/Xaaes. + + - XCONTROL crashes. + + - The rebuilded XCONTROL.ACC fix this problem. + +@endnode + + +@node "PARX.SYS modules and the copyback" +@toc "Cache" +@{U}5.4 PARX.SYS modules and the copyback FIREBEE - FIRETOS@{u} + + If a program who use PARX.SYS crashes at start, you can try to + remove the caches with GENERAL6.CPX, load the program and set to + on the caches after. For example PICCOLO works with this method. + + A global solution is to remove the caches during 5 seconds when + a program is started under TOS with the Boot menu inside the + configuration CPX, but this method penalize all programs. + +@endnode + + +@node "TSR programs who crashes in the AUTO folder" +@toc "Cache" +@{U}5.5 TSR programs who crashes in the AUTO folder FIREBEE - FIRETOS@{u} + + Like CPX, the programs who not uses the Pexec function for load + modules crashes with the SDRAM in copyback, so the best way is + to load the program in ST-RAM (cache in writethrough). You can + use FILEINFO.CPX for change the flags. + + For example you must remove TT-ram flags of METAXBS.PRG + (Metados) because when the OVL modules are loaded there are no + flush after relocation, it's not compatible with the SDRAM and + the CPU cache in copyback. + + A global solution is to remove the caches during 5 seconds when + a program is started under TOS with the Boot menu inside the + configuration CPX, but this method penalize all programs. + +@endnode + + +@node "Programs packed by Ice" +@toc "Cache" +@{U}5.6 Programs packed by Ice FIREBEE - FIRETOS@{u} + + The TOS test the programs packed by Ice, there are a patch for + flush caches (inside the Pexec function). Without this patch, + programs packed by Ice crashes with the copyback cache (SDRAM). + This problem is not solved under MagiC or MiNT. + +@endnode + + +@node "Compatibility" +@toc "Main" +@{U}6 Compatibility FIREBEE - FIRETOS@{u} + + 6.1 Crashes + 6.1.1 Crashes with the Coldfire + 6.1.2 Crashes with caches + 6.2 Solutions + +@endnode + + +@node "Crashes" +@toc "Compatibility" +@{U}6.1 Crashes FIREBEE - FIRETOS@{u} + + 6.1.1 Crashes with the Coldfire + 6.1.2 Crashes with caches + +@endnode + + +@node "Crashes with the Coldfire" +@toc "Crashes" +@{U}6.1.1 Crashes with the Coldfire FIREBEE - FIRETOS@{u} + + The TOS use the CF68KLIB for emulate the 68060, when the + instruction or the adressing mode not exist there are no problem + the CF68KLIB can do his job. But with some instructions there + are no exception for the CF68KLIB, excepted with a complete + virtual CPU (like 68KEMU) who slow down the program, the + solution is to modify sources, if it's not possible the TOS has + a solution (a patcher inside Pexec) because 95% of problems are + Pure C programs : + + - A byte push/pop on stack has 2 bytes aligment on a 68K, not + on the Coldfire. + + - There are no exception for 64 bits instructions mul/div. + + - Atari line A is MAC instruction on Coldfire (not specific + to Pure C programs). + + The TOS test Pure C programs (during Pexec) and try to replace + theses instructions by unused opcode (Line A) who are handled by + te CF68KLIB : + + - Line A 0xA000-0xA00F already used for mac instructions + replaced by opcode 0xA920-0xA92F. + + - move.b DX,-(SP) replaced by opcode 0xA910-0xA917. + + - move.b (SP)+,DX replaced by opcode 0xA918-0xA91F. + + - move.b (AX),-(SP) replaced by opcode 0xA930-0xA937. + + - move.b (SP)+,(AX) replaced by opcode 0xA938-0xA93F. + + - move.b d(AX),-(SP) replaced by opcode 0xA9B0-0xA9B7. + + - move.b (SP)+,d(AX) replaced by opcode 0xA9B8-0xA9BF. + + - move.b abs.l,-(SP) replaced by opcode 0xA9F1. + + - move.b d(PC),-(SP) replaced by opcode 0xA9F2. + + - move.b (SP)+,abs.l replaced by opcode 0xA9F9. + + - mulu/s.l ea,dh:dl replaced by opcode 0xABC0-0xABFF. + + - divu/s.l ea:dr:dq replaced by opcode 0xAFC0-0xAFFF. + + NOTE : This solution can't work with modules not loaded with + Pexec or Pure C programs who havn't signature. + +@endnode + + +@node "Crashes with caches" +@toc "Crashes" +@{U}6.1.2 Crashes with caches FIREBEE - FIRETOS@{u} + + You can try to remove the caches with GENERAL6.CPX, start the + program who causes crashes, load the program and set to on the + caches after. + + You can use FILEINFO.CPX for change the flags and force the + program to use ST-RAM. + + For more informations, you can read the part 'Cache'. + +@endnode + + +@node "Solutions" +@toc "Compatibility" +@{U}6.2 Solutions FIREBEE - FIRETOS@{u} + + +@line 5 0 16 +@line 20 0 16 +@line 31 0 16 +@line 66 0 16 +@line 5 61 0 + @{B}Software@{b} @{B}Problem@{b} @{B}Solution@{b} +@line 5 61 0 + HD Driver Crashes Use only HDDRUTIL for create + partitions and use the internal + driver (1GB TOS/DOS partitions). +@line 5 61 0 + NVDI 5 Not works Rename all NVDIDRV*.SYS to + NVDIDRV*.SY (for example). + Replace hex sequence 48E7E0E0A000 + by 48E7E0E0A920 inside all + OFF*.NOD files. +@line 5 61 0 + MagiC 6 Not works Use MiNT ;-) +@line 5 61 0 + Picollo Crashes Remove the caches during start + D2D Crashes or remove the Fast-Ram flags + Gemview Crashes or use the cache delay inside + Gembench Crashes the configuration CPX under TOS. + Swiftel Photo Crashes +@line 5 61 0 + Xcontrol Crashes Use the rebuilded version. +@line 5 61 0 + + + +@line 1 0 24 +@line 14 0 24 +@line 28 0 24 +@line 74 0 24 +@line 1 73 0 + @{B}Hard@{b} @{B}Problem@{b} @{B}Solution@{b} +@line 1 73 0 + DSP DSP errors Not implemented inside the FPGA. + Disable DSP. +@line 1 73 0 + Sound No sound Replace the BAS by dBUG or rescue TOS. +@line 1 73 0 + Display Slow Decrease size, there are no hardware + acceleration (blitter) with the Videl + FPGA emulation, or use a Radeon on PCI bus. +@line 1 73 0 + Ethernet Not works Load the latest FPGA file with FLASH060. +@line 1 73 0 + USB Not works Fix the 3V3 voltage. +@line 1 73 0 + USB stick Not works Load the PCI bus for example with a + Radeon board ;-) +@line 1 73 0 + Adapter Destroyed Use an ATX power supply or a DC adapter + with a minimum of 1.5 A. +@line 1 73 0 + Floppy Writing not Use an SD-Card or wait an FPGA update. + works +@line 1 73 0 + Monitor not works Try another monitor or wait an FPGA or/and + TOS drivers update. +@line 1 73 0 + SCSI Not works Not implemented inside the FPGA. + Use an IDE drive. +@line 1 73 0 + Radeon Not works Use a Radeon for PC. TOS use an X86 emulator + for MAC for initialize the board. +@line 1 73 0 + Radeon 7000 DVI not work Clocks over 135 MHz have heat isues with DVI + (RV100) on RV100. + Now high modes are rejected (drivers V1.01). +@line 1 73 0 + + +@endnode + + +@node "Annexes" +@toc "Main" +@{U}7 Annexes FIREBEE - FIRETOS@{u} + + 7.1 TOS Keyboard shortcuts + 7.2 Load TOS with dBUG + 7.3 DBUG task + 7.4 Firebee MMU mapping + 7.5 LWIP socket cookie 'SOCK' + +@endnode + + +@node "TOS Keyboard shortcuts" +@toc "Annexes" +@{U}7.1 TOS Keyboard shortcuts FIREBEE - FIRETOS@{u} + + CTRL: If pressed before the Atari logo, jump the bios PCI. + Boot without AUTO folder and ACC. + ALT: If pressed before the Atari logo, jump the bios PCI. + Remove cache if pressed before the SDRAM init. + Boot without disk if pressed after. + SHIFTL-SHIFTR: Boot without SDRAM if pressed before the Atari logo. + SHIFTL: Displays infos about the SDRAM module. + CTRL-ALT-UNDO: NVM and Flash Parameters init if pressed during the + memory test until the Reset. You need to set the delay + at boot to 60 seconds with the configuration CPX + (oups can't work with the Firebee boot menu). + +@endnode + + +@node "Load TOS with dBUG" +@toc "Annexes" +@{U}7.2 Load TOS with dBUG FIREBEE - FIRETOS@{u} + + For load firetos.hex (the TOS) with an host TFTP server with + dBUG cmds : + + The 1st time, set TFTP vars (for example) : + + - set server 192.168.1.1 (host IP server) + + - set client 192.168.1.2 (FIREBEE IP) + + - set filename /home/firetos_firebee.hex + + - set filetype S-Record + + - set baud 19200 + + After just use : + + - dn -o 20000000 + + - fl w E0400000 400000 f0000 + + - go E0400000 (or go) + + Or if jou want preserve flash : + + - dn -o 20000000 + + - go 4000000 (or go) + + The TOS can start from anywere (-o is for add an offset and put + the S-record file in SDRAM), the boot part copy and apply + patches to the original TOS and uncompress the driver part to + the target address (0x00E00000). If the source address is equal + to the target address (0x00E00000), the boot has a jump to + 0xE0400000. + + WARNING : The ethernet part of dBUG need a clock on the PHY, so + if the FLASH above 0xE7000000 is destroyed ethernet can't work! + + NOTE : If the BAS is installed, it's possible to use ethernet + without dBUG with some limitations (3 flash parameters used) : + + - You can change only the 3 lastest bytes of the MAC address + with the CPX (stop/misc menu), begin is 00:CF:54 + + - You can change board IP and host IP with the CPX (stop/misc + menu). + + - The netmask is automatic if the choice is CPX setting. + + - The default gateway is 0.0.0.0. + + - The default path/filename for TFTP is /home/firebee.hex. + + - If the board IP address is at 0.0.0.0 or 255.255.255.255 + dBUG setting are used for board IP / gateway / netmask / + path/filename. + + - If the host IP address is at 0.0.0.0 or 255.255.255.255 + dBUG setting are used for host IP. + + - If the 3 last bytes of MAC address are 00:00:00 or FF:FF:FF + dBUG setting are used. + +@endnode + + +@node "DBUG task" +@toc "Annexes" +@{U}7.3 DBUG task FIREBEE - FIRETOS@{u} + + This DBUG task use the highspeed serial port, this is the list + of CF68KLIB, LWIP and FreeRTOS commands : + + Command Description Syntax + cb Clear Breakpoint cb + db Define Breakpoint db <-c|t value> <-r addr..> <-i> <-m> + dm Display Memory dm begin + dis Disassemble dis + dr Display Registers CF68KLIB dr + go Execute, Insert Breakpt go + lb List Breakpoints lb + pm Patch Memory pm addr + qt Query Tasks qt + st Single Step (after db) st + cat Concatenate File(s) cat file(s) + chdir Change Directory chdir dir + chmod Change Attibutes chmod filename attributes + cp Copy File cp source dest + ls List Directory ls + mkdir Make Directory mkdir dir + mv Rename File mv source dest + rm Remove File rm file + rmdir Remove Directory rmdir dir + arp Address Resol. Protocol arp <-a> + ifconfig Interface Configuration ifconfig <-a> ... + ping Ping ping <-n echos> <-w delay> host + netstat Network Stats netstat + cache Cache cache on/off + debug Debug CF68KLIB debug on/off + inter Interrupts CF68KLIB inter + reset System Reset reset + trap Traps CF68KLIB trap on/off + help Help help + + Excepted debug commands, it's also possible to use these + commands with Telnet. You can set the baudrate of the highspeed + serial port with the CPX. + + Usage example : + + > qt + Name TID Prio Status Sys/User Stack # + ------------------------------------------------------------ + ROOT F1006C 0A Ready 3987/NU/4096 0 + IDLE F141D0 00 Ready 4067/NU/4096 1 + lwIP0 F18510 1E Blocked 3977/NU/4096 2 + lwIP1 F1C750 1E Suspend 4003/NU/4096 3 + TELNETd F208B4 0F Suspend 3998/NU/4096 4 + FTPd F26EDC 0A Blocked 4000/NU/4096 5 + TFTPd F2B040 0A Suspend 3944/NU/4096 6 + HTTPd F2F1A4 0A Suspend 4024/NU/4096 7 + TOS F33308 05 Ready 4073/NU/4096 8 + DBUG F3746C 14 Ready 3004/NU/4096 9 + HMES F3BCF0 0A Ready 4004/NU/4096 10 + HT01 F3FF58 09 Suspend 3981/NU/4096 11 + HT02 F440BC 09 Suspend 3981/NU/4096 12 + HT03 F48220 09 Suspend 3981/NU/4096 13 + HT04 F4C384 09 Suspend 3981/NU/4096 14 + HT05 F504E8 09 Suspend 3981/NU/4096 15 + USBT F54D08 06 Ready 4035/NU/4096 16 + USBd F591D0 1F Suspend 3003/NU/4096 17 + => qt command displays FreeRTOS tasks, the TOS himself is a task. + Only the TOS use the CF68KLIB. + + > inter + int + NATIVE/RTOS CF68KLIB/TOS LEV PRI INTERRUPTS + OFF OFF 1 0 Edge port 1 Int(65) + OFF OFF 2 0 Edge port 2 Int(66) + OFF OFF 3 0 Edge port 3 Int(67) + OFF OFF 4 0 Edge port 4 Int(68) + OFF OFF 5 0 Edge port 5 Int(69) + OFF OFF 6 0 Edge port 6 Int(70) + OFF OFF 7 0 Edge port 7 Int(71) + OFF OFF 0 0 DSPI Int(89) + OFF OFF 0 0 DSPI Int(90) + OFF OFF 0 0 DSPI Int(91) + OFF OFF 0 0 DSPI Int(92) + OFF OFF 0 0 DSPI Int(93) + OFF OFF 0 0 DSPI Int(94) + OFF OFF 0 0 DSPI Int(95) + OFF OFF 0 0 PSC3 Int(96) + OFF OFF 0 0 PSC2 Int(97) + OFF OFF 0 0 PSC1 Int(98) + OFF ON 6 5 PSC0 Int(99) + OFF OFF 0 0 Comm Timer Int(100) + OFF OFF 0 0 SEC Int(101) + OFF OFF 0 0 FEC1 Int(102) + ON ON 5 1 FEC0 Int(103) + OFF OFF 0 0 I2C Int(104) + OFF OFF 0 0 PCIARB Int(105) + OFF OFF 0 0 CBPCI Int(106) + OFF OFF 0 0 XLBPCI Int(107) + ON ON 7 7 XLBARB Int(111) + ON ON 6 0 DMA Int(112) + OFF OFF 0 0 CAN0 ERROR Int(113) + OFF OFF 0 0 CAN0 BUSOFF Int(114) + OFF OFF 0 0 CAN0 MBOR Int(115) + OFF OFF 0 0 SLT1 Int(117) + ON ON 6 7 SLT0 Int(118) + OFF ON 6 4 CAN1 ERROR Int(119) + OFF ON 6 4 CAN1 BUSOFF Int(120) + OFF ON 6 4 CAN1 MBOR Int(121) + OFF OFF 0 0 GPT3 Int(123) + OFF OFF 0 0 GPT2 Int(124) + OFF OFF 0 0 GPT1 Int(125) + OFF OFF 0 0 GPT0 Int(126) + => By default TOS interrupts not works without CF68KLIB + (excepted the TOS himself), so some interrupts are disabled + out of the TOS task. + + 'db' install a breakpoint, without address db install a + breakpoint at the beginning of the program during Pexec (BDOS + feature). + +@endnode + + +@node "Firebee MMU mapping" +@toc "Annexes" +@{U}7.4 Firebee MMU mapping FIREBEE - FIRETOS@{u} + + 00000000 - 00CF0000 : STRAM 13 MB (cache in writethrough) + 00D00000 - 00DFFFFF : Mirror FPGA 1MB VIDEO RAM (cache in writethrough) + 00E00000 - 00EFFFFF : TOS404 1 MB (write protected) + 00F00000 - 00F01FFF : Mirror FPGA - ATARI IDE (8K) + 00F02000 - 00F0FFFF : invalid (bus error) + 00F10000 - 00F9FFFF : USB descriptors memory, DMA from PCI (no cache) + 00FA0000 - 00FBFFFF : invalid (bus error) + 00FC0000 - 00FEFFFF : TOS404 192 KB (write protected) + 00FF0000 - 00FF7FFF : invalid (bus error) + 00FF8000 - 00FFFFFF : Mirror FPGA - ATARI I/O (32K - no cache) + 01000000 - 1FFFFFFF : SDRAM 496 MB (cache in copyback) + 20000000 - 3FFFFFFF : invalid (bus error) + 40000000 - 7FFFFFFF : FPGA FBCS4 VIDEO RAM + 80000000 - BFFFFFFF : PCI MEM (1024 MB) + C0000000 - CFFFFFFF : invalid (bus error) + D0000000 - DFFFFFFF : PCI I/O (256 MB) + E0000000 - E07FFFFF : FBCS0 flash 8 MB (flash parameters at 0xE04F0000) + E0800000 - EFFFFFFF : invalid (bus error) + F0000000 - F7FFFFFF : FPGA FBCS2 ACP I/O + F8000000 - FBFFFFFF : FPGA FBCS3 SRAM + FC000000 - FEFFFFFF : invalid (bus error) + FF000000 - FF01FFFF : MBAR coldfire (no cache) + FF020000 - FF03FFFF : invalid (bus error) + FF040000 - FF04FFFF : MMU_BASE coldfire (no cache) + FF050000 - FFEFFFFF : invalid (bus error) + FFF00000 - FFFFFFFF : FPGA FBCS1 - ATARI IDE - ATARI I/O (1MB - no cache) + +@endnode + + +@node "LWIP socket cookie 'SOCK'" +@toc "Annexes" +@{U}7.5 LWIP socket cookie 'SOCK' FIREBEE - FIRETOS@{u} + + typedef struct socket_cookie + { + long version; /* 0x0101 for example */ + long magic; /* 'SOCK' */ + int (*socket)(int domain, int type, int protocol); + int (*bind)(int s, struct sockaddr *name, socklen_t namelen); + int (*listen)(int s, int backlog); + int (*accept)(int s, struct sockaddr *addr, socklen_t *addrlen); + int (*connect)(int s, struct sockaddr *name, socklen_t namelen); + int (*write)(int s, void *dataptr, int size); + int (*send)(int s, void *dataptr, int size, unsigned int flags); + int (*sendto)(int s, void *dataptr, int size, unsigned int flags, struct sockaddr *to, socklen_t tolen); + int (*read)(int s, void *mem, int len); + int (*recv)(int s, void *mem, int len, unsigned int flags); + int (*recvfrom)(int s, void *mem, int len, unsigned int flags, struct sockaddr *from, socklen_t *fromlen); + int (*shutdown)(int s, int how); + int (*close)(int s); + int (*getsockname)(int s, struct sockaddr *name, socklen_t *namelen); + int (*getpeername)(int s, struct sockaddr *name, socklen_t *namelen); + int (*getsockopt)(int s, int level, int optname, void *optval, socklen_t *optlen); + int (*setsockopt)(int s, int level, int optname, const void *optval, socklen_t optlen); + int (*select)(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout); + int (*ioctlsocket)(int s, long cmd, void *argp); + struct hostent *(*gethostbyname)(const char *name); + int (*geterrno)(void); + } SOCKET_COOKIE; + +@endnode + + +@node "Contacts" +@toc "Main" +@{U}8 Contacts FIREBEE - FIRETOS@{u} + + Flash Tool, Configuration, and system : + Didier MEQUIGNON + aniplay@@wanadoo.fr + +@endnode + + + diff --git a/sources/firehyp/firebee.u b/sources/firehyp/firebee.u new file mode 100644 index 0000000..374d6fa --- /dev/null +++ b/sources/firehyp/firebee.u @@ -0,0 +1,1083 @@ +!tex \documentstyle[11pt]{article} +!stg @subject "Documentation" +!english +!title Documentation of the +!programimage ..\img\firebee.img +!program FIREBEE - FIRETOS +!version Version Boot 2.01, Drivers 1.01 +!date (!today) +!author Didier MEQUIGNON +!email aniplay@wanadoo.fr +!use_auto_subtocs [info,html,stg,tvh,win] +!use_auto_subsubtocs [info,html,stg,tvh,win] +!no_effects [asc] +!begin_document +!maketitle +!tableofcontents + +!node Presentation + +The Firebee use a Coldfire V4e at 266 MHz (MCF5475) and an FPGA for emulate obsolete +Atari devices and add new features (DSP ?) in the future. Today for new FPGA feature, +there are just a DVI-I port connected to him (Videl ACP extended modes without +hardware acceleration). + +!image ..\img\schema.img +!begin_verbatim + +!end_verbatim + +Some new devices are connected to the Coldfire : + +!begin_itemize +!item USB controller on his PCI bus. +!item AC97 audio codec on his AC-LINK interface. +!item EDID from monitor to his I2C interface. +!item Ethernet 10/100. +!end_itemize + + +!subnode Coldfire V4e + +This coldfire like all the members of his familly is a microcontroller, there are : + +!begin_itemize +!item Two Fast Ethernet Controllers (FEC 10/100), but only the first is used on +the Firebee. +!item Four Programmable Serial Controllers (PSC), the first port is the highspeed +serial port, the third port is for the AC97 audio codec. +!item A PCI controller connnected to an USB host controller, the PCI configured +at 33MHz on the Firebee. +!item An USB slave device not used on the Firebee. +!item A Flexbus connected to the FPGA and 8 MB of Flash memory (multiplexd bus, +same frequency than the PCI). +!item A Memory Controller connected to 512MB of SDRAM memory. +!item An I2C interface connected to the DVI-I port. +!item An DSPI interface connected to the SD-Card socket. +!item A multichannel DMA (used for example for the AC97). +!item 6 Timers. +!end_itemize + +!image ..\img\v4e.img +!begin_verbatim + +!end_verbatim + + +!subnode TOS 4.04 + +The TOS404 for FIREBEE use the CF68KLIB (68060 emulation) and use : + +!begin_itemize +!item Timers and MFP (FPGA emulation). +!item Serial ports (MFP FPGA emulation and PSC0 from Coldfire). +!item Serial port for IKBD with Eiffel. +!item ACIA for original IKBD (FPGA emulation). +!item ACIA for MIDI (FPGA emulation). +!item Ethernet 10/100. +!item PCI: USB / Radeon (USB support mouse & keyboard, and mass storage) with +plug & play feature. +!item CompactFlash (FPGA emulation). +!item SD-Card (using DSPI). +!item Atari Falcon IDE / SCSI (FPGA emulation, SCSI not implemented). +!item Coldfire DMA. +!item MMU. +!item PSG (YAMAHA - FPGA emulation) +!item Atari Floppy (FPGA emulation, only reading works) +!item RTC (PIC & FPGA emulation) +!item Videl ACP extended modes with EDID probing (monitor detection) +!item AC97 Sound. +!end_itemize + +The TOS has four parts : + +!begin_itemize +!item The original TOS 4.04. +!item The boot who can start from reset, initialize the board, start the CF68KLIB, +apply the patches to the TOS, add some XBIOS and boot disk parts rewrited, and +start the PCI BIOS. +!item The CF68KLIB for a 68060 emulation. +!item The driver part (AC97, Radeon, DMA, USB, Video ACP, rewrited VDI, TCP/IP stack, +etc ...). +!end_itemize + + +!node TOS in Flash + +!subnode Start TOS + +The TOS located at 0xE0400000 need an FPGA init before start. +There are 3 solutions for start the TOS from reset (from 0xE0000000) : + +!begin_itemize +!item dBUG who has Ethernet support (TOS easy to update without risk, +see 'Load TOS with dBUG') +!item BAS the original solution of Fredi (but sound not works under TOS). +!item The TOS himself with the rescue TOS who initialize the FPGA. +!end_itemize + +NOTE: Only the 2 latest solutions can also start EMUTOS. + + +!subnode Drivers + +The drivers part on the Firebee add features to TOS : + +!begin_itemize +!item AC97 driver. +!item Videl ACP externded modes driver (256 /65K / 16M colors) with EDID +monitor detection. +!item USB driver. +!item SD-Card driver (thanks to Fredi). +!item DMA driver. +!item Flash driver. +!item Fast Ethernet Controller (FEC) driver. +!item Ethernet PHY driver (tranceiver). +!item VDI/fVDI replacement. +!item X86 emulator (for a graphic card initialization). +!item ATI Radeon driver. +!item XBIOS GSXB driver. +!item BDOS (GEMDOS replacement). +!item TCP/IP stack (LwIP/FreeRTOS) with TFTP, FTP, Telnet, HTTP servers +(you can see screen like a VNC server). +!item GlueSTiK and socket interfaces (from cookies 'STiK' and 'SOCK'). +!item Real time OS (FreeRTOS) with DBUG task. +!item 68K/Coldfire disassembler. +!end_itemize + + +!subnode Technical (boot) + +This is a TOS 4.04 patched by the boot (2.0+), in this order there are : + +!begin_itemize +!item Board initialization (Coldfire and ACP registers). +!item The copy of the TOS in SDRAM after apply the patches. +!item The initialization of the MMU. All the ST-RAM is in +writethrough and the SDRAM declaration in copyback. +!item Start the CF68KLIB, TOS is a task for FreeRTOS (driver part). +!item The installation of the cookies '_CPU', '_FPU', '_CF_'. +!item The patchs for cache, MMU, address in 0x00FFxxxx, and the +instructions movep replaced. +!item The bombs inside exceptions displayed with texts in clear of a crash. +!item The XBIOS function 0xC60A to 0xC60D (temperature, parameters in +Flash, cache...), and the DSP (functions with handshake). +!item The needful patchs for the blitter, the system fonts and the Atari +logo copied at the top of the ST-RAM. +!item The replacement of the XBIOS Bconout routine (display texts). +!item Check and fix the modecode get from NVM. +!item Start the PCI BIOS and the drivers. +!item The display of the V4e's type (revision, mask and frequency). +!item The declaration of the SDRAM to the TOS. +!item The initialization of the SDRAM, and the MB/s during writing +displayed. +!item The fastram buffer created and his cookie '_FRB'. +!item The extended fastram buffer created and his cookie 'XFRB'. +!item The patch for the boot order of the drives IDE and SCSI (8 choices). +!item Extra boot features : +!begin_itemize +!item Add SCSIDRV and XHDI protocols. +!item Add identify device procedure for SCSI and IDE drives, the boot wait + if a removable drive is not ready. +!item Add IDE slave support. +!item Add CompactFlash support. +!item Add combined MSDOS/TOS root and partition support, this feature +support byte swapping needed by MSDOS format and search a *.SYS for +load the disk driver. +!item Add speed test for bootables devices. +!item Start internal hard disk driver if no bootable disk as an external +driver. +!end_itemize +!item The patch for the boot menu. +!item The displays redirection of the AUTO programs to a file boot.log. +!item The patch for the Pexec function for the copyback (cpush after the +relocation). +!item The blitter patchs of the VDI functions, vro_cpyfm, vr_trnfm, and +vrt_cpyfm for work in SDRAM (an intermediate buffer inside ST-RAM is used). +!item The AES patchs for change the Newdesk buffer of 4 KB to 32 KB. +!item Scan-codes used with the Eiffel card : +!begin_itemize +!item PAGE UP/DOWN. +!item PRINT SCREEN. +!item POWER (set 2 only, Eiffel 1.0.5). +!item VOLUME UP/DOWN (set 2 only, Eiffel 1.0.5). +!end_itemize +!end_itemize + + +!subnode Boot menu + +There are two boot menu on the Firebee : + +!begin_itemize +!item The original use the NVRAM OS setting, the TOS is started. +!item The second can start EMUTOS in native mode or a TOS to test after board +initialization. Switches or TOS source area (normal or rescue) change the +content of this menu. +!end_itemize + + +!subsubnode Original boot menu (TOS started) + +The TOS can replace magxboot (MagiC) in the AUTO folder for a fast boot +(no programs inside the AUTO folder to start). You can enable a boot menu +with the configuration CPX. This menu arrives if the entry of the favourite +OS inside is <> '-'. + +You can select TOS, or MagiC, value is stored inside the NVM. + +With MagiC, the TOS try to found MAGIC.RAM inside the main directory +of the boot folder. + +Sure you can always use MAGXBOOT.PRG or ATABOOT.PRG inside the AUTO +folder. + +(!B) +IMPORTANT MOTE : In the current status of emulation, MagiC can't run on Firebee. +(!b) + + +!subsubnode Firebee boot menu (after board init) + +Boot menu and rescue features context is the result of the switches. +SW6 and SW5 are inside the cookie '_SWI': + +!begin_itemize +!item B7: (1) SW6 DOWN, (0) SW6 UP. +!item B6: (1) SW5 DOWN, (0) SW5 UP. +!item B0: (1) rescue TOS started from 0xE0000000 (replace BAS or dBUG). +!end_itemize + +SW6 up is the normal usage. + +SW6 down allows to TOS to start FTP (build option), HTTP, TFTP servers and create a Ram-Disk +actually in B (this feature is also possible with dBUG at 0xE0000000). + +SW5 up is the normal usage for start the TOS at 0xE0400000 (same usage inside BAS or dBUG at +0xE0000000) and a boot menu has 2 choices TOS or EMUTOS (TOS by default). + +SW5 down is the rescue mode, TOS at 0xE0000000 continue to run and a boot menu displays 3 choices : + +!begin_itemize +!item TOS404 (at 0xE0000000 - boot) => TOS rescue (default choice) +!item EMUTOS (at 0xE0600000) +!item TOS404 (at 0xE0400000 - normal) => TOS to test +!end_itemize + +(!B) +IT'S IMPORTANT TO FLASH ONLY AT 0xE0000000 AN OFFICIAL STABLE RELEASE OF THE TOS (rescuetos.hex) +OR CONTINUE TO USE DBUG OR BAS AT 0xE0000000. +(!b) + +NOTES : + +!begin_itemize +!item If BAS used for start the TOS, SW5 and SW6 must be up, else you start EMUTOS or nothing. +!item If dBUG used for start the TOS, SW5 must be up, else you must use the command 'go E0400000'. +!end_itemize + + +!node Flash Tool + +!subnode Use Flash Tool + +!image ..\img\flash1.img +!begin_verbatim + +!end_verbatim + +The main task of this program is to put TOS binary (.BIN) or Srecord files +(.HEX) inside the flash. + +Since the BOOT v2.0, it's possible to load separate files for the TOS404, the +BOOT and the PCI drivers: +!begin_itemize +!item FIRETOS.HEX: contains BOOT + TOS404 + Atari Diagnostics (must disappear). +!item BOOT_FIREBEE.HEX: contains the BOOT (must arrive). +!item DRIVERS_FIREBEE.HEX: contains the PCI drivers (GPL licence, not in this archive). +!item TOS404.BIN (not in the archive): just for put the TOS in flash, in the +case of FIRETOS.HEX isn't used. +!end_itemize + +NOTE : A binary file (.BIN) has a target address fixed at 0xE0400000. + + +!node Configuration + +!subnode Introduction + +The Firebee's configuration is set with a CPX, used normally with XCONTROL, +ZCONTROL, or COPS. + +This CPX allows to : + +!begin_itemize +!item Configure the Non Volatile Memory. +!item Configure the boot in Flash Eprom. +!item Measure MIPS. +!item See the load of the system (MiNT or MagiC only). +!item See the Firebee temperature (need and Eiffel card inside the same box). +!item Blank the monitor after a delay. +!end_itemize + +!image ..\img\cpx3.img +!begin_verbatim + +!end_verbatim + +There are five common buttons on this CPX : + +!begin_itemize +!item Save : Button for save adjustments on the disk. +!item Load : Button for load adjustments saved on the disk. +!item OK : Button for validate the values changed into the non volatile +ram and the flash parameters. +!item Cancel : Button for not change values to the configuration. +!item i : Button for display informations (authors). +!end_itemize + +For check get a CPU average load, blank the screen, or get the +temperature (with Eiffel) the CPX : + +!begin_itemize +!item Under TOS create a desk-accessory CT60TEMP.ACC (sorry for the name ;-) ) +and ask to reboot. +!item Under MiNT create the program CT60TEMP.APP and start this program. +!item Under MagiC start a thread. +!end_itemize + + +!subnode Average load + +!image ..\img\cpx1.img +!begin_verbatim + +!end_verbatim + +At this page you can see for MiNT and MagiC : + +!begin_itemize +!item The current value of CPU average load. +!item The level of CPU average load. +!item The curve of CPU average load during the last hour. Without MiNT 1.11 +or more, this curve is very approximate. +!end_itemize + + +!subnode Temperature + +!image ..\img\cpx2.img +!begin_verbatim + +!end_verbatim + +At this page you can see the Firebee's temperature during the last hour if +you have an Eiffel card (with the cookie 'Temp'). This curve is normally +in blue and change to magenta if the fan works (set to on by the Effeil card). + +The green curve, the 68060 temperature value, and the trigger level are not used +because there are no sensor on the Coldfire (it's a 68060 feature). + + +!subnode Memory / uP + +!image ..\img\cpx3.img +!begin_verbatim + +!end_verbatim + +At this page you can : + +!begin_itemize + +!item See the total capacity of the ST-Ram. + +!item See the total capacity of the Fast-Ram. + +!item See the number of free bytes for the ST-Ram. + +!item See the number of free bytes for the Fast-Ram. + +!item See the number of millions instructions by second worked out by the +microprocessor (BogoMips). + +!item Select with/without FPU. + + +!subnode Boot + +!image ..\img\cpx4.img +!begin_verbatim + +!end_verbatim + +At this page you can : + +!begin_itemize +!item Select the boot order on the IDE and SCSI drives (8 choices). +!item Select at boot the operating system by default. +!item Select at boot the SCSI arbitration. +!item Select at boot the SCSI identificator (0 to 7). +!item Set the delay at boot in seconds (used for timeout with the boot menu). +!item Set the default speed of the highspeed serial port used also for debug. +!item Under TOS, remove the caches during 5 seconds when a program is +started or remove the copyback alert box. +!item Redirect displays of the AUTO folder's programs to a file boot.log. +!item Get a debug file video.log. +!item Swap the two IDE ports (CompactFlash and IDE). +!end_itemize + +NOTES : + +!begin_itemize +!item Theses settings are writed inside the NVRAM or flash parameters with +the 'OK' button. +!item If you use the CompactFlash as drive or want use the internal driver, +please use only new boot (the old boot is the original boot of the TOS 4.04). +!end_itemize + + +!subnode Stop/Misc + +!image ..\img\cpx5.img +!begin_verbatim + +!end_verbatim + +At this page you can : + +!begin_itemize +!item Set a delay for blank monitor (disabled if set to 0). +!item Set 3 last bytes of MAC address, begin is 00:CF:54. +!item Set board IP address. +!item Set host IP address (for TFTP). +!end_itemize + +NOTES : + +!begin_itemize +!item The delay is saved inside the CPX with the 'Save' button +(and not in NVRAM or flash parameters). It's CT60TEMP.ACC/APP features. +!item The ethernet parameters are writed in the flash parameters with +the 'OK' button. If the valuse are 255/FF or 0, dBUG setting are used. +!item The default gateway address is 0.0.0.0. +!item The default path/filename for TFTP is /home/firebee.hex. +!end_itemize + + +!subnode Langage + +!image ..\img\cpx6.img +!begin_verbatim + +!end_verbatim + +At this page you can : + +!begin_itemize +!item Select at boot the language by default. +!item Select at boot the keyboard type. +!item Select at boot the date format. +!item Select at boot the time format 12 or 24 hours. +!item Select at boot the date separator. +!end_itemize + +NOTE : Theses settings are writed inside the NVRAM with the 'OK' button. + + +!subnode Video + +!image ..\img\cpx7.img +!begin_verbatim + +!end_verbatim + +With the default TOS404 (Videl/Blitter) modes you can : + +!begin_itemize +!item Select at boot the monitor type. +!item Select at boot the display's mode : NTSC = 60 Hz, PAL = 50 Hz. +!item Select at boot the screen resolution. +!item Select at boot the numbers of colors. +!item Select at boot the ST compatibility mode. +!item Select at boot the overscan mode on TV. +!item Replace the NVRAM reading by TOS values saved in the Flash and use the +IKBD clock instead of the RTC. This feature is for fix NVM problems caused +by a battery failure. +!end_itemize + +NOTES : + +!begin_itemize +!item Theses settings are writed inside the NVRAM with the 'OK' button +!item Because there are no blitter actually inside the FPGA emulation +you can't see/use theses settings. +!end_itemize + + +!image ..\img\cpx7_acp.img +!begin_verbatim + +!end_verbatim + +If the video display use the Radeon or extended ACP modes (screen above +0x01000000) you can : + +!begin_itemize +!item Select at boot the screen resolution, if the prefered video mode is +found on the monitor, the mode added to the list. +!item Select at boot the numbers of colors (256/65K/16M). +!item Select at boot the monitor layout on the Radeon board (MON.1,MON.2) : +!begin_itemize +!item DEFAULT (automatic mode) +!item CRT,NONE +!item CRT,CRT +!item CRT,TMDS +!item TMDS,CRT +!item TMDS,TMDS +!end_itemize +!item Select using DMA for boost display (this feature is used only for +the Radeon board, because the Flexbus has troubles sometimes with ACP video). +!item Replace the NVRAM reading by TOS values saved in the Flash and use the +IKBD clock instead of the RTC. +!end_itemize + +NOTE : The Radeon/ACP mode not overwrite the Videl mode, the mode is +writed inside a flash parameter with the 'OK' button. + + +!subnode CT60TEMP.APP + +This program is created by the CPX. For get a CPU average load, blank +the screen, or get the temperature (with Eiffel) the CPX : + +!begin_itemize +!item Under TOS create a desk-accessory CT60TEMP.ACC and ask to reboot. +!item Under MiNT create the program CT60TEMP.APP and start this program. +!item Under MagiC start a thread. +!end_itemize + +Some is the solution used (thead, accessory or application), it's +possible to use the multimedia keys features of the Eiffel PS/2 interface +(http://eiffel3.atari.org), especially with the set number 2 PS/2. The +(!B) POWER (!b) key start a stop after a shutdown procedure. + +If CT60TEMP.APP is used under MagiC or MiNT (for MagiC boot under TOS and +copy CT60TEMP.ACC to CT60TEMP.APP), by using environment variables, it's +possible to use others multimedia keys of the Eiffel PS/2 interface : + +!begin_itemize +!item (!B) WWW HOME : (!b) Start the internet navigator with the +environment variable BROWSER. +!item (!B) E-MAIL : (!b) Start the email program with the environment +variable MAILER. +!item (!B) WWW SEARCH : (!b) Start the internet navigator with the +environment variable BROWSER with the home page of Google. +!item (!B) MY COMPUTER : (!b) Start the hypertexte viewer with the +environment variable HELPVIEWER with the documentation of the CT60. +!end_itemize + +You must install the program E_TEMP.PRG inside the AUTO folder (the +'Eiff' cookie is used). + + +!subnode BubbleGEM + + Under a multitasking operating system (for example MagiC, MultiTOS, +Geneva etc) BubbleGEM can be placed in the auto start folder where it +will be automatically started as a GEM program on booting the system. + + Under single TOS BubbleGEM can be run as a desk accessory by renaming +BUBBLE.APP to BUBBLE.ACC and copying it to the root directory of your +boot partition, then rebooting. + + BubbleGEM-aware programs send a message and pass a character string to +BubbleGEM if the user clicks with the right mouse button on an icon, +button or window area. BubbleGEM then displays the character string, +formatted in a cute speech bubble which remains displayed until the user +moves the mouse pointer to another window area, or until the user clicks +again to burst the bubble. + + Optionally bubbles can be displayed by clicking and holding down the +right mouse button; in this case the bubble bursts as soon as the +button is released again. + + While a bubble is open two keyboard shortcuts are active: +!begin_verbatim + : The content of the bubble is copied to the clipboard and + the bubble remains open. + : The content of the bubble is copied to the clipboard and + the bubble is closed. +!end_verbatim + +The author of BubbleGEM is Thomas Much; his email address is: + + Thomas.Much@stud.uni-karlsruhe.de + + +!node Cache + +!subnode The Coldfire's V4e caches + +There are two caches of 32KB inside the Coldfire V4e, data and instruction. + +The ST-RAM is in writethrough, at each time than the Coldfire write to the +RAM, he write in the same time than the data cache. + +The TT-RAM is in copyback, the Coldfire write always inside his data cache, +he write in the memory the old data of his cache for found some place for +the new data. + +The Coldfire has also an instruction cache, witch the direct link with the +data cache is only the memory. The result is than it's possible to obtain +incoherency between the data cache and the instruction cache. The example +is the excecution of a relocated program, without precaution and without +system call this is a crash. + + +!subnode GENERAL6.CPX + +This CPX is a patched version of the Falcon GENERAL.CPX for the TOS +060. The cache on/off selection now uses XBIOS calls. + + +!subnode XCONTROL, ZCONTROL, COPS, and SDRAM in copyback + +!begin_itemize + +!item COPS only flush caches after load the CPX and works fine. + +!item ZCONTROL works under MiNT 1.16/Xaaes. + +!item XCONTROL crashes. + +!item The rebuilded XCONTROL.ACC fix this problem. + +!end_itemize + + +!subnode PARX.SYS modules and the copyback + +If a program who use PARX.SYS crashes at start, you can try to remove the +caches with GENERAL6.CPX, load the program and set to on the caches +after. For example PICCOLO works with this method. + +A global solution is to remove the caches during 5 seconds when a program +is started under TOS with the Boot menu inside the configuration CPX, but +this method penalize all programs. + + +!subnode TSR programs who crashes in the AUTO folder + +Like CPX, the programs who not uses the Pexec function for load +modules crashes with the SDRAM in copyback, so the best way is to load +the program in ST-RAM (cache in writethrough). You can use FILEINFO.CPX +for change the flags. + +For example you must remove TT-ram flags of METAXBS.PRG (Metados) +because when the OVL modules are loaded there are no flush after +relocation, it's not compatible with the SDRAM and the CPU cache in +copyback. + +A global solution is to remove the caches during 5 seconds when a program +is started under TOS with the Boot menu inside the configuration CPX, but +this method penalize all programs. + + +!subnode Programs packed by Ice + +The TOS test the programs packed by Ice, there are a patch for flush +caches (inside the Pexec function). Without this patch, programs packed by +Ice crashes with the copyback cache (SDRAM). This problem is not solved +under MagiC or MiNT. + + +!node Compatibility + +!subnode Crashes + +!subsubnode Crashes with the Coldfire + +The TOS use the CF68KLIB for emulate the 68060, when the instruction or +the adressing mode not exist there are no problem the CF68KLIB can do his job. +But with some instructions there are no exception for the CF68KLIB, excepted +with a complete virtual CPU (like 68KEMU) who slow down the program, the +solution is to modify sources, if it's not possible the TOS has a solution +(a patcher inside Pexec) because 95% of problems are Pure C programs : + +!begin_itemize +!item A byte push/pop on stack has 2 bytes aligment on a 68K, not on the Coldfire. +!item There are no exception for 64 bits instructions mul/div. +!item Atari line A is MAC instruction on Coldfire (not specific to Pure C programs). +!end_itemize + +The TOS test Pure C programs (during Pexec) and try to replace theses instructions +by unused opcode (Line A) who are handled by te CF68KLIB : + +!begin_itemize +!item Line A 0xA000-0xA00F already used for mac instructions replaced by opcode 0xA920-0xA92F. +!item move.b DX,-(SP) replaced by opcode 0xA910-0xA917. +!item move.b (SP)+,DX replaced by opcode 0xA918-0xA91F. +!item move.b (AX),-(SP) replaced by opcode 0xA930-0xA937. +!item move.b (SP)+,(AX) replaced by opcode 0xA938-0xA93F. +!item move.b d(AX),-(SP) replaced by opcode 0xA9B0-0xA9B7. +!item move.b (SP)+,d(AX) replaced by opcode 0xA9B8-0xA9BF. +!item move.b abs.l,-(SP) replaced by opcode 0xA9F1. +!item move.b d(PC),-(SP) replaced by opcode 0xA9F2. +!item move.b (SP)+,abs.l replaced by opcode 0xA9F9. +!item mulu/s.l ea,dh:dl replaced by opcode 0xABC0-0xABFF. +!item divu/s.l ea:dr:dq replaced by opcode 0xAFC0-0xAFFF. +!end_itemize + +NOTE : This solution can't work with modules not loaded with Pexec or Pure C +programs who havn't signature. + + +!subsubnode Crashes with caches + +You can try to remove the caches with GENERAL6.CPX, start the program who +causes crashes, load the program and set to on the caches after. + +You can use FILEINFO.CPX for change the flags and force the program to +use ST-RAM. + +For more informations, you can read the part 'Cache'. + + +!subnode Solutions + +!begin_table [|l|l|l|] !hline +(!B)Software(!b) !! (!B)Problem(!b) !! (!B)Solution(!b) +!hline +HD Driver !! Crashes !! Use only HDDRUTIL for create + !! !! partitions and use the internal + !! !! driver (1GB TOS/DOS partitions). +!hline +NVDI 5 !! Not works !! Rename all NVDIDRV*.SYS to + !! !! NVDIDRV*.SY (for example). + !! !! Replace hex sequence 48E7E0E0A000 + !! !! by 48E7E0E0A920 inside all + !! !! OFF*.NOD files. +!hline +MagiC 6 !! Not works !! Use MiNT ;-) +!hline +Picollo !! Crashes !! Remove the caches during start +D2D !! Crashes !! or remove the Fast-Ram flags +Gemview !! Crashes !! or use the cache delay inside +Gembench !! Crashes !! the configuration CPX under TOS. +Swiftel Photo !! Crashes !! +!hline +Xcontrol !! Crashes !! Use the rebuilded version. +!hline +!end_table + +!begin_table [|l|l|l|] !hline +(!B)Hard(!b) !! (!B)Problem(!b) !! (!B)Solution(!b) +!hline +DSP !! DSP errors !! Not implemented inside the FPGA. + !! !! Disable DSP. +!hline +Sound !! No sound !! Replace the BAS by dBUG or rescue TOS. +!hline +Display !! Slow !! Decrease size, there are no hardware + !! !! acceleration (blitter) with the Videl + !! !! FPGA emulation, or use a Radeon on PCI bus. +!hline +Ethernet !! Not works !! Load the latest FPGA file with FLASH060. +!hline +USB !! Not works !! Fix the 3V3 voltage. +!hline +USB stick !! Not works !! Load the PCI bus for example with a + !! !! Radeon board ;-) +!hline +Adapter !! Destroyed !! Use an ATX power supply or a DC adapter + !! !! with a minimum of 1.5 A. +!hline +Floppy !! Writing not !! Use an SD-Card or wait an FPGA update. + !! works !! +!hline +Monitor !! not works !! Try another monitor or wait an FPGA or/and + !! !! TOS drivers update. +!hline +SCSI !! Not works !! Not implemented inside the FPGA. + !! !! Use an IDE drive. +!hline +Radeon !! Not works !! Use a Radeon for PC. TOS use an X86 emulator +for MAC !! !! for initialize the board. +!hline +Radeon 7000 !! DVI not work !! Clocks over 135 MHz have heat isues with DVI +(RV100) !! !! on RV100. + !! !! Now high modes are rejected (drivers V1.01). +!hline +!end_table + + +!node Annexes + +!subnode TOS Keyboard shortcuts + +!begin_verbatim +CTRL: If pressed before the Atari logo, jump the bios PCI. + Boot without AUTO folder and ACC. +ALT: If pressed before the Atari logo, jump the bios PCI. + Remove cache if pressed before the SDRAM init. + Boot without disk if pressed after. +SHIFTL-SHIFTR: Boot without SDRAM if pressed before the Atari logo. +SHIFTL: Displays infos about the SDRAM module. +CTRL-ALT-UNDO: NVM and Flash Parameters init if pressed during the + memory test until the Reset. You need to set the delay + at boot to 60 seconds with the configuration CPX + (oups can't work with the Firebee boot menu). +!end_verbatim + + +!subnode Load TOS with dBUG + +For load firetos.hex (the TOS) with an host TFTP server with dBUG cmds : + +The 1st time, set TFTP vars (for example) : + +!begin_itemize +!item set server 192.168.1.1 (host IP server) +!item set client 192.168.1.2 (FIREBEE IP) +!item set filename /home/firetos_firebee.hex +!item set filetype S-Record +!item set baud 19200 +!end_itemize + +After just use : + +!begin_itemize +!item dn -o 20000000 +!item fl w E0400000 400000 f0000 +!item go E0400000 (or go) +!end_itemize + +Or if jou want preserve flash : + +!begin_itemize +!item dn -o 20000000 +!item go 4000000 (or go) +!end_itemize + +The TOS can start from anywere (-o is for add an offset and put the +S-record file in SDRAM), the boot part copy and apply patches to +the original TOS and uncompress the driver part to the target address +(0x00E00000). If the source address is equal to the target address +(0x00E00000), the boot has a jump to 0xE0400000. + +WARNING : The ethernet part of dBUG need a clock on the PHY, so if the +FLASH above 0xE7000000 is destroyed ethernet can't work! + +NOTE : If the BAS is installed, it's possible to use ethernet without +dBUG with some limitations (3 flash parameters used) : + +!begin_itemize +!item You can change only the 3 lastest bytes of the MAC address with +the CPX (stop/misc menu), begin is 00:CF:54 +!item You can change board IP and host IP with the CPX (stop/misc menu). +!item The netmask is automatic if the choice is CPX setting. +!item The default gateway is 0.0.0.0. +!item The default path/filename for TFTP is /home/firebee.hex. +!item If the board IP address is at 0.0.0.0 or 255.255.255.255 dBUG +setting are used for board IP / gateway / netmask / path/filename. +!item If the host IP address is at 0.0.0.0 or 255.255.255.255 dBUG +setting are used for host IP. +!item If the 3 last bytes of MAC address are 00:00:00 or FF:FF:FF dBUG +setting are used. +!end_itemize + + +!subnode DBUG task + +This DBUG task use the highspeed serial port, this is the list of CF68KLIB, +LWIP and FreeRTOS commands : + +!begin_verbatim + Command Description Syntax + cb Clear Breakpoint cb + db Define Breakpoint db <-c|t value> <-r addr..> <-i> <-m> + dm Display Memory dm begin + dis Disassemble dis + dr Display Registers CF68KLIB dr + go Execute, Insert Breakpt go + lb List Breakpoints lb + pm Patch Memory pm addr + qt Query Tasks qt + st Single Step (after db) st + cat Concatenate File(s) cat file(s) + chdir Change Directory chdir dir + chmod Change Attibutes chmod filename attributes + cp Copy File cp source dest + ls List Directory ls + mkdir Make Directory mkdir dir + mv Rename File mv source dest + rm Remove File rm file + rmdir Remove Directory rmdir dir + arp Address Resol. Protocol arp <-a> +ifconfig Interface Configuration ifconfig <-a> ... + ping Ping ping <-n echos> <-w delay> host + netstat Network Stats netstat + cache Cache cache on/off + debug Debug CF68KLIB debug on/off + inter Interrupts CF68KLIB inter + reset System Reset reset + trap Traps CF68KLIB trap on/off + help Help help +!end_verbatim + +Excepted debug commands, it's also possible to use these commands with Telnet. +You can set the baudrate of the highspeed serial port with the CPX. + +Usage example : + +!begin_verbatim +> qt +Name TID Prio Status Sys/User Stack # +------------------------------------------------------------ +ROOT F1006C 0A Ready 3987/NU/4096 0 +IDLE F141D0 00 Ready 4067/NU/4096 1 +lwIP0 F18510 1E Blocked 3977/NU/4096 2 +lwIP1 F1C750 1E Suspend 4003/NU/4096 3 +TELNETd F208B4 0F Suspend 3998/NU/4096 4 +FTPd F26EDC 0A Blocked 4000/NU/4096 5 +TFTPd F2B040 0A Suspend 3944/NU/4096 6 +HTTPd F2F1A4 0A Suspend 4024/NU/4096 7 +TOS F33308 05 Ready 4073/NU/4096 8 +DBUG F3746C 14 Ready 3004/NU/4096 9 +HMES F3BCF0 0A Ready 4004/NU/4096 10 +HT01 F3FF58 09 Suspend 3981/NU/4096 11 +HT02 F440BC 09 Suspend 3981/NU/4096 12 +HT03 F48220 09 Suspend 3981/NU/4096 13 +HT04 F4C384 09 Suspend 3981/NU/4096 14 +HT05 F504E8 09 Suspend 3981/NU/4096 15 +USBT F54D08 06 Ready 4035/NU/4096 16 +USBd F591D0 1F Suspend 3003/NU/4096 17 +=> qt command displays FreeRTOS tasks, the TOS himself is a task. + Only the TOS use the CF68KLIB. + +> inter +int +NATIVE/RTOS CF68KLIB/TOS LEV PRI INTERRUPTS +OFF OFF 1 0 Edge port 1 Int(65) +OFF OFF 2 0 Edge port 2 Int(66) +OFF OFF 3 0 Edge port 3 Int(67) +OFF OFF 4 0 Edge port 4 Int(68) +OFF OFF 5 0 Edge port 5 Int(69) +OFF OFF 6 0 Edge port 6 Int(70) +OFF OFF 7 0 Edge port 7 Int(71) +OFF OFF 0 0 DSPI Int(89) +OFF OFF 0 0 DSPI Int(90) +OFF OFF 0 0 DSPI Int(91) +OFF OFF 0 0 DSPI Int(92) +OFF OFF 0 0 DSPI Int(93) +OFF OFF 0 0 DSPI Int(94) +OFF OFF 0 0 DSPI Int(95) +OFF OFF 0 0 PSC3 Int(96) +OFF OFF 0 0 PSC2 Int(97) +OFF OFF 0 0 PSC1 Int(98) +OFF ON 6 5 PSC0 Int(99) +OFF OFF 0 0 Comm Timer Int(100) +OFF OFF 0 0 SEC Int(101) +OFF OFF 0 0 FEC1 Int(102) +ON ON 5 1 FEC0 Int(103) +OFF OFF 0 0 I2C Int(104) +OFF OFF 0 0 PCIARB Int(105) +OFF OFF 0 0 CBPCI Int(106) +OFF OFF 0 0 XLBPCI Int(107) +ON ON 7 7 XLBARB Int(111) +ON ON 6 0 DMA Int(112) +OFF OFF 0 0 CAN0 ERROR Int(113) +OFF OFF 0 0 CAN0 BUSOFF Int(114) +OFF OFF 0 0 CAN0 MBOR Int(115) +OFF OFF 0 0 SLT1 Int(117) +ON ON 6 7 SLT0 Int(118) +OFF ON 6 4 CAN1 ERROR Int(119) +OFF ON 6 4 CAN1 BUSOFF Int(120) +OFF ON 6 4 CAN1 MBOR Int(121) +OFF OFF 0 0 GPT3 Int(123) +OFF OFF 0 0 GPT2 Int(124) +OFF OFF 0 0 GPT1 Int(125) +OFF OFF 0 0 GPT0 Int(126) +=> By default TOS interrupts not works without CF68KLIB + (excepted the TOS himself), so some interrupts are disabled + out of the TOS task. +!end_verbatim + +'db' install a breakpoint, without address db install a breakpoint +at the beginning of the program during Pexec (BDOS feature). + + +!subnode Firebee MMU mapping + +!begin_verbatim + 00000000 - 00CF0000 : STRAM 13 MB (cache in writethrough) + 00D00000 - 00DFFFFF : Mirror FPGA 1MB VIDEO RAM (cache in writethrough) + 00E00000 - 00EFFFFF : TOS404 1 MB (write protected) + 00F00000 - 00F01FFF : Mirror FPGA - ATARI IDE (8K) + 00F02000 - 00F0FFFF : invalid (bus error) + 00F10000 - 00F9FFFF : USB descriptors memory, DMA from PCI (no cache) + 00FA0000 - 00FBFFFF : invalid (bus error) + 00FC0000 - 00FEFFFF : TOS404 192 KB (write protected) + 00FF0000 - 00FF7FFF : invalid (bus error) + 00FF8000 - 00FFFFFF : Mirror FPGA - ATARI I/O (32K - no cache) + 01000000 - 1FFFFFFF : SDRAM 496 MB (cache in copyback) + 20000000 - 3FFFFFFF : invalid (bus error) + 40000000 - 7FFFFFFF : FPGA FBCS4 VIDEO RAM + 80000000 - BFFFFFFF : PCI MEM (1024 MB) + C0000000 - CFFFFFFF : invalid (bus error) + D0000000 - DFFFFFFF : PCI I/O (256 MB) + E0000000 - E07FFFFF : FBCS0 flash 8 MB (flash parameters at 0xE04F0000) + E0800000 - EFFFFFFF : invalid (bus error) + F0000000 - F7FFFFFF : FPGA FBCS2 ACP I/O + F8000000 - FBFFFFFF : FPGA FBCS3 SRAM + FC000000 - FEFFFFFF : invalid (bus error) + FF000000 - FF01FFFF : MBAR coldfire (no cache) + FF020000 - FF03FFFF : invalid (bus error) + FF040000 - FF04FFFF : MMU_BASE coldfire (no cache) + FF050000 - FFEFFFFF : invalid (bus error) + FFF00000 - FFFFFFFF : FPGA FBCS1 - ATARI IDE - ATARI I/O (1MB - no cache) +!end_verbatim + + +!subnode LWIP socket cookie 'SOCK' + +!begin_verbatim +typedef struct socket_cookie +{ + long version; /* 0x0101 for example */ + long magic; /* 'SOCK' */ + int (*socket)(int domain, int type, int protocol); + int (*bind)(int s, struct sockaddr *name, socklen_t namelen); + int (*listen)(int s, int backlog); + int (*accept)(int s, struct sockaddr *addr, socklen_t *addrlen); + int (*connect)(int s, struct sockaddr *name, socklen_t namelen); + int (*write)(int s, void *dataptr, int size); + int (*send)(int s, void *dataptr, int size, unsigned int flags); + int (*sendto)(int s, void *dataptr, int size, unsigned int flags, struct sockaddr *to, socklen_t tolen); + int (*read)(int s, void *mem, int len); + int (*recv)(int s, void *mem, int len, unsigned int flags); + int (*recvfrom)(int s, void *mem, int len, unsigned int flags, struct sockaddr *from, socklen_t *fromlen); + int (*shutdown)(int s, int how); + int (*close)(int s); + int (*getsockname)(int s, struct sockaddr *name, socklen_t *namelen); + int (*getpeername)(int s, struct sockaddr *name, socklen_t *namelen); + int (*getsockopt)(int s, int level, int optname, void *optval, socklen_t *optlen); + int (*setsockopt)(int s, int level, int optname, const void *optval, socklen_t optlen); + int (*select)(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout); + int (*ioctlsocket)(int s, long cmd, void *argp); + struct hostent *(*gethostbyname)(const char *name); + int (*geterrno)(void); +} SOCKET_COOKIE; +!end_verbatim + + +!node Contacts + +!begin_verbatim +Flash Tool, Configuration, and system : +Didier MEQUIGNON +aniplay@wanadoo.fr +!end_verbatim + +!end_document diff --git a/sources/firehyp/img/cpx1.img b/sources/firehyp/img/cpx1.img new file mode 100644 index 0000000..f94fcf1 Binary files /dev/null and b/sources/firehyp/img/cpx1.img differ diff --git a/sources/firehyp/img/cpx2.img b/sources/firehyp/img/cpx2.img new file mode 100644 index 0000000..5d9ee35 Binary files /dev/null and b/sources/firehyp/img/cpx2.img differ diff --git a/sources/firehyp/img/cpx3.img b/sources/firehyp/img/cpx3.img new file mode 100644 index 0000000..f34bd5e Binary files /dev/null and b/sources/firehyp/img/cpx3.img differ diff --git a/sources/firehyp/img/cpx4.img b/sources/firehyp/img/cpx4.img new file mode 100644 index 0000000..391b399 Binary files /dev/null and b/sources/firehyp/img/cpx4.img differ diff --git a/sources/firehyp/img/cpx5.img b/sources/firehyp/img/cpx5.img new file mode 100644 index 0000000..2f61677 Binary files /dev/null and b/sources/firehyp/img/cpx5.img differ diff --git a/sources/firehyp/img/cpx6.img b/sources/firehyp/img/cpx6.img new file mode 100644 index 0000000..f2ff870 Binary files /dev/null and b/sources/firehyp/img/cpx6.img differ diff --git a/sources/firehyp/img/cpx7.img b/sources/firehyp/img/cpx7.img new file mode 100644 index 0000000..a0ee48d Binary files /dev/null and b/sources/firehyp/img/cpx7.img differ diff --git a/sources/firehyp/img/cpx7_acp.img b/sources/firehyp/img/cpx7_acp.img new file mode 100644 index 0000000..202b165 Binary files /dev/null and b/sources/firehyp/img/cpx7_acp.img differ diff --git a/sources/firehyp/img/firebee.img b/sources/firehyp/img/firebee.img new file mode 100644 index 0000000..503b504 Binary files /dev/null and b/sources/firehyp/img/firebee.img differ diff --git a/sources/firehyp/img/flash1.img b/sources/firehyp/img/flash1.img new file mode 100644 index 0000000..76be14e Binary files /dev/null and b/sources/firehyp/img/flash1.img differ diff --git a/sources/firehyp/img/schema.img b/sources/firehyp/img/schema.img new file mode 100644 index 0000000..582a993 Binary files /dev/null and b/sources/firehyp/img/schema.img differ diff --git a/sources/firehyp/img/v4e.img b/sources/firehyp/img/v4e.img new file mode 100644 index 0000000..ca29707 Binary files /dev/null and b/sources/firehyp/img/v4e.img differ diff --git a/sources/z-tools.tar b/sources/z-tools.tar deleted file mode 100644 index 0cfa347..0000000 Binary files a/sources/z-tools.tar and /dev/null differ diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/copyright b/sources/z-tools/tags/zweather-1.2/zcodeclib/copyright new file mode 100644 index 0000000..ed55bd4 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/copyright @@ -0,0 +1,503 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/exemple/8.gif b/sources/z-tools/tags/zweather-1.2/zcodeclib/exemple/8.gif new file mode 100644 index 0000000..bb06206 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zcodeclib/exemple/8.gif differ diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/exemple/exemple.app b/sources/z-tools/tags/zweather-1.2/zcodeclib/exemple/exemple.app new file mode 100644 index 0000000..73e4e7c Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zcodeclib/exemple/exemple.app differ diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/exemple/main.c b/sources/z-tools/tags/zweather-1.2/zcodeclib/exemple/main.c new file mode 100644 index 0000000..519205e --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/exemple/main.c @@ -0,0 +1,89 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +int main( int argc, char *argv[]) +{ + IMAGE *test_img = NULL; + MFDB *resize = NULL, screen = {0}; + int16 xy[8]; + + /* We load the wanted codecs but if we want to + load the entire codecs's pack, we can do "codecs_init( "all"); */ + if( !codecs_init( "gif.ldg")) + Cconws("can't init the codec \n\r"); + + if ( argc > 1) + { /* we load the dragged picture, we put - 1 to both w and h options because we don't want zoom */ + if( ! (test_img = load_img( argv[argc - 1], -1, -1, 0))) + { + Cconws("can't load image \n\r"); + codecs_quit(); + return 0; + } + } + else + { + Cconws("Drag and Drop a gif image\n\r"); + codecs_quit(); + return 0; + } + + xy[0] = 0; + xy[1] = 0; + xy[2] = test_img->image[0].fd_w - 1; + xy[3] = test_img->image[0].fd_h - 1; + xy[4] = 20; + xy[5] = 20; + xy[6] = xy[4] + xy[2]; + xy[7] = xy[5] + xy[3]; + + if ( test_img->image[0].fd_nplanes == 1) + { + int16 color[2] = { 0, 1}; + + vrt_cpyfm( vdi_handle, MD_REPLACE, xy, &test_img->image[0], &screen, color); + } + else + vro_cpyfm( vdi_handle, S_ONLY, xy, &test_img->image[0], &screen); + + if( !( resize = pic_resize( &test_img->image[0],64, 64, 1))) + { + Cconws("can't resize image \n\r"); + delete_img( test_img); + codecs_quit(); + return 0; + } + + xy[0] = 0; + xy[1] = 0; + xy[2] = resize->fd_w - 1; + xy[3] = resize->fd_h - 1; + xy[4] = 20 + test_img->image[0].fd_w - 1; + xy[5] = 20; + xy[6] = xy[4] + xy[2]; + xy[7] = xy[5] + xy[3]; + + /* draw the image */ + if ( resize->fd_nplanes == 1) + { + int16 color[2] = { 0, 1}; + + vrt_cpyfm( vdi_handle, MD_REPLACE, xy, resize, &screen, color); + } + else + vro_cpyfm( vdi_handle, S_ONLY, xy, resize, &screen); + + + delete_mfdb( resize, 1); + delete_img( test_img); + codecs_quit(); + return 0; +} diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/exemple/makefile b/sources/z-tools/tags/zweather-1.2/zcodeclib/exemple/makefile new file mode 100644 index 0000000..68e5ca7 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/exemple/makefile @@ -0,0 +1,41 @@ +ifeq ($(CROSS),yes) +AS = m68k-atari-mint-as +CC = m68k-atari-mint-gcc +STACK = m68k-atari-mint-stack +INCLUDE_PATH = /home/zorro/cross-tools/include +LIB_PATH = /home/zorro/cross-tools/lib +else +AS = as +CC = gcc +STACK = stack +INCLUDE_PATH = /usr/GEM/include +LIB_PATH = /usr/GEM/lib +endif + +STACKSIZE = 128k +COMPRESS = upx +OPTIMISATION = -O2 -fomit-frame-pointer -finline-functions +CPU = -m68020-60 +LIB = -lzcodec -lgem -lldg + +CFLAGS = $(CPU) $(OPTIMISATION) -Wall -I$(INCLUDE_PATH) + +OBJ = main.o + +PROGRAM = exemple.app + + +all: $(PROGRAM) stack #compress + +$(PROGRAM): $(OBJ) + $(CC) -o$@ $(OBJ) -Xlinker -s -L$(LIB_PATH) $(LIB) + +stack: + $(STACK) -S $(STACKSIZE) $(PROGRAM) + +compress: + $(COMPRESS) $(PROGRAM) + +clean: + rm -f *.o + diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/include/types2b.h b/sources/z-tools/tags/zweather-1.2/zcodeclib/include/types2b.h new file mode 100644 index 0000000..2343950 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/include/types2b.h @@ -0,0 +1,43 @@ +#ifndef __2B_UNIVERSAL_TYPES__ +#define __2B_UNIVERSAL_TYPES__ + +typedef signed char int8; +typedef unsigned char uint8; +typedef signed long int32; +typedef unsigned long uint32; +typedef int32 fix31; + +#ifdef __GNUC__ + typedef signed short int16; + typedef unsigned short uint16; + #define __2B_HAS64_SUPPORT /* Compiler supports 64 Bit Integers */ + typedef signed long long int64; + typedef unsigned long long uint64; +#else /* Compiler doesn't support 64 Bit Integers */ + typedef signed int int16; + typedef unsigned int uint16; + + typedef struct + { + int32 hi; + uint32 lo; + } int64; + + typedef struct + { + int32 hi; + uint32 lo; + } loff_t; + + typedef struct + { + uint32 hi; + uint32 lo; + } uint64; +#endif + + +typedef int32 boolean; + + +#endif /* __2B_UNIVERSAL_TYPES__ */ diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/include/zcodec.h b/sources/z-tools/tags/zweather-1.2/zcodeclib/include/zcodec.h new file mode 100644 index 0000000..0198e4c --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/include/zcodec.h @@ -0,0 +1,29 @@ +#ifndef __ZCODECLIB_ZCODEC_H__ +#define __ZCODECLIB_ZCODEC_H__ + +#include + +struct LDG; +struct MFDB; + +typedef struct +{ + int16 page; /* Number of page/image in the file */ + uint16 *delay; /* Animation delay in millise. between each frame */ + MFDB *image; /* The Image itself */ +}IMAGE; + +extern int16 planar, vdi_handle, nplanes, vdi_work_in[10], vdi_work_out[57]; +extern LDG *ldg_mem; + +extern int16 codecs_init( char *codec_name); +extern void codecs_quit( void); +extern IMAGE *load_img( const char *file, int16 w, int16 h, int16 keep_ratio); +extern void delete_img( IMAGE *img); +extern MFDB *pic_resize( MFDB *in, int16 w, int16 h, int16 keep_ratio); +extern void delete_mfdb( MFDB *bm, int16 nbr); + +#define shared_malloc( s) _ldg_malloc( s, ldg_global[2]); +#define shared_free( s) _ldg_free( s, ldg_global[2]); + +#endif diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/Makefile b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/Makefile new file mode 100644 index 0000000..4195124 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/Makefile @@ -0,0 +1,28 @@ +ifeq ($(CROSS),yes) +AS = m68k-atari-mint-as +AR = m68k-atari-mint-ar +CC = m68k-atari-mint-gcc +STACK = m68k-atari-mint-stack +else +AS = as +CC = gcc +STACK = stack +endif + +OPTIMISATION = -O2 -fomit-frame-pointer +CPU = -m68020-60 + +CFLAGS = $(CPU) $(OPTIMISATION) -Wall -I../include -I/usr/local/include + +VDI_OBJ = zvdi/p2c.o zvdi/color.o zvdi/dither.o zvdi/raster.o zvdi/raresize.o zvdi/vdi.o + +OBJ = $(VDI_OBJ) img.o resize.o codecs.o mfdb.o load_img.o ztext.o mem.o + +TARGET = ../lib/m68020-60/libzcodec.a + +$(TARGET): $(OBJ) + rm -f $@ + $(AR) cru $@ $^ + +clean: + rm -f *.o zvdi/*.o *.O zvdi/*.O *~ $(TARGET) diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/codecs.c b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/codecs.c new file mode 100644 index 0000000..f8e4425 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/codecs.c @@ -0,0 +1,146 @@ +#include "general.h" +#include "ztext.h" +#ifdef __PUREC__ +#include "zvdi\vdi.h" +#else +#include "zvdi/vdi.h" +#endif + + +/* Prototype */ +int16 plugins_init( void); +void plugins_quit( void); + +/* LDG function */ +void CDECL( *codec_init)( void) = NULL; + +static int16 vdi_initialised = 0; +static int16 mem_initialised = 0; + +/* Global variable */ +int16 plugins_nbr = 0; +LDG *codecs[100]; + + +/*==================================================================================* + * void plugins_quit: * + * unload all the codec from memory. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void codecs_quit( void) +{ + int16 i; + + for( i = 0; i < plugins_nbr; i++) + { + ldg_close( codecs[i], ldg_global); + } + + mem_quit(); +} + + +/*==================================================================================* + * void plugins_init: * + * load codec(s) to memory. * + *----------------------------------------------------------------------------------* + * input: * + * codec_name: the name of the codec to load, if this one is "all", we load * + * the codec. * + *----------------------------------------------------------------------------------* + * returns: * + * 0 if error. * + *==================================================================================*/ +int16 codecs_init( char *codec_name) +{ + char *env_ldg, current_dir[1024], plugin_dir[1024]; + DIR *dir; + LDG_INFOS *cook; + struct dirent *de; + int16 len; + char extention[4]; + + shel_envrn( &env_ldg, "LDGPATH="); + + if( ldg_cookie( LDG_COOKIE, ( int32*)&cook)) + strcpy( plugin_dir, cook->path); + else if( env_ldg) + strcpy( plugin_dir, env_ldg); + else + strcpy( plugin_dir, "C:\\gemsys\\ldg\\"); + + len = ( int16)strlen( plugin_dir); + + if( plugin_dir[len-1] != '\\') + strcat( plugin_dir, "\\"); + + strcat( plugin_dir, "codecs"); + + current_dir[0] = 'A' + Dgetdrv(); + current_dir[1] = ':'; + Dgetpath( current_dir + 2, 0); + + if( vdi_initialised == 0) + if( !( vdi_initialised = vdi_init())) + return( 0); + + if( mem_initialised == 0) + if( !( mem_initialised = mem_init())) + return( 0); + + if ( chdir( plugin_dir) != 0) + { + mem_quit(); + return( 0); + } + + if( strcmp ( codec_name, "all") == 0) + { + if (( dir = opendir( ".")) != NULL) + { + while(( de = readdir( dir)) != NULL) + { + if (( strcmp( de->d_name, ".") == 0) || ( strcmp( de->d_name, "..") == 0)) + continue; + + strcpy ( extention, de->d_name + strlen( de->d_name) - 3); + str2lower( extention); + + if( strcmp ( extention, "ldg") == 0) + { + if ( ( codecs[plugins_nbr] = ldg_open( de->d_name, ldg_global))) + { + if ( ( codec_init = ldg_find( "plugin_init", codecs[plugins_nbr]))) + { + codec_init(); + plugins_nbr++; + } + else + ldg_close( codecs[plugins_nbr], ldg_global); + } + } + } + closedir( dir); + } + } + else if ( ( codecs[plugins_nbr] = ldg_open( codec_name, ldg_global))) + { + if ( ( codec_init = ldg_find( "plugin_init", codecs[plugins_nbr]))) + { + codec_init(); + plugins_nbr++; + } + else + ldg_close( codecs[plugins_nbr], ldg_global); + } + + chdir( current_dir); + + return plugins_nbr; +} + diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/codecs.h b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/codecs.h new file mode 100644 index 0000000..847b199 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/codecs.h @@ -0,0 +1,2 @@ +extern LDG *codecs[100]; +extern int16 plugins_nbr; diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/general.h b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/general.h new file mode 100644 index 0000000..dd71dfb --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/general.h @@ -0,0 +1,48 @@ +/* + * zcodeclib. + * Copyright (c) 2001-2005 Zorro ( zorro270@yahoo.fr) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#ifdef __PUREC__ +#include +#elif defined (__GNUC__) +#include +#include +#include +#include +#endif +#include +#include +#include +#include +#include "mem.h" + +#define shared_malloc( s) _ldg_malloc( s, ldg_global[2]); +#define shared_free( s) _ldg_free( s, ldg_global[2]); + +#ifndef MIN +#define MAX(a,b) ((a)>(b)?(a):(b)) +#define MIN(a,b) ((a)<(b)?(a):(b)) +#endif + +#ifndef TRUE +# define TRUE 1 +# define FALSE 0 +#endif + diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/img.c b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/img.c new file mode 100644 index 0000000..a87f237 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/img.c @@ -0,0 +1,53 @@ +#include "general.h" +#include "mfdb.h" +#include "load_img.h" + +IMAGE *init_img( int16 page, int16 w, int16 h, int16 planes) +{ + IMAGE *data; + int16 i; + + data = ( IMAGE *)shared_malloc( sizeof( IMAGE)); + + if( data == NULL) + return NULL; + + data->page = page; + data->delay = NULL; + + data->image = ( MFDB *)shared_malloc( sizeof( MFDB) * page); + + if( data->image == NULL) + { + shared_free( data); + return NULL; + } + + for ( i = 0 ; i < page ; i++) + { + if ( !init_mfdb( &data->image[i], w, h, planes)) + { + if( i) + delete_mfdb( data->image, i + 1); + + shared_free( data->image); + shared_free( data); + return NULL; + } + } + + return data; +} + +void delete_img( IMAGE *data) +{ + if( data == NULL) + return; + + delete_mfdb( data->image, data->page); + + if( data->delay) + shared_free( data->delay); + + shared_free( data); +} diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/img.h b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/img.h new file mode 100644 index 0000000..dad47b0 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/img.h @@ -0,0 +1,3 @@ +extern IMAGE *init_img( int16 page, int16 w, int16 h, int16 planes); +extern void delete_img( IMAGE *data); + diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/load_img.c b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/load_img.c new file mode 100644 index 0000000..ed22ff4 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/load_img.c @@ -0,0 +1,265 @@ +#include "general.h" +#include "codecs.h" +#include "load_img.h" +#include "img.h" +#include "ztext.h" +#ifdef __PUREC__ +#include "zvdi\color.h" +#include "zvdi\raster.h" +#include "zvdi\vdi.h" +#else +#include "zvdi/color.h" +#include "zvdi/raster.h" +#include "zvdi/vdi.h" +#endif + +boolean decoder_init_done = FALSE; + +void ( *raster) ( DECDATA, void *dst); +void ( *raster_cmap) ( DECDATA, void *); +void ( *raster_true) ( DECDATA, void *); +void ( *cnvpal_color) ( IMGINFO, DECDATA); +void ( *raster_gray) ( DECDATA, void *); +void CDECL ( *decoder_quit) ( IMGINFO); +boolean CDECL ( *decoder_init) ( const char *, IMGINFO); +boolean CDECL ( *decoder_read) ( IMGINFO, uint8 *); + + +static IMAGE *setup ( IMGINFO info, DECDATA data, int16 w, int16 h, int16 keep_ratio) +{ + int16 n_planes = ( ( info->planes == 1 && info->components == 1) ? 1: nplanes); + uint16 display_w, display_h; + int16 wanted_w = ( w > 0 ? w : info->width), wanted_h = ( h > 0 ? h : info->height); + float precise_x, precise_y; + size_t src_line_size; + IMAGE *image; + + /* the image size is different that the original and we want to keep the aspect ratio */ + if( keep_ratio && ( info->width != wanted_w) && ( info->height != wanted_h)) + { + float factor = MAX( ( float)info->height / ( float)wanted_h, ( float)info->width / ( float)wanted_w); + precise_x = ( float)info->width / factor; + precise_y = ( float)info->height / factor; + + display_w = ( ( uint16)precise_x > 0 ? ( uint16)precise_x : 16); + display_h = ( ( uint16)precise_y > 0 ? ( uint16)precise_y : 16); + data->IncXfx = ((( uint32)info->width << 16) + ( display_w >> 1)) / display_w; + data->IncYfx = ((( uint32)info->height << 16) + ( display_h >> 1)) / display_h; + } + else if(( info->width != wanted_w) && ( info->height != wanted_h)) + { + float x_factor = ( float)info->width / ( float)wanted_w; + float y_factor = ( float)info->height / ( float)wanted_h; + precise_x = ( float)info->width / x_factor; + precise_y = ( float)info->height / y_factor; + + display_w = ( ( uint16)precise_x > 0 ? ( uint16)precise_x : 16); + display_h = ( ( uint16)precise_y > 0 ? ( uint16)precise_y : 16); + data->IncXfx = ((( uint32)info->width << 16) + ( display_w >> 1)) / display_w; + data->IncYfx = ((( uint32)info->height << 16) + ( display_h >> 1)) / display_h; + } + else + { + display_w = info->width; + display_h = info->height; + data->IncXfx = 0x10000uL; + data->IncYfx = 0x10000uL; + } + + image = init_img( info->page, display_w, display_h, n_planes); + + if( image == NULL) + return NULL; + +/* we assume that the pixel size is minimum 8 bits because some GNU libraries return 1 and 4 bits format like 8 bits ones. + We add also a little more memory for avoid buffer overflow for plugin badly coded. */ + src_line_size = ( info->width + 64) * info->components; + + data->RowBuf = ( uint8*)shared_malloc( src_line_size); + + if( !data->RowBuf) + return NULL; + + if(( info->planes == 1 && info->components == 1) || nplanes > 8) + data->DthBuf = NULL; + else + { + size_t size = ( display_w + 15) * 3; + + data->DthBuf = shared_malloc( size); + + if( data->DthBuf == NULL) + return NULL; + + memset( data->DthBuf, 0, size); + } + + data->DthWidth = display_w; + data->PixMask = ( 1 << info->planes) - 1; + data->LnSize = image->image[0].fd_wdwidth * n_planes; + + if ( info->planes == 1 && info->components == 1) + { + cnvpal_mono( info, data); + raster = raster_mono; + } + else + { + if ( info->indexed_color) + { + ( *cnvpal_color)( info, data); + raster = raster_cmap; + } + else + raster = ( info->components >= 3 ? raster_true : raster_gray); + } + + image->delay = NULL; + + return image; +} + +static inline void read_img ( IMAGE *img, IMGINFO info, DECDATA data) +{ + uint16 *dst; + int16 y_dst, i, y, img_h = info->height; + int32 line_size = data->LnSize; + uint8 *buf = data->RowBuf; + + for ( i = 0; i < img->page; i++) + { + uint32 scale = ( data->IncYfx + 1) >> 1; + y_dst = img->image[0].fd_h; + dst = img->image[i].fd_addr; + + if( info->orientation == DOWN_TO_UP) + { + dst += data->LnSize * ( y_dst - 1); + line_size = -data->LnSize; + } + + info->page_wanted = i; + + for( y = 1; y <= img_h; y++) + { + if( !decoder_read( info, buf)) + return; + + while(( scale >> 16) < y) + { + ( *raster)( data, dst); + dst += line_size; + scale += data->IncYfx; + if (!--y_dst) break; + } + } + + if( img->delay != NULL ) + { + img->delay[i] = info->delay; + } + } +} + + + +void quit_img( IMGINFO info, DECDATA data) +{ + if( decoder_init_done == TRUE) + decoder_quit( info); + + if( data->DthBuf) + shared_free( data->DthBuf); + + if( data->RowBuf) + shared_free( data->RowBuf); + + shared_free( data); + shared_free( info); + + decoder_init_done = FALSE; +} + + +boolean get_pic_info( const char *file, IMGINFO info) +{ + int16 i, j, c = 0; + char extention[3+1], plugin[3]; + + strcpy ( extention, file + strlen( file) - 3); + str2upper( extention); + + /* We check if a plug-ins can do the job */ + for( i = 0; i < plugins_nbr; i++, c = 0) + { + for( j = 0; j < codecs[i]->user_ext; j++) + { + plugin[0] = codecs[i]->infos[c++]; + plugin[1] = codecs[i]->infos[c++]; + plugin[2] = codecs[i]->infos[c++]; + + if( strncmp ( extention, plugin, 3) == 0) + { + if ( !( decoder_init = ldg_find( "reader_init", codecs[i])) + || !( decoder_read = ldg_find( "reader_read", codecs[i])) + || !( decoder_quit = ldg_find( "reader_quit", codecs[i]))) + { + return FALSE; + } + + return decoder_init( file, info); + } + } + } + + /* I wish that it will never append ! */ + return FALSE; +} + +IMAGE *load_img( const char *file, int16 w, int16 h, int16 keep_ratio) +{ + IMGINFO info; + DECDATA data; + IMAGE *img; + + /* One codec or more must be present */ + if( codecs[0] == NULL) + return( NULL); + + info = ( img_info *)shared_malloc( sizeof( img_info)); + + if( !info) + return( NULL); + + data = ( dec_data *)shared_malloc( sizeof( dec_data)); + + if( !data) + { + shared_free( info); + return ( NULL); + } + + info->background_color = 0xFFFFFF; + info->thumbnail = FALSE; + + if (( decoder_init_done = get_pic_info( file, info)) == FALSE) + { + shared_free( data); + shared_free( info); + return ( NULL); + } + + img = setup ( info, data, w, h, keep_ratio); + if( img == NULL) + { + delete_img( img); + quit_img( info, data); + return ( NULL); + } + + read_img ( img, info, data); + + quit_img( info, data); + + return ( img); +} diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/load_img.h b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/load_img.h new file mode 100644 index 0000000..b2b9b38 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/load_img.h @@ -0,0 +1,92 @@ +#define UP_TO_DOWN 0 +#define DOWN_TO_UP 1 + + +typedef struct +{ + uint8 red; + uint8 green; + uint8 blue; +} COLOR_MAP; + +typedef struct _img_info *IMGINFO; + +typedef struct _img_info +{ + /* Data returned by the decoder Picture's initialisation */ + uint16 width; /* Picture width */ + uint16 height; /* Picture Height */ + uint16 components; /* Picture components */ + uint16 planes; /* Picture bits by pixel */ + uint32 colors; /* Picture colors number */ + int16 orientation; /* picture orientation: UP_TO_DOWN or DONW_TO_UP ( ex: TGA) */ + uint16 page; /* Number of page/image in the file */ + uint16 delay; /* Animation delay in 200th sec. between each frame. */ + uint16 num_comments; /* Lines in the file's comment. ( 0 if none) */ + uint16 max_comments_length; /* The length of the greater line in the comment */ + int16 indexed_color; /* Picture has a palette: 0) No 1) Yes */ + int16 memory_alloc; /* where to do the memory allocation for the reader_read + function buffer, possible values are ST_RAM or TT_RAM */ + COLOR_MAP palette[256]; /* Palette in standard RGB format */ + + + /* data send to the codec */ + uint32 background_color; /* The wanted background's color in hexa */ + int16 thumbnail; /* 1 if true else 0. + Some format have thumbnail inside the picture, if 1, we + want only this thumbnail and not the image itself */ + uint16 page_wanted; /* The wanted page to get for the reader_read() function + The first page is 0 and the last is img_info->page - 1 */ + + + /* The following variable are only for Information Prupose, the zview doesn't + use it for decoding routine but only for the information dialog */ + int8 info[40]; /* Picture's info, for ex: "Gif 87a" */ + int8 compression[5]; /* Compression type, ex: "LZW" */ + uint16 real_width; /* Real picture width( if the thumbnail variable is 1) */ + uint16 real_height; /* Ral picture Height( if the thumbnail variable is 1) */ + + + /* Private data for the plugin */ + void *_priv_ptr; + void *_priv_ptr_more; + void *__priv_ptr_more; + + int32 _priv_var; + int32 _priv_var_more; + +} img_info; + + +typedef struct _dec_data *DECDATA; + +typedef struct _dec_data +{ + uint8 *RowBuf; + void *DthBuf; + uint8 *DstBuf; + uint16 DthWidth; + uint16 PixMask; + int32 LnSize; + uint32 IncXfx; + uint32 IncYfx; + uint32 Pixel[256]; +} dec_data; + + + +typedef struct _img +{ + int16 page; /* Number of page/image in the file */ + uint16 *delay; /* Animation delay in millise. between each frame */ + MFDB *image; /* The Image itself */ +}IMAGE; + +extern void ( *raster) ( DECDATA, void *dst); +extern void ( *raster_cmap) ( DECDATA, void *); +extern void ( *raster_true) ( DECDATA, void *); +extern void ( *cnvpal_color)( IMGINFO, DECDATA); +extern void ( *raster_gray) ( DECDATA, void *); + +extern IMAGE *load_img( const char *file, int16 w, int16 h, int16 keep_ratio); + diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/mem.c b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/mem.c new file mode 100644 index 0000000..9950163 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/mem.c @@ -0,0 +1,55 @@ +#include "general.h" + +/* Prototype */ +void mem_quit( void); +int16 mem_init( void); + +LDG *ldg_mem = NULL; + +/*==================================================================================* + * int16 mem_init: * + * Initialise the memory manager. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * '1' if all is OK else '0' * + *==================================================================================*/ + +int16 mem_init( void) +{ + ldg_mem = ldg_open( "C:\\gemsys\\ldg\\mem.ldg", ldg_global); + + if( !ldg_mem) + ldg_mem = ldg_open( "mem.ldg", ldg_global); + + _ldg_malloc = ldg_find( "ldg_malloc", ldg_mem); + _ldg_free = ldg_find( "ldg_free", ldg_mem); + _ldg_allocmode = ldg_find( "ldg_allocmode", ldg_mem); + + if ( !ldg_mem || !_ldg_malloc || !_ldg_free || !_ldg_allocmode) + return( 0); + + ldg_allocmode( 0L); + + return( 1); +} + + +/*==================================================================================* + * void mem_quit: * + * close the memory manager. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void mem_quit( void) +{ + if( ldg_mem) + ldg_close( ldg_mem, ldg_global); +} + diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/mem.h b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/mem.h new file mode 100644 index 0000000..0fa7630 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/mem.h @@ -0,0 +1,4 @@ +extern int16 mem_init( void); +extern void mem_quit( void); + + diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/mfdb.c b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/mfdb.c new file mode 100644 index 0000000..4479b33 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/mfdb.c @@ -0,0 +1,71 @@ +#include "general.h" + + +/* Prototype */ +int16 init_mfdb( MFDB *bm, int16 width, int16 height, int16 planes); +void delete_mfdb( MFDB *bm, int16 nbr); + + +/*==================================================================================* + * int16 init_mfdb: * + * fit a MFDB with the parameters suppplied. * + *----------------------------------------------------------------------------------* + * input: * + * bm -> The MFDB to fit. * + * width -> Image's width. * + * height -> Image's height. * + * planes -> Screen planes or 1 if the image is monochrome. * + *----------------------------------------------------------------------------------* + * returns: * + * '0' if error or the memory size allocated. * + *==================================================================================*/ +int16 init_mfdb( MFDB *bm, int16 width, int16 height, int16 planes) +{ + uint32 length; + + bm->fd_w = width; + bm->fd_h = height; + bm->fd_wdwidth = ( width >> 4) + (( width % 16) != 0); + bm->fd_stand = 0; + bm->fd_nplanes = planes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + + length = (( (( uint32)bm->fd_wdwidth << 1 ) * ( uint32)bm->fd_nplanes) * ( uint32)bm->fd_h) + 256L; + bm->fd_addr = shared_malloc( length); + + if ( bm->fd_addr) + return ( 1); + else + return ( 0); +} + + +/*==================================================================================* + * int16 delete_mfdb: * + * free the data of MFDB struct. * + *----------------------------------------------------------------------------------* + * input: * + * bm -> pointer to the MFDB to delete. * + * nbr -> The number of MFDB struct. to delete. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void delete_mfdb( MFDB *bm, int16 nbr) +{ + register int16 i; + + if( nbr == 0 || bm == NULL) + return; + + for ( i = 0; i < nbr; i++) + { + if ( bm[i].fd_addr) + shared_free( bm[i].fd_addr); + } + + shared_free( bm); +} + diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/mfdb.h b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/mfdb.h new file mode 100644 index 0000000..e1a27c2 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/mfdb.h @@ -0,0 +1,2 @@ +extern int16 init_mfdb( MFDB *bm, int16 width, int16 height, int16 planes); +extern void delete_mfdb( MFDB *bm, int16 nbr); diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/resize.c b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/resize.c new file mode 100644 index 0000000..850ed9b --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/resize.c @@ -0,0 +1,162 @@ +#include "general.h" +#include "load_img.h" +#include "mfdb.h" +#ifdef __PUREC__ +#include "zvdi\raresize.h" +#include "zvdi\vdi.h" +#include "zvdi\p2c.h" +#else +#include "zvdi/raresize.h" +#include "zvdi/vdi.h" +#include "zvdi/p2c.h" +#endif + + +void ( *resize)( DECDATA, void *dst); +void ( *my_resize)( DECDATA, void *dst); + +extern int32 plane2packed( int32 no_words, int32 plane_length, int16 no_planes, void *src, void *dst); + + +static int16 resize_setup( MFDB *in, MFDB *out, DECDATA data, int16 w, int16 h, int16 keep_ratio) +{ + uint16 display_w, display_h; + float precise_x, precise_y; + + /* the image size is different that the original and we want to keep the aspect ratio */ + if( keep_ratio) + { + float factor = MAX( ( float)in->fd_h / ( float)h, ( float)in->fd_w / ( float)w); + precise_x = ( float)in->fd_w / factor; + precise_y = ( float)in->fd_h / factor; + + display_w = ( ( uint16)precise_x > 0 ? ( uint16)precise_x : 16); + display_h = ( ( uint16)precise_y > 0 ? ( uint16)precise_y : 16); + data->IncXfx = ((( uint32)in->fd_w << 16) + ( display_w >> 1)) / display_w; + data->IncYfx = ((( uint32)in->fd_h << 16) + ( display_h >> 1)) / display_h; + } + else + { + float x_factor = ( float)in->fd_w / ( float)w; + float y_factor = ( float)in->fd_h / ( float)h; + precise_x = ( float)in->fd_w / x_factor; + precise_y = ( float)in->fd_h / y_factor; + + display_w = ( ( uint16)precise_x > 0 ? ( uint16)precise_x : 16); + display_h = ( ( uint16)precise_y > 0 ? ( uint16)precise_y : 16); + data->IncXfx = ((( uint32)in->fd_w << 16) + ( display_w >> 1)) / display_w; + data->IncYfx = ((( uint32)in->fd_h << 16) + ( display_h >> 1)) / display_h; + } + + if ( !init_mfdb( out, display_w, display_h, in->fd_nplanes)) + return ( 0); + + data->RowBuf = in->fd_addr; + + if( planar) + { + data->DstBuf = shared_malloc((( uint32)in->fd_wdwidth << 4 ) + 256uL); + + if( data->DstBuf == NULL) + { + delete_mfdb( out, 1); + return ( 0); + } + } + else + data->DstBuf = NULL; + + data->DthWidth = display_w; + data->LnSize = out->fd_wdwidth * out->fd_nplanes; + + if( out->fd_nplanes == 1) + my_resize = resize_mono; + else + my_resize = resize; + + return( 1); +} + + +static inline void resize_img( MFDB *in, MFDB *out, DECDATA data) +{ + uint16 *dst = out->fd_addr; + int16 y = 0; + int32 in_line_size = (( uint32)in->fd_wdwidth << 1 ) * ( uint32)in->fd_nplanes, + out_line_size = data->LnSize; + uint32 scale = ( data->IncYfx + 1) >> 1; + int16 y_dst = out->fd_h; + + + while ( y < in->fd_h) + { + y++; + + if( planar) + { + if( ( scale >> 16) < y) + planar_to_chunky( data->RowBuf, data->DstBuf, in->fd_w); + } + + while (( scale >> 16) < y) + { + my_resize( data, dst); + dst += out_line_size; + scale += data->IncYfx; + if ( !--y_dst) break; + } + + data->RowBuf += in_line_size; + } +} + + +/*==================================================================================* + * pic_resize: * + * Create a resized MFDB. * + *----------------------------------------------------------------------------------* + * in: The src MFDB. * + * img: The target MFDB. * + *----------------------------------------------------------------------------------* + * returns: '0' if error else 1. * + *==================================================================================*/ + +MFDB *pic_resize( MFDB *in, int16 w, int16 h, int16 keep_ratio) +{ + DECDATA data; + MFDB *out; + + /* 2 planes zoom not available */ + if( in->fd_nplanes == 2) + return NULL; + + out = ( MFDB *)shared_malloc( sizeof( MFDB)); + + if( out == NULL) + return NULL; + + data = ( dec_data *)shared_malloc( sizeof( dec_data)); + + if( !data) + { + shared_free( out); + return NULL; + } + + + if( !resize_setup( in, out, data, w, h, keep_ratio)) + { + shared_free( data); + shared_free( out); + return NULL; + } + + resize_img ( in, out, data); + + if( data->DstBuf) + shared_free( data->DstBuf); + + shared_free( data); + + return( out); +} diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/resize.h b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/resize.h new file mode 100644 index 0000000..7b13bea --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/resize.h @@ -0,0 +1,3 @@ +extern void ( *resize)( DECDATA, void *dst); +extern MFDB *pic_resize( MFDB *in, int16 w, int16 h, int16 keep_ratio); + diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/ztext.c b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/ztext.c new file mode 100644 index 0000000..71f6cd9 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/ztext.c @@ -0,0 +1,78 @@ +#include "general.h" + + +/* Local variable */ +typedef struct +{ + char upper; + char lower; +} CUL; + + +static CUL c[] = { {'A', 'a'}, {'B', 'b'}, {'C', 'c'}, {'D', 'd'}, {'E', 'e'}, {'F', 'f'}, {'G', 'g'}, {'H', 'h'}, + {'I', 'i'}, {'J', 'j'}, {'K', 'k'}, {'L', 'l'}, {'M', 'm'}, {'N', 'n'}, {'O', 'o'}, {'P', 'p'}, + {'Q', 'q'}, {'R', 'r'}, {'S', 's'}, {'T', 't'}, {'U', 'u'}, {'V', 'v'}, {'W', 'w'}, {'X', 'x'}, + {'Y', 'y'}, {'Z', 'z'}, {'š', ''}, {'', '‚'}, {'Ž', '„'}, {0xb6, '…'}, {'', '†'}, {'€', '‡'}, + {'’', '‘'}, {'™', '”'}, {'¥', '¤'}, {0xb7, 0xb0}, {0xb8, 0xb1}, {0xb2, 0xb3}, {0xb5, 0xb4} }; + + +/* Prototype */ +void str2lower(char *str); +void str2upper(char *str); + + +/*==================================================================================* + * str2lower: * + * Transforms all letters in the string to lower case. * + *----------------------------------------------------------------------------------* + * returns: - * + *----------------------------------------------------------------------------------* + * str: Pointer to null terminated string. * + *==================================================================================*/ +void str2lower(char *str) +{ + int16 i, k; + + i = 0; + while (str[i] != '\0') + { + for (k = 0; k < (sizeof(c) / sizeof(CUL)); k++) + { + if (c[k].upper == str[i]) + { + str[i] = c[k].lower; + break; + } + } + i++; + } +} + + +/*==================================================================================* + * str2upper: * + * Transforms all letters in the string to uper case. * + *----------------------------------------------------------------------------------* + * returns: - * + *----------------------------------------------------------------------------------* + * str: Pointer to null terminated string. * + *==================================================================================*/ +void str2upper(char *str) +{ + int16 i, k; + + i = 0; + while (str[i] != '\0') + { + for (k = 0; k < (sizeof(c) / sizeof(CUL)); k++) + { + if (c[k].lower == str[i]) + { + str[i] = c[k].upper; + break; + } + } + i++; + } +} + diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/ztext.h b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/ztext.h new file mode 100644 index 0000000..f046cba --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/ztext.h @@ -0,0 +1,5 @@ +extern void size_to_text( char *txt, float size); +extern void str2lower(char *str); +extern void str2upper(char *str); +extern int16 name_shorter( int16 handle, int16 max_size, char *str); +extern char *zstrncpy( char *dst, const char *src, size_t n); diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/color.c b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/color.c new file mode 100644 index 0000000..c06081e --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/color.c @@ -0,0 +1,200 @@ +#ifdef __PUREC__ +#include "..\general.h" +#include "..\load_img.h" +#else +#include "../general.h" +#include "../load_img.h" +#endif +#include "vdi.h" + +typedef struct +{ + uint8 satur; + uint8 red, green, blue; +} SRGB; + +static SRGB screen_colortab[256]; + + +/* prototype */ +void save_colors(void); +int16 remap_color (int32 value); +uint32 color_lookup ( uint32 rgb, int16 *trans); +void cnvpal_mono ( IMGINFO info, DECDATA data); +void cnvpal_1_2 (IMGINFO info, DECDATA data); +void cnvpal_4_8( IMGINFO info, DECDATA data); +void cnvpal_15( IMGINFO info, DECDATA data); +void cnvpal_high( IMGINFO info, DECDATA data); +void cnvpal_true( IMGINFO info, DECDATA data); + + +static uint8 saturation (uint8 * rgb) +{ + uint8 satr; + + if (rgb[0] >= rgb[1]) + { + if (rgb[1] >= rgb[2]) + satr = rgb[0] - rgb[2]; + else if (rgb[0] > rgb[2]) + satr = rgb[0] - rgb[1]; + else + satr = rgb[2] - rgb[1]; + } + else if (rgb[1] >= rgb[2]) + { + if (rgb[0] >= rgb[2]) + satr = rgb[1] - rgb[2]; + else + satr = rgb[1] - rgb[0]; + } + else + satr = rgb[2] - rgb[0]; + + return satr; +} + + +void save_colors(void) +{ + register int16 i; + int16 colors = 1 << nplanes; + + for( i = 0; i < colors; i++) + { + int16 coltab[3]; + + vq_color( vdi_handle, i, 1, coltab); + + screen_colortab[i].red = ((((int32)coltab[0] << 8 ) - coltab[0]) + 500) / 1000; + screen_colortab[i].green = ((((int32)coltab[1] << 8 ) - coltab[1]) + 500) / 1000; + screen_colortab[i].blue = ((((int32)coltab[2] << 8 ) - coltab[2]) + 500) / 1000; + screen_colortab[i].satur = saturation ( &screen_colortab[i].red); + } +} + +int16 remap_color (int32 value) +{ + int16 red = ((uint8*)&value)[1]; + int16 green = ((uint8*)&value)[2]; + int16 blue = ((uint8*)&value)[3]; + int16 satur = saturation (((uint8*)&value) +1); + + int16 best_fit = 0; + uint16 best_err = 0xFFFFu; + int16 max_color = 1 << nplanes; + + int16 i = 0; + + value = ( value & 0x00FFFFFFl) | (( int32)satur << 24); + + do + { + if ( *( int32*)&screen_colortab[i] == value) + { + /* gotcha! */ + best_fit = i; + break; + } + else + { + uint16 err = + ( red > screen_colortab[i].red ? red - screen_colortab[i].red : screen_colortab[i].red - red) + + (green > screen_colortab[i].green ? green - screen_colortab[i].green : screen_colortab[i].green - green) + + (blue > screen_colortab[i].blue ? blue - screen_colortab[i].blue : screen_colortab[i].blue - blue) + + (satur > screen_colortab[i].satur ? satur - screen_colortab[i].satur : screen_colortab[i].satur - satur); + + if (err <= best_err) + { + best_err = err; + best_fit = i; + } + } + } while (++i < max_color); + + return best_fit; +} + + +uint32 color_lookup ( uint32 rgb, int16 *trans) +{ + uint8 idx = ((rgb & ~0xFFuL) == ~0xFFuL ? rgb : remap_color (rgb)); + return ( (( int32)(trans ? trans[idx] : idx) << 24) | (*(int32*)&screen_colortab[idx] & 0x00FFFFFFuL)); +} + + +void cnvpal_mono ( IMGINFO info, DECDATA data) +{ +/* if ( info->indexed_color) + { + uint32 bgnd, fgnd; + + bgnd = (((( int32)info->palette[0].red <<8) | info->palette[0].green) <<8) | info->palette[0].blue; + fgnd = (((( int32)info->palette[1].red <<8) | info->palette[1].green) <<8) | info->palette[1].blue; + + data->Pixel[0] = remap_color ( bgnd); + data->Pixel[1] = remap_color ( fgnd); + + } + else +*/ { + data->Pixel[0] = G_WHITE; + data->Pixel[1] = G_BLACK; + } +} + + +void cnvpal_1_2 (IMGINFO info, DECDATA data) +{ + register int32 i; + + for( i = 0; i < info->colors; i++) + { + data->Pixel[i] = ( int16)info->palette[i].red * 5 + ( int16)info->palette[i].green * 9 + (( int16)info->palette[i].blue << 1); + } +} + + +void cnvpal_4_8( IMGINFO info, DECDATA data) +{ + register int32 i; + + for( i = 0; i < info->colors; i++) + { + uint32 rgb = (((( int32)info->palette[i].red << 8) | info->palette[i].green) << 8) | info->palette[i].blue; + data->Pixel[i] = rgb | (( int32)pixel_val[remap_color ( rgb)] << 24); + } +} + + +void cnvpal_15( IMGINFO info, DECDATA data) +{ + register int32 i; + + for( i = 0; i < info->colors; i++) + { + data->Pixel[i] = (( int16)( info->palette[i].red & 0xF8) << 7) | (( int16)( info->palette[i].green & 0xF8) << 2) | ( info->palette[i].blue >> 3); + } +} + + +void cnvpal_high( IMGINFO info, DECDATA data) +{ + register int32 i; + + for( i = 0; i < info->colors; i++) + { + data->Pixel[i] = (( int16)( info->palette[i].red & 0xF8) << 8) | (( int16)( info->palette[i].green & 0xFC) << 3) | ( info->palette[i].blue >> 3); + } +} + + +void cnvpal_true ( IMGINFO info, DECDATA data) +{ + register int32 i; + + for( i = 0; i < info->colors; i++) + { + data->Pixel[i] = (((( int32)info->palette[i].red << 8) | info->palette[i].green) << 8) | info->palette[i].blue; + } +} diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/color.h b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/color.h new file mode 100644 index 0000000..9610647 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/color.h @@ -0,0 +1,14 @@ +extern void save_colors( void); +extern int16 remap_color( int32 value); + +extern uint32 color_lookup( uint32 rgb, int16 *trans); + +extern void cnvpal_mono( IMGINFO info, DECDATA data); +extern void cnvpal_1_2( IMGINFO info, DECDATA data); +extern void cnvpal_4_8( IMGINFO info, DECDATA data); +extern void cnvpal_15( IMGINFO info, DECDATA data); +extern void cnvpal_high( IMGINFO info, DECDATA data); +extern void cnvpal_true( IMGINFO info, DECDATA data); + +extern void ( *cnvpal_color)( IMGINFO, DECDATA); + diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/dither.c b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/dither.c new file mode 100644 index 0000000..65ce5cb --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/dither.c @@ -0,0 +1,46 @@ +#ifdef __PUREC__ +#include "..\general.h" +#else +#include "../general.h" +#endif + + +extern uint32 cube216[216]; +extern uint32 graymap[32]; + +/* prototype */ +inline uint8 dither_true ( uint8 * rgb, int16 * err, int8 ** buf); +inline uint8 dither_gray( uint8 *gray, int16 *err, int8 **buf); + +inline uint8 dither_true ( uint8 * rgb, int16 * err, int8 ** buf) +{ + int8 *dth = *buf; + unsigned short r = (( err[0] += ( int16)dth[0] + rgb[0]) <= 42 ? 0 : err[0] >= 213 ? 5 : ( err[0] * 3) >> 7); + unsigned short g = (( err[1] += ( int16)dth[1] + rgb[1]) <= 42 ? 0 : err[1] >= 213 ? 5 : ( err[1] * 3) >> 7); + unsigned short b = (( err[2] += ( int16)dth[2] + rgb[2]) <= 42 ? 0 : err[2] >= 213 ? 5 : ( err[2] * 3) >> 7); + uint8 * irgb = ( uint8*)&cube216[( r * 6 + g) * 6 + b]; + + err[0] -= irgb[1]; + dth[0] = ( err[0] <= -254 ? ( err[0] =- 127) : err[0] >= +254 ? ( err[0] =+ 127) : ( err[0] >>= 1)); + err[1] -= irgb[2]; + dth[1] = ( err[1] <= -254 ? ( err[1] =- 127) : err[1] >= +254 ? ( err[1] =+ 127) : ( err[1] >>= 1)); + err[2] -= irgb[3]; + dth[2] = ( err[2] <= -254 ? ( err[2] = -127) : err[2] >= +254 ? ( err[2] = +127) : ( err[2] >>= 1)); + ( *buf) += 3; + + return irgb[0]; +} + + +inline uint8 dither_gray( uint8 *gray, int16 *err, int8 **buf) +{ + int8 *dth = *buf; + unsigned short idx = (( err[0] += ( int16)dth[0] + gray[0]) <= 0x07 ? 0 : err[0] >= 0xF8 ? 0x1F : err[0] >> 3); + uint8 *irgb = ( uint8*)&graymap[idx]; + + err[0] -= irgb[1]; + dth[0] = ( err[0] <= -254 ? ( err[0] = -127) : err[0] >= +254 ? ( err[0] =+ 127) : ( err[0] >>= 1)); + (*buf) += 1; + + return irgb[0]; +} diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/dither.h b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/dither.h new file mode 100644 index 0000000..273c31c --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/dither.h @@ -0,0 +1,2 @@ +extern inline uint8 dither_true ( uint8 * rgb, int16 * err, int8 ** buf); +extern inline uint8 dither_gray( uint8 *gray, int16 *err, int8 **buf); diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/p2c.c b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/p2c.c new file mode 100644 index 0000000..fe1fe57 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/p2c.c @@ -0,0 +1,87 @@ +#ifdef __PUREC__ +#include "..\general.h" +#else +#include "../general.h" +#endif + + +void ( *planar_to_chunky)( uint8 *in, uint8 *out, int16 width); + + +inline void planar8_to_chunky8( uint8 *in, uint8 *out, int16 width) +{ + uint8 *l; + uint16 x, c, p0, p1, p2, p3, p4, p5, p6, p7; + + for( x = 0, l = in; x < width; l += 16) + { + p0 = ( l[0] << 8) | l[1]; + p1 = ( l[2] << 8) | l[3]; + p2 = ( l[4] << 8) | l[5]; + p3 = ( l[6] << 8) | l[7]; + p4 = ( l[8] << 8) | l[9]; + p5 = ( l[10] << 8) | l[11]; + p6 = ( l[12] << 8) | l[13]; + p7 = ( l[14] << 8) | l[15]; + + for ( c = 0; c < 16; c++) + { + out[x++] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2) | ((p2 >> 13) & 4) | ((p3 >> 12) & 8) | + ((p4 >> 11) & 16) | ((p5 >> 10) & 32)| ((p6 >> 9) & 64) | ((p7 >> 8) & 128); + p0 <<= 1; + p1 <<= 1; + p2 <<= 1; + p3 <<= 1; + p4 <<= 1; + p5 <<= 1; + p6 <<= 1; + p7 <<= 1; + } + } +} + + +inline void planar4_to_chunky8( uint8 *in, uint8 *out, int16 width) +{ + uint8 *l; + uint16 x, c, p0, p1, p2, p3; + + for( x = 0, l = in; x < width; l += 8) + { + p0 = ( l[0] << 8) | l[1]; + p1 = ( l[2] << 8) | l[3]; + p2 = ( l[4] << 8) | l[5]; + p3 = ( l[6] << 8) | l[7]; + + for ( c = 0; c < 16; c++) + { + out[x++] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2) | ((p2 >> 13) & 4) | ((p3 >> 12) & 8); + + p0 <<= 1; + p1 <<= 1; + p2 <<= 1; + p3 <<= 1; + } + } +} + + +inline void planar2_to_chunky8( uint8 *in, uint8 *out, int16 width) +{ + uint8 *l; + uint16 x, c, p0, p1; + + for ( x = 0, l = in; x < width; l += 4) + { + p0 = (l[0] << 8) | l[1]; + p1 = (l[2] << 8) | l[3]; + + for (c = 0; c < 16; c++) + { + out[x++] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2); + p0 <<= 1; + p1 <<= 1; + } + } +} + diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/p2c.h b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/p2c.h new file mode 100644 index 0000000..bb837d0 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/p2c.h @@ -0,0 +1,5 @@ +extern void ( *planar_to_chunky)( uint8 *in, uint8 *out, int16 width); +extern void planar8_to_chunky8( uint8 *in, uint8 *out, int16 width); +extern void planar4_to_chunky8( uint8 *in, uint8 *out, int16 width); +extern void planar2_to_chunky8( uint8 *in, uint8 *out, int16 width); + diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/raresize.c b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/raresize.c new file mode 100644 index 0000000..25d0e49 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/raresize.c @@ -0,0 +1,152 @@ +#ifdef __PUREC__ +#include "..\general.h" +#include "..\load_img.h" +#else +#include "../general.h" +#include "../load_img.h" +#endif +#include "dither.h" +#include "raster.h" + +inline void resize_mono ( DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 4; + uint16 pixel = 0x80, chunk = 0; + + do + { + chunk |= ( info->RowBuf[x >> 16] & 1); + chunk <<= 1; + + if ( !--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + chunk = 0; + pixel = 0x80; + } + + x += ( info->IncXfx >> 3); + + } while ( width); +} + + +inline void resize_I4 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + *(tmp++) = *( uint8*)&info->DstBuf[x >> 16]; + + if (!--width || !--n) + { + raster_chunk4( buf, dst, tmp - buf); + dst += 4; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while ( width); +} + + +inline void resize_I8 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + *(tmp++) = *( uint8*)&info->DstBuf[x >> 16]; + + if (!--width || !--n) + { + raster_chunk8 (buf, dst, tmp - buf); + dst += 8; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while (width); +} + + +inline void resize_P8(DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 *rgb = &info->RowBuf[x >> 16]; + *(dst++) = *(rgb); + x += info->IncXfx; + } while (--width); +} + + +inline void resize_16(DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 *rgb = &info->RowBuf[(x >> 16) << 1]; + *(dst++) = *(rgb++); + *(dst++) = *(rgb); + x += info->IncXfx; + } while (--width); +} + + +inline void resize_24(DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >>16) * 3]; + *(dst++) = *(rgb++); + *(dst++) = *(rgb++); + *(dst++) = *(rgb); + x += info->IncXfx; + } while (--width); +} + + +inline void resize_32( DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >> 16) << 2]; + *(dst++) = *(rgb++); + *(dst++) = *(rgb++); + *(dst++) = *(rgb++); + *(dst++) = *(rgb); + + x += info->IncXfx; + } while (--width); +} diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/raresize.h b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/raresize.h new file mode 100644 index 0000000..cc6af3b --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/raresize.h @@ -0,0 +1,8 @@ +extern void resize_mono( DECDATA info, void * _dst); +extern void resize_I4( DECDATA info, void * _dst); +extern void resize_I8( DECDATA info, void * _dst); +extern void resize_P8( DECDATA info, void * _dst); +extern void resize_16( DECDATA info, void * _dst); +extern void resize_24( DECDATA info, void * _dst); +extern void resize_32( DECDATA info, void * _dst); + diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/raster.c b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/raster.c new file mode 100644 index 0000000..c374555 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/raster.c @@ -0,0 +1,877 @@ +#ifdef __PUREC__ +#include "..\general.h" +#include "..\load_img.h" +#else +#include "../general.h" +#include "../load_img.h" +#endif +#include "dither.h" +#include "raster.h" + +inline void raster_mono ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + uint32 *map = info->Pixel; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + if ( map[(int16)info->RowBuf[x >>16] & 1]) + chunk |= pixel; + + if ( !--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while ( width); +} + +inline void raster_D1 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + int16 *buf = info->DthBuf; + int16 ins = 0; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + ins += *buf + map[(int16)info->RowBuf[x >>16] & mask]; + + if ( ins < 2040) + chunk |= pixel; + else + ins -= 4080; + + *(buf++) = (ins >>= 2); + + if ( !--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while ( width); +} + +inline void gscale_D1( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = ( info->IncXfx + 1) >> 1; + int16 *buf = info->DthBuf; + int16 ins = 0; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + ins += *buf + ( int16)info->RowBuf[x >>16]; + + if ( ins < 0x80) + chunk |= pixel; + else + ins -= 0xFF; + + *(buf++) = (ins >>= 2); + + if ( !--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while (width); +} + +inline void dither_D1 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = ( info->IncXfx + 1) >> 1; + int16 *buf = info->DthBuf; + int16 ins = 0; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + uint8 *rgb = &info->RowBuf[(x >>16) *3]; + ins += *buf + ( int16)rgb[0] * 5 + ( int16)rgb[1] * 9 + ( int16)rgb[2] * 2; + + if (ins < 2040) + chunk |= pixel; + else + ins -= 4080; + + *(buf++) = (ins >>= 2); + + if (!--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while( width); +} + +inline void raster_D2 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = ( info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + int16 *buf = info->DthBuf; + int16 ins = 0; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + ins += *buf + map[( int16)info->RowBuf[x >>16] & mask]; + + if ( ins < 2040) + chunk |= pixel; + else + ins -= 4080; + + *(buf++) = (ins >>= 2); + + if (!--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while ( width); +} + +inline void gscale_D2( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = ( info->IncXfx + 1) >> 1; + int16 *buf = info->DthBuf; + int16 ins = 0; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + ins += *buf + (short)info->RowBuf[x >>16]; + + if (ins < 0x80) + chunk |= pixel; + else + ins -= 0xFF; + + *(buf++) = (ins >>= 2); + + if (!--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while (width); +} + +inline void dither_D2 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = ( info->IncXfx + 1) >> 1; + int16 *buf = info->DthBuf; + int16 ins = 0; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + uint8 *rgb = &info->RowBuf[( x >>16) * 3]; + ins += *buf + (int16)rgb[0] * 5 + (int16)rgb[1] * 9 + (int16)rgb[2] * 2; + + if (ins < 2040) + chunk |= pixel; + else + ins -= 4080; + + *(buf++) = (ins >>= 2); + + if (!--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while ( width); +} + +inline void raster_chunks ( uint8 *src, uint16 *dst, uint16 num, uint16 depth) +{ + uint16 mask = 0x8000; + uint16 *chunk = dst; + uint8 pixel = *src; + int16 i = depth; + + do + { + *( chunk++) = ( pixel & 1 ? mask : 0); + pixel >>= 1; + } while (--i); + + while (--num) + { + mask >>= 1; + chunk = dst; + pixel = *( ++src); + i = depth; + + do + { + if ( pixel & 1) *chunk |= mask; + else *chunk &= ~mask; + chunk++; + pixel >>= 1; + } while (--i); + } +} + + + +inline void raster_I4 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + uint16 idx = info->RowBuf[x >>16]; + *(tmp++) = *( uint8*)&info->Pixel[idx]; + + if (!--width || !--n) + { + raster_chunk4( buf, dst, tmp - buf); + dst += 4; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while ( width); +} + +inline void gscale_I4( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + int8 *dth = info->DthBuf; + int16 err = 0; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + *(tmp++) = dither_gray (&info->RowBuf[x >>16], &err, &dth); + + if (!--width || !--n) + { + raster_chunk4 (buf, dst, tmp - buf); + dst += 4; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while (width); +} + +inline void dither_I4 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + int8 *dth = info->DthBuf; + int16 err[3] = { 0, 0, 0 }; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + *(tmp++) = dither_true (&info->RowBuf[(x >>16) *3], err, &dth); + + if (!--width || !--n) + { + raster_chunk4 (buf, dst, tmp - buf); + dst += 4; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while (width); +} + +inline void raster_I8 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + uint16 idx = info->RowBuf[x >>16]; + *(tmp++) = *(uint8*)&info->Pixel[idx]; + + if (!--width || !--n) + { + raster_chunk8 (buf, dst, tmp - buf); + dst += 8; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while (width); +} + +inline void gscale_I8( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + int8 *dth = info->DthBuf; + int16 err = 0; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + *(tmp++) = dither_gray (&info->RowBuf[x >>16], &err, &dth); + + if (!--width || !--n) { + raster_chunk8 (buf, dst, tmp - buf); + dst += 8; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while (width); +} + +inline void dither_I8 (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + int8 *dth = info->DthBuf; + int16 err[3] = { 0, 0, 0 }; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + *(tmp++) = dither_true (&info->RowBuf[(x >>16) *3], err, &dth); + + if (!--width || !--n) + { + raster_chunk8 (buf, dst, tmp - buf); + dst += 8; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while ( width); +} + +inline void raster_P8 (DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + *(dst++) = *( uint8*)&map[( int16)info->RowBuf[x >>16] & mask]; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_P8( DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + int8 *dth = info->DthBuf; + int16 err = 0; + + do + { + *(dst++) = dither_gray (&info->RowBuf[x >>16], &err, &dth); + x += info->IncXfx; + } while (--width); +} + +inline void dither_P8 (DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + int8 *dth = info->DthBuf; + int16 err[3] = { 0, 0, 0 }; + + do + { + *(dst++) = dither_true (&info->RowBuf[(x >>16) *3], err, &dth); + x += info->IncXfx; + } while (--width); +} + +inline void raster_15 (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + *(dst++) = map[(short)info->RowBuf[x >>16] & mask]; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_15( DECDATA info, void * _dst) +{ + uint16 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint16 rgb = info->RowBuf[(x >>16)]; + rgb = ((rgb & 0xF8) <<7) | ((rgb & 0xF8) <<2) | (rgb >>3); + *(dst++) = (rgb >> 8) | (rgb << 8); + x += info->IncXfx; + } while (--width); +} + +inline void dither_15 (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do { + uint8 * rgb = &info->RowBuf[(x >>16) * 3]; + *(dst++) = (((uint16)rgb[0] & 0xF8) << 7) | (((uint16)rgb[1] & 0xF8) << 2) | ( rgb[2] >> 3); + x += info->IncXfx; + } while (--width); +} + +inline void raster_15r (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + uint16 rgb = map[(short)info->RowBuf[x >>16] & mask]; + *(dst++) = (rgb >> 8) | (rgb << 8); + x += info->IncXfx; + } while (--width); +} + +inline void gscale_15r( DECDATA info, void * _dst) +{ + uint16 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint16 rgb = info->RowBuf[(x >>16)]; + rgb = ((rgb & 0xF8) <<7) | ((rgb & 0xF8) <<2) | (rgb >>3); + *(dst++) = (rgb >> 8) | (rgb << 8); + x += info->IncXfx; + } while (--width); +} + +inline void dither_15r (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >>16) * 3]; + uint16 pix = (((uint16)rgb[0] & 0xF8) << 7) | (((uint16)rgb[1] & 0xF8) << 2) | (rgb[2] >> 3); + *(dst++) = (pix >> 8) | (pix << 8); + x += info->IncXfx; + } while (--width); +} + +inline void raster_16 (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + *(dst++) = map[(int16)info->RowBuf[x >>16] & mask]; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_16( DECDATA info, void * _dst) +{ + register uint16 *dst = _dst; + register int16 width = info->DthWidth; + register uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint16 rgb = info->RowBuf[(x >>16)]; + *(dst++) = ((rgb & 0xF8) <<8) | ((rgb & 0xFC) <<3) | (rgb >>3); + x += info->IncXfx; + } while (--width); +} + +inline void dither_16 (DECDATA info, void * _dst) +{ + register uint16 *dst = _dst; + register int16 width = info->DthWidth; + register uint32 x = (info->IncXfx + 1) >> 1; + + do + { + register uint8 *rgb = &info->RowBuf[(x >> 16) * 3]; + + *(dst++) = (((uint16)rgb[0] & 0xF8) << 8) | (((uint16)rgb[1] & 0xFC) << 3) | ( rgb[2] >> 3); + x += info->IncXfx; + } while (--width); +} + + +inline void raster_16r (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + uint16 rgb = map[(int16)info->RowBuf[x >>16] & mask]; + *(dst++) = (rgb >> 8) | (rgb << 8); + x += info->IncXfx; + } while (--width); +} + +inline void gscale_16r( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint16 rgb = info->RowBuf[(x >>16)]; + rgb = ((rgb & 0xF8) <<8) | ((rgb & 0xFC) <<3) | (rgb >>3); + *(dst++) = (rgb >> 8) | (rgb << 8); + x += info->IncXfx; + } while (--width); +} + +inline void dither_16r (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >>16) *3]; + uint16 pix = ((( uint16)rgb[0] & 0xF8) << 8) | ((( uint16)rgb[1] & 0xFC) << 3) | ( rgb[2] >> 3); + *(dst++) = (pix >> 8) | (pix << 8); + x += info->IncXfx; + } while (--width); +} + +inline void raster_24 (DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + uint8 * rgb = (uint8*)&map[( int16)info->RowBuf[x >>16] & mask]; + *(dst++) = *(++rgb); + *(dst++) = *(++rgb); + *(dst++) = *(++rgb); + x += info->IncXfx; + } while (--width); +} + +inline void gscale_24( DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 rgb = info->RowBuf[(x >>16)]; + *(dst++) = rgb; + *(dst++) = rgb; + *(dst++) = rgb; + x += info->IncXfx; + } while (--width); +} + +inline void dither_24 (DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >>16) *3]; + *(dst++) = *(rgb++); + *(dst++) = *(rgb++); + *(dst++) = *(rgb); + x += info->IncXfx; + } while (--width); +} + + +inline void raster_24r (DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + uint8 * rgb = (uint8*)&map[(int16)info->RowBuf[x >>16] & mask]; + *(dst++) = rgb[3]; + *(dst++) = rgb[2]; + *(dst++) = rgb[1]; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_24r( DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 rgb = info->RowBuf[(x >> 16)]; + *(dst++) = rgb; + *(dst++) = rgb; + *(dst++) = rgb; + x += info->IncXfx; + } while (--width); +} + +inline void dither_24r( DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >> 16) *3]; + *(dst++) = rgb[2]; + *(dst++) = rgb[1]; + *(dst++) = rgb[0]; + x += info->IncXfx; + } while (--width); +} + +inline void raster_32 (DECDATA info, void * _dst) +{ + uint32 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + *(dst++) = map[(int16)info->RowBuf[x >> 16] & mask]; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_32( DECDATA info, void * _dst) +{ + uint32 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint32 rgb = info->RowBuf[(x >> 16)]; + *(dst++) = ((( rgb << 8) | rgb) << 8) | rgb; + x += info->IncXfx; + } while (--width); +} + +inline void dither_32 (DECDATA info, void * _dst) +{ + uint32 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >> 16) *3]; + *(dst++) = ((((uint32)rgb[0] << 8) | rgb[1]) << 8) | rgb[2]; + x += info->IncXfx; + } while (--width); +} + + +inline void raster_32r( DECDATA info, void * _dst) +{ + uint32 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + uint8 * rgb = (uint8*)&map[(int16)info->RowBuf[x >>16] & mask]; + *(dst++) = (((((int32)rgb[3] << 8) | rgb[2]) << 8) | rgb[1]) << 8; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_32r( DECDATA info, void * _dst) +{ + uint32 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint32 rgb = info->RowBuf[(x >>16)]; + *(dst++) = (((( rgb << 8) | rgb) << 8) | rgb) << 8; + x += info->IncXfx; + } while (--width); +} + +inline void dither_32r (DECDATA info, void * _dst) +{ + uint32 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >>16) *3]; + *(dst++) = (((((uint32)rgb[2] <<8) | rgb[1]) << 8) | rgb[0]) << 8; + x += info->IncXfx; + } while (--width); +} + +inline void raster_32z ( DECDATA info, void * _dst) +{ + uint32 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + uint32 * map = info->Pixel; + uint16 mask = info->PixMask; + do { + *(dst++) = map[(int16)info->RowBuf[x >>16] & mask] << 8; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_32z (DECDATA info, void * _dst) +{ + uint32 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + do { + uint32 rgb = info->RowBuf[(x >>16)]; + *(dst++) = ((((rgb <<8) | rgb) <<8) | rgb) << 8; + x += info->IncXfx; + } while (--width); +} + +inline void dither_32z (DECDATA info, void * _dst) +{ + uint32 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + do { + uint8 * rgb = &info->RowBuf[(x >>16) *3]; + *(dst++) = (((((uint32)rgb[0] <<8) | rgb[1]) <<8) | rgb[2]) << 8; + x += info->IncXfx; + } while (--width); +} diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/raster.h b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/raster.h new file mode 100644 index 0000000..f396ed4 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/raster.h @@ -0,0 +1,63 @@ +extern void raster_chunks ( uint8 *src, uint16 *dst, uint16 num, uint16 depth); + +#define raster_chunk4(s,d,n) raster_chunks ( s, d, n, 4) +#define raster_chunk8(s,d,n) raster_chunks ( s, d, n, 8) + +extern void raster_mono ( DECDATA info, void * _dst); +extern void raster_D1 ( DECDATA info, void * _dst); +extern void dither_D1 ( DECDATA info, void * _dst); +extern void gscale_D1 ( DECDATA info, void * _dst); + +extern void raster_D2 ( DECDATA info, void * _dst); + +extern void dither_D2 ( DECDATA info, void * _dst); +extern void gscale_D2 ( DECDATA info, void * _dst); + +extern void raster_I4 ( DECDATA info, void * _dst); +extern void dither_I4 ( DECDATA info, void * _dst); +extern void gscale_I4 ( DECDATA info, void * _dst); + +extern void raster_I8 ( DECDATA info, void * _dst); +extern void dither_I8 ( DECDATA info, void * _dst); +extern void gscale_I8 ( DECDATA info, void * _dst); + +extern void raster_P8 ( DECDATA info, void * _dst); +extern void dither_P8 ( DECDATA info, void * _dst); +extern void gscale_P8 ( DECDATA info, void * _dst); + +extern void raster_15 ( DECDATA info, void * _dst); +extern void dither_15 ( DECDATA info, void * _dst); +extern void gscale_15 ( DECDATA info, void * _dst); + +extern void raster_15r ( DECDATA info, void * _dst); +extern void dither_15r ( DECDATA info, void * _dst); +extern void gscale_15r ( DECDATA info, void * _dst); + +extern void raster_16 ( DECDATA info, void * _dst); +extern void dither_16 ( DECDATA info, void * _dst); +extern void gscale_16 ( DECDATA info, void * _dst); + +extern void raster_16r ( DECDATA info, void * _dst); +extern void dither_16r ( DECDATA info, void * _dst); +extern void gscale_16r ( DECDATA info, void * _dst); + +extern void raster_24 ( DECDATA info, void * _dst); +extern void dither_24 ( DECDATA info, void * _dst); +extern void gscale_24 ( DECDATA info, void * _dst); + +extern void raster_24r ( DECDATA info, void * _dst); +extern void dither_24r ( DECDATA info, void * _dst); +extern void gscale_24r ( DECDATA info, void * _dst); + +extern void raster_32 ( DECDATA info, void * _dst); +extern void dither_32 ( DECDATA info, void * _dst); +extern void gscale_32 ( DECDATA info, void * _dst); + +extern void raster_32r ( DECDATA info, void * _dst); +extern void dither_32r ( DECDATA info, void * _dst); +extern void gscale_32r ( DECDATA info, void * _dst); + +extern void raster_32z ( DECDATA info, void * _dst); +extern void dither_32z ( DECDATA info, void * _dst); +extern void gscale_32z ( DECDATA info, void * _dst); + diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/vdi.c b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/vdi.c new file mode 100644 index 0000000..a8a8868 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/vdi.c @@ -0,0 +1,221 @@ +#ifdef __PUREC__ +#include "..\general.h" +#include "..\resize.h" +#include "..\load_img.h" +#else +#include "../general.h" +#include "../load_img.h" +#include "../resize.h" +#endif +#include "raster.h" +#include "raresize.h" +#include "color.h" +#include "p2c.h" + +int16 pixel_val[256]; +uint32 cube216[216]; +uint32 graymap[32]; +int16 planar = 0; +int16 vdi_handle, nplanes, vdi_work_in[10], vdi_work_out[57]; + + +/* prototype */ +int16 vdi_init ( void); + + +int16 vdi_init( void) +{ + int16 out[273] = { -1, }; + int16 dum, depth, aes_handle; + boolean reverse, z_trail; + int32 cookie_dum; + + if( !ldg_cookie( 0x45644449L, (int32*)&cookie_dum)) + return( 0); + + /* open a VDI workstation */ + aes_handle = graf_handle( &dum, &dum, &dum, &dum); + vq_extnd( aes_handle, 1, vdi_work_out); + nplanes = vdi_work_out[ 4]; + vdi_work_in[0] = Getrez() + 2; + vdi_handle = aes_handle; + v_opnvwk( vdi_work_in, &vdi_handle, vdi_work_out); + + /* Get the screen's informations */ + vq_scrninfo ( vdi_handle, out); + + if ( nplanes <= 8) + { + save_colors(); + memcpy ( pixel_val, out + 16, 512); + } + + depth = (( uint16)out[4] == 0x8000u ? 15 : out[2]); /* bits per pixel used */ + reverse = (out[16] < out[48]); /* intel crap... */ + z_trail = (out[48] > 0); /* bits are shifted to the right side */ + + if ( depth == 1) + { /* monochrome */ + cnvpal_color = cnvpal_1_2; + raster_cmap = raster_D1; + raster_true = dither_D1; + raster_gray = gscale_D1; + resize = resize_mono; + } + else if ( out[0] == 0) /* Planar */ + { + planar = 1; + + switch ( depth) + { + case 2: + cnvpal_color = cnvpal_1_2; + raster_cmap = raster_D2; + raster_true = dither_D2; + raster_gray = gscale_D2; + planar_to_chunky = planar2_to_chunky8; + break; + case 4: + cnvpal_color = cnvpal_4_8; + raster_cmap = raster_I4; + raster_true = dither_I4; + raster_gray = gscale_I4; + resize = resize_I4; + planar_to_chunky = planar4_to_chunky8; + break; + case 8: + cnvpal_color = cnvpal_4_8; + raster_cmap = raster_I8; + raster_true = dither_I8; + raster_gray = gscale_I8; + resize = resize_I8; + planar_to_chunky = planar8_to_chunky8; + break; + } + } + else if ( out[0] == 2) /* chunky */ + switch ( depth) + { + case 8: + cnvpal_color = cnvpal_4_8; + raster_cmap = raster_P8; + raster_true = dither_P8; + raster_gray = gscale_P8; + resize = resize_P8; + break; + + case 15: + if (!(out[14] & 0x02)) + { + cnvpal_color = cnvpal_15; + + if (reverse) + { + raster_cmap = raster_15r; + raster_gray = gscale_15r; + raster_true = dither_15r; + } + else + { + raster_cmap = raster_15; + raster_gray = gscale_15; + raster_true = dither_15; + } + + resize = resize_16; + + break; + } + + case 16: + cnvpal_color = cnvpal_high; + + if (reverse) + { + raster_cmap = raster_16r; + raster_gray = gscale_16r; + raster_true = dither_16r; + } + else + { + raster_cmap = raster_16; + raster_gray = gscale_16; + raster_true = dither_16; + } + + resize = resize_16; + + break; + + case 24: + cnvpal_color = cnvpal_true; + + if (reverse) + { + raster_cmap = raster_24r; + raster_gray = gscale_24r; + raster_true = dither_24r; + } + else + { + raster_cmap = raster_24; + raster_gray = gscale_24; + raster_true = dither_24; + } + + resize = resize_24; + + break; + + case 32: + cnvpal_color = cnvpal_true; + + if (reverse) + { + raster_cmap = raster_32r; + raster_gray = gscale_32r; + raster_true = dither_32r; + } + else if( z_trail) + { + raster_cmap = raster_32z; + raster_gray = gscale_32z; + raster_true = dither_32z; + } + else + { + raster_cmap = raster_32; + raster_gray = gscale_32; + raster_true = dither_32; + } + + resize = resize_32; + + break; + } + + if (depth == 4 || depth == 8) + { + uint32 * dst; + uint32 r, g, b; + dst = cube216; + + for (r = 0x000000uL; r <= 0xFF0000uL; r += 0x330000uL) + { + for (g = 0x000000uL; g <= 0x00FF00uL; g += 0x003300uL) + { + for (b = 0x000000uL; b <= 0x0000FFuL; b += 0x000033uL) + { + *(dst++) = color_lookup ( r | g | b, pixel_val); + } + } + } + + dst = graymap; + + for ( g = 0x000000uL; g <= 0xF8F8F8uL; g += 0x080808uL) + *( dst++) = color_lookup ( g | (( g >> 5) & 0x030303uL), pixel_val); + } + + return( 1); +} diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/vdi.h b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/vdi.h new file mode 100644 index 0000000..0732c46 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/src/zvdi/vdi.h @@ -0,0 +1,7 @@ +extern int16 pixel_val[256]; +extern uint32 cube216[216]; +extern uint32 graymap[32]; + +extern int16 vdi_init( void); +extern int16 planar, vdi_handle, nplanes, vdi_work_in[10], vdi_work_out[57]; + diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/zcodeclib.hyp b/sources/z-tools/tags/zweather-1.2/zcodeclib/zcodeclib.hyp new file mode 100644 index 0000000..1c9639d Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zcodeclib/zcodeclib.hyp differ diff --git a/sources/z-tools/tags/zweather-1.2/zcodeclib/zcodeclib.stg b/sources/z-tools/tags/zweather-1.2/zcodeclib/zcodeclib.stg new file mode 100644 index 0000000..728acdf --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zcodeclib/zcodeclib.stg @@ -0,0 +1,355 @@ +@database "zcodeclib Dev. Guide" +@subject "Documentation" +@author "Zorro" +@$VER: ZCODEC.HYP (@:"__DATE__") +@options +Z +@options -S + +@default Index + +@node Index "zcodeclib dev." +zcodeclib dev. +@line 1 70 0 0 1 + + + 1. Introduction + 2. Functions + 3. Global variables + 4. The IMAGE structure. + 5. Do you use MEM.LDG in your application? + + +@endnode + + +@node "Introduction" +1. Introduction +@line 1 70 0 0 1 + +Make a basic GEM application is a very easy task but problems +become when we have to draw something on the screen. + +Indeed, on Atari and others TOS computers, there are many +different screens' formats and, of course, we can't deal with +it in the same manner. + +The problem is worst when we have to load and to draw a picture +from, for example, a JPG file. We have to make ourselves loading +routines, etc... A real nightmare! + +The goal of this library is to offer easy and fast functions for +load images from file and for, especially, deal with the screen. +It provide also useful functions like MFDB zooming and others. + +This library load and use the zview's codecs, so it's fast and +stable. + +@{B}For use this library, you need:@{0} + +- A VDI with a valid EDDI (like NovaVDI, NVDI > 2.5, fVDI, etc..). +- The zview's codec correctly installed with mem.ldg (provided in +the zview archive). +- the LDG library ( http://ldg.org.free.fr) +- A recent GEMLIB. + + +(Index) + +@endnode + +@node "Functions" +2. Functions +@line 1 70 0 0 1 + + + 1. codecs_init() + 2. codecs_quit() + 3. load_img() + 4. delete_img() + 5. pic_resize() + 6. delete_mfdb() + + +(Index) + +@endnode + + +@node "codecs_init()" +codecs_init() +@line 1 70 0 0 1 + +@{B}NAME@{0} + codec_init - initialise and load the wanted codecs. + +@{B}PROTOTYPAGE@{0} + int16 codecs_init( char *codec_name); + + +@{B}PARAMETERS@{0} + codec_name: the name of the codec to load. + + return: 0 if an error occurs else 1. + + +@{B}DESCRIPTION@{0} + It's the first function to call. + + The function's job is to initialize the VDI's informations, + load MEM.LDG ( for shareable allocation) and load the wanted + codecs. + + For example: + + codecs_init( "jpg.ldg"); + + If you need others codecs, you can to call this function any + numbers of times like: + + codecs_init( "jpg.ldg"); + codecs_init( "png.ldg"); + .... + + Cool feature, you can load the complete codec's pack with: + + codec_init( "all"); + + +@{B}IMPORTANT@{0} + Be careful, you can't load two times the same codec so, don't + call again this function after a codec_init( "all"). + + +(Index) + +@endnode + +@node "codecs_quit()" +codecs_quit() +@line 1 70 0 0 1 + +@{B}NAME@{0} + codecs_quit - unload the codecs and MEM.LDG. + +@{B}PROTOTYPAGE@{0} + void codecs_quit( void); + + +@{B}DESCRIPTION@{0} + You must call this function at the end of your code or when we + don't use anymore the functions form this library. + + It unloads MEM.LDG and the codecs previously loaded. + + +(Index) + +@endnode + +@node "load_img()" +load_img() +@line 1 70 0 0 1 + +@{B}NAME@{0}l + load_img() - load, convert and zoom a image. + +@{B}PROTOTYPAGE@{0} + IMAGE *load_img( const char *file, int16 w, int16 h, int16 keep_ratio); + + +@{B}PARAMETERS@{0} + file: the file to load. + + w: the wanted image's width. + -1 for to keep the image's width. + + h: the wanted image's height. + -1 for to keep the image's height. + + keep_ratio: in the case where you set the wanted image's size + with the w and h variables, if 'keep_ratio' if TRUE, + the image is resized to fit in w and h for maintain + the aspect ratio else the image will be exactly at + the wanted size. + + + return: NULL if an error occurs else a valid IMAGE structure. + + +@{B}DESCRIPTION@{0} + The most important function of this library; it loads, converts + to screen format and eventually, zooms a picture. All in one + function! + + +@{B}IMPORTANT@{0} + Don't allocate the IMG structure yourself, the function make it + for you (see example.c). + + +(Index) + +@endnode + + + +@endnode + +@node "delete_img()" +delete_img() +@line 1 70 0 0 1 + +@{B}NAME@{0} + delete_img - free a IMAGE structure. + +@{B}PROTOTYPAGE@{0} + void delete_img( IMAGE *img); + + +@{B}DESCRIPTION@{0} + This function frees all the memories previously allocated for + the "img" structure and also "img" itself. + +(Index) + +@endnode + + +@node "pic_resize()" +pic_resize() +@line 1 70 0 0 1 + +@{B}NAME@{0}l + pic_resize() - resize a MFDB. + +@{B}PROTOTYPAGE@{0} + MFDB *pic_resize( MFDB *in, int16 w, int16 h, int16 keep_ratio); + + +@{B}PARAMETERS@{0} + in: the input MFDB address. + + w: the wanted MFDB's width. + + h: the wanted MFDB's height. + + keep_ratio: if 'keep_ratio' if TRUE, the MFDB is resized for to + fit in 'w' and 'h' for maintain the aspect ratio + else the MFDB will be exactly at the 'w' and 'h' size. + + return: NULL if an error occurs else a valid MFDB address. + + +@{B}DESCRIPTION@{0} + Return a MFDB resized with the data of 'in'. + + +@{B}IMPORTANT@{0} + 1) Don't allocate the "out" MFDB yourself, the function make it + for you (see example.c). + 2) You can't free the MFDB youself, use delete_mfdb() for do that. + + +(Index) + +@endnode + + + +@node "delete_mfdb()" +delete_mfdb() +@line 1 70 0 0 1 + +@{B}NAME@{0}l + delete_mfdb() - delete one or more MFDB structure(s). + +@{B}PROTOTYPAGE@{0} + void delete_mfdb( MFDB *bm, int16 nbr); + + +@{B}PARAMETERS@{0} + bm: the MFDB to free. + + nbr: the number of MFDB in 'bm'. + + return: nothing. + + +@{B}DESCRIPTION@{0} + Free one or more MFDB created with pic_resize(). + + +(Index) + +@endnode + + +@node "Global variables" +Global variables +@line 1 70 0 0 1 + + + All this global variable are in in16 format( short). + + planar: The screen format, 1 if planar else 0. + + nplanes: the screen planes' number. + + vdi_work_in[10], vdi_work_out[57]: useful information about + the VDI. + + vdi_handle: a "ready to use" VDI handle. + + +(Index) + +@endnode + + +@node "IMAGE" +IMAGE +@line 1 70 0 0 1 + + +typedef struct +{ + int16 page; + uint16 *delay; + MFDB *image; +} IMAGE; + + +delay: exists only if the image is a animated one ( for example: + animated GIF, FLI, etc..). + +page: is the number of image returned (For animated picture or + multi-pages documents like FAX). + +image: is one of many MFDB structure(s) ready to be transferred to + the screen. + + +@endnode + + +@node "Do you use MEM.LDG in your application?" +Do you use MEM.LDG in your application? +@line 1 70 0 0 1 + + +Libzcodec loads already the MEM.LDG so you can't do it again in your +code! + +For this prupose, in the header's file, we can find +'shared_malloc( a)' and 'shared_free( a)'. + +This functions are only ldg_malloc() and ldg_free() binded; you +can use it without any problem and if far better that Mintlib malloc's +function. + +If you need ldg_realloc or ldg_calloc, you need to make a +ldg_find( "ldg_calloc", ldg_mem) youself. ( ldg_mem is a global +variable used for load MEM.LDG). + + +@endnode diff --git a/sources/z-tools/tags/zweather-1.2/zweather/Makefile b/sources/z-tools/tags/zweather-1.2/zweather/Makefile new file mode 100644 index 0000000..5c10aec --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/Makefile @@ -0,0 +1,49 @@ +CROSS = no + +ifeq ($(CROSS),yes) +CC = m68k-atari-mint-gcc +STRIP = m68k-atari-mint-strip +STACK = m68k-atari-mint-stack +LIBXML = /usr/m68k-atari-mint/include/libxml2 +FLAGS = m68k-atari-mint-flags -r +else +CC = gcc +STRIP = strip +STACK = stack +LIBXML = /usr/include/libxml2 +FLAGS = flags -r +endif +COMPRESS = upx -9 + +STACKSIZE = 64k +OPTIMISATION = -O2 -fomit-frame-pointer -finline-functions +CPU = -m68020-60 +LIB = -lwindom1 -lzcodec -lldg -lgem -lxml2 -lm -lmem -lz +CFLAGS = $(CPU) $(OPTIMISATION) -Wall -Wshadow -I$(LIBXML) +ifeq ($(CROSS),no) +CFLAGS += -I/usr/local/include +LDFLAGS += -L/usr/local/lib/m68020-60 +endif +OBJ = inet.o http_client.o parsers.o get_data.o \ + debug.o zstring.o dialog.o prefs.o zaes.o icon.o main.o + +PROGRAM = zweather.app + + +all: $(PROGRAM) stack strip compress + +$(PROGRAM): $(OBJ) + $(CC) $(CPU) $(OPTIMISATION) -o $@ $(OBJ) $(LDFLAGS) $(LIB) + +strip: + $(STRIP) -s $(PROGRAM) + +stack: + $(STACK) -S $(STACKSIZE) $(PROGRAM) + +compress: + $(COMPRESS) $(PROGRAM) + $(FLAGS) $(PROGRAM) + +clean: + rm -f *.o *.app *~ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/debug.c b/sources/z-tools/tags/zweather-1.2/zweather/debug.c new file mode 100644 index 0000000..fde6edb --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/debug.c @@ -0,0 +1,28 @@ +#include "general.h" + + +/*==================================================================================* + * void zdebug: * + * print debug information in 'wout' window. * + *----------------------------------------------------------------------------------* + * input: * + * ... -> text and parameter are the same that sandard "printf" function. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void zdebug( const char *format, ...) +{ +#ifdef DEBUG + va_list args; + char fo_buff[255], *p; + + va_start( args, format); + vsprintf( fo_buff, format, args); + p = fo_buff; + va_end( args); + + wout_printf("%s\n", p); +#endif +} diff --git a/sources/z-tools/tags/zweather-1.2/zweather/dialog.c b/sources/z-tools/tags/zweather-1.2/zweather/dialog.c new file mode 100644 index 0000000..a339795 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/dialog.c @@ -0,0 +1,194 @@ +#include "general.h" +#include "icon.h" +#include "parsers.h" + +extern struct xml_weather *zweatherdata; +extern int8 wind_direction[8]; +extern void init_stik (void); + +WINDOW *windialog = NULL; +int16 hcell = 0; +int8 icon_temp[8] = ""; + +/*==================================================================================* + * void WindIconify: * + * Function to handle iconfied windows drawing... If the icon doesn't exist, * + * It is created. * + *----------------------------------------------------------------------------------* + * input: * + * win -> the window to handle. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +static void WindIconify( WINDOW *win) +{ + int16 posx, posy, x, y, w, h, xy[8]; + MFDB screen = {0}; + MFDB *iconified_icon = &main_icon->image[0]; + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + + xy[0] = x; + xy[1] = y; + xy[2] = xy[0] + w - 1; + xy[3] = xy[1] + h - 1; + + vsf_color( win->graf.handle, LWHITE); + v_bar( win->graf.handle, xy); + + posx = MAX( x + (( w - iconified_icon->fd_w) >> 1), x); + posy = MAX( y + (( h - iconified_icon->fd_h) >> 1), y); + + if (posx == x) + xy[2] = w - 1; + else + xy[2] = iconified_icon->fd_w - 1; + + if (posy == y) + xy[3] = h - 1; + else + xy[3] = iconified_icon->fd_h - 1; + + xy[0] = 0; + xy[1] = 0; + xy[4] = posx; + xy[5] = posy; + xy[6] = posx + xy[2]; + xy[7] = posy + xy[3]; + + /* draw the image */ + if ( iconified_icon->fd_nplanes == 1) + { + int16 color[2] = { BLACK, WHITE}; + + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, iconified_icon, &screen, color); + } + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, iconified_icon, &screen); + + v_ftext( win->graf.handle, x + w - 2, y + h - hcell, icon_temp); +} + +/* +void send_iconify( void) +{ + WindSet( windialog, WF_ICONIFY, 0, 1, 0, 1); + ObjcChange( OC_FORM, windialog, WEATHER_ICONIFY, NORMAL, 0); +} +*/ + + +static void sting_layer( WINDOW *win, int16 obj_index) +{ + use_sting = ( use_sting == TRUE ? FALSE : TRUE); + + /* a wait loop while the mouse button is pressed */ + while(( evnt.mbut == 1) || ( evnt.mbut == 2)) + graf_mkstate( &evnt.mx, &evnt.my, &evnt.mbut, &evnt.mkstate); +} + + +void force_update( void) +{ + OBJECT *weather_form = get_tree( WEATHER); + int time_minute; + + graf_mouse( BUSYBEE, NULL); + + if( EvntFind( NULL, WM_XTIMER)) + EvntDelete( NULL, WM_XTIMER); + + if( zweatherdata) + xml_weather_free( zweatherdata); + + if( use_sting) + init_stik(); + + strcpy( location_code, ObjcString( weather_form, WEATHER_CODE, NULL)); + + zweatherdata = update_weatherdata( location_code); + + time_minute = atoi( ( const char*)ObjcString( weather_form, WEATHER_UPDATE_TIME, NULL)); + + update_time = ( clock_t)( ( int32)time_minute * 12000L); + + ObjcChange( OC_FORM, windialog, WEATHER_UPDATE, NORMAL, 0); + + snd_rdw( windialog); + + EvntAttach( NULL, WM_XTIMER, timer_function); + + graf_mouse( ARROW, NULL); +} + + +void weather_dialog( void) +{ + OBJECT *weather_form = get_tree( WEATHER); + int frms[] = { WEATHER_PANEL1, WEATHER_PANEL2, WEATHER_PANEL3}; + int buts[] = { WEATHER_MAIN, WEATHER_FORECAST, WEATHER_PREF}; + int time_minute = ( int)( update_time / 12000L); + int16 dum; + + strcpy( ObjcString( weather_form, WEATHER_CODE, NULL), location_code); + sprintf( ObjcString( weather_form, WEATHER_UPDATE_TIME, NULL), "%d", time_minute); + + if( use_sting == 1) + ObjcChange( OC_OBJC, weather_form, WEATHER_STING, SELECTED, 0); + else + ObjcChange( OC_OBJC, weather_form, WEATHER_STING, NORMAL, 0); + + windialog = FormCreate( weather_form, NAME|MOVER|SMALLER, NULL, " zWeather ", NULL, TRUE, FALSE); + + RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON, draw_weather_icon, NULL); + RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON1, draw_forecast1_icon, NULL); + RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON2, draw_forecast2_icon, NULL); + RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON3, draw_forecast3_icon, NULL); + RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON4, draw_forecast4_icon, NULL); + RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON5, draw_forecast5_icon, NULL); + RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON6, draw_forecast6_icon, NULL); + RsrcUserDraw( OC_FORM, windialog, WEATHER_WICON, draw_boussole_icon, NULL); + + FormThumb( windialog, frms, buts, 3); + + if( main_icon == NULL) + main_icon = icons[25]; + + if( forecast_icon[0] == NULL) + forecast_icon[0] = icons[25]; + + if( forecast_icon[1] == NULL) + forecast_icon[1] = icons[25]; + + if( forecast_icon[2] == NULL) + forecast_icon[2] = icons[25]; + + if( forecast_icon[3] == NULL) + forecast_icon[3] = icons[25]; + + if( forecast_icon[4] == NULL) + forecast_icon[4] = icons[25]; + + if( forecast_icon[5] == NULL) + forecast_icon[5] = icons[25]; + + ObjcAttach( OC_FORM, windialog, WEATHER_METRIC, BIND_VAR, &unit); + ObjcAttach( OC_FORM, windialog, WEATHER_IMPERIAL, BIND_VAR, &unit); + ObjcAttach( OC_FORM, windialog, WEATHER_UPDATE, BIND_FUNC, force_update); + ObjcAttach( OC_FORM, windialog, WEATHER_STING, BIND_FUNC, sting_layer); + ObjcAttach( OC_FORM, windialog, WEATHER_QUIT, BIND_FUNC, applexit); + + vswr_mode( windialog->graf.handle, MD_TRANS); + vst_point( windialog->graf.handle, 8, &dum, &dum, &dum, &hcell); + vst_alignment( windialog->graf.handle, 2, 5, &dum, &dum); + vst_color( windialog->graf.handle, LBLUE); + vsl_color( windialog->graf.handle, RED); + hcell++; + + WindSetStr( windialog, WF_ICONDRAW, WindIconify); + +// EvntAttach( wininfo, WM_CLOSED, close_modal); +} + diff --git a/sources/z-tools/tags/zweather-1.2/zweather/general.h b/sources/z-tools/tags/zweather-1.2/zweather/general.h new file mode 100644 index 0000000..70c056c --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/general.h @@ -0,0 +1,72 @@ +/* + * zView. + * Copyright (c) 2004 Zorro ( zorro270@yahoo.fr) + * + * This application is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef DEBUG +#include +#endif +#include +#include +#include +#include "zstring.h" +#include "zaes.h" +#include "prefs.h" +#include "zweather.rsh" + +/* Custom message code */ +#define E_RSC 10002 +#define E_OK 0 + +/* Option */ +// #define DEBUG + + +#ifndef MAXNAMLEN + #define MAXNAMLEN 255 +#endif + +#ifndef MAX_PATH + #define MAX_PATH 1024 +#endif + +extern WINDOW *windialog; +extern void timer_function( WINDOW *win); +extern void applexit( void); +extern void snd_rdw( WINDOW *win); +extern struct xml_weather *update_weatherdata( int8 *location); +extern void snd_msg( WINDOW *win, int msg, int par1, int par2, int par3, int par4); +extern void zdebug( const char *format, ...); + diff --git a/sources/z-tools/tags/zweather-1.2/zweather/get_data.c b/sources/z-tools/tags/zweather-1.2/zweather/get_data.c new file mode 100644 index 0000000..9c1b082 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/get_data.c @@ -0,0 +1,206 @@ +#include "general.h" +#include "get_data.h" + +int8 dummy[2] = "0"; + + +int8 *get_data_uv(struct xml_uv *data, enum datas_uv type) +{ + int8 *str = dummy; + + if ( !data) + return str; + + switch(type) + { + case _UV_INDEX: str = data->i; break; + case _UV_TRANS: str = data->t; break; + default: break; + } + + return str; +} + + +int8 *get_data_bar(struct xml_bar *data, enum datas_bar type) +{ + int8 *str = dummy; + + if ( !data) + return str; + + switch(type) + { + case _BAR_R: str = data->r; break; + case _BAR_D: str = data->d; break; + default: break; + } + + return str; +} + +int8 *get_data_wind(struct xml_wind *data, enum datas_wind type) +{ + int8 *str = dummy; + + if ( !data) + return str; + + switch(type) + { + case _WIND_SPEED: str = data->s; break; + case _WIND_GUST: str = data->gust; break; + case _WIND_DIRECTION: str = data->t; break; + case _WIND_TRANS: str = data->d; break; + default: break; + } + + return str; +} + +int8 *get_data_cc( struct xml_cc *data, enum datas type) +{ + int8 *str = dummy; + + if ( !data) + return str; + + switch(type) + { + case LSUP: str = data->lsup; break; + case OBST: str = data->obst; break; + case FLIK: str = data->flik; break; + case TRANS: str = data->t; break; + case TEMP: str = data->tmp; break; + case HMID: str = data->hmid; break; + case VIS: str = data->vis; break; + case UV_INDEX: return get_data_uv(data->uv, _UV_INDEX); + case UV_TRANS: return get_data_uv(data->uv, _UV_TRANS); + case WIND_SPEED: return get_data_wind(data->wind, _WIND_SPEED); + case WIND_GUST: return get_data_wind(data->wind, _WIND_GUST); + case WIND_DIRECTION: return get_data_wind(data->wind, _WIND_DIRECTION); + case WIND_TRANS: return get_data_wind(data->wind, _WIND_TRANS); + case BAR_R: return get_data_bar(data->bar, _BAR_R); + case BAR_D: return get_data_bar(data->bar, _BAR_D); + case DEWP: str = data->dewp; break; + case WICON: str = data->icon; break; + default: break; + } + return str; +} + +int8 *get_data_loc(struct xml_loc *data, enum datas_loc type) +{ + int8 *str = dummy; + + if ( !data) + return str; + + switch(type) + { + case DNAM: str = data->dnam; break; + case SUNR: str = data->sunr; break; + case SUNS: str = data->suns; break; + default: break; + } + + return str; +} + +const int8 *get_data(struct xml_weather *data, enum datas type) +{ + int8 *str = dummy; + + if( data) + { + switch (type & 0xFF00) + { + case DATAS_CC: str = get_data_cc(data->cc, type); break; + case DATAS_LOC: str = get_data_loc(data->loc, type); break; + default: break; + } + } + + return str; +} + +int8 *get_data_part(struct xml_part *data, enum forecast type) +{ + int8 *str = dummy; + + if ( !data) + return str; + + switch (type & 0x000F) + { + case F_ICON: str = data->icon; break; + case F_TRANS: str = data->t; break; + case F_PPCP: str = data->ppcp; break; + case F_W_SPEED: str = get_data_wind(data->wind, _WIND_SPEED); break; + case F_W_DIRECTION: str = get_data_wind(data->wind, _WIND_DIRECTION); break; + default: break; + } + + return str; +} + +const int8 *get_data_f(struct xml_dayf *data, enum forecast type) +{ + int8 *str = dummy; + + if (data) + { + switch (type & 0x0F00) + { + case ITEMS: + switch(type) + { + case WDAY: str = data->day; break; + case TEMP_MIN: str = data->low; break; + case TEMP_MAX: str = data->hi; break; + default: break; + } + break; + case NPART: str = get_data_part(data->part[1], type); break; + case DPART: str = get_data_part(data->part[0], type); break; + } + } + + return str; +} + +const int8 *get_unit( int myunit, enum datas type) +{ + int8 *str = dummy; + + switch (type & 0x00F0) + { + case 0x0020: str = (myunit == WEATHER_METRIC ? "ø C" : "ø F"); break; + case 0x0030: str = "%"; break; + case 0x0040: str = (myunit == WEATHER_METRIC ? "km/h" : "mph"); break; + case 0x0050: str = (myunit == WEATHER_METRIC ? "mb" : "in"); break; + default: break; + } + + return str; +} + +const int8 *get_lnks(struct xml_lnks *lnks, enum link type, int num) +{ + int8* str = ""; + + if( !lnks || num >= XML_WEATHER_LINK_N) + return str; + + switch (type) + { + case LINK: + str = lnks->l[num]; + case TEXT: + str = lnks->t[num]; + default: + break; + } + + return str; +} diff --git a/sources/z-tools/tags/zweather-1.2/zweather/get_data.h b/sources/z-tools/tags/zweather-1.2/zweather/get_data.h new file mode 100644 index 0000000..2d4140a --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/get_data.h @@ -0,0 +1,98 @@ +#ifndef GET_DATA_H +#define GET_DATA_H + +#include "parsers.h" + +#define DATAS_CC 0x0100 +#define DATAS_LOC 0x0200 +#define DATAS_DAYF 0x0300 + +enum datas_wind { + _WIND_SPEED, + _WIND_GUST, + _WIND_DIRECTION, + _WIND_TRANS +}; + +enum datas_bar { + _BAR_R, + _BAR_D +}; + +enum datas_uv { + _UV_INDEX, + _UV_TRANS +}; + +enum datas { + /* cc */ + LSUP = 0x0101, + OBST = 0x0102, + TRANS = 0x0103, + VIS = 0x0104, + UV_INDEX = 0x0105, + UV_TRANS = 0x0106, + WIND_DIRECTION = 0x0107, + BAR_D = 0x0108, + WIND_TRANS = 0x0109, + WICON = 0x0110, + + FLIK = 0x0120, + TEMP = 0x0121, + DEWP = 0x0122, + + HMID = 0x0130, + + WIND_SPEED = 0x0140, + WIND_GUST = 0x0141, + + + BAR_R = 0x0150 +}; + + +enum datas_loc { + DNAM = 0x0201, + SUNR = 0x0202, + SUNS = 0x0203 +}; + +enum forecast { + ITEMS = 0x0100, + WDAY = 0x0101, + TEMP_MIN = 0x0102, + TEMP_MAX = 0x0103, + + F_ICON = 0x0001, + F_PPCP = 0x0002, + F_W_DIRECTION = 0x0003, + F_W_SPEED = 0x0004, + F_TRANS = 0x0005, + + NPART = 0x0200, + ICON_N = 0x0201, + PPCP_N = 0x0202, + W_DIRECTION_N = 0x0203, + W_SPEED_N = 0x0204, + TRANS_N = 0x0205, + + DPART = 0x0300, + ICON_D = 0x0301, + PPCP_D = 0x0302, + W_DIRECTION_D = 0x0303, + W_SPEED_D = 0x0304, + TRANS_D = 0x0305 +}; + +enum link { + LINK, + TEXT +}; + + +const int8 *get_data(struct xml_weather *data, enum datas type); +const int8 *get_data_f(struct xml_dayf * , enum forecast type); +const int8 *get_unit( int myunit, enum datas type); +const int8 *get_lnks(struct xml_lnks *lnks, enum link type, int num); + +#endif diff --git a/sources/z-tools/tags/zweather-1.2/zweather/history.txt b/sources/z-tools/tags/zweather-1.2/zweather/history.txt new file mode 100644 index 0000000..56c0dfb --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/history.txt @@ -0,0 +1,31 @@ +27 January 2010: 1.02 +===================== + +- Fixed issues with memory protection +- Updated for correct cooperation with zweather.com + + + +8 August 2005: 1.01 +=================== + +- Updated to use the news zview codecs. + + + +14 march 2005: FINAL 1.0 +======================== + +- STing compatibility layer added. +- Now, zweather works on old 8+3 partitions. +- A very bad bug was present in "icon" code.. it caused a memory leak. +- Minor bugs fixes about text alignment. +- Some code clean up. +- 'O.png' had an incorrect size. + + + +3 march 2005: BETA1 +=================== + +- First public release. diff --git a/sources/z-tools/tags/zweather-1.2/zweather/http_client.c b/sources/z-tools/tags/zweather-1.2/zweather/http_client.c new file mode 100644 index 0000000..78eab54 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/http_client.c @@ -0,0 +1,155 @@ +#include "general.h" +#include "inet.h" + +long http_recv( int32 fd, int8 **buffer) +{ + long n = 0L; /* 1 = good, 0 = conn terminated, -1 = error */ + int8 thisbuffer[1024]; + clock_t time_out = 0; + + for(;;) + { + n = inet_recv ( fd, thisbuffer, 1023L); + + if( n < 0L) + { + *buffer = NULL; + break; + } + else if( n == 0) + { + clock_t clk = clock(); + + if ( !time_out) + { + time_out = clk; + continue; + } + else if (( clk -= time_out) < 3000) + { + continue; + } + else break; + } + else + { + thisbuffer[n] = '\0'; + *buffer = strdup(( const int8 *)thisbuffer); + break; + } + } + return n; +} + + +boolean http_get_header( int32 fd, int8 **buffer) +{ + int8 lastchar = 0, *thisbuffer; + int32 l; + + while((l = http_recv( fd, &thisbuffer)) > 0) + { + boolean found = FALSE; + int8 *where = NULL, *p; + + if (lastchar == '\r' && ( p = strstr_len( thisbuffer, 3, "\n\r\n"))) + { + where = p + 3; + found = TRUE; + } + else if (( p = strstr(thisbuffer, "\r\n\r\n"))) + { + where = p + 4; + found = TRUE; + } + + if( found) + { + /*TODO check if at end*/ + *buffer = strdup(where); + } + else + lastchar = thisbuffer[l]; + + free(thisbuffer); + + if( found) + return TRUE; + } + + return FALSE; +} + + +int16 http_get_file( int8 *url, int8 *hostname, int8 *filename) +{ + int32 addr, fd = -1, error; + FILE *file = NULL; + int8 *buffer= NULL, *request = NULL; + + if( inet_host_addr ( hostname, &addr) != E_OK) + { + return FALSE; + } + + if( !( fd = inet_connect( addr, 80, 10))) + { + return FALSE; + } + + request = strdup_printf( "GET %s HTTP/1.0\r\n""HOST: %s\r\n\r\n", url, hostname); + + if( request == NULL) + { + inet_close(fd); + return FALSE; + } + + error = inet_send( fd, request, strlen(request)); + free( request); + + if ( error <= 0) + { + inet_close(fd); + return FALSE; + } + + file = fopen( filename, "w"); + + if ( !file) + { + inet_close(fd); + return FALSE; + } + + + if( http_get_header( fd, &buffer) == FALSE) + { + inet_close(fd); + fclose(file); + return FALSE; + } + + + if( buffer) + { + int l = strlen(buffer); + fwrite(buffer, sizeof(char), l, file); + free(buffer); + } + + while(( error = http_recv(fd, &buffer)) > 0) + { + int l = strlen( buffer); + fwrite( buffer, sizeof(char), l, file); + free(buffer); + } + + fclose(file); + inet_close(fd); + + if( error != -316) + return FALSE; + + return TRUE; +} diff --git a/sources/z-tools/tags/zweather-1.2/zweather/http_client.h b/sources/z-tools/tags/zweather-1.2/zweather/http_client.h new file mode 100644 index 0000000..6dde962 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/http_client.h @@ -0,0 +1 @@ +extern int16 http_get_file( int8 *url, int8 *hostname, int8 *filename); diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icon.c b/sources/z-tools/tags/zweather-1.2/zweather/icon.c new file mode 100644 index 0000000..ac5132d --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/icon.c @@ -0,0 +1,56 @@ +#include "general.h" + +IMAGE *main_icon = NULL; +IMAGE *boussole = NULL; +IMAGE *logo = NULL; +IMAGE *forecast_icon[5] = { NULL }; +IMAGE *icons[48] = { NULL }; + +int16 codec_load = 0; + +int16 register_icons( void) +{ + int16 i, end = 0; + int8 icon_name[16]; + + if( !( codec_load = codecs_init( "png.ldg"))) + goto error; + + for( i = 0; i <= 47; i++) + { + sprintf( icon_name, "icons\\%d.png", i); + + if( ! ( icons[i] = load_img( icon_name, -1, -1, 1))) + goto error; + } + + if( !( boussole = load_img( "icons\\boussole.png", -1, -1, 1))) + goto error; + + if( !( logo = load_img( "icons\\logo.png", -1, -1, 1))) + goto error; + + end = 1; + + error: + return end; +} + +void unregister_icons( void) +{ + int16 i; + + if( codec_load == 0) + return; + + codecs_quit(); + + delete_img( logo); + + delete_img( boussole); + + for( i = 0; i <= 47; i++) + { + delete_img( icons[i]); + } +} diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icon.h b/sources/z-tools/tags/zweather-1.2/zweather/icon.h new file mode 100644 index 0000000..2c9a53d --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/icon.h @@ -0,0 +1,7 @@ +extern IMAGE *main_icon; +extern IMAGE *forecast_icon[5]; +extern IMAGE *icons[47]; +extern IMAGE *boussole; +extern IMAGE *logo; +extern int16 register_icons( void); +extern void unregister_icons( void); diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/0.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/0.png new file mode 100644 index 0000000..0d2979a Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/0.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/1.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/1.png new file mode 100644 index 0000000..3fdaffd Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/1.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/10.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/10.png new file mode 100644 index 0000000..a893ff8 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/10.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/11.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/11.png new file mode 100644 index 0000000..cc60ccd Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/11.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/12.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/12.png new file mode 100644 index 0000000..7968a02 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/12.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/13.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/13.png new file mode 100644 index 0000000..9e7ec42 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/13.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/14.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/14.png new file mode 100644 index 0000000..a47e0f6 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/14.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/15.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/15.png new file mode 100644 index 0000000..00b962d Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/15.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/16.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/16.png new file mode 100644 index 0000000..00b962d Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/16.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/17.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/17.png new file mode 100644 index 0000000..e4bbf95 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/17.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/18.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/18.png new file mode 100644 index 0000000..7968a02 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/18.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/19.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/19.png new file mode 100644 index 0000000..801aef2 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/19.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/2.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/2.png new file mode 100644 index 0000000..3fdaffd Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/2.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/20.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/20.png new file mode 100644 index 0000000..3d04d03 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/20.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/21.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/21.png new file mode 100644 index 0000000..32bdc09 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/21.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/22.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/22.png new file mode 100644 index 0000000..8d5ce76 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/22.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/23.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/23.png new file mode 100644 index 0000000..844e088 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/23.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/24.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/24.png new file mode 100644 index 0000000..844e088 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/24.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/25.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/25.png new file mode 100644 index 0000000..0d2979a Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/25.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/26.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/26.png new file mode 100644 index 0000000..d2075fa Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/26.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/27.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/27.png new file mode 100644 index 0000000..687bfb0 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/27.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/28.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/28.png new file mode 100644 index 0000000..a0e9485 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/28.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/29.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/29.png new file mode 100644 index 0000000..9b27651 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/29.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/3.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/3.png new file mode 100644 index 0000000..e4bbf95 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/3.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/30.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/30.png new file mode 100644 index 0000000..a0e9485 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/30.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/31.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/31.png new file mode 100644 index 0000000..f58029d Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/31.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/32.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/32.png new file mode 100644 index 0000000..34012dd Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/32.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/33.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/33.png new file mode 100644 index 0000000..d155533 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/33.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/34.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/34.png new file mode 100644 index 0000000..7901588 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/34.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/35.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/35.png new file mode 100644 index 0000000..e4bbf95 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/35.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/36.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/36.png new file mode 100644 index 0000000..0d2979a Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/36.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/37.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/37.png new file mode 100644 index 0000000..e4bbf95 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/37.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/38.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/38.png new file mode 100644 index 0000000..e4bbf95 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/38.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/39.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/39.png new file mode 100644 index 0000000..7968a02 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/39.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/4.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/4.png new file mode 100644 index 0000000..e4bbf95 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/4.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/40.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/40.png new file mode 100644 index 0000000..7968a02 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/40.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/41.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/41.png new file mode 100644 index 0000000..00b962d Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/41.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/42.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/42.png new file mode 100644 index 0000000..00b962d Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/42.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/43.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/43.png new file mode 100644 index 0000000..b5c2531 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/43.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/44.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/44.png new file mode 100644 index 0000000..a0e9485 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/44.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/45.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/45.png new file mode 100644 index 0000000..28b7c30 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/45.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/46.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/46.png new file mode 100644 index 0000000..1d19dd1 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/46.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/47.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/47.png new file mode 100644 index 0000000..f47459d Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/47.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/5.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/5.png new file mode 100644 index 0000000..00b962d Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/5.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/6.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/6.png new file mode 100644 index 0000000..cc60ccd Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/6.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/7.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/7.png new file mode 100644 index 0000000..a893ff8 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/7.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/8.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/8.png new file mode 100644 index 0000000..a893ff8 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/8.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/9.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/9.png new file mode 100644 index 0000000..29dc2ac Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/9.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/boussole.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/boussole.png new file mode 100644 index 0000000..479943e Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/boussole.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/icons/logo.png b/sources/z-tools/tags/zweather-1.2/zweather/icons/logo.png new file mode 100644 index 0000000..baad92a Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/icons/logo.png differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/inet.c b/sources/z-tools/tags/zweather-1.2/zweather/inet.c new file mode 100644 index 0000000..4ca0f0f --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/inet.c @@ -0,0 +1,202 @@ +#include "general.h" +#include + +static boolean timeout = FALSE; +TPL *tpl = NULL; +DRV_LIST *drivers = NULL; + + +static void sig_alrm (long sig) +{ + (void)sig; + timeout = TRUE; +} + + +void init_stik (void) +{ + if ( !tpl) + { + struct { + long cktag; + long ckvalue; + } * jar = (void*)Setexc (0x5A0 /4, (void (*)())-1); + long tag = 'STiK'; + + while (jar->cktag) { + if (jar->cktag == tag) { + drivers = (DRV_LIST*)jar->ckvalue; + if (strcmp (MAGIC, drivers->magic) == 0) { + tpl = (TPL*)get_dftab(TRANSPORT_DRIVER); + } + break; + } + jar++; + } + } +} + + + +void inet_close (long fh) +{ + if( fh >= 0) + { + if ( tpl && use_sting) + TCP_close ((int16)fh, 0, NULL); + else + close (fh); + } +} + + +short inet_host_addr ( const char * name, long * addr) +{ + short ret = -1; + + if ( tpl && use_sting) + { + // zdebug( "STING"); + + if ( resolve ((char*)name, NULL, ( uint32*)addr, 1) > 0) + ret = E_OK; + } + else + { + // zdebug( "MintNet"); + + struct hostent *host = gethostbyname (name); + + if (host) + { + *addr = *(long*)host->h_addr; + ret = E_OK; + } + else + ret = -errno; + } + + return ret; +} + +long inet_connect (long addr, long port, long tout_sec) +{ + long fh = -1; + + if ( tpl && use_sting) + { + long alrm = Psignal (14/*SIGALRM*/, (long)sig_alrm); + if (alrm >= 0) { + timeout = FALSE; + Talarm (tout_sec); + } + if ((fh = TCP_open (addr, (int16)port, 0, 1024)) < 0) { + fh = -( fh == -1001L ? ETIMEDOUT : 1); + } + if (alrm >= 0) { + Talarm (0); + Psignal (14/*SIGALRM*/, alrm); + } + } + else + { + struct sockaddr_in s_in; + s_in.sin_family = AF_INET; + s_in.sin_port = htons ((short)port); + s_in.sin_addr = *(struct in_addr *)&addr; + if ((fh = socket( PF_INET, SOCK_STREAM, 0)) < 0) { + fh = -errno; + } else { + long alrm = Psignal (14/*SIGALRM*/, (long)sig_alrm); + if (alrm >= 0) { + timeout = FALSE; + Talarm (tout_sec); + } + if (connect (fh, (struct sockaddr *)&s_in, sizeof (s_in)) < 0) { + close (fh); + fh = -( timeout && errno == EINTR ? ETIMEDOUT : errno); + } + if (alrm >= 0) { + Talarm (0); + Psignal (14/*SIGALRM*/, alrm); + } + } + } + + return fh; +} + + +long inet_send( long fh, const char * buf, size_t len) +{ + long ret = -1; + + + if ( tpl && use_sting) + { + if ((ret = TCP_send ((int16)fh, (char*)buf, (int16)len)) == 0) + ret = len; + } + else + ret = Fwrite( fh, len, buf); + + return ret; +} + +long inet_recv (long fh, char *buf, size_t len) +{ + long ret = 0; + + if ( tpl && use_sting) + { + while (len) + { + short n = CNbyte_count ((int16)fh); + + if (n < E_NODATA) + { + if ( !ret) ret = (n == E_EOF || n == E_RRESET ? -316 : -1); + break; + } + else if (n > 0) + { + if (n > len) n = len; + if ((n = CNget_block ((int16)fh, buf, n)) < 0) + { + if (!ret) ret = -1; + break; + } + else + { + ret += n; + buf += n; + len -= n; + } + } else break; + + } + } + else + { + while (len) + { + long n = Finstat (fh); + if (n < 0) { + if (!ret) ret = n; + break; + } else if (n == 0x7FFFFFFF) { /* connection closed */ + if ( !ret) ret = -316; + break; + } else if (n && (n = Fread (fh, ( n < len ? n : len), buf)) < 0) { + if (!ret) ret = -errno; + break; + } else if (n) { + ret += n; + buf += n; + len -= n; + } else break; + } + } + return ret; +} + diff --git a/sources/z-tools/tags/zweather-1.2/zweather/inet.h b/sources/z-tools/tags/zweather-1.2/zweather/inet.h new file mode 100644 index 0000000..e8953d6 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/inet.h @@ -0,0 +1,6 @@ +extern void inet_close (long fh); +extern short inet_host_addr (const char * name, long * addr); +extern long inet_connect (long addr, long port, long tout_sec); +extern long inet_send( long fh, const char * buf, size_t len); +extern long inet_recv (long fh, char *buf, size_t len); + diff --git a/sources/z-tools/tags/zweather-1.2/zweather/main.c b/sources/z-tools/tags/zweather-1.2/zweather/main.c new file mode 100644 index 0000000..c474107 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/main.c @@ -0,0 +1,248 @@ +#include "general.h" +#include "http_client.h" +#include "parsers.h" +#include "icon.h" +#include "get_data.h" + +static clock_t chrono_value; +struct xml_weather *zweatherdata = NULL; + +extern void init_stik (void); +extern void weather_dialog( void); +extern int8 wind_direction[8]; +extern int8 icon_temp[8]; + + +struct xml_weather *update_weatherdata( int8 *location) +{ + OBJECT *weather_form = get_tree( WEATHER); + xmlNode *cur_node = NULL; + xmlDoc *doc = NULL; + struct xml_weather *weather = NULL; + struct stat attrs; + int icon_to_draw; + int8 fullfilename[256], url[1024]; + + sprintf( fullfilename, "cache\\%s.xml", location); + sprintf( url, "/weather/local/%s?cc=*&dayf=%d&unit=%c", location, XML_WEATHER_DAYF_N, unit == WEATHER_METRIC ? 'm' : 's'); + strcat( url, "&link=xoap&prod=xoap&par=1160181056&key=1031965b2f676b1b" ); + + if( !http_get_file( url, "xoap.weather.com", fullfilename)) + return NULL; + + stat( fullfilename, &attrs); + + if( attrs.st_size < 1024) + { + errshow( "", BADDATA); + return NULL; + } + + if( !( doc = xmlParseFile( fullfilename))) + return NULL; + + cur_node = xmlDocGetRootElement( doc); + + if( cur_node) + { + const int8 *sTmp; + + weather = parse_weather( cur_node); + + sprintf( weather_form[WEATHER_REPORT].ob_spec.tedinfo->te_ptext, "%s", get_data(weather, DNAM)); + sprintf( weather_form[WEATHER_TIME].ob_spec.tedinfo->te_ptext, "Last update: %s", get_data(weather, LSUP)); + sprintf( weather_form[WEATHER_TEMP].ob_spec.tedinfo->te_ptext, "%s%s", get_data(weather, TEMP), get_unit(unit, TEMP)); + sprintf( weather_form[WEATHER_FEEL].ob_spec.tedinfo->te_ptext, "%s%s", get_data(weather, FLIK), get_unit(unit, FLIK)); + zstrncpy( weather_form[WEATHER_DESCRIPTION].ob_spec.tedinfo->te_ptext, get_data(weather, TRANS), 26L); + sprintf( weather_form[WEATHER_DEW].ob_spec.tedinfo->te_ptext, "%s%s", get_data(weather, DEWP), get_unit(unit, DEWP)); + sprintf( weather_form[WEATHER_WSPEED].ob_spec.tedinfo->te_ptext, "%s %s", get_data(weather, WIND_SPEED), get_unit(unit, WIND_SPEED)); + + sprintf( weather_form[WEATHER_SUNRISE].ob_spec.tedinfo->te_ptext, "%s", get_data(weather, SUNR)); + sprintf( weather_form[WEATHER_SUNSET].ob_spec.tedinfo->te_ptext, "%s", get_data(weather, SUNS)); + sprintf( weather_form[WEATHER_UV].ob_spec.tedinfo->te_ptext, "%s %s", get_data(weather, UV_INDEX), get_data(weather, UV_TRANS)); + sprintf( weather_form[WEATHER_HUMIDITY].ob_spec.tedinfo->te_ptext, "%s%s", get_data(weather, HMID), get_unit(unit, HMID)); + sprintf( weather_form[WEATHER_VISIBILITY].ob_spec.tedinfo->te_ptext, "%s", get_data(weather, VIS)); + sprintf( weather_form[WEATHER_PRESSURE].ob_spec.tedinfo->te_ptext, "%s %s and %s.", get_data(weather, BAR_R), get_unit(unit, BAR_R), get_data(weather, BAR_D)); + + sprintf( ObjcString( weather_form, WEATHER_FORECAST1, NULL), " %s ", get_data_f(weather->dayf[0], WDAY)); + // today data may be outdated afternoon + sTmp = get_data_f(weather->dayf[0], TEMP_MAX); + strcpy( weather_form[WEATHER_DAY1].ob_spec.tedinfo->te_ptext, sTmp); + if( strcmp( sTmp, "N/A") != 0) + { + strcat( weather_form[WEATHER_DAY1].ob_spec.tedinfo->te_ptext, get_unit(unit, TEMP)); + } + sTmp = get_data_f(weather->dayf[0], TEMP_MIN); + strcpy( weather_form[WEATHER_NIGHT1].ob_spec.tedinfo->te_ptext, sTmp); + if( strcmp( sTmp, "N/A") != 0) + { + strcat( weather_form[WEATHER_NIGHT1].ob_spec.tedinfo->te_ptext, get_unit(unit, TEMP)); + } + sTmp = get_data_f(weather->dayf[0], W_SPEED_D); + strcpy( weather_form[WEATHER_WIND1].ob_spec.tedinfo->te_ptext, sTmp); + if( strcmp( sTmp, "N/A") != 0) + { + strcat( weather_form[WEATHER_WIND1].ob_spec.tedinfo->te_ptext, " "); + strcat( weather_form[WEATHER_WIND1].ob_spec.tedinfo->te_ptext, get_unit(unit, WIND_SPEED)); + } + zstrncpy( weather_form[WEATHER_DESCRIPTION1].ob_spec.tedinfo->te_ptext, get_data_f(weather->dayf[0], TRANS_D), 18L); + + sprintf( ObjcString( weather_form, WEATHER_FORECAST2, NULL), " %s ", get_data_f(weather->dayf[1], WDAY)); + sprintf( weather_form[WEATHER_DAY2].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[1], TEMP_MAX), get_unit(unit, TEMP)); + sprintf( weather_form[WEATHER_NIGHT2].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[1], TEMP_MIN), get_unit(unit, TEMP)); + sprintf( weather_form[WEATHER_WIND2].ob_spec.tedinfo->te_ptext, "%s %s",get_data_f(weather->dayf[1], W_SPEED_D), get_unit(unit, WIND_SPEED)); + zstrncpy( weather_form[WEATHER_DESCRIPTION2].ob_spec.tedinfo->te_ptext, get_data_f(weather->dayf[1], TRANS_D), 18L); + + sprintf( ObjcString( weather_form, WEATHER_FORECAST3, NULL), " %s ", get_data_f(weather->dayf[2], WDAY)); + sprintf( weather_form[WEATHER_DAY3].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[2], TEMP_MAX), get_unit(unit, TEMP)); + sprintf( weather_form[WEATHER_NIGHT3].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[2], TEMP_MIN), get_unit(unit, TEMP)); + sprintf( weather_form[WEATHER_WIND3].ob_spec.tedinfo->te_ptext, "%s %s",get_data_f(weather->dayf[2], W_SPEED_D), get_unit(unit, WIND_SPEED)); + zstrncpy( weather_form[WEATHER_DESCRIPTION3].ob_spec.tedinfo->te_ptext, get_data_f(weather->dayf[2], TRANS_D), 18L); + + sprintf( ObjcString( weather_form, WEATHER_FORECAST4, NULL), " %s ", get_data_f(weather->dayf[3], WDAY)); + sprintf( weather_form[WEATHER_DAY4].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[3], TEMP_MAX), get_unit(unit, TEMP)); + sprintf( weather_form[WEATHER_NIGHT4].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[3], TEMP_MIN), get_unit(unit, TEMP)); + sprintf( weather_form[WEATHER_WIND4].ob_spec.tedinfo->te_ptext, "%s %s",get_data_f(weather->dayf[3], W_SPEED_D), get_unit(unit, WIND_SPEED)); + zstrncpy( weather_form[WEATHER_DESCRIPTION4].ob_spec.tedinfo->te_ptext, get_data_f(weather->dayf[3], TRANS_D), 18L); + + sprintf( ObjcString( weather_form, WEATHER_FORECAST5, NULL), " %s ", get_data_f(weather->dayf[4], WDAY)); + sprintf( weather_form[WEATHER_DAY5].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[4], TEMP_MAX), get_unit(unit, TEMP)); + sprintf( weather_form[WEATHER_NIGHT5].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[4], TEMP_MIN), get_unit(unit, TEMP)); + sprintf( weather_form[WEATHER_WIND5].ob_spec.tedinfo->te_ptext, "%s %s",get_data_f(weather->dayf[4], W_SPEED_D), get_unit(unit, WIND_SPEED)); + zstrncpy( weather_form[WEATHER_DESCRIPTION5].ob_spec.tedinfo->te_ptext, get_data_f(weather->dayf[4], TRANS_D), 18L); + + zstrncpy( weather_form[WEATHER_LINK1].ob_spec.tedinfo->te_ptext, get_lnks(weather->lnks, TEXT, 0), 20L); + zstrncpy( weather_form[WEATHER_LINK2].ob_spec.tedinfo->te_ptext, get_lnks(weather->lnks, TEXT, 1), 20L); + zstrncpy( weather_form[WEATHER_LINK3].ob_spec.tedinfo->te_ptext, get_lnks(weather->lnks, TEXT, 2), 20L); + zstrncpy( weather_form[WEATHER_LINK4].ob_spec.tedinfo->te_ptext, get_lnks(weather->lnks, TEXT, 3), 20L); + + icon_to_draw = atoi( ( const char*)get_data(weather, WICON)); + main_icon = icons[icon_to_draw]; + + icon_to_draw = atoi( ( const char*)get_data_f(weather->dayf[0], ICON_D)); + forecast_icon[0] = icons[icon_to_draw]; + + icon_to_draw = atoi( ( const char*)get_data_f(weather->dayf[1], ICON_D)); + forecast_icon[1] = icons[icon_to_draw]; + + icon_to_draw = atoi( ( const char*)get_data_f(weather->dayf[2], ICON_D)); + forecast_icon[2] = icons[icon_to_draw]; + + icon_to_draw = atoi( ( const char*)get_data_f(weather->dayf[3], ICON_D)); + forecast_icon[3] = icons[icon_to_draw]; + + icon_to_draw = atoi( ( const char*)get_data_f(weather->dayf[4], ICON_D)); + forecast_icon[4] = icons[icon_to_draw]; + + sprintf( icon_temp, "%sø", get_data( weather, TEMP)); + sprintf( wind_direction, "%s", get_data( weather, WIND_DIRECTION)); + } + + xmlFreeDoc( doc); + + return weather; +} + +void timer_function( WINDOW *win) +{ + #ifdef DEBUG + char tmp[15]; + struct tm *tmt; + time_t tim; + #endif + + clock_t current_t = clock(); + clock_t relative_t; + + relative_t = current_t - chrono_value; + + if( relative_t < update_time) + return; + + chrono_value = current_t; + + #ifdef DEBUG + tim = time( NULL); + tmt = localtime( &tim); + strftime( tmp, 12, "%H:%M:%S", tmt); + zdebug( "update: %s", tmp); + #endif + + if( zweatherdata) + xml_weather_free( zweatherdata); + + zweatherdata = update_weatherdata( location_code); + + if( windialog) + snd_rdw( windialog); +} + +void applexit( void) +{ + if( EvntFind( NULL, WM_XTIMER)) + EvntDelete( NULL, WM_XTIMER); + + while( wglb.first) + { + snd_msg( wglb.first, WM_DESTROY, 0, 0, 0, 0); + EvntWindom( MU_MESAG); + } + + if( zweatherdata) + xml_weather_free( zweatherdata); + + prefs_write(); + unregister_icons(); + RsrcXtype( 0, NULL, 0); + RsrcFree(); + xmlCleanupParser(); + ApplExit(); + exit( 0); +} + + +int main( int argc, char *argv[]) +{ + ApplInit(); + + if( !RsrcLoad( "zweather.rsc")) + { + errshow( "", E_RSC); + ApplExit(); + return 0; + } + + RsrcXtype( RSRC_XTYPE, NULL, 0); + + if( !register_icons()) + { + errshow( "", NOZCODECS); + unregister_icons(); + RsrcXtype( 0, NULL, 0); + RsrcFree(); + ApplExit(); + return 0; + } + + prefs_read(); + + if( use_sting) + init_stik(); + + zweatherdata = update_weatherdata( location_code); + + evnt.timer = 1000L; + + weather_dialog(); + + chrono_value = clock(); + EvntAttach( NULL, WM_XTIMER, timer_function); + EvntAttach( NULL, AP_TERM, applexit); + + for(;;) + EvntWindom( MU_MESAG|MU_TIMER|MU_KEYBD|MU_BUTTON); + + applexit(); + return 0; +} + diff --git a/sources/z-tools/tags/zweather-1.2/zweather/parsers.c b/sources/z-tools/tags/zweather-1.2/zweather/parsers.c new file mode 100644 index 0000000..903755f --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/parsers.c @@ -0,0 +1,391 @@ +#include "general.h" +#include "parsers.h" + +struct xml_weather *parse_weather( xmlNode *cur_node) +{ + struct xml_weather *ret; + + if( !NODE_IS_TYPE(cur_node, "weather")) + return NULL; + + if(( ret = malloc( sizeof( struct xml_weather))) == NULL) + return NULL; + + for( cur_node = cur_node->children; cur_node; cur_node = cur_node->next) + { + if(cur_node->type != XML_ELEMENT_NODE) + continue; + + if( NODE_IS_TYPE( cur_node, "cc")) + ret->cc = parse_cc(cur_node); + else if( NODE_IS_TYPE(cur_node, "loc")) + ret->loc = parse_loc(cur_node); + else if( NODE_IS_TYPE(cur_node, "lnks")) + ret->lnks = parse_lnks(cur_node); + else if( NODE_IS_TYPE(cur_node, "dayf")) + { + xmlNode *child_node; + int i = 0; + + for( child_node = cur_node->children; child_node; child_node = child_node->next) + { + if( NODE_IS_TYPE(child_node, "day")) + { + if( i >= XML_WEATHER_DAYF_N) + break; + + ret->dayf[i] = parse_dayf( child_node); + i++; + } + } + } + } + + return ret; +} + +struct xml_loc *parse_loc(xmlNode *cur_node) +{ + struct xml_loc *ret; + + if(( ret = malloc( sizeof( struct xml_loc))) == NULL) + return NULL; + + for( cur_node = cur_node->children; cur_node; cur_node = cur_node->next) + { + if( cur_node->type != XML_ELEMENT_NODE) + continue; + + if( NODE_IS_TYPE(cur_node, "dnam")) + ret->dnam = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "sunr")) + ret->sunr = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "suns")) + ret->suns = DATA(cur_node); + } + + return ret; +} + +struct xml_lnks *parse_lnks(xmlNode *cur_node) +{ + struct xml_lnks *ret; + int i = 0; + + if ((ret = malloc( sizeof(struct xml_lnks))) == NULL) + return NULL; + + for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next) + { + if (cur_node->type != XML_ELEMENT_NODE) + continue; + + if (NODE_IS_TYPE(cur_node, "link")) + { + xmlNode *child_node; + + if( i >= XML_WEATHER_LINK_N) + break; + + for( child_node = cur_node->children; child_node; child_node = child_node->next) + { + if (NODE_IS_TYPE(child_node, "l")) + { + ret->l[i] = DATA(child_node); + } + else if (NODE_IS_TYPE(child_node, "t")) + { + ret->t[i] = DATA(child_node); + } + } + + i++; + } + } + + return ret; +} + +struct xml_uv *parse_uv (xmlNode *cur_node) +{ + struct xml_uv *ret; + + if(( ret = malloc( sizeof( struct xml_uv))) == NULL) + return NULL; + + for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next) + { + if (cur_node->type != XML_ELEMENT_NODE) + continue; + + if (NODE_IS_TYPE(cur_node, "i")) + ret->i = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "t")) + ret->t = DATA(cur_node); + } + return ret; +} + +struct xml_bar *parse_bar (xmlNode *cur_node) +{ + struct xml_bar *ret; + + if ((ret = malloc(sizeof( struct xml_bar))) == NULL) + return NULL; + + for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next) + { + if (cur_node->type != XML_ELEMENT_NODE) + continue; + + if (NODE_IS_TYPE(cur_node, "r")) + ret->r = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "d")) + ret->d = DATA(cur_node); + } + return ret; +} + +struct xml_wind *parse_wind (xmlNode *cur_node) +{ + struct xml_wind *ret; + + if ((ret = malloc(sizeof( struct xml_wind))) == NULL) + return NULL; + + for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next) + { + if (cur_node->type != XML_ELEMENT_NODE) + continue; + + if (NODE_IS_TYPE(cur_node, "s")) + ret->s = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "gust")) + ret->gust = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "d")) + ret->d = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "t")) + ret->t = DATA(cur_node); + } + return ret; +} + +struct xml_cc *parse_cc(xmlNode *cur_node) +{ + struct xml_cc *ret; + + if ((ret = malloc( sizeof(struct xml_cc))) == NULL) + return NULL; + + for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next) + { + if (cur_node->type != XML_ELEMENT_NODE) + continue; + + if (NODE_IS_TYPE(cur_node, "tmp")) + ret->tmp = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "icon")) + ret->icon = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "t")) + ret->t = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "flik")) + ret->flik = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "bar")) + ret->bar = parse_bar(cur_node); + else if (NODE_IS_TYPE(cur_node, "wind")) + ret->wind = parse_wind(cur_node); + else if (NODE_IS_TYPE(cur_node, "hmid")) + ret->hmid = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "vis")) + ret->vis = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "uv")) + ret->uv = parse_uv(cur_node); + else if (NODE_IS_TYPE(cur_node, "dewp")) + ret->dewp = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "lsup")) + ret->lsup = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "obst")) + ret->obst = DATA(cur_node); + } + return ret; +} + +struct xml_part *parse_part(xmlNode *cur_node) +{ + struct xml_part *ret; + + if (( ret = malloc( sizeof( struct xml_part))) == NULL) + return NULL; + + for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next) + { + if (cur_node->type != XML_ELEMENT_NODE) + continue; + + if (NODE_IS_TYPE(cur_node, "icon")) + ret->icon = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "t")) + ret->t = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "wind")) + ret->wind = parse_wind(cur_node); + else if (NODE_IS_TYPE(cur_node, "ppcp")) + ret->ppcp = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "hmid")) + ret->hmid = DATA(cur_node); + } + + return ret; +} + + + +struct xml_dayf *parse_dayf(xmlNode *cur_node) +{ + struct xml_dayf *ret; + int8 *value; + + if ((ret = malloc(sizeof(struct xml_dayf))) == NULL) + return NULL; + + ret->day = xmlGetProp (cur_node, (const xmlChar *) "t"); + ret->date = xmlGetProp (cur_node, (const xmlChar *) "dt"); + + for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next) + { + if (cur_node->type != XML_ELEMENT_NODE) + continue; + + if (NODE_IS_TYPE(cur_node, "hi")) + ret->hi = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "low")) + ret->low = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "part")) + { + value = xmlGetProp (cur_node, (const xmlChar *) "p"); + + if (xmlStrEqual ((const xmlChar *)value, "d")) + ret->part[0] = parse_part(cur_node); + else if (xmlStrEqual ((const xmlChar *)value, "n")) + ret->part[1] = parse_part(cur_node); + + free(value); + } + } + return ret; +} + +#define CHK_FREE(this) if (this) free(this); + +void xml_uv_free(struct xml_uv *data) +{ + CHK_FREE(data->i); + CHK_FREE(data->t); +} + +void xml_wind_free(struct xml_wind *data) +{ + CHK_FREE(data->s); + CHK_FREE(data->gust); + CHK_FREE(data->d); + CHK_FREE(data->t); +} + +void xml_bar_free(struct xml_bar *data) +{ + CHK_FREE(data->r); + CHK_FREE(data->d); +} + +void xml_cc_free(struct xml_cc *data) +{ + CHK_FREE(data->obst); + CHK_FREE(data->lsup); + CHK_FREE(data->flik); + CHK_FREE(data->t); + CHK_FREE(data->icon); + CHK_FREE(data->tmp); + CHK_FREE(data->hmid); + CHK_FREE(data->vis); + CHK_FREE(data->dewp); + + if (data->uv) + xml_uv_free(data->uv); + + if (data->wind) + xml_wind_free(data->wind); + + if (data->bar) + xml_bar_free(data->bar); +} + +void xml_loc_free(struct xml_loc *data) +{ + CHK_FREE(data->dnam); + CHK_FREE(data->sunr); + CHK_FREE(data->suns); +} + +void xml_part_free(struct xml_part *data) +{ + if( !data) + return; + + CHK_FREE(data->icon); + CHK_FREE(data->t); + CHK_FREE(data->ppcp); + CHK_FREE(data->hmid); + + if (data->wind) + xml_wind_free(data->wind); +} + +void xml_dayf_free(struct xml_dayf *data) +{ + if (!data) + return; + + CHK_FREE(data->day); + CHK_FREE(data->date); + CHK_FREE(data->hi); + CHK_FREE(data->low); + + if (data->part[0]) + xml_part_free(data->part[0]); + + if (data->part[1]) + xml_part_free(data->part[1]); +} + +void xml_weather_free(struct xml_weather *data) +{ + if (data->cc) + xml_cc_free( data->cc); + + if (data->loc) + xml_loc_free( data->loc); + + if( data->lnks) + { + int i; + for (i = 0; i < XML_WEATHER_LINK_N; i++) + { + CHK_FREE(data->lnks->l[i]); + CHK_FREE(data->lnks->t[i]); + } + + } + + if (data->dayf) + { + int i; + for (i = 0; i < XML_WEATHER_DAYF_N; i++) + { + if (!data->dayf[i]) + break; + + xml_dayf_free(data->dayf[i]); + } + } + + free(data); +} diff --git a/sources/z-tools/tags/zweather-1.2/zweather/parsers.h b/sources/z-tools/tags/zweather-1.2/zweather/parsers.h new file mode 100644 index 0000000..0d50688 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/parsers.h @@ -0,0 +1,99 @@ +#ifndef PARSERS_H +#define PARSERS_H + +#define DATA(node) xmlNodeListGetString(node->doc, node->children, 1) +#define NODE_IS_TYPE(node, type) xmlStrEqual (node->name, (const xmlChar *) type) + + +#define XML_WEATHER_DAYF_N 5 +#define XML_WEATHER_LINK_N 4 + +struct xml_weather +{ + struct xml_loc *loc; + struct xml_lnks *lnks; + struct xml_cc *cc; + struct xml_dayf *dayf[XML_WEATHER_DAYF_N]; +}; + +struct xml_loc +{ + int8 *dnam; + int8 *sunr; + int8 *suns; +}; + +struct xml_lnks +{ + int8 *l[XML_WEATHER_LINK_N]; + int8 *t[XML_WEATHER_LINK_N]; +}; + +struct xml_uv +{ + int8 *i; + int8 *t; +}; + +struct xml_wind +{ + int8 *s; + int8 *gust; + int8 *d; + int8 *t; +}; + +struct xml_bar +{ + int8 *r; + int8 *d; +}; + +struct xml_cc +{ + int8 *lsup; + int8 *obst; + int8 *flik; + int8 *t; + int8 *icon; + int8 *tmp; + + int8 *hmid; + int8 *vis; + + struct xml_uv *uv; + struct xml_wind *wind; + struct xml_bar *bar; + + int8 *dewp; +}; + +struct xml_part +{ + int8 *icon; + int8 *t; + int8 *ppcp; + int8 *hmid; + + struct xml_wind *wind; +}; + +struct xml_dayf +{ + int8 *day; + int8 *date; + + int8 *hi; + int8 *low; + + struct xml_part *part[2]; +}; + +struct xml_weather *parse_weather(xmlNode *cur_node); +struct xml_loc *parse_loc(xmlNode *cur_node); +struct xml_lnks *parse_lnks(xmlNode *cur_node); +struct xml_cc *parse_cc(xmlNode *cur_node); +struct xml_dayf *parse_dayf(xmlNode *cur_node); + +void xml_weather_free(struct xml_weather *); +#endif diff --git a/sources/z-tools/tags/zweather-1.2/zweather/prefs.c b/sources/z-tools/tags/zweather-1.2/zweather/prefs.c new file mode 100644 index 0000000..8c7d960 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/prefs.c @@ -0,0 +1,170 @@ +#include "general.h" + +int unit = WEATHER_METRIC; +int iconify_at_start = 1; +int use_sting = 0; +char location_code[9] = "BEXX0006"; +clock_t update_time = 360000L; + +/* Prototype */ +int prefs_read( void); +int prefs_write( void); + + +/*==================================================================================* + * prefs_read: * + * Reads the content of the INF file an put it in the preference global variables. * + *----------------------------------------------------------------------------------* + * returns: 0 if error * + *==================================================================================*/ +int prefs_read( void) +{ + char filename[256] = ""; + char unknown_s[256] = ""; + FILE *inffile; + int time_minute; + int32 filepos; + char *env_home; + int16 len; + boolean valid_entry_found; + + + shel_envrn( &env_home, "HOME="); + + /* Home directory exist? */ + if ( env_home != NULL) + { + strcpy( filename, env_home); + len = ( int16)strlen( filename); + + if ((filename[len - 1] != '\\') && (filename[len - 1] != '/')) + { + strcat( filename, "\\"); + } + + strcat( filename, "zweather.inf"); + + if (( inffile = fopen( filename, "rb+")) != NULL) + goto loop; + + } + + /* With ftell, we MUST open the file in binary mode and not in text mode !!! */ + if (( inffile = fopen( "zweather.inf", "rb+")) == NULL) + return( 0); + +loop: + + do + { + valid_entry_found = FALSE; + + filepos = ftell( inffile); + + if ( fscanf( inffile, "unit=%d ", &unit) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if (fscanf( inffile, "iconify_at_start=%d ", &iconify_at_start) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "update_time=%d ", &time_minute) == 1) + { + update_time = ( clock_t)( ( int32)time_minute * 12000L); + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "location_code=%s ", location_code) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if (fscanf( inffile, "use_sting=%d ", &use_sting) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "%s ", unknown_s) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + + } while ( valid_entry_found); + + fclose( inffile); + + return( 1); +} + + + +/*==================================================================================* + * prefs_write: * + * Writes the preference variables in the preference file. * + *----------------------------------------------------------------------------------* + * returns: 0 if error * + *==================================================================================*/ +int prefs_write( void) +{ + char filename[256] = ""; + FILE *inffile; + char *env_home; + int time_minute; + int16 len; + + shel_envrn( &env_home, "HOME="); + + /* Home directory exist? */ + if ( env_home) + { + strcpy( filename, env_home); + + len = ( int16)strlen( filename); + + if ((filename[len - 1] != '\\') && (filename[len - 1] != '/')) + strcat( filename, "\\"); + + strcat( filename, "zweather.inf"); + } + else + strcpy( filename, "zweather.inf"); + + + /* With ftell, we MUST open the file in binary mode and not in text mode !!! */ + if (( inffile = fopen( filename, "wb+")) == NULL) + return( 0); + + + time_minute = ( int)( update_time / 12000L); + + fprintf( inffile, "unit=%d\r\n", unit); + fprintf( inffile, "iconify_at_start=%d\r\n", iconify_at_start); + fprintf( inffile, "update_time=%d\r\n", time_minute); + fprintf( inffile, "location_code=%s\r\n", location_code); + fprintf( inffile, "use_sting=%d\r\n", use_sting); + fclose( inffile); + + return( 1); +} diff --git a/sources/z-tools/tags/zweather-1.2/zweather/prefs.h b/sources/z-tools/tags/zweather-1.2/zweather/prefs.h new file mode 100644 index 0000000..f485b72 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/prefs.h @@ -0,0 +1,12 @@ +/* Global variable */ +extern int unit; +extern int iconify_at_start; +extern int use_sting; +extern char location_code[9]; +extern clock_t update_time; + +/* Function */ +extern int prefs_read( void); +extern int prefs_write( void); + + diff --git a/sources/z-tools/tags/zweather-1.2/zweather/zaes.c b/sources/z-tools/tags/zweather-1.2/zweather/zaes.c new file mode 100644 index 0000000..73ca0ca --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/zaes.c @@ -0,0 +1,293 @@ +#include "general.h" +#include "icon.h" +#include "get_data.h" + +/* the variable need to be global because this function is done by */ +/* the AES in supervisor mode.. it's safe. */ +static int16 xy[8]; +static MFDB screen = {0}; +int8 wind_direction[8] = ""; +extern struct xml_weather *zweatherdata; + +void generic_form_event( WINDOW *win) +{ + ObjcChange( OC_FORM, win, evnt.buff[4], NORMAL, FALSE); + ApplWrite( app.id, WM_CLOSED, win->handle, 0, 0, 0, 0); +} + + +OBJECT *get_tree( int16 obj_index) +{ + OBJECT *tree; + RsrcGaddr( NULL, 0, obj_index, &tree); + return tree; +} + + +/* Return a string from resource file */ + +int8 *get_string( int16 str_index) +{ + int8 *txt; + rsrc_gaddr( 5, str_index, &txt); + return txt; +} + +void CDECL draw_boussole_icon( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = xy[1] = 0; + xy[2] = 47; + xy[3] = 47; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 47; + xy[7] = xy[5] + 47; + + vro_cpyfm( win->graf.handle, S_ONLY, xy, &boussole->image[0], &screen); + + xy[2] = pblk->pb_x + 23; + xy[3] = pblk->pb_y + 23; + + switch( wind_direction[0]) + { + case 'N': + if( strcmp( wind_direction, "NNE") == 0) + { + xy[0] = pblk->pb_x + 27; + xy[1] = pblk->pb_y + 9; + break; + } + + if( strcmp( wind_direction, "NNW") == 0) + { + xy[0] = pblk->pb_x + 18; + xy[1] = pblk->pb_y + 9; + break; + } + + if( strcmp( wind_direction, "NW") == 0) + { + xy[0] = pblk->pb_x + 12; + xy[1] = pblk->pb_y + 12; + break; + } + + if( strcmp( wind_direction, "NE") == 0) + { + xy[0] = pblk->pb_x + 34; + xy[1] = pblk->pb_y + 12; + break; + } + + /* default 'N'*/ + xy[0] = pblk->pb_x + 23; + xy[1] = pblk->pb_y + 8; + break; + + case 'E': + if( strcmp( wind_direction, "ENE") == 0) + { + xy[0] = pblk->pb_x + 36; + xy[1] = pblk->pb_y + 17; + break; + } + + if( strcmp( wind_direction, "ESE") == 0) + { + xy[0] = pblk->pb_x + 36; + xy[1] = pblk->pb_y + 28; + break; + } + + /* default 'E'*/ + xy[0] = pblk->pb_x + 38; + xy[1] = pblk->pb_y + 23; + break; + + case 'W': + if( strcmp( wind_direction, "WSW") == 0) + { + xy[0] = pblk->pb_x + 9; + xy[1] = pblk->pb_y + 28; + break; + } + + if( strcmp( wind_direction, "WNW") == 0) + { + xy[0] = pblk->pb_x + 9; + xy[1] = pblk->pb_y + 17; + break; + } + + /* default 'W'*/ + xy[0] = pblk->pb_x + 8; + xy[1] = pblk->pb_y + 23; + break; + + case 'S': + if( strcmp( wind_direction, "SSE") == 0) + { + xy[0] = pblk->pb_x + 28; + xy[1] = pblk->pb_y + 36; + break; + } + + if( strcmp( wind_direction, "SSW") == 0) + { + xy[0] = pblk->pb_x + 18; + xy[1] = pblk->pb_y + 36; + break; + } + + if( strcmp( wind_direction, "SW") == 0) + { + xy[0] = pblk->pb_x + 12; + xy[1] = pblk->pb_y + 33; + break; + } + + if( strcmp( wind_direction, "SE") == 0) + { + xy[0] = pblk->pb_x + 34; + xy[1] = pblk->pb_y + 33;; + break; + } + + default: + + /* default 'S'*/ + xy[0] = pblk->pb_x + 23; + xy[1] = pblk->pb_y + 38; + break; + } + + v_pline( win->graf.handle, 2, xy); +} + +void CDECL draw_weather_icon( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = xy[1] = 0; + xy[2] = 47; + xy[3] = 47; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 47; + xy[7] = xy[5] + 47; + + vro_cpyfm( win->graf.handle, S_ONLY, xy, &main_icon->image[0], &screen); +} + +void CDECL draw_forecast1_icon( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = xy[1] = 0; + xy[2] = 47; + xy[3] = 47; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 47; + xy[7] = xy[5] + 47; + + vro_cpyfm( win->graf.handle, S_ONLY, xy, &forecast_icon[0]->image[0], &screen); +} + + +void CDECL draw_forecast2_icon( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = xy[1] = 0; + xy[2] = 47; + xy[3] = 47; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 47; + xy[7] = xy[5] + 47; + + vro_cpyfm( win->graf.handle, S_ONLY, xy, &forecast_icon[1]->image[0], &screen); +} + +void CDECL draw_forecast3_icon( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = xy[1] = 0; + xy[2] = 47; + xy[3] = 47; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 47; + xy[7] = xy[5] + 47; + + vro_cpyfm( win->graf.handle, S_ONLY, xy, &forecast_icon[2]->image[0], &screen); +} + +void CDECL draw_forecast4_icon( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = xy[1] = 0; + xy[2] = 47; + xy[3] = 47; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 47; + xy[7] = xy[5] + 47; + + vro_cpyfm( win->graf.handle, S_ONLY, xy, &forecast_icon[3]->image[0], &screen); +} + +void CDECL draw_forecast5_icon( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = xy[1] = 0; + xy[2] = 47; + xy[3] = 47; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 47; + xy[7] = xy[5] + 47; + + vro_cpyfm( win->graf.handle, S_ONLY, xy, &forecast_icon[4]->image[0], &screen); +} + +void CDECL draw_forecast6_icon( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = xy[1] = 0; + xy[2] = 60; + xy[3] = 60; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 60; + xy[7] = xy[5] + 60; + + vro_cpyfm( win->graf.handle, S_ONLY, xy, &logo->image[0], &screen); +} + + + +void errshow( const char *name, int16 error) +{ + switch( error) + { + case ALERT_WINDOW: + ( void)FormAlert( 1 , get_string( ALERT_WINDOW)); + break; + case ENOMEM: + ( void)FormAlert( 1 , get_string( NOMEM)); + break; + case E_RSC: + ( void)FormAlert( 1 , "[1][zweather.rsc not found!][Abort]"); + break; + case CANT_LOAD_IMG: + ( void)FormAlert( 1 , get_string( CANT_LOAD_IMG), name); + break; + case NOZCODECS: + ( void)FormAlert( 1 , get_string( NOZCODECS)); + break; + case BADDATA: + ( void)FormAlert( 1 , get_string( BADDATA)); + break; + default: + ( void)FormAlert( 1 , get_string( GENERIC)); + break; + } +} + + + + + + diff --git a/sources/z-tools/tags/zweather-1.2/zweather/zaes.h b/sources/z-tools/tags/zweather-1.2/zweather/zaes.h new file mode 100644 index 0000000..0de9c12 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/zaes.h @@ -0,0 +1,13 @@ +extern OBJECT *get_tree( int16 obj_index); +extern int8 *get_string( int16 str_index); +extern void errshow( const char *name, int16 error); +extern void generic_form_event( WINDOW *win); + +extern void CDECL draw_weather_icon( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_forecast1_icon( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_forecast2_icon( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_forecast3_icon( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_forecast4_icon( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_forecast5_icon( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_forecast6_icon( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_boussole_icon( WINDOW *win, PARMBLK *pblk, void *data); diff --git a/sources/z-tools/tags/zweather-1.2/zweather/zstring.c b/sources/z-tools/tags/zweather-1.2/zweather/zstring.c new file mode 100644 index 0000000..67445d6 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/zstring.c @@ -0,0 +1,131 @@ +#include "general.h" + +extern int vasprintf( int8 **strp, const int8 *fmt, va_list ap); + + +char *zstrncpy( char *dst, const char *src, size_t n) +{ + register const char *source = src; + register char *dest = dst; + register size_t count = n; + + if( dest && !source && count) + *dest = '\0'; + else if( dest && source && (count >= 1)) + { + for( count--; count > 0 && *source != '\0'; count--) + *dest++ = *source++; + *dest = '\0'; + } + return dst; +} + +int8 *stpcpy( int8 *dest, const int8 *src) +{ + register int8 *d = dest; + register const int8 *s = src; + + if( dest == NULL || src == NULL) + return NULL; + + do + *d++ = *s; + while (*s++ != '\0'); + + return d - 1; +} + +int8 *strstr_len( const int8 *haystack, int32 haystack_len, const int8 *needle) +{ + if( haystack == NULL || needle == NULL) + return NULL; + + if (haystack_len < 0) + return strstr (haystack, needle); + else + { + const int8 *end, *p = haystack; + int32 i, needle_len = strlen ( needle); + + if (needle_len == 0) + return (int8 *)haystack; + + if (haystack_len < needle_len) + return NULL; + + end = haystack + haystack_len - needle_len; + + while (*p && p <= end) + { + for (i = 0; i < needle_len; i++) + + if (p[i] != needle[i]) + goto next; + + return (int8 *)p; + + next: + p++; + } + + return NULL; + } +} + + +int8 *strdup_printf( const int8 *format, ...) +{ + int8 *buffer; + int len; + va_list args; + + va_start( args, format); + + len = vasprintf( &buffer, format, args); + + if( len < 0) + buffer = NULL; + + va_end( args); + + return buffer; +} + + +int8* strconcat( const int8 *string1, ...) +{ + int32 l; + int8 *s, *concat, *ptr; + va_list args; + + if( !string1) + return NULL; + + l = 1 + strlen( string1); + va_start( args, string1); + s = va_arg( args, int8*); + + while( s) + { + l += strlen (s); + s = va_arg ( args, int8*); + } + va_end (args); + + concat = malloc( sizeof( int8) * l); + ptr = concat; + + ptr = stpcpy ( ptr, string1); + va_start (args, string1); + s = va_arg (args, int8*); + + while (s) + { + ptr = stpcpy( ptr, s); + s = va_arg (args, int8*); + } + va_end (args); + + return concat; +} + diff --git a/sources/z-tools/tags/zweather-1.2/zweather/zstring.h b/sources/z-tools/tags/zweather-1.2/zweather/zstring.h new file mode 100644 index 0000000..4535f57 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/zstring.h @@ -0,0 +1,6 @@ +extern int8 *stpcpy( int8 *dest, const int8 *src); +extern int8 *strstr_len( const int8 *haystack, int32 haystack_len, const int8 *needle); +extern int8 *strdup_printf( const int8 *format, ...); +extern int8 *strconcat( const int8 *string1, ...); +extern char *zstrncpy( char *dst, const char *src, size_t n); + diff --git a/sources/z-tools/tags/zweather-1.2/zweather/zweather.hrd b/sources/z-tools/tags/zweather-1.2/zweather/zweather.hrd new file mode 100644 index 0000000..a64d4e4 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/zweather.hrd differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/zweather.rsc b/sources/z-tools/tags/zweather-1.2/zweather/zweather.rsc new file mode 100644 index 0000000..57cbf49 Binary files /dev/null and b/sources/z-tools/tags/zweather-1.2/zweather/zweather.rsc differ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/zweather.rsh b/sources/z-tools/tags/zweather-1.2/zweather/zweather.rsh new file mode 100644 index 0000000..577533f --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/zweather.rsh @@ -0,0 +1,79 @@ + /* Resource C-Header-file v1.95 for ResourceMaster v2.06&up by ARDISOFT */ + +#define WEATHER 0 /* form/dial */ +#define WEATHER_PANEL3 1 /* BUTTON in tree WEATHER */ +#define WEATHER_CODE 2 /* FBOXTEXT in tree WEATHER */ +#define WEATHER_UPDATE_TIME 10 /* FBOXTEXT in tree WEATHER */ +#define WEATHER_METRIC 13 /* BUTTON in tree WEATHER */ +#define WEATHER_IMPERIAL 14 /* BUTTON in tree WEATHER */ +#define WEATHER_DATE 16 /* TEXT in tree WEATHER */ +#define WEATHER_STING 21 /* BUTTON in tree WEATHER */ +#define WEATHER_PANEL2 22 /* BUTTON in tree WEATHER */ +#define WEATHER_FORECAST1 23 /* BUTTON in tree WEATHER */ +#define WEATHER_DESCRIPTION1 24 /* TEXT in tree WEATHER */ +#define WEATHER_DAY1 25 /* TEXT in tree WEATHER */ +#define WEATHER_ICON1 26 /* BOX in tree WEATHER */ +#define WEATHER_NIGHT1 29 /* TEXT in tree WEATHER */ +#define WEATHER_WIND1 31 /* TEXT in tree WEATHER */ +#define WEATHER_FORECAST3 32 /* BUTTON in tree WEATHER */ +#define WEATHER_DESCRIPTION3 33 /* TEXT in tree WEATHER */ +#define WEATHER_DAY3 34 /* TEXT in tree WEATHER */ +#define WEATHER_ICON3 35 /* BOX in tree WEATHER */ +#define WEATHER_NIGHT3 38 /* TEXT in tree WEATHER */ +#define WEATHER_WIND3 40 /* TEXT in tree WEATHER */ +#define WEATHER_FORECAST5 41 /* BUTTON in tree WEATHER */ +#define WEATHER_DESCRIPTION5 42 /* TEXT in tree WEATHER */ +#define WEATHER_DAY5 43 /* TEXT in tree WEATHER */ +#define WEATHER_ICON5 44 /* BOX in tree WEATHER */ +#define WEATHER_NIGHT5 47 /* TEXT in tree WEATHER */ +#define WEATHER_WIND5 49 /* TEXT in tree WEATHER */ +#define WEATHER_FORECAST2 50 /* BUTTON in tree WEATHER */ +#define WEATHER_DESCRIPTION2 51 /* TEXT in tree WEATHER */ +#define WEATHER_DAY2 52 /* TEXT in tree WEATHER */ +#define WEATHER_ICON2 53 /* BOX in tree WEATHER */ +#define WEATHER_NIGHT2 56 /* TEXT in tree WEATHER */ +#define WEATHER_WIND2 58 /* TEXT in tree WEATHER */ +#define WEATHER_FORECAST4 59 /* BUTTON in tree WEATHER */ +#define WEATHER_DESCRIPTION4 60 /* TEXT in tree WEATHER */ +#define WEATHER_DAY4 61 /* TEXT in tree WEATHER */ +#define WEATHER_ICON4 62 /* BOX in tree WEATHER */ +#define WEATHER_NIGHT4 65 /* TEXT in tree WEATHER */ +#define WEATHER_WIND4 67 /* TEXT in tree WEATHER */ +#define WEATHER_ICON6 68 /* BOX in tree WEATHER */ +#define WEATHER_LINK1 69 /* TEXT in tree WEATHER */ +#define WEATHER_LINK2 70 /* TEXT in tree WEATHER */ +#define WEATHER_LINK3 71 /* TEXT in tree WEATHER */ +#define WEATHER_LINK4 72 /* TEXT in tree WEATHER */ +#define WEATHER_FORECAST 73 /* BUTTON in tree WEATHER */ +#define WEATHER_PREF 74 /* BUTTON in tree WEATHER */ +#define WEATHER_QUIT 75 /* BUTTON in tree WEATHER */ +#define WEATHER_PANEL1 76 /* BUTTON in tree WEATHER */ +#define WEATHER_DESCRIPTION 78 /* TEXT in tree WEATHER */ +#define WEATHER_TEMP 80 /* TEXT in tree WEATHER */ +#define WEATHER_FEEL 82 /* TEXT in tree WEATHER */ +#define WEATHER_DEW 84 /* TEXT in tree WEATHER */ +#define WEATHER_ICON 85 /* BOX in tree WEATHER */ +#define WEATHER_SUNSET 88 /* TEXT in tree WEATHER */ +#define WEATHER_SUNRISE 90 /* TEXT in tree WEATHER */ +#define WEATHER_UV 92 /* TEXT in tree WEATHER */ +#define WEATHER_PRESSURE 95 /* TEXT in tree WEATHER */ +#define WEATHER_WSPEED 97 /* TEXT in tree WEATHER */ +#define WEATHER_WICON 98 /* BOX in tree WEATHER */ +#define WEATHER_HUMIDITY 101 /* TEXT in tree WEATHER */ +#define WEATHER_VISIBILITY 103 /* TEXT in tree WEATHER */ +#define WEATHER_TIME 104 /* TEXT in tree WEATHER */ +#define WEATHER_REPORT 105 /* TEXT in tree WEATHER */ +#define WEATHER_MAIN 106 /* BUTTON in tree WEATHER */ +#define WEATHER_UPDATE 107 /* BUTTON in tree WEATHER */ + +#define NOMEM 0 /* Alert string */ + +#define ALERT_WINDOW 1 /* Alert string */ + +#define GENERIC 2 /* Alert string */ + +#define CANT_LOAD_IMG 3 /* Alert string */ + +#define NOZCODECS 4 /* Alert string */ + +#define BADDATA 5 /* Alert string */ diff --git a/sources/z-tools/tags/zweather-1.2/zweather/zweather.rsm b/sources/z-tools/tags/zweather-1.2/zweather/zweather.rsm new file mode 100644 index 0000000..487e4c2 --- /dev/null +++ b/sources/z-tools/tags/zweather-1.2/zweather/zweather.rsm @@ -0,0 +1,79 @@ +ResourceMaster v3.65 +#C 1@6@0@0@ +#N 99@32@AZAaza___ _@AZAaza090___ _@@_@ +#FoHRD@rsm2out@HRD@hrd@@@[HRD-File@0@ +#FoC-Header@rsm2out@C-Header@rsh@@@[C-Header@0@ +#R 0@0@3@1@4@1@ +#M 01010100@0@7728@719@ +#T 0@2@WEATHER@@109@@ +#O 1@26@PANEL3@@ +#O 2@30@CODE@@ +#O 10@30@UPDATE_TIME@@ +#O 13@26@METRIC@@ +#O 14@26@IMPERIAL@@ +#O 16@21@DATE@@ +#O 21@26@STING@@ +#O 22@26@PANEL2@@ +#O 23@26@FORECAST1@@ +#O 24@21@DESCRIPTION1@@ +#O 25@21@DAY1@@ +#O 26@20@ICON1@@ +#O 29@21@NIGHT1@@ +#O 31@21@WIND1@@ +#O 32@26@FORECAST3@@ +#O 33@21@DESCRIPTION3@@ +#O 34@21@DAY3@@ +#O 35@20@ICON3@@ +#O 38@21@NIGHT3@@ +#O 40@21@WIND3@@ +#O 41@26@FORECAST5@@ +#O 42@21@DESCRIPTION5@@ +#O 43@21@DAY5@@ +#O 44@20@ICON5@@ +#O 47@21@NIGHT5@@ +#O 49@21@WIND5@@ +#O 50@26@FORECAST2@@ +#O 51@21@DESCRIPTION2@@ +#O 52@21@DAY2@@ +#O 53@20@ICON2@@ +#O 56@21@NIGHT2@@ +#O 58@21@WIND2@@ +#O 59@26@FORECAST4@@ +#O 60@21@DESCRIPTION4@@ +#O 61@21@DAY4@@ +#O 62@20@ICON4@@ +#O 65@21@NIGHT4@@ +#O 67@21@WIND4@@ +#O 68@20@ICON6@@ +#O 69@21@LINK1@@ +#O 70@21@LINK2@@ +#O 71@21@LINK3@@ +#O 72@21@LINK4@@ +#O 73@26@FORECAST@@ +#O 74@26@PREF@@ +#O 75@26@QUIT@@ +#O 76@26@PANEL1@@ +#O 78@21@DESCRIPTION@@ +#O 80@21@TEMP@@ +#O 82@21@FEEL@@ +#O 84@21@DEW@@ +#O 85@20@ICON@@ +#O 88@21@SUNSET@@ +#O 90@21@SUNRISE@@ +#O 92@21@UV@@ +#O 95@21@PRESSURE@@ +#O 97@21@WSPEED@@ +#O 98@20@WICON@@ +#O 101@21@HUMIDITY@@ +#O 103@21@VISIBILITY@@ +#O 104@21@TIME@@ +#O 105@21@REPORT@@ +#O 106@26@MAIN@@ +#O 107@26@UPDATE@@ +#S 0@4@NOMEM@@ +#S 1@4@ALERT_WINDOW@@ +#S 2@4@GENERIC@@ +#S 3@4@CANT_LOAD_IMG@@ +#S 4@4@NOZCODECS@@ +#S 5@4@BADDATA@@ +#c 9210@ diff --git a/sources/z-tools/trunk/common.mak b/sources/z-tools/trunk/common.mak new file mode 100644 index 0000000..c8cd940 --- /dev/null +++ b/sources/z-tools/trunk/common.mak @@ -0,0 +1,43 @@ +CROSS = yes + +ifeq ($(CROSS),yes) +AS = m68k-atari-mint-as +CC = m68k-atari-mint-gcc +CXX = m68k-atari-mint-g++ +AR = m68k-atari-mint-ar +RANLIB = m68k-atari-mint-ranlib +STRIP = m68k-atari-mint-strip -s +STACK = m68k-atari-mint-stack +FLAGS = m68k-atari-mint-flags -r +else +AS = as +CC = gcc +CXX = g++ +AR = ar +RANLIB = ranlib +STRIP = strip -s +STACK = stack +FLAGS = flags -r +endif +COMPRESS = upx -9 + +CFLAGS += -Wno-pointer-sign +LDG_STARTUP_OBJ = /home/mikro/gnu-tools/m68k-atari-mint/lib/m68020-60/ldgstart.o + +all: $(PROGRAM) stack strip compress + +$(PROGRAM): $(OBJ) + $(CC) $(CPU) $(OPTIMISATION) -o $@ $(OBJ) $(LDFLAGS) $(LIB) + +strip: $(PROGRAM) + $(STRIP) $(PROGRAM) + +stack: $(PROGRAM) + $(STACK) -S $(STACKSIZE) $(PROGRAM) + +compress: $(PROGRAM) + $(COMPRESS) $(PROGRAM) + $(FLAGS) $(PROGRAM) + +clean: + rm -f $(filter-out $(LDG_STARTUP_OBJ),$(OBJ)) $(PROGRAM) *~ diff --git a/sources/z-tools/trunk/prerequisites.txt b/sources/z-tools/trunk/prerequisites.txt new file mode 100644 index 0000000..c4df3b7 --- /dev/null +++ b/sources/z-tools/trunk/prerequisites.txt @@ -0,0 +1,18 @@ +Current zTools are verified to work / compile with: + +- freetype 2.4.6 +- gemlib (latest from CVS) +- ldg (latest SVN plus fix for memory protection) +- libmem (same source as ldg) +- libshare 0.1.1 +- libxml 2.3.11 +- mintlib (latest CVS) +- pml 2.03 (from Vincent's gcc4 port) +- transprt.h (STiK/STinG header file, available from http://mikro.atari.org) +- windom 1.21.3 (plus fix for gcc4 and memory protection) [zView, current zWeather] +- windom (latest from CVS) [zTask, zWeather in future release] +- xpdf 3.03 +- zlib 1.2.5 + +Compiler used for development is gcc / g++ 4.6.x with binutils 2.21, CFLAGS +and CXXFLAGS for all components are '-m68060-20 -O2 -fomit-frame-pointer'. diff --git a/sources/z-tools/trunk/todo.txt b/sources/z-tools/trunk/todo.txt new file mode 100644 index 0000000..45addb7 --- /dev/null +++ b/sources/z-tools/trunk/todo.txt @@ -0,0 +1,7 @@ +- reuse some code parts, for example: + - zView should use zcodeclib, it has its own copy&pasted routines + - things like zvdi, debug, general.h, memory in all projects +- convert zView to windom 2.x (zWeather is done in the latest revision) +- add right licenses, to zXXX code, plugins, libraries used by plugins, ... +- implement true http links in zWeather -- now both icon and promo links are only shown, they should open + browser with URL from weather.com license diff --git a/sources/z-tools/trunk/zcodeclib/copyright b/sources/z-tools/trunk/zcodeclib/copyright new file mode 100644 index 0000000..ed55bd4 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/copyright @@ -0,0 +1,503 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/sources/z-tools/trunk/zcodeclib/exemple/8.gif b/sources/z-tools/trunk/zcodeclib/exemple/8.gif new file mode 100644 index 0000000..bb06206 Binary files /dev/null and b/sources/z-tools/trunk/zcodeclib/exemple/8.gif differ diff --git a/sources/z-tools/trunk/zcodeclib/exemple/exemple.app b/sources/z-tools/trunk/zcodeclib/exemple/exemple.app new file mode 100644 index 0000000..73e4e7c Binary files /dev/null and b/sources/z-tools/trunk/zcodeclib/exemple/exemple.app differ diff --git a/sources/z-tools/trunk/zcodeclib/exemple/main.c b/sources/z-tools/trunk/zcodeclib/exemple/main.c new file mode 100644 index 0000000..519205e --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/exemple/main.c @@ -0,0 +1,89 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +int main( int argc, char *argv[]) +{ + IMAGE *test_img = NULL; + MFDB *resize = NULL, screen = {0}; + int16 xy[8]; + + /* We load the wanted codecs but if we want to + load the entire codecs's pack, we can do "codecs_init( "all"); */ + if( !codecs_init( "gif.ldg")) + Cconws("can't init the codec \n\r"); + + if ( argc > 1) + { /* we load the dragged picture, we put - 1 to both w and h options because we don't want zoom */ + if( ! (test_img = load_img( argv[argc - 1], -1, -1, 0))) + { + Cconws("can't load image \n\r"); + codecs_quit(); + return 0; + } + } + else + { + Cconws("Drag and Drop a gif image\n\r"); + codecs_quit(); + return 0; + } + + xy[0] = 0; + xy[1] = 0; + xy[2] = test_img->image[0].fd_w - 1; + xy[3] = test_img->image[0].fd_h - 1; + xy[4] = 20; + xy[5] = 20; + xy[6] = xy[4] + xy[2]; + xy[7] = xy[5] + xy[3]; + + if ( test_img->image[0].fd_nplanes == 1) + { + int16 color[2] = { 0, 1}; + + vrt_cpyfm( vdi_handle, MD_REPLACE, xy, &test_img->image[0], &screen, color); + } + else + vro_cpyfm( vdi_handle, S_ONLY, xy, &test_img->image[0], &screen); + + if( !( resize = pic_resize( &test_img->image[0],64, 64, 1))) + { + Cconws("can't resize image \n\r"); + delete_img( test_img); + codecs_quit(); + return 0; + } + + xy[0] = 0; + xy[1] = 0; + xy[2] = resize->fd_w - 1; + xy[3] = resize->fd_h - 1; + xy[4] = 20 + test_img->image[0].fd_w - 1; + xy[5] = 20; + xy[6] = xy[4] + xy[2]; + xy[7] = xy[5] + xy[3]; + + /* draw the image */ + if ( resize->fd_nplanes == 1) + { + int16 color[2] = { 0, 1}; + + vrt_cpyfm( vdi_handle, MD_REPLACE, xy, resize, &screen, color); + } + else + vro_cpyfm( vdi_handle, S_ONLY, xy, resize, &screen); + + + delete_mfdb( resize, 1); + delete_img( test_img); + codecs_quit(); + return 0; +} diff --git a/sources/z-tools/trunk/zcodeclib/exemple/makefile b/sources/z-tools/trunk/zcodeclib/exemple/makefile new file mode 100644 index 0000000..68e5ca7 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/exemple/makefile @@ -0,0 +1,41 @@ +ifeq ($(CROSS),yes) +AS = m68k-atari-mint-as +CC = m68k-atari-mint-gcc +STACK = m68k-atari-mint-stack +INCLUDE_PATH = /home/zorro/cross-tools/include +LIB_PATH = /home/zorro/cross-tools/lib +else +AS = as +CC = gcc +STACK = stack +INCLUDE_PATH = /usr/GEM/include +LIB_PATH = /usr/GEM/lib +endif + +STACKSIZE = 128k +COMPRESS = upx +OPTIMISATION = -O2 -fomit-frame-pointer -finline-functions +CPU = -m68020-60 +LIB = -lzcodec -lgem -lldg + +CFLAGS = $(CPU) $(OPTIMISATION) -Wall -I$(INCLUDE_PATH) + +OBJ = main.o + +PROGRAM = exemple.app + + +all: $(PROGRAM) stack #compress + +$(PROGRAM): $(OBJ) + $(CC) -o$@ $(OBJ) -Xlinker -s -L$(LIB_PATH) $(LIB) + +stack: + $(STACK) -S $(STACKSIZE) $(PROGRAM) + +compress: + $(COMPRESS) $(PROGRAM) + +clean: + rm -f *.o + diff --git a/sources/z-tools/trunk/zcodeclib/include/types2b.h b/sources/z-tools/trunk/zcodeclib/include/types2b.h new file mode 100644 index 0000000..2343950 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/include/types2b.h @@ -0,0 +1,43 @@ +#ifndef __2B_UNIVERSAL_TYPES__ +#define __2B_UNIVERSAL_TYPES__ + +typedef signed char int8; +typedef unsigned char uint8; +typedef signed long int32; +typedef unsigned long uint32; +typedef int32 fix31; + +#ifdef __GNUC__ + typedef signed short int16; + typedef unsigned short uint16; + #define __2B_HAS64_SUPPORT /* Compiler supports 64 Bit Integers */ + typedef signed long long int64; + typedef unsigned long long uint64; +#else /* Compiler doesn't support 64 Bit Integers */ + typedef signed int int16; + typedef unsigned int uint16; + + typedef struct + { + int32 hi; + uint32 lo; + } int64; + + typedef struct + { + int32 hi; + uint32 lo; + } loff_t; + + typedef struct + { + uint32 hi; + uint32 lo; + } uint64; +#endif + + +typedef int32 boolean; + + +#endif /* __2B_UNIVERSAL_TYPES__ */ diff --git a/sources/z-tools/trunk/zcodeclib/include/zcodec.h b/sources/z-tools/trunk/zcodeclib/include/zcodec.h new file mode 100644 index 0000000..0198e4c --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/include/zcodec.h @@ -0,0 +1,29 @@ +#ifndef __ZCODECLIB_ZCODEC_H__ +#define __ZCODECLIB_ZCODEC_H__ + +#include + +struct LDG; +struct MFDB; + +typedef struct +{ + int16 page; /* Number of page/image in the file */ + uint16 *delay; /* Animation delay in millise. between each frame */ + MFDB *image; /* The Image itself */ +}IMAGE; + +extern int16 planar, vdi_handle, nplanes, vdi_work_in[10], vdi_work_out[57]; +extern LDG *ldg_mem; + +extern int16 codecs_init( char *codec_name); +extern void codecs_quit( void); +extern IMAGE *load_img( const char *file, int16 w, int16 h, int16 keep_ratio); +extern void delete_img( IMAGE *img); +extern MFDB *pic_resize( MFDB *in, int16 w, int16 h, int16 keep_ratio); +extern void delete_mfdb( MFDB *bm, int16 nbr); + +#define shared_malloc( s) _ldg_malloc( s, ldg_global[2]); +#define shared_free( s) _ldg_free( s, ldg_global[2]); + +#endif diff --git a/sources/z-tools/trunk/zcodeclib/src/Makefile b/sources/z-tools/trunk/zcodeclib/src/Makefile new file mode 100644 index 0000000..f30446b --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/Makefile @@ -0,0 +1,29 @@ +ifeq ($(CROSS),yes) +AS = m68k-atari-mint-as +AR = m68k-atari-mint-ar +CC = m68k-atari-mint-gcc +STACK = m68k-atari-mint-stack +else +AS = as +AR = ar +CC = gcc +STACK = stack +endif + +OPTIMISATION = -O2 -fomit-frame-pointer +CPU = -m68020-60 + +CFLAGS = $(CPU) $(OPTIMISATION) -Wall -I../include + +VDI_OBJ = zvdi/p2c.o zvdi/color.o zvdi/dither.o zvdi/raster.o zvdi/raresize.o zvdi/vdi.o + +OBJ = $(VDI_OBJ) img.o resize.o codecs.o mfdb.o load_img.o ztext.o mem.o + +TARGET = ../lib/m68020-60/libzcodec.a + +$(TARGET): $(OBJ) + rm -f $@ + $(AR) cru $@ $^ + +clean: + rm -f *.o zvdi/*.o *.O zvdi/*.O *~ $(TARGET) diff --git a/sources/z-tools/trunk/zcodeclib/src/codecs.c b/sources/z-tools/trunk/zcodeclib/src/codecs.c new file mode 100644 index 0000000..15c02dd --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/codecs.c @@ -0,0 +1,142 @@ +#include "general.h" +#include "ztext.h" +#include "zvdi/vdi.h" + + +/* Prototype */ +int16 plugins_init( void); +void plugins_quit( void); + +/* LDG function */ +void CDECL( *codec_init)( void) = NULL; + +static int16 vdi_initialised = 0; +static int16 mem_initialised = 0; + +/* Global variable */ +int16 plugins_nbr = 0; +LDG *codecs[100]; + + +/*==================================================================================* + * void plugins_quit: * + * unload all the codec from memory. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void codecs_quit( void) +{ + int16 i; + + for( i = 0; i < plugins_nbr; i++) + { + ldg_close( codecs[i], ldg_global); + } + + mem_quit(); +} + + +/*==================================================================================* + * void plugins_init: * + * load codec(s) to memory. * + *----------------------------------------------------------------------------------* + * input: * + * codec_name: the name of the codec to load, if this one is "all", we load * + * the codec. * + *----------------------------------------------------------------------------------* + * returns: * + * 0 if error. * + *==================================================================================*/ +int16 codecs_init( char *codec_name) +{ + char *env_ldg, current_dir[1024], plugin_dir[1024]; + DIR *dir; + LDG_INFOS *cook; + struct dirent *de; + int16 len; + char extention[4]; + + shel_envrn( &env_ldg, "LDGPATH="); + + if( ldg_cookie( LDG_COOKIE, ( int32*)&cook)) + strcpy( plugin_dir, cook->path); + else if( env_ldg) + strcpy( plugin_dir, env_ldg); + else + strcpy( plugin_dir, "C:\\gemsys\\ldg\\"); + + len = ( int16)strlen( plugin_dir); + + if( plugin_dir[len-1] != '\\') + strcat( plugin_dir, "\\"); + + strcat( plugin_dir, "codecs"); + + current_dir[0] = 'A' + Dgetdrv(); + current_dir[1] = ':'; + Dgetpath( current_dir + 2, 0); + + if( vdi_initialised == 0) + if( !( vdi_initialised = vdi_init())) + return( 0); + + if( mem_initialised == 0) + if( !( mem_initialised = mem_init())) + return( 0); + + if ( chdir( plugin_dir) != 0) + { + mem_quit(); + return( 0); + } + + if( strcmp ( codec_name, "all") == 0) + { + if (( dir = opendir( ".")) != NULL) + { + while(( de = readdir( dir)) != NULL) + { + if (( strcmp( de->d_name, ".") == 0) || ( strcmp( de->d_name, "..") == 0)) + continue; + + strcpy ( extention, de->d_name + strlen( de->d_name) - 3); + str2lower( extention); + + if( strcmp ( extention, "ldg") == 0) + { + if ( ( codecs[plugins_nbr] = ldg_open( de->d_name, ldg_global))) + { + if ( ( codec_init = ldg_find( "plugin_init", codecs[plugins_nbr]))) + { + codec_init(); + plugins_nbr++; + } + else + ldg_close( codecs[plugins_nbr], ldg_global); + } + } + } + closedir( dir); + } + } + else if ( ( codecs[plugins_nbr] = ldg_open( codec_name, ldg_global))) + { + if ( ( codec_init = ldg_find( "plugin_init", codecs[plugins_nbr]))) + { + codec_init(); + plugins_nbr++; + } + else + ldg_close( codecs[plugins_nbr], ldg_global); + } + + chdir( current_dir); + + return plugins_nbr; +} + diff --git a/sources/z-tools/trunk/zcodeclib/src/codecs.h b/sources/z-tools/trunk/zcodeclib/src/codecs.h new file mode 100644 index 0000000..847b199 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/codecs.h @@ -0,0 +1,2 @@ +extern LDG *codecs[100]; +extern int16 plugins_nbr; diff --git a/sources/z-tools/trunk/zcodeclib/src/general.h b/sources/z-tools/trunk/zcodeclib/src/general.h new file mode 100644 index 0000000..e17a106 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/general.h @@ -0,0 +1,44 @@ +/* + * zcodeclib. + * Copyright (c) 2001-2005 Zorro ( zorro270@yahoo.fr) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "mem.h" + +#define shared_malloc( s) _ldg_malloc( s, ldg_global[2]); +#define shared_free( s) _ldg_free( s, ldg_global[2]); + +#ifndef MIN +#define MAX(a,b) ((a)>(b)?(a):(b)) +#define MIN(a,b) ((a)<(b)?(a):(b)) +#endif + +#ifndef TRUE +# define TRUE 1 +# define FALSE 0 +#endif + diff --git a/sources/z-tools/trunk/zcodeclib/src/img.c b/sources/z-tools/trunk/zcodeclib/src/img.c new file mode 100644 index 0000000..a87f237 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/img.c @@ -0,0 +1,53 @@ +#include "general.h" +#include "mfdb.h" +#include "load_img.h" + +IMAGE *init_img( int16 page, int16 w, int16 h, int16 planes) +{ + IMAGE *data; + int16 i; + + data = ( IMAGE *)shared_malloc( sizeof( IMAGE)); + + if( data == NULL) + return NULL; + + data->page = page; + data->delay = NULL; + + data->image = ( MFDB *)shared_malloc( sizeof( MFDB) * page); + + if( data->image == NULL) + { + shared_free( data); + return NULL; + } + + for ( i = 0 ; i < page ; i++) + { + if ( !init_mfdb( &data->image[i], w, h, planes)) + { + if( i) + delete_mfdb( data->image, i + 1); + + shared_free( data->image); + shared_free( data); + return NULL; + } + } + + return data; +} + +void delete_img( IMAGE *data) +{ + if( data == NULL) + return; + + delete_mfdb( data->image, data->page); + + if( data->delay) + shared_free( data->delay); + + shared_free( data); +} diff --git a/sources/z-tools/trunk/zcodeclib/src/img.h b/sources/z-tools/trunk/zcodeclib/src/img.h new file mode 100644 index 0000000..dad47b0 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/img.h @@ -0,0 +1,3 @@ +extern IMAGE *init_img( int16 page, int16 w, int16 h, int16 planes); +extern void delete_img( IMAGE *data); + diff --git a/sources/z-tools/trunk/zcodeclib/src/load_img.c b/sources/z-tools/trunk/zcodeclib/src/load_img.c new file mode 100644 index 0000000..d26cc7a --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/load_img.c @@ -0,0 +1,259 @@ +#include "general.h" +#include "codecs.h" +#include "load_img.h" +#include "img.h" +#include "ztext.h" +#include "zvdi/color.h" +#include "zvdi/raster.h" +#include "zvdi/vdi.h" + +boolean decoder_init_done = FALSE; + +void ( *raster) ( DECDATA, void *dst); +void ( *raster_cmap) ( DECDATA, void *); +void ( *raster_true) ( DECDATA, void *); +void ( *cnvpal_color) ( IMGINFO, DECDATA); +void ( *raster_gray) ( DECDATA, void *); +void CDECL ( *decoder_quit) ( IMGINFO); +boolean CDECL ( *decoder_init) ( const char *, IMGINFO); +boolean CDECL ( *decoder_read) ( IMGINFO, uint8 *); + + +static IMAGE *setup ( IMGINFO info, DECDATA data, int16 w, int16 h, int16 keep_ratio) +{ + int16 n_planes = ( ( info->planes == 1 && info->components == 1) ? 1: nplanes); + uint16 display_w, display_h; + int16 wanted_w = ( w > 0 ? w : info->width), wanted_h = ( h > 0 ? h : info->height); + float precise_x, precise_y; + size_t src_line_size; + IMAGE *image; + + /* the image size is different that the original and we want to keep the aspect ratio */ + if( keep_ratio && ( info->width != wanted_w) && ( info->height != wanted_h)) + { + float factor = MAX( ( float)info->height / ( float)wanted_h, ( float)info->width / ( float)wanted_w); + precise_x = ( float)info->width / factor; + precise_y = ( float)info->height / factor; + + display_w = ( ( uint16)precise_x > 0 ? ( uint16)precise_x : 16); + display_h = ( ( uint16)precise_y > 0 ? ( uint16)precise_y : 16); + data->IncXfx = ((( uint32)info->width << 16) + ( display_w >> 1)) / display_w; + data->IncYfx = ((( uint32)info->height << 16) + ( display_h >> 1)) / display_h; + } + else if(( info->width != wanted_w) && ( info->height != wanted_h)) + { + float x_factor = ( float)info->width / ( float)wanted_w; + float y_factor = ( float)info->height / ( float)wanted_h; + precise_x = ( float)info->width / x_factor; + precise_y = ( float)info->height / y_factor; + + display_w = ( ( uint16)precise_x > 0 ? ( uint16)precise_x : 16); + display_h = ( ( uint16)precise_y > 0 ? ( uint16)precise_y : 16); + data->IncXfx = ((( uint32)info->width << 16) + ( display_w >> 1)) / display_w; + data->IncYfx = ((( uint32)info->height << 16) + ( display_h >> 1)) / display_h; + } + else + { + display_w = info->width; + display_h = info->height; + data->IncXfx = 0x10000uL; + data->IncYfx = 0x10000uL; + } + + image = init_img( info->page, display_w, display_h, n_planes); + + if( image == NULL) + return NULL; + +/* we assume that the pixel size is minimum 8 bits because some GNU libraries return 1 and 4 bits format like 8 bits ones. + We add also a little more memory for avoid buffer overflow for plugin badly coded. */ + src_line_size = ( info->width + 64) * info->components; + + data->RowBuf = ( uint8*)shared_malloc( src_line_size); + + if( !data->RowBuf) + return NULL; + + if(( info->planes == 1 && info->components == 1) || nplanes > 8) + data->DthBuf = NULL; + else + { + size_t size = ( display_w + 15) * 3; + + data->DthBuf = shared_malloc( size); + + if( data->DthBuf == NULL) + return NULL; + + memset( data->DthBuf, 0, size); + } + + data->DthWidth = display_w; + data->PixMask = ( 1 << info->planes) - 1; + data->LnSize = image->image[0].fd_wdwidth * n_planes; + + if ( info->planes == 1 && info->components == 1) + { + cnvpal_mono( info, data); + raster = raster_mono; + } + else + { + if ( info->indexed_color) + { + ( *cnvpal_color)( info, data); + raster = raster_cmap; + } + else + raster = ( info->components >= 3 ? raster_true : raster_gray); + } + + image->delay = NULL; + + return image; +} + +static inline void read_img ( IMAGE *img, IMGINFO info, DECDATA data) +{ + uint16 *dst; + int16 y_dst, i, y, img_h = info->height; + int32 line_size = data->LnSize; + uint8 *buf = data->RowBuf; + + for ( i = 0; i < img->page; i++) + { + uint32 scale = ( data->IncYfx + 1) >> 1; + y_dst = img->image[0].fd_h; + dst = img->image[i].fd_addr; + + if( info->orientation == DOWN_TO_UP) + { + dst += data->LnSize * ( y_dst - 1); + line_size = -data->LnSize; + } + + info->page_wanted = i; + + for( y = 1; y <= img_h; y++) + { + if( !decoder_read( info, buf)) + return; + + while(( scale >> 16) < y) + { + ( *raster)( data, dst); + dst += line_size; + scale += data->IncYfx; + if (!--y_dst) break; + } + } + + if( img->delay != NULL ) + { + img->delay[i] = info->delay; + } + } +} + + + +void quit_img( IMGINFO info, DECDATA data) +{ + if( decoder_init_done == TRUE) + decoder_quit( info); + + if( data->DthBuf) + shared_free( data->DthBuf); + + if( data->RowBuf) + shared_free( data->RowBuf); + + shared_free( data); + shared_free( info); + + decoder_init_done = FALSE; +} + + +boolean get_pic_info( const char *file, IMGINFO info) +{ + int16 i, j, c = 0; + char extention[3+1], plugin[3]; + + strcpy ( extention, file + strlen( file) - 3); + str2upper( extention); + + /* We check if a plug-ins can do the job */ + for( i = 0; i < plugins_nbr; i++, c = 0) + { + for( j = 0; j < codecs[i]->user_ext; j++) + { + plugin[0] = codecs[i]->infos[c++]; + plugin[1] = codecs[i]->infos[c++]; + plugin[2] = codecs[i]->infos[c++]; + + if( strncmp ( extention, plugin, 3) == 0) + { + if ( !( decoder_init = ldg_find( "reader_init", codecs[i])) + || !( decoder_read = ldg_find( "reader_read", codecs[i])) + || !( decoder_quit = ldg_find( "reader_quit", codecs[i]))) + { + return FALSE; + } + + return decoder_init( file, info); + } + } + } + + /* I wish that it will never append ! */ + return FALSE; +} + +IMAGE *load_img( const char *file, int16 w, int16 h, int16 keep_ratio) +{ + IMGINFO info; + DECDATA data; + IMAGE *img; + + /* One codec or more must be present */ + if( codecs[0] == NULL) + return( NULL); + + info = ( img_info *)shared_malloc( sizeof( img_info)); + + if( !info) + return( NULL); + + data = ( dec_data *)shared_malloc( sizeof( dec_data)); + + if( !data) + { + shared_free( info); + return ( NULL); + } + + info->background_color = 0xFFFFFF; + info->thumbnail = FALSE; + + if (( decoder_init_done = get_pic_info( file, info)) == FALSE) + { + shared_free( data); + shared_free( info); + return ( NULL); + } + + img = setup ( info, data, w, h, keep_ratio); + if( img == NULL) + { + delete_img( img); + quit_img( info, data); + return ( NULL); + } + + read_img ( img, info, data); + + quit_img( info, data); + + return ( img); +} diff --git a/sources/z-tools/trunk/zcodeclib/src/load_img.h b/sources/z-tools/trunk/zcodeclib/src/load_img.h new file mode 100644 index 0000000..b2b9b38 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/load_img.h @@ -0,0 +1,92 @@ +#define UP_TO_DOWN 0 +#define DOWN_TO_UP 1 + + +typedef struct +{ + uint8 red; + uint8 green; + uint8 blue; +} COLOR_MAP; + +typedef struct _img_info *IMGINFO; + +typedef struct _img_info +{ + /* Data returned by the decoder Picture's initialisation */ + uint16 width; /* Picture width */ + uint16 height; /* Picture Height */ + uint16 components; /* Picture components */ + uint16 planes; /* Picture bits by pixel */ + uint32 colors; /* Picture colors number */ + int16 orientation; /* picture orientation: UP_TO_DOWN or DONW_TO_UP ( ex: TGA) */ + uint16 page; /* Number of page/image in the file */ + uint16 delay; /* Animation delay in 200th sec. between each frame. */ + uint16 num_comments; /* Lines in the file's comment. ( 0 if none) */ + uint16 max_comments_length; /* The length of the greater line in the comment */ + int16 indexed_color; /* Picture has a palette: 0) No 1) Yes */ + int16 memory_alloc; /* where to do the memory allocation for the reader_read + function buffer, possible values are ST_RAM or TT_RAM */ + COLOR_MAP palette[256]; /* Palette in standard RGB format */ + + + /* data send to the codec */ + uint32 background_color; /* The wanted background's color in hexa */ + int16 thumbnail; /* 1 if true else 0. + Some format have thumbnail inside the picture, if 1, we + want only this thumbnail and not the image itself */ + uint16 page_wanted; /* The wanted page to get for the reader_read() function + The first page is 0 and the last is img_info->page - 1 */ + + + /* The following variable are only for Information Prupose, the zview doesn't + use it for decoding routine but only for the information dialog */ + int8 info[40]; /* Picture's info, for ex: "Gif 87a" */ + int8 compression[5]; /* Compression type, ex: "LZW" */ + uint16 real_width; /* Real picture width( if the thumbnail variable is 1) */ + uint16 real_height; /* Ral picture Height( if the thumbnail variable is 1) */ + + + /* Private data for the plugin */ + void *_priv_ptr; + void *_priv_ptr_more; + void *__priv_ptr_more; + + int32 _priv_var; + int32 _priv_var_more; + +} img_info; + + +typedef struct _dec_data *DECDATA; + +typedef struct _dec_data +{ + uint8 *RowBuf; + void *DthBuf; + uint8 *DstBuf; + uint16 DthWidth; + uint16 PixMask; + int32 LnSize; + uint32 IncXfx; + uint32 IncYfx; + uint32 Pixel[256]; +} dec_data; + + + +typedef struct _img +{ + int16 page; /* Number of page/image in the file */ + uint16 *delay; /* Animation delay in millise. between each frame */ + MFDB *image; /* The Image itself */ +}IMAGE; + +extern void ( *raster) ( DECDATA, void *dst); +extern void ( *raster_cmap) ( DECDATA, void *); +extern void ( *raster_true) ( DECDATA, void *); +extern void ( *cnvpal_color)( IMGINFO, DECDATA); +extern void ( *raster_gray) ( DECDATA, void *); + +extern IMAGE *load_img( const char *file, int16 w, int16 h, int16 keep_ratio); + diff --git a/sources/z-tools/trunk/zcodeclib/src/mem.c b/sources/z-tools/trunk/zcodeclib/src/mem.c new file mode 100644 index 0000000..9950163 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/mem.c @@ -0,0 +1,55 @@ +#include "general.h" + +/* Prototype */ +void mem_quit( void); +int16 mem_init( void); + +LDG *ldg_mem = NULL; + +/*==================================================================================* + * int16 mem_init: * + * Initialise the memory manager. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * '1' if all is OK else '0' * + *==================================================================================*/ + +int16 mem_init( void) +{ + ldg_mem = ldg_open( "C:\\gemsys\\ldg\\mem.ldg", ldg_global); + + if( !ldg_mem) + ldg_mem = ldg_open( "mem.ldg", ldg_global); + + _ldg_malloc = ldg_find( "ldg_malloc", ldg_mem); + _ldg_free = ldg_find( "ldg_free", ldg_mem); + _ldg_allocmode = ldg_find( "ldg_allocmode", ldg_mem); + + if ( !ldg_mem || !_ldg_malloc || !_ldg_free || !_ldg_allocmode) + return( 0); + + ldg_allocmode( 0L); + + return( 1); +} + + +/*==================================================================================* + * void mem_quit: * + * close the memory manager. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void mem_quit( void) +{ + if( ldg_mem) + ldg_close( ldg_mem, ldg_global); +} + diff --git a/sources/z-tools/trunk/zcodeclib/src/mem.h b/sources/z-tools/trunk/zcodeclib/src/mem.h new file mode 100644 index 0000000..0fa7630 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/mem.h @@ -0,0 +1,4 @@ +extern int16 mem_init( void); +extern void mem_quit( void); + + diff --git a/sources/z-tools/trunk/zcodeclib/src/mfdb.c b/sources/z-tools/trunk/zcodeclib/src/mfdb.c new file mode 100644 index 0000000..4479b33 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/mfdb.c @@ -0,0 +1,71 @@ +#include "general.h" + + +/* Prototype */ +int16 init_mfdb( MFDB *bm, int16 width, int16 height, int16 planes); +void delete_mfdb( MFDB *bm, int16 nbr); + + +/*==================================================================================* + * int16 init_mfdb: * + * fit a MFDB with the parameters suppplied. * + *----------------------------------------------------------------------------------* + * input: * + * bm -> The MFDB to fit. * + * width -> Image's width. * + * height -> Image's height. * + * planes -> Screen planes or 1 if the image is monochrome. * + *----------------------------------------------------------------------------------* + * returns: * + * '0' if error or the memory size allocated. * + *==================================================================================*/ +int16 init_mfdb( MFDB *bm, int16 width, int16 height, int16 planes) +{ + uint32 length; + + bm->fd_w = width; + bm->fd_h = height; + bm->fd_wdwidth = ( width >> 4) + (( width % 16) != 0); + bm->fd_stand = 0; + bm->fd_nplanes = planes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + + length = (( (( uint32)bm->fd_wdwidth << 1 ) * ( uint32)bm->fd_nplanes) * ( uint32)bm->fd_h) + 256L; + bm->fd_addr = shared_malloc( length); + + if ( bm->fd_addr) + return ( 1); + else + return ( 0); +} + + +/*==================================================================================* + * int16 delete_mfdb: * + * free the data of MFDB struct. * + *----------------------------------------------------------------------------------* + * input: * + * bm -> pointer to the MFDB to delete. * + * nbr -> The number of MFDB struct. to delete. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void delete_mfdb( MFDB *bm, int16 nbr) +{ + register int16 i; + + if( nbr == 0 || bm == NULL) + return; + + for ( i = 0; i < nbr; i++) + { + if ( bm[i].fd_addr) + shared_free( bm[i].fd_addr); + } + + shared_free( bm); +} + diff --git a/sources/z-tools/trunk/zcodeclib/src/mfdb.h b/sources/z-tools/trunk/zcodeclib/src/mfdb.h new file mode 100644 index 0000000..e1a27c2 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/mfdb.h @@ -0,0 +1,2 @@ +extern int16 init_mfdb( MFDB *bm, int16 width, int16 height, int16 planes); +extern void delete_mfdb( MFDB *bm, int16 nbr); diff --git a/sources/z-tools/trunk/zcodeclib/src/resize.c b/sources/z-tools/trunk/zcodeclib/src/resize.c new file mode 100644 index 0000000..da4370a --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/resize.c @@ -0,0 +1,156 @@ +#include "general.h" +#include "load_img.h" +#include "mfdb.h" +#include "zvdi/raresize.h" +#include "zvdi/vdi.h" +#include "zvdi/p2c.h" + + +void ( *resize)( DECDATA, void *dst); +void ( *my_resize)( DECDATA, void *dst); + +extern int32 plane2packed( int32 no_words, int32 plane_length, int16 no_planes, void *src, void *dst); + + +static int16 resize_setup( MFDB *in, MFDB *out, DECDATA data, int16 w, int16 h, int16 keep_ratio) +{ + uint16 display_w, display_h; + float precise_x, precise_y; + + /* the image size is different that the original and we want to keep the aspect ratio */ + if( keep_ratio) + { + float factor = MAX( ( float)in->fd_h / ( float)h, ( float)in->fd_w / ( float)w); + precise_x = ( float)in->fd_w / factor; + precise_y = ( float)in->fd_h / factor; + + display_w = ( ( uint16)precise_x > 0 ? ( uint16)precise_x : 16); + display_h = ( ( uint16)precise_y > 0 ? ( uint16)precise_y : 16); + data->IncXfx = ((( uint32)in->fd_w << 16) + ( display_w >> 1)) / display_w; + data->IncYfx = ((( uint32)in->fd_h << 16) + ( display_h >> 1)) / display_h; + } + else + { + float x_factor = ( float)in->fd_w / ( float)w; + float y_factor = ( float)in->fd_h / ( float)h; + precise_x = ( float)in->fd_w / x_factor; + precise_y = ( float)in->fd_h / y_factor; + + display_w = ( ( uint16)precise_x > 0 ? ( uint16)precise_x : 16); + display_h = ( ( uint16)precise_y > 0 ? ( uint16)precise_y : 16); + data->IncXfx = ((( uint32)in->fd_w << 16) + ( display_w >> 1)) / display_w; + data->IncYfx = ((( uint32)in->fd_h << 16) + ( display_h >> 1)) / display_h; + } + + if ( !init_mfdb( out, display_w, display_h, in->fd_nplanes)) + return ( 0); + + data->RowBuf = in->fd_addr; + + if( planar) + { + data->DstBuf = shared_malloc((( uint32)in->fd_wdwidth << 4 ) + 256uL); + + if( data->DstBuf == NULL) + { + delete_mfdb( out, 1); + return ( 0); + } + } + else + data->DstBuf = NULL; + + data->DthWidth = display_w; + data->LnSize = out->fd_wdwidth * out->fd_nplanes; + + if( out->fd_nplanes == 1) + my_resize = resize_mono; + else + my_resize = resize; + + return( 1); +} + + +static inline void resize_img( MFDB *in, MFDB *out, DECDATA data) +{ + uint16 *dst = out->fd_addr; + int16 y = 0; + int32 in_line_size = (( uint32)in->fd_wdwidth << 1 ) * ( uint32)in->fd_nplanes, + out_line_size = data->LnSize; + uint32 scale = ( data->IncYfx + 1) >> 1; + int16 y_dst = out->fd_h; + + + while ( y < in->fd_h) + { + y++; + + if( planar) + { + if( ( scale >> 16) < y) + planar_to_chunky( data->RowBuf, data->DstBuf, in->fd_w); + } + + while (( scale >> 16) < y) + { + my_resize( data, dst); + dst += out_line_size; + scale += data->IncYfx; + if ( !--y_dst) break; + } + + data->RowBuf += in_line_size; + } +} + + +/*==================================================================================* + * pic_resize: * + * Create a resized MFDB. * + *----------------------------------------------------------------------------------* + * in: The src MFDB. * + * img: The target MFDB. * + *----------------------------------------------------------------------------------* + * returns: '0' if error else 1. * + *==================================================================================*/ + +MFDB *pic_resize( MFDB *in, int16 w, int16 h, int16 keep_ratio) +{ + DECDATA data; + MFDB *out; + + /* 2 planes zoom not available */ + if( in->fd_nplanes == 2) + return NULL; + + out = ( MFDB *)shared_malloc( sizeof( MFDB)); + + if( out == NULL) + return NULL; + + data = ( dec_data *)shared_malloc( sizeof( dec_data)); + + if( !data) + { + shared_free( out); + return NULL; + } + + + if( !resize_setup( in, out, data, w, h, keep_ratio)) + { + shared_free( data); + shared_free( out); + return NULL; + } + + resize_img ( in, out, data); + + if( data->DstBuf) + shared_free( data->DstBuf); + + shared_free( data); + + return( out); +} diff --git a/sources/z-tools/trunk/zcodeclib/src/resize.h b/sources/z-tools/trunk/zcodeclib/src/resize.h new file mode 100644 index 0000000..7b13bea --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/resize.h @@ -0,0 +1,3 @@ +extern void ( *resize)( DECDATA, void *dst); +extern MFDB *pic_resize( MFDB *in, int16 w, int16 h, int16 keep_ratio); + diff --git a/sources/z-tools/trunk/zcodeclib/src/ztext.c b/sources/z-tools/trunk/zcodeclib/src/ztext.c new file mode 100644 index 0000000..71f6cd9 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/ztext.c @@ -0,0 +1,78 @@ +#include "general.h" + + +/* Local variable */ +typedef struct +{ + char upper; + char lower; +} CUL; + + +static CUL c[] = { {'A', 'a'}, {'B', 'b'}, {'C', 'c'}, {'D', 'd'}, {'E', 'e'}, {'F', 'f'}, {'G', 'g'}, {'H', 'h'}, + {'I', 'i'}, {'J', 'j'}, {'K', 'k'}, {'L', 'l'}, {'M', 'm'}, {'N', 'n'}, {'O', 'o'}, {'P', 'p'}, + {'Q', 'q'}, {'R', 'r'}, {'S', 's'}, {'T', 't'}, {'U', 'u'}, {'V', 'v'}, {'W', 'w'}, {'X', 'x'}, + {'Y', 'y'}, {'Z', 'z'}, {'š', ''}, {'', '‚'}, {'Ž', '„'}, {0xb6, '…'}, {'', '†'}, {'€', '‡'}, + {'’', '‘'}, {'™', '”'}, {'¥', '¤'}, {0xb7, 0xb0}, {0xb8, 0xb1}, {0xb2, 0xb3}, {0xb5, 0xb4} }; + + +/* Prototype */ +void str2lower(char *str); +void str2upper(char *str); + + +/*==================================================================================* + * str2lower: * + * Transforms all letters in the string to lower case. * + *----------------------------------------------------------------------------------* + * returns: - * + *----------------------------------------------------------------------------------* + * str: Pointer to null terminated string. * + *==================================================================================*/ +void str2lower(char *str) +{ + int16 i, k; + + i = 0; + while (str[i] != '\0') + { + for (k = 0; k < (sizeof(c) / sizeof(CUL)); k++) + { + if (c[k].upper == str[i]) + { + str[i] = c[k].lower; + break; + } + } + i++; + } +} + + +/*==================================================================================* + * str2upper: * + * Transforms all letters in the string to uper case. * + *----------------------------------------------------------------------------------* + * returns: - * + *----------------------------------------------------------------------------------* + * str: Pointer to null terminated string. * + *==================================================================================*/ +void str2upper(char *str) +{ + int16 i, k; + + i = 0; + while (str[i] != '\0') + { + for (k = 0; k < (sizeof(c) / sizeof(CUL)); k++) + { + if (c[k].lower == str[i]) + { + str[i] = c[k].upper; + break; + } + } + i++; + } +} + diff --git a/sources/z-tools/trunk/zcodeclib/src/ztext.h b/sources/z-tools/trunk/zcodeclib/src/ztext.h new file mode 100644 index 0000000..f046cba --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/ztext.h @@ -0,0 +1,5 @@ +extern void size_to_text( char *txt, float size); +extern void str2lower(char *str); +extern void str2upper(char *str); +extern int16 name_shorter( int16 handle, int16 max_size, char *str); +extern char *zstrncpy( char *dst, const char *src, size_t n); diff --git a/sources/z-tools/trunk/zcodeclib/src/zvdi/color.c b/sources/z-tools/trunk/zcodeclib/src/zvdi/color.c new file mode 100644 index 0000000..c06081e --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/zvdi/color.c @@ -0,0 +1,200 @@ +#ifdef __PUREC__ +#include "..\general.h" +#include "..\load_img.h" +#else +#include "../general.h" +#include "../load_img.h" +#endif +#include "vdi.h" + +typedef struct +{ + uint8 satur; + uint8 red, green, blue; +} SRGB; + +static SRGB screen_colortab[256]; + + +/* prototype */ +void save_colors(void); +int16 remap_color (int32 value); +uint32 color_lookup ( uint32 rgb, int16 *trans); +void cnvpal_mono ( IMGINFO info, DECDATA data); +void cnvpal_1_2 (IMGINFO info, DECDATA data); +void cnvpal_4_8( IMGINFO info, DECDATA data); +void cnvpal_15( IMGINFO info, DECDATA data); +void cnvpal_high( IMGINFO info, DECDATA data); +void cnvpal_true( IMGINFO info, DECDATA data); + + +static uint8 saturation (uint8 * rgb) +{ + uint8 satr; + + if (rgb[0] >= rgb[1]) + { + if (rgb[1] >= rgb[2]) + satr = rgb[0] - rgb[2]; + else if (rgb[0] > rgb[2]) + satr = rgb[0] - rgb[1]; + else + satr = rgb[2] - rgb[1]; + } + else if (rgb[1] >= rgb[2]) + { + if (rgb[0] >= rgb[2]) + satr = rgb[1] - rgb[2]; + else + satr = rgb[1] - rgb[0]; + } + else + satr = rgb[2] - rgb[0]; + + return satr; +} + + +void save_colors(void) +{ + register int16 i; + int16 colors = 1 << nplanes; + + for( i = 0; i < colors; i++) + { + int16 coltab[3]; + + vq_color( vdi_handle, i, 1, coltab); + + screen_colortab[i].red = ((((int32)coltab[0] << 8 ) - coltab[0]) + 500) / 1000; + screen_colortab[i].green = ((((int32)coltab[1] << 8 ) - coltab[1]) + 500) / 1000; + screen_colortab[i].blue = ((((int32)coltab[2] << 8 ) - coltab[2]) + 500) / 1000; + screen_colortab[i].satur = saturation ( &screen_colortab[i].red); + } +} + +int16 remap_color (int32 value) +{ + int16 red = ((uint8*)&value)[1]; + int16 green = ((uint8*)&value)[2]; + int16 blue = ((uint8*)&value)[3]; + int16 satur = saturation (((uint8*)&value) +1); + + int16 best_fit = 0; + uint16 best_err = 0xFFFFu; + int16 max_color = 1 << nplanes; + + int16 i = 0; + + value = ( value & 0x00FFFFFFl) | (( int32)satur << 24); + + do + { + if ( *( int32*)&screen_colortab[i] == value) + { + /* gotcha! */ + best_fit = i; + break; + } + else + { + uint16 err = + ( red > screen_colortab[i].red ? red - screen_colortab[i].red : screen_colortab[i].red - red) + + (green > screen_colortab[i].green ? green - screen_colortab[i].green : screen_colortab[i].green - green) + + (blue > screen_colortab[i].blue ? blue - screen_colortab[i].blue : screen_colortab[i].blue - blue) + + (satur > screen_colortab[i].satur ? satur - screen_colortab[i].satur : screen_colortab[i].satur - satur); + + if (err <= best_err) + { + best_err = err; + best_fit = i; + } + } + } while (++i < max_color); + + return best_fit; +} + + +uint32 color_lookup ( uint32 rgb, int16 *trans) +{ + uint8 idx = ((rgb & ~0xFFuL) == ~0xFFuL ? rgb : remap_color (rgb)); + return ( (( int32)(trans ? trans[idx] : idx) << 24) | (*(int32*)&screen_colortab[idx] & 0x00FFFFFFuL)); +} + + +void cnvpal_mono ( IMGINFO info, DECDATA data) +{ +/* if ( info->indexed_color) + { + uint32 bgnd, fgnd; + + bgnd = (((( int32)info->palette[0].red <<8) | info->palette[0].green) <<8) | info->palette[0].blue; + fgnd = (((( int32)info->palette[1].red <<8) | info->palette[1].green) <<8) | info->palette[1].blue; + + data->Pixel[0] = remap_color ( bgnd); + data->Pixel[1] = remap_color ( fgnd); + + } + else +*/ { + data->Pixel[0] = G_WHITE; + data->Pixel[1] = G_BLACK; + } +} + + +void cnvpal_1_2 (IMGINFO info, DECDATA data) +{ + register int32 i; + + for( i = 0; i < info->colors; i++) + { + data->Pixel[i] = ( int16)info->palette[i].red * 5 + ( int16)info->palette[i].green * 9 + (( int16)info->palette[i].blue << 1); + } +} + + +void cnvpal_4_8( IMGINFO info, DECDATA data) +{ + register int32 i; + + for( i = 0; i < info->colors; i++) + { + uint32 rgb = (((( int32)info->palette[i].red << 8) | info->palette[i].green) << 8) | info->palette[i].blue; + data->Pixel[i] = rgb | (( int32)pixel_val[remap_color ( rgb)] << 24); + } +} + + +void cnvpal_15( IMGINFO info, DECDATA data) +{ + register int32 i; + + for( i = 0; i < info->colors; i++) + { + data->Pixel[i] = (( int16)( info->palette[i].red & 0xF8) << 7) | (( int16)( info->palette[i].green & 0xF8) << 2) | ( info->palette[i].blue >> 3); + } +} + + +void cnvpal_high( IMGINFO info, DECDATA data) +{ + register int32 i; + + for( i = 0; i < info->colors; i++) + { + data->Pixel[i] = (( int16)( info->palette[i].red & 0xF8) << 8) | (( int16)( info->palette[i].green & 0xFC) << 3) | ( info->palette[i].blue >> 3); + } +} + + +void cnvpal_true ( IMGINFO info, DECDATA data) +{ + register int32 i; + + for( i = 0; i < info->colors; i++) + { + data->Pixel[i] = (((( int32)info->palette[i].red << 8) | info->palette[i].green) << 8) | info->palette[i].blue; + } +} diff --git a/sources/z-tools/trunk/zcodeclib/src/zvdi/color.h b/sources/z-tools/trunk/zcodeclib/src/zvdi/color.h new file mode 100644 index 0000000..9610647 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/zvdi/color.h @@ -0,0 +1,14 @@ +extern void save_colors( void); +extern int16 remap_color( int32 value); + +extern uint32 color_lookup( uint32 rgb, int16 *trans); + +extern void cnvpal_mono( IMGINFO info, DECDATA data); +extern void cnvpal_1_2( IMGINFO info, DECDATA data); +extern void cnvpal_4_8( IMGINFO info, DECDATA data); +extern void cnvpal_15( IMGINFO info, DECDATA data); +extern void cnvpal_high( IMGINFO info, DECDATA data); +extern void cnvpal_true( IMGINFO info, DECDATA data); + +extern void ( *cnvpal_color)( IMGINFO, DECDATA); + diff --git a/sources/z-tools/trunk/zcodeclib/src/zvdi/dither.c b/sources/z-tools/trunk/zcodeclib/src/zvdi/dither.c new file mode 100644 index 0000000..65ce5cb --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/zvdi/dither.c @@ -0,0 +1,46 @@ +#ifdef __PUREC__ +#include "..\general.h" +#else +#include "../general.h" +#endif + + +extern uint32 cube216[216]; +extern uint32 graymap[32]; + +/* prototype */ +inline uint8 dither_true ( uint8 * rgb, int16 * err, int8 ** buf); +inline uint8 dither_gray( uint8 *gray, int16 *err, int8 **buf); + +inline uint8 dither_true ( uint8 * rgb, int16 * err, int8 ** buf) +{ + int8 *dth = *buf; + unsigned short r = (( err[0] += ( int16)dth[0] + rgb[0]) <= 42 ? 0 : err[0] >= 213 ? 5 : ( err[0] * 3) >> 7); + unsigned short g = (( err[1] += ( int16)dth[1] + rgb[1]) <= 42 ? 0 : err[1] >= 213 ? 5 : ( err[1] * 3) >> 7); + unsigned short b = (( err[2] += ( int16)dth[2] + rgb[2]) <= 42 ? 0 : err[2] >= 213 ? 5 : ( err[2] * 3) >> 7); + uint8 * irgb = ( uint8*)&cube216[( r * 6 + g) * 6 + b]; + + err[0] -= irgb[1]; + dth[0] = ( err[0] <= -254 ? ( err[0] =- 127) : err[0] >= +254 ? ( err[0] =+ 127) : ( err[0] >>= 1)); + err[1] -= irgb[2]; + dth[1] = ( err[1] <= -254 ? ( err[1] =- 127) : err[1] >= +254 ? ( err[1] =+ 127) : ( err[1] >>= 1)); + err[2] -= irgb[3]; + dth[2] = ( err[2] <= -254 ? ( err[2] = -127) : err[2] >= +254 ? ( err[2] = +127) : ( err[2] >>= 1)); + ( *buf) += 3; + + return irgb[0]; +} + + +inline uint8 dither_gray( uint8 *gray, int16 *err, int8 **buf) +{ + int8 *dth = *buf; + unsigned short idx = (( err[0] += ( int16)dth[0] + gray[0]) <= 0x07 ? 0 : err[0] >= 0xF8 ? 0x1F : err[0] >> 3); + uint8 *irgb = ( uint8*)&graymap[idx]; + + err[0] -= irgb[1]; + dth[0] = ( err[0] <= -254 ? ( err[0] = -127) : err[0] >= +254 ? ( err[0] =+ 127) : ( err[0] >>= 1)); + (*buf) += 1; + + return irgb[0]; +} diff --git a/sources/z-tools/trunk/zcodeclib/src/zvdi/dither.h b/sources/z-tools/trunk/zcodeclib/src/zvdi/dither.h new file mode 100644 index 0000000..273c31c --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/zvdi/dither.h @@ -0,0 +1,2 @@ +extern inline uint8 dither_true ( uint8 * rgb, int16 * err, int8 ** buf); +extern inline uint8 dither_gray( uint8 *gray, int16 *err, int8 **buf); diff --git a/sources/z-tools/trunk/zcodeclib/src/zvdi/p2c.c b/sources/z-tools/trunk/zcodeclib/src/zvdi/p2c.c new file mode 100644 index 0000000..fe1fe57 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/zvdi/p2c.c @@ -0,0 +1,87 @@ +#ifdef __PUREC__ +#include "..\general.h" +#else +#include "../general.h" +#endif + + +void ( *planar_to_chunky)( uint8 *in, uint8 *out, int16 width); + + +inline void planar8_to_chunky8( uint8 *in, uint8 *out, int16 width) +{ + uint8 *l; + uint16 x, c, p0, p1, p2, p3, p4, p5, p6, p7; + + for( x = 0, l = in; x < width; l += 16) + { + p0 = ( l[0] << 8) | l[1]; + p1 = ( l[2] << 8) | l[3]; + p2 = ( l[4] << 8) | l[5]; + p3 = ( l[6] << 8) | l[7]; + p4 = ( l[8] << 8) | l[9]; + p5 = ( l[10] << 8) | l[11]; + p6 = ( l[12] << 8) | l[13]; + p7 = ( l[14] << 8) | l[15]; + + for ( c = 0; c < 16; c++) + { + out[x++] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2) | ((p2 >> 13) & 4) | ((p3 >> 12) & 8) | + ((p4 >> 11) & 16) | ((p5 >> 10) & 32)| ((p6 >> 9) & 64) | ((p7 >> 8) & 128); + p0 <<= 1; + p1 <<= 1; + p2 <<= 1; + p3 <<= 1; + p4 <<= 1; + p5 <<= 1; + p6 <<= 1; + p7 <<= 1; + } + } +} + + +inline void planar4_to_chunky8( uint8 *in, uint8 *out, int16 width) +{ + uint8 *l; + uint16 x, c, p0, p1, p2, p3; + + for( x = 0, l = in; x < width; l += 8) + { + p0 = ( l[0] << 8) | l[1]; + p1 = ( l[2] << 8) | l[3]; + p2 = ( l[4] << 8) | l[5]; + p3 = ( l[6] << 8) | l[7]; + + for ( c = 0; c < 16; c++) + { + out[x++] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2) | ((p2 >> 13) & 4) | ((p3 >> 12) & 8); + + p0 <<= 1; + p1 <<= 1; + p2 <<= 1; + p3 <<= 1; + } + } +} + + +inline void planar2_to_chunky8( uint8 *in, uint8 *out, int16 width) +{ + uint8 *l; + uint16 x, c, p0, p1; + + for ( x = 0, l = in; x < width; l += 4) + { + p0 = (l[0] << 8) | l[1]; + p1 = (l[2] << 8) | l[3]; + + for (c = 0; c < 16; c++) + { + out[x++] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2); + p0 <<= 1; + p1 <<= 1; + } + } +} + diff --git a/sources/z-tools/trunk/zcodeclib/src/zvdi/p2c.h b/sources/z-tools/trunk/zcodeclib/src/zvdi/p2c.h new file mode 100644 index 0000000..bb837d0 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/zvdi/p2c.h @@ -0,0 +1,5 @@ +extern void ( *planar_to_chunky)( uint8 *in, uint8 *out, int16 width); +extern void planar8_to_chunky8( uint8 *in, uint8 *out, int16 width); +extern void planar4_to_chunky8( uint8 *in, uint8 *out, int16 width); +extern void planar2_to_chunky8( uint8 *in, uint8 *out, int16 width); + diff --git a/sources/z-tools/trunk/zcodeclib/src/zvdi/raresize.c b/sources/z-tools/trunk/zcodeclib/src/zvdi/raresize.c new file mode 100644 index 0000000..25d0e49 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/zvdi/raresize.c @@ -0,0 +1,152 @@ +#ifdef __PUREC__ +#include "..\general.h" +#include "..\load_img.h" +#else +#include "../general.h" +#include "../load_img.h" +#endif +#include "dither.h" +#include "raster.h" + +inline void resize_mono ( DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 4; + uint16 pixel = 0x80, chunk = 0; + + do + { + chunk |= ( info->RowBuf[x >> 16] & 1); + chunk <<= 1; + + if ( !--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + chunk = 0; + pixel = 0x80; + } + + x += ( info->IncXfx >> 3); + + } while ( width); +} + + +inline void resize_I4 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + *(tmp++) = *( uint8*)&info->DstBuf[x >> 16]; + + if (!--width || !--n) + { + raster_chunk4( buf, dst, tmp - buf); + dst += 4; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while ( width); +} + + +inline void resize_I8 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + *(tmp++) = *( uint8*)&info->DstBuf[x >> 16]; + + if (!--width || !--n) + { + raster_chunk8 (buf, dst, tmp - buf); + dst += 8; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while (width); +} + + +inline void resize_P8(DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 *rgb = &info->RowBuf[x >> 16]; + *(dst++) = *(rgb); + x += info->IncXfx; + } while (--width); +} + + +inline void resize_16(DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 *rgb = &info->RowBuf[(x >> 16) << 1]; + *(dst++) = *(rgb++); + *(dst++) = *(rgb); + x += info->IncXfx; + } while (--width); +} + + +inline void resize_24(DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >>16) * 3]; + *(dst++) = *(rgb++); + *(dst++) = *(rgb++); + *(dst++) = *(rgb); + x += info->IncXfx; + } while (--width); +} + + +inline void resize_32( DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >> 16) << 2]; + *(dst++) = *(rgb++); + *(dst++) = *(rgb++); + *(dst++) = *(rgb++); + *(dst++) = *(rgb); + + x += info->IncXfx; + } while (--width); +} diff --git a/sources/z-tools/trunk/zcodeclib/src/zvdi/raresize.h b/sources/z-tools/trunk/zcodeclib/src/zvdi/raresize.h new file mode 100644 index 0000000..cc6af3b --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/zvdi/raresize.h @@ -0,0 +1,8 @@ +extern void resize_mono( DECDATA info, void * _dst); +extern void resize_I4( DECDATA info, void * _dst); +extern void resize_I8( DECDATA info, void * _dst); +extern void resize_P8( DECDATA info, void * _dst); +extern void resize_16( DECDATA info, void * _dst); +extern void resize_24( DECDATA info, void * _dst); +extern void resize_32( DECDATA info, void * _dst); + diff --git a/sources/z-tools/trunk/zcodeclib/src/zvdi/raster.c b/sources/z-tools/trunk/zcodeclib/src/zvdi/raster.c new file mode 100644 index 0000000..c374555 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/zvdi/raster.c @@ -0,0 +1,877 @@ +#ifdef __PUREC__ +#include "..\general.h" +#include "..\load_img.h" +#else +#include "../general.h" +#include "../load_img.h" +#endif +#include "dither.h" +#include "raster.h" + +inline void raster_mono ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + uint32 *map = info->Pixel; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + if ( map[(int16)info->RowBuf[x >>16] & 1]) + chunk |= pixel; + + if ( !--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while ( width); +} + +inline void raster_D1 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + int16 *buf = info->DthBuf; + int16 ins = 0; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + ins += *buf + map[(int16)info->RowBuf[x >>16] & mask]; + + if ( ins < 2040) + chunk |= pixel; + else + ins -= 4080; + + *(buf++) = (ins >>= 2); + + if ( !--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while ( width); +} + +inline void gscale_D1( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = ( info->IncXfx + 1) >> 1; + int16 *buf = info->DthBuf; + int16 ins = 0; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + ins += *buf + ( int16)info->RowBuf[x >>16]; + + if ( ins < 0x80) + chunk |= pixel; + else + ins -= 0xFF; + + *(buf++) = (ins >>= 2); + + if ( !--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while (width); +} + +inline void dither_D1 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = ( info->IncXfx + 1) >> 1; + int16 *buf = info->DthBuf; + int16 ins = 0; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + uint8 *rgb = &info->RowBuf[(x >>16) *3]; + ins += *buf + ( int16)rgb[0] * 5 + ( int16)rgb[1] * 9 + ( int16)rgb[2] * 2; + + if (ins < 2040) + chunk |= pixel; + else + ins -= 4080; + + *(buf++) = (ins >>= 2); + + if (!--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while( width); +} + +inline void raster_D2 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = ( info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + int16 *buf = info->DthBuf; + int16 ins = 0; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + ins += *buf + map[( int16)info->RowBuf[x >>16] & mask]; + + if ( ins < 2040) + chunk |= pixel; + else + ins -= 4080; + + *(buf++) = (ins >>= 2); + + if (!--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while ( width); +} + +inline void gscale_D2( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = ( info->IncXfx + 1) >> 1; + int16 *buf = info->DthBuf; + int16 ins = 0; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + ins += *buf + (short)info->RowBuf[x >>16]; + + if (ins < 0x80) + chunk |= pixel; + else + ins -= 0xFF; + + *(buf++) = (ins >>= 2); + + if (!--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while (width); +} + +inline void dither_D2 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = ( info->IncXfx + 1) >> 1; + int16 *buf = info->DthBuf; + int16 ins = 0; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + uint8 *rgb = &info->RowBuf[( x >>16) * 3]; + ins += *buf + (int16)rgb[0] * 5 + (int16)rgb[1] * 9 + (int16)rgb[2] * 2; + + if (ins < 2040) + chunk |= pixel; + else + ins -= 4080; + + *(buf++) = (ins >>= 2); + + if (!--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while ( width); +} + +inline void raster_chunks ( uint8 *src, uint16 *dst, uint16 num, uint16 depth) +{ + uint16 mask = 0x8000; + uint16 *chunk = dst; + uint8 pixel = *src; + int16 i = depth; + + do + { + *( chunk++) = ( pixel & 1 ? mask : 0); + pixel >>= 1; + } while (--i); + + while (--num) + { + mask >>= 1; + chunk = dst; + pixel = *( ++src); + i = depth; + + do + { + if ( pixel & 1) *chunk |= mask; + else *chunk &= ~mask; + chunk++; + pixel >>= 1; + } while (--i); + } +} + + + +inline void raster_I4 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + uint16 idx = info->RowBuf[x >>16]; + *(tmp++) = *( uint8*)&info->Pixel[idx]; + + if (!--width || !--n) + { + raster_chunk4( buf, dst, tmp - buf); + dst += 4; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while ( width); +} + +inline void gscale_I4( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + int8 *dth = info->DthBuf; + int16 err = 0; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + *(tmp++) = dither_gray (&info->RowBuf[x >>16], &err, &dth); + + if (!--width || !--n) + { + raster_chunk4 (buf, dst, tmp - buf); + dst += 4; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while (width); +} + +inline void dither_I4 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + int8 *dth = info->DthBuf; + int16 err[3] = { 0, 0, 0 }; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + *(tmp++) = dither_true (&info->RowBuf[(x >>16) *3], err, &dth); + + if (!--width || !--n) + { + raster_chunk4 (buf, dst, tmp - buf); + dst += 4; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while (width); +} + +inline void raster_I8 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + uint16 idx = info->RowBuf[x >>16]; + *(tmp++) = *(uint8*)&info->Pixel[idx]; + + if (!--width || !--n) + { + raster_chunk8 (buf, dst, tmp - buf); + dst += 8; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while (width); +} + +inline void gscale_I8( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + int8 *dth = info->DthBuf; + int16 err = 0; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + *(tmp++) = dither_gray (&info->RowBuf[x >>16], &err, &dth); + + if (!--width || !--n) { + raster_chunk8 (buf, dst, tmp - buf); + dst += 8; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while (width); +} + +inline void dither_I8 (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + int8 *dth = info->DthBuf; + int16 err[3] = { 0, 0, 0 }; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + *(tmp++) = dither_true (&info->RowBuf[(x >>16) *3], err, &dth); + + if (!--width || !--n) + { + raster_chunk8 (buf, dst, tmp - buf); + dst += 8; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while ( width); +} + +inline void raster_P8 (DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + *(dst++) = *( uint8*)&map[( int16)info->RowBuf[x >>16] & mask]; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_P8( DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + int8 *dth = info->DthBuf; + int16 err = 0; + + do + { + *(dst++) = dither_gray (&info->RowBuf[x >>16], &err, &dth); + x += info->IncXfx; + } while (--width); +} + +inline void dither_P8 (DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + int8 *dth = info->DthBuf; + int16 err[3] = { 0, 0, 0 }; + + do + { + *(dst++) = dither_true (&info->RowBuf[(x >>16) *3], err, &dth); + x += info->IncXfx; + } while (--width); +} + +inline void raster_15 (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + *(dst++) = map[(short)info->RowBuf[x >>16] & mask]; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_15( DECDATA info, void * _dst) +{ + uint16 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint16 rgb = info->RowBuf[(x >>16)]; + rgb = ((rgb & 0xF8) <<7) | ((rgb & 0xF8) <<2) | (rgb >>3); + *(dst++) = (rgb >> 8) | (rgb << 8); + x += info->IncXfx; + } while (--width); +} + +inline void dither_15 (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do { + uint8 * rgb = &info->RowBuf[(x >>16) * 3]; + *(dst++) = (((uint16)rgb[0] & 0xF8) << 7) | (((uint16)rgb[1] & 0xF8) << 2) | ( rgb[2] >> 3); + x += info->IncXfx; + } while (--width); +} + +inline void raster_15r (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + uint16 rgb = map[(short)info->RowBuf[x >>16] & mask]; + *(dst++) = (rgb >> 8) | (rgb << 8); + x += info->IncXfx; + } while (--width); +} + +inline void gscale_15r( DECDATA info, void * _dst) +{ + uint16 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint16 rgb = info->RowBuf[(x >>16)]; + rgb = ((rgb & 0xF8) <<7) | ((rgb & 0xF8) <<2) | (rgb >>3); + *(dst++) = (rgb >> 8) | (rgb << 8); + x += info->IncXfx; + } while (--width); +} + +inline void dither_15r (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >>16) * 3]; + uint16 pix = (((uint16)rgb[0] & 0xF8) << 7) | (((uint16)rgb[1] & 0xF8) << 2) | (rgb[2] >> 3); + *(dst++) = (pix >> 8) | (pix << 8); + x += info->IncXfx; + } while (--width); +} + +inline void raster_16 (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + *(dst++) = map[(int16)info->RowBuf[x >>16] & mask]; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_16( DECDATA info, void * _dst) +{ + register uint16 *dst = _dst; + register int16 width = info->DthWidth; + register uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint16 rgb = info->RowBuf[(x >>16)]; + *(dst++) = ((rgb & 0xF8) <<8) | ((rgb & 0xFC) <<3) | (rgb >>3); + x += info->IncXfx; + } while (--width); +} + +inline void dither_16 (DECDATA info, void * _dst) +{ + register uint16 *dst = _dst; + register int16 width = info->DthWidth; + register uint32 x = (info->IncXfx + 1) >> 1; + + do + { + register uint8 *rgb = &info->RowBuf[(x >> 16) * 3]; + + *(dst++) = (((uint16)rgb[0] & 0xF8) << 8) | (((uint16)rgb[1] & 0xFC) << 3) | ( rgb[2] >> 3); + x += info->IncXfx; + } while (--width); +} + + +inline void raster_16r (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + uint16 rgb = map[(int16)info->RowBuf[x >>16] & mask]; + *(dst++) = (rgb >> 8) | (rgb << 8); + x += info->IncXfx; + } while (--width); +} + +inline void gscale_16r( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint16 rgb = info->RowBuf[(x >>16)]; + rgb = ((rgb & 0xF8) <<8) | ((rgb & 0xFC) <<3) | (rgb >>3); + *(dst++) = (rgb >> 8) | (rgb << 8); + x += info->IncXfx; + } while (--width); +} + +inline void dither_16r (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >>16) *3]; + uint16 pix = ((( uint16)rgb[0] & 0xF8) << 8) | ((( uint16)rgb[1] & 0xFC) << 3) | ( rgb[2] >> 3); + *(dst++) = (pix >> 8) | (pix << 8); + x += info->IncXfx; + } while (--width); +} + +inline void raster_24 (DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + uint8 * rgb = (uint8*)&map[( int16)info->RowBuf[x >>16] & mask]; + *(dst++) = *(++rgb); + *(dst++) = *(++rgb); + *(dst++) = *(++rgb); + x += info->IncXfx; + } while (--width); +} + +inline void gscale_24( DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 rgb = info->RowBuf[(x >>16)]; + *(dst++) = rgb; + *(dst++) = rgb; + *(dst++) = rgb; + x += info->IncXfx; + } while (--width); +} + +inline void dither_24 (DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >>16) *3]; + *(dst++) = *(rgb++); + *(dst++) = *(rgb++); + *(dst++) = *(rgb); + x += info->IncXfx; + } while (--width); +} + + +inline void raster_24r (DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + uint8 * rgb = (uint8*)&map[(int16)info->RowBuf[x >>16] & mask]; + *(dst++) = rgb[3]; + *(dst++) = rgb[2]; + *(dst++) = rgb[1]; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_24r( DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 rgb = info->RowBuf[(x >> 16)]; + *(dst++) = rgb; + *(dst++) = rgb; + *(dst++) = rgb; + x += info->IncXfx; + } while (--width); +} + +inline void dither_24r( DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >> 16) *3]; + *(dst++) = rgb[2]; + *(dst++) = rgb[1]; + *(dst++) = rgb[0]; + x += info->IncXfx; + } while (--width); +} + +inline void raster_32 (DECDATA info, void * _dst) +{ + uint32 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + *(dst++) = map[(int16)info->RowBuf[x >> 16] & mask]; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_32( DECDATA info, void * _dst) +{ + uint32 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint32 rgb = info->RowBuf[(x >> 16)]; + *(dst++) = ((( rgb << 8) | rgb) << 8) | rgb; + x += info->IncXfx; + } while (--width); +} + +inline void dither_32 (DECDATA info, void * _dst) +{ + uint32 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >> 16) *3]; + *(dst++) = ((((uint32)rgb[0] << 8) | rgb[1]) << 8) | rgb[2]; + x += info->IncXfx; + } while (--width); +} + + +inline void raster_32r( DECDATA info, void * _dst) +{ + uint32 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + uint8 * rgb = (uint8*)&map[(int16)info->RowBuf[x >>16] & mask]; + *(dst++) = (((((int32)rgb[3] << 8) | rgb[2]) << 8) | rgb[1]) << 8; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_32r( DECDATA info, void * _dst) +{ + uint32 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint32 rgb = info->RowBuf[(x >>16)]; + *(dst++) = (((( rgb << 8) | rgb) << 8) | rgb) << 8; + x += info->IncXfx; + } while (--width); +} + +inline void dither_32r (DECDATA info, void * _dst) +{ + uint32 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >>16) *3]; + *(dst++) = (((((uint32)rgb[2] <<8) | rgb[1]) << 8) | rgb[0]) << 8; + x += info->IncXfx; + } while (--width); +} + +inline void raster_32z ( DECDATA info, void * _dst) +{ + uint32 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + uint32 * map = info->Pixel; + uint16 mask = info->PixMask; + do { + *(dst++) = map[(int16)info->RowBuf[x >>16] & mask] << 8; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_32z (DECDATA info, void * _dst) +{ + uint32 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + do { + uint32 rgb = info->RowBuf[(x >>16)]; + *(dst++) = ((((rgb <<8) | rgb) <<8) | rgb) << 8; + x += info->IncXfx; + } while (--width); +} + +inline void dither_32z (DECDATA info, void * _dst) +{ + uint32 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + do { + uint8 * rgb = &info->RowBuf[(x >>16) *3]; + *(dst++) = (((((uint32)rgb[0] <<8) | rgb[1]) <<8) | rgb[2]) << 8; + x += info->IncXfx; + } while (--width); +} diff --git a/sources/z-tools/trunk/zcodeclib/src/zvdi/raster.h b/sources/z-tools/trunk/zcodeclib/src/zvdi/raster.h new file mode 100644 index 0000000..f396ed4 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/zvdi/raster.h @@ -0,0 +1,63 @@ +extern void raster_chunks ( uint8 *src, uint16 *dst, uint16 num, uint16 depth); + +#define raster_chunk4(s,d,n) raster_chunks ( s, d, n, 4) +#define raster_chunk8(s,d,n) raster_chunks ( s, d, n, 8) + +extern void raster_mono ( DECDATA info, void * _dst); +extern void raster_D1 ( DECDATA info, void * _dst); +extern void dither_D1 ( DECDATA info, void * _dst); +extern void gscale_D1 ( DECDATA info, void * _dst); + +extern void raster_D2 ( DECDATA info, void * _dst); + +extern void dither_D2 ( DECDATA info, void * _dst); +extern void gscale_D2 ( DECDATA info, void * _dst); + +extern void raster_I4 ( DECDATA info, void * _dst); +extern void dither_I4 ( DECDATA info, void * _dst); +extern void gscale_I4 ( DECDATA info, void * _dst); + +extern void raster_I8 ( DECDATA info, void * _dst); +extern void dither_I8 ( DECDATA info, void * _dst); +extern void gscale_I8 ( DECDATA info, void * _dst); + +extern void raster_P8 ( DECDATA info, void * _dst); +extern void dither_P8 ( DECDATA info, void * _dst); +extern void gscale_P8 ( DECDATA info, void * _dst); + +extern void raster_15 ( DECDATA info, void * _dst); +extern void dither_15 ( DECDATA info, void * _dst); +extern void gscale_15 ( DECDATA info, void * _dst); + +extern void raster_15r ( DECDATA info, void * _dst); +extern void dither_15r ( DECDATA info, void * _dst); +extern void gscale_15r ( DECDATA info, void * _dst); + +extern void raster_16 ( DECDATA info, void * _dst); +extern void dither_16 ( DECDATA info, void * _dst); +extern void gscale_16 ( DECDATA info, void * _dst); + +extern void raster_16r ( DECDATA info, void * _dst); +extern void dither_16r ( DECDATA info, void * _dst); +extern void gscale_16r ( DECDATA info, void * _dst); + +extern void raster_24 ( DECDATA info, void * _dst); +extern void dither_24 ( DECDATA info, void * _dst); +extern void gscale_24 ( DECDATA info, void * _dst); + +extern void raster_24r ( DECDATA info, void * _dst); +extern void dither_24r ( DECDATA info, void * _dst); +extern void gscale_24r ( DECDATA info, void * _dst); + +extern void raster_32 ( DECDATA info, void * _dst); +extern void dither_32 ( DECDATA info, void * _dst); +extern void gscale_32 ( DECDATA info, void * _dst); + +extern void raster_32r ( DECDATA info, void * _dst); +extern void dither_32r ( DECDATA info, void * _dst); +extern void gscale_32r ( DECDATA info, void * _dst); + +extern void raster_32z ( DECDATA info, void * _dst); +extern void dither_32z ( DECDATA info, void * _dst); +extern void gscale_32z ( DECDATA info, void * _dst); + diff --git a/sources/z-tools/trunk/zcodeclib/src/zvdi/vdi.c b/sources/z-tools/trunk/zcodeclib/src/zvdi/vdi.c new file mode 100644 index 0000000..a8a8868 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/zvdi/vdi.c @@ -0,0 +1,221 @@ +#ifdef __PUREC__ +#include "..\general.h" +#include "..\resize.h" +#include "..\load_img.h" +#else +#include "../general.h" +#include "../load_img.h" +#include "../resize.h" +#endif +#include "raster.h" +#include "raresize.h" +#include "color.h" +#include "p2c.h" + +int16 pixel_val[256]; +uint32 cube216[216]; +uint32 graymap[32]; +int16 planar = 0; +int16 vdi_handle, nplanes, vdi_work_in[10], vdi_work_out[57]; + + +/* prototype */ +int16 vdi_init ( void); + + +int16 vdi_init( void) +{ + int16 out[273] = { -1, }; + int16 dum, depth, aes_handle; + boolean reverse, z_trail; + int32 cookie_dum; + + if( !ldg_cookie( 0x45644449L, (int32*)&cookie_dum)) + return( 0); + + /* open a VDI workstation */ + aes_handle = graf_handle( &dum, &dum, &dum, &dum); + vq_extnd( aes_handle, 1, vdi_work_out); + nplanes = vdi_work_out[ 4]; + vdi_work_in[0] = Getrez() + 2; + vdi_handle = aes_handle; + v_opnvwk( vdi_work_in, &vdi_handle, vdi_work_out); + + /* Get the screen's informations */ + vq_scrninfo ( vdi_handle, out); + + if ( nplanes <= 8) + { + save_colors(); + memcpy ( pixel_val, out + 16, 512); + } + + depth = (( uint16)out[4] == 0x8000u ? 15 : out[2]); /* bits per pixel used */ + reverse = (out[16] < out[48]); /* intel crap... */ + z_trail = (out[48] > 0); /* bits are shifted to the right side */ + + if ( depth == 1) + { /* monochrome */ + cnvpal_color = cnvpal_1_2; + raster_cmap = raster_D1; + raster_true = dither_D1; + raster_gray = gscale_D1; + resize = resize_mono; + } + else if ( out[0] == 0) /* Planar */ + { + planar = 1; + + switch ( depth) + { + case 2: + cnvpal_color = cnvpal_1_2; + raster_cmap = raster_D2; + raster_true = dither_D2; + raster_gray = gscale_D2; + planar_to_chunky = planar2_to_chunky8; + break; + case 4: + cnvpal_color = cnvpal_4_8; + raster_cmap = raster_I4; + raster_true = dither_I4; + raster_gray = gscale_I4; + resize = resize_I4; + planar_to_chunky = planar4_to_chunky8; + break; + case 8: + cnvpal_color = cnvpal_4_8; + raster_cmap = raster_I8; + raster_true = dither_I8; + raster_gray = gscale_I8; + resize = resize_I8; + planar_to_chunky = planar8_to_chunky8; + break; + } + } + else if ( out[0] == 2) /* chunky */ + switch ( depth) + { + case 8: + cnvpal_color = cnvpal_4_8; + raster_cmap = raster_P8; + raster_true = dither_P8; + raster_gray = gscale_P8; + resize = resize_P8; + break; + + case 15: + if (!(out[14] & 0x02)) + { + cnvpal_color = cnvpal_15; + + if (reverse) + { + raster_cmap = raster_15r; + raster_gray = gscale_15r; + raster_true = dither_15r; + } + else + { + raster_cmap = raster_15; + raster_gray = gscale_15; + raster_true = dither_15; + } + + resize = resize_16; + + break; + } + + case 16: + cnvpal_color = cnvpal_high; + + if (reverse) + { + raster_cmap = raster_16r; + raster_gray = gscale_16r; + raster_true = dither_16r; + } + else + { + raster_cmap = raster_16; + raster_gray = gscale_16; + raster_true = dither_16; + } + + resize = resize_16; + + break; + + case 24: + cnvpal_color = cnvpal_true; + + if (reverse) + { + raster_cmap = raster_24r; + raster_gray = gscale_24r; + raster_true = dither_24r; + } + else + { + raster_cmap = raster_24; + raster_gray = gscale_24; + raster_true = dither_24; + } + + resize = resize_24; + + break; + + case 32: + cnvpal_color = cnvpal_true; + + if (reverse) + { + raster_cmap = raster_32r; + raster_gray = gscale_32r; + raster_true = dither_32r; + } + else if( z_trail) + { + raster_cmap = raster_32z; + raster_gray = gscale_32z; + raster_true = dither_32z; + } + else + { + raster_cmap = raster_32; + raster_gray = gscale_32; + raster_true = dither_32; + } + + resize = resize_32; + + break; + } + + if (depth == 4 || depth == 8) + { + uint32 * dst; + uint32 r, g, b; + dst = cube216; + + for (r = 0x000000uL; r <= 0xFF0000uL; r += 0x330000uL) + { + for (g = 0x000000uL; g <= 0x00FF00uL; g += 0x003300uL) + { + for (b = 0x000000uL; b <= 0x0000FFuL; b += 0x000033uL) + { + *(dst++) = color_lookup ( r | g | b, pixel_val); + } + } + } + + dst = graymap; + + for ( g = 0x000000uL; g <= 0xF8F8F8uL; g += 0x080808uL) + *( dst++) = color_lookup ( g | (( g >> 5) & 0x030303uL), pixel_val); + } + + return( 1); +} diff --git a/sources/z-tools/trunk/zcodeclib/src/zvdi/vdi.h b/sources/z-tools/trunk/zcodeclib/src/zvdi/vdi.h new file mode 100644 index 0000000..0732c46 --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/src/zvdi/vdi.h @@ -0,0 +1,7 @@ +extern int16 pixel_val[256]; +extern uint32 cube216[216]; +extern uint32 graymap[32]; + +extern int16 vdi_init( void); +extern int16 planar, vdi_handle, nplanes, vdi_work_in[10], vdi_work_out[57]; + diff --git a/sources/z-tools/trunk/zcodeclib/zcodeclib.hyp b/sources/z-tools/trunk/zcodeclib/zcodeclib.hyp new file mode 100644 index 0000000..1c9639d Binary files /dev/null and b/sources/z-tools/trunk/zcodeclib/zcodeclib.hyp differ diff --git a/sources/z-tools/trunk/zcodeclib/zcodeclib.stg b/sources/z-tools/trunk/zcodeclib/zcodeclib.stg new file mode 100644 index 0000000..728acdf --- /dev/null +++ b/sources/z-tools/trunk/zcodeclib/zcodeclib.stg @@ -0,0 +1,355 @@ +@database "zcodeclib Dev. Guide" +@subject "Documentation" +@author "Zorro" +@$VER: ZCODEC.HYP (@:"__DATE__") +@options +Z +@options -S + +@default Index + +@node Index "zcodeclib dev." +zcodeclib dev. +@line 1 70 0 0 1 + + + 1. Introduction + 2. Functions + 3. Global variables + 4. The IMAGE structure. + 5. Do you use MEM.LDG in your application? + + +@endnode + + +@node "Introduction" +1. Introduction +@line 1 70 0 0 1 + +Make a basic GEM application is a very easy task but problems +become when we have to draw something on the screen. + +Indeed, on Atari and others TOS computers, there are many +different screens' formats and, of course, we can't deal with +it in the same manner. + +The problem is worst when we have to load and to draw a picture +from, for example, a JPG file. We have to make ourselves loading +routines, etc... A real nightmare! + +The goal of this library is to offer easy and fast functions for +load images from file and for, especially, deal with the screen. +It provide also useful functions like MFDB zooming and others. + +This library load and use the zview's codecs, so it's fast and +stable. + +@{B}For use this library, you need:@{0} + +- A VDI with a valid EDDI (like NovaVDI, NVDI > 2.5, fVDI, etc..). +- The zview's codec correctly installed with mem.ldg (provided in +the zview archive). +- the LDG library ( http://ldg.org.free.fr) +- A recent GEMLIB. + + +(Index) + +@endnode + +@node "Functions" +2. Functions +@line 1 70 0 0 1 + + + 1. codecs_init() + 2. codecs_quit() + 3. load_img() + 4. delete_img() + 5. pic_resize() + 6. delete_mfdb() + + +(Index) + +@endnode + + +@node "codecs_init()" +codecs_init() +@line 1 70 0 0 1 + +@{B}NAME@{0} + codec_init - initialise and load the wanted codecs. + +@{B}PROTOTYPAGE@{0} + int16 codecs_init( char *codec_name); + + +@{B}PARAMETERS@{0} + codec_name: the name of the codec to load. + + return: 0 if an error occurs else 1. + + +@{B}DESCRIPTION@{0} + It's the first function to call. + + The function's job is to initialize the VDI's informations, + load MEM.LDG ( for shareable allocation) and load the wanted + codecs. + + For example: + + codecs_init( "jpg.ldg"); + + If you need others codecs, you can to call this function any + numbers of times like: + + codecs_init( "jpg.ldg"); + codecs_init( "png.ldg"); + .... + + Cool feature, you can load the complete codec's pack with: + + codec_init( "all"); + + +@{B}IMPORTANT@{0} + Be careful, you can't load two times the same codec so, don't + call again this function after a codec_init( "all"). + + +(Index) + +@endnode + +@node "codecs_quit()" +codecs_quit() +@line 1 70 0 0 1 + +@{B}NAME@{0} + codecs_quit - unload the codecs and MEM.LDG. + +@{B}PROTOTYPAGE@{0} + void codecs_quit( void); + + +@{B}DESCRIPTION@{0} + You must call this function at the end of your code or when we + don't use anymore the functions form this library. + + It unloads MEM.LDG and the codecs previously loaded. + + +(Index) + +@endnode + +@node "load_img()" +load_img() +@line 1 70 0 0 1 + +@{B}NAME@{0}l + load_img() - load, convert and zoom a image. + +@{B}PROTOTYPAGE@{0} + IMAGE *load_img( const char *file, int16 w, int16 h, int16 keep_ratio); + + +@{B}PARAMETERS@{0} + file: the file to load. + + w: the wanted image's width. + -1 for to keep the image's width. + + h: the wanted image's height. + -1 for to keep the image's height. + + keep_ratio: in the case where you set the wanted image's size + with the w and h variables, if 'keep_ratio' if TRUE, + the image is resized to fit in w and h for maintain + the aspect ratio else the image will be exactly at + the wanted size. + + + return: NULL if an error occurs else a valid IMAGE structure. + + +@{B}DESCRIPTION@{0} + The most important function of this library; it loads, converts + to screen format and eventually, zooms a picture. All in one + function! + + +@{B}IMPORTANT@{0} + Don't allocate the IMG structure yourself, the function make it + for you (see example.c). + + +(Index) + +@endnode + + + +@endnode + +@node "delete_img()" +delete_img() +@line 1 70 0 0 1 + +@{B}NAME@{0} + delete_img - free a IMAGE structure. + +@{B}PROTOTYPAGE@{0} + void delete_img( IMAGE *img); + + +@{B}DESCRIPTION@{0} + This function frees all the memories previously allocated for + the "img" structure and also "img" itself. + +(Index) + +@endnode + + +@node "pic_resize()" +pic_resize() +@line 1 70 0 0 1 + +@{B}NAME@{0}l + pic_resize() - resize a MFDB. + +@{B}PROTOTYPAGE@{0} + MFDB *pic_resize( MFDB *in, int16 w, int16 h, int16 keep_ratio); + + +@{B}PARAMETERS@{0} + in: the input MFDB address. + + w: the wanted MFDB's width. + + h: the wanted MFDB's height. + + keep_ratio: if 'keep_ratio' if TRUE, the MFDB is resized for to + fit in 'w' and 'h' for maintain the aspect ratio + else the MFDB will be exactly at the 'w' and 'h' size. + + return: NULL if an error occurs else a valid MFDB address. + + +@{B}DESCRIPTION@{0} + Return a MFDB resized with the data of 'in'. + + +@{B}IMPORTANT@{0} + 1) Don't allocate the "out" MFDB yourself, the function make it + for you (see example.c). + 2) You can't free the MFDB youself, use delete_mfdb() for do that. + + +(Index) + +@endnode + + + +@node "delete_mfdb()" +delete_mfdb() +@line 1 70 0 0 1 + +@{B}NAME@{0}l + delete_mfdb() - delete one or more MFDB structure(s). + +@{B}PROTOTYPAGE@{0} + void delete_mfdb( MFDB *bm, int16 nbr); + + +@{B}PARAMETERS@{0} + bm: the MFDB to free. + + nbr: the number of MFDB in 'bm'. + + return: nothing. + + +@{B}DESCRIPTION@{0} + Free one or more MFDB created with pic_resize(). + + +(Index) + +@endnode + + +@node "Global variables" +Global variables +@line 1 70 0 0 1 + + + All this global variable are in in16 format( short). + + planar: The screen format, 1 if planar else 0. + + nplanes: the screen planes' number. + + vdi_work_in[10], vdi_work_out[57]: useful information about + the VDI. + + vdi_handle: a "ready to use" VDI handle. + + +(Index) + +@endnode + + +@node "IMAGE" +IMAGE +@line 1 70 0 0 1 + + +typedef struct +{ + int16 page; + uint16 *delay; + MFDB *image; +} IMAGE; + + +delay: exists only if the image is a animated one ( for example: + animated GIF, FLI, etc..). + +page: is the number of image returned (For animated picture or + multi-pages documents like FAX). + +image: is one of many MFDB structure(s) ready to be transferred to + the screen. + + +@endnode + + +@node "Do you use MEM.LDG in your application?" +Do you use MEM.LDG in your application? +@line 1 70 0 0 1 + + +Libzcodec loads already the MEM.LDG so you can't do it again in your +code! + +For this prupose, in the header's file, we can find +'shared_malloc( a)' and 'shared_free( a)'. + +This functions are only ldg_malloc() and ldg_free() binded; you +can use it without any problem and if far better that Mintlib malloc's +function. + +If you need ldg_realloc or ldg_calloc, you need to make a +ldg_find( "ldg_calloc", ldg_mem) youself. ( ldg_mem is a global +variable used for load MEM.LDG). + + +@endnode diff --git a/sources/z-tools/trunk/ztask/Makefile b/sources/z-tools/trunk/ztask/Makefile new file mode 100644 index 0000000..a43b9f1 --- /dev/null +++ b/sources/z-tools/trunk/ztask/Makefile @@ -0,0 +1,12 @@ +DEBUG = # -DDEBUG +STACKSIZE = 64k +OPTIMISATION = -O2 -fomit-frame-pointer +CPU = -m68020-60 +LIB = -lwindom -lgem -lldg -lm #-lwout +CFLAGS = $(CPU) $(OPTIMISATION) $(DEBUG) -Wall -Wshadow + +OBJ = debug.o gmem.o prefs.o color_selector.o taskman.o pref_panel.o shutdown.o quit.o app.o process.o cpu.o string.o popup.o win.o main.o + +PROGRAM = ztask.app + +include ../common.mak diff --git a/sources/z-tools/trunk/ztask/app.c b/sources/z-tools/trunk/ztask/app.c new file mode 100644 index 0000000..6387e4f --- /dev/null +++ b/sources/z-tools/trunk/ztask/app.c @@ -0,0 +1,310 @@ +#include "general.h" +#include "gmem.h" +#include "string.h" + +app_data *root = NULL, *selected = NULL, *old_selected = NULL; +int16 app_nbr = 0; + + +int16 find_top_app_by_window( void) +{ + int16 win_handle, next_win_handle, aes_id, dum; + + if( mt_wind_get( 0, WF_TOP, &win_handle, &aes_id, &next_win_handle, &dum, app.aes_global) == 0) + return -1; + + return aes_id; +} + + + +/*==================================================================================* + * app_data_attach: * + * attach a entry in the global application list. * + *----------------------------------------------------------------------------------* + * input: * + * name: The application name. * + * name_shown: The name to be shown in the taskbar. * + * id: The AES ID of the application. * + * name_shown_width: The text width of 'name_shown' in pixel. * + *----------------------------------------------------------------------------------* + * returns: * + * TRUE if all is ok else FALSE * + *==================================================================================*/ + +int16 app_data_attach( char *name, char *name_shown, int16 id, int16 pid, int16 name_shown_width) +{ + app_data *new = ( app_data *)gmalloc( sizeof(app_data)); + + if( !new) + return FALSE; + + new -> id = id; + new -> pid = pid; + new -> next = root; + new -> name_shown_width = name_shown_width; + + strcpy( new -> name, name); + strcpy( new -> name_shown, name_shown); + + root = new; + + app_nbr++; + + return TRUE; +} + + +/*==================================================================================* + * app_data_find_parent: * + * find the parent( previous) entry in the application list. * + *----------------------------------------------------------------------------------* + * input: * + * child: the function returns the parent of this entry. * + *----------------------------------------------------------------------------------* + * returns: * + * the parent entry else the root entry. * + *==================================================================================*/ +app_data *app_data_find_parent( app_data *child) +{ + app_data *scan = root; + + while( scan) + { + if( scan->next != child) + { + scan = scan->next; + continue; + } + + break; + } + + return( scan); +} + + +/*==================================================================================* + * app_data_delete: * + * Delete an entry in the application list. * + *----------------------------------------------------------------------------------* + * input: * + * id: the AES id of the entry to delete. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void app_data_delete( int16 id) +{ + app_data *scan = root, *parent; + + while( scan) + { + if( scan->id != id) + { + scan = scan->next; + continue; + } + + parent = app_data_find_parent( scan); + + if( parent == NULL) + root = scan->next; + else + parent->next = scan->next; + + gfree( scan); + app_nbr--; + break; + } +} + + +/*==================================================================================* + * app_data_find: * + * Find an entry in the application list. * + *----------------------------------------------------------------------------------* + * input: * + * id: the AES id of the entry to find. * + *----------------------------------------------------------------------------------* + * returns: * + * the entry or NULL if not found. * + *==================================================================================*/ +app_data *app_data_find( int16 id) +{ + app_data *scan = root, *result = NULL; + + while( scan) + { + if( scan->id != id) + { + scan = scan->next; + continue; + } + + result = scan; + break; + } + + return( result); +} + + +/*==================================================================================* + * app_have_wind: * + * Check if an application owns at least one window. * + *----------------------------------------------------------------------------------* + * input: * + * id: the AES id of the entry to check. * + *----------------------------------------------------------------------------------* + * returns: * + * 1 if TRUE else 0. * + *==================================================================================*/ +int16 app_have_wind( int16 id) +{ + int16 result = 0, dum, aes_win, next = -1, status, aes_id; + + if( mt_wind_get( 0, WF_OWNER, &aes_id, &status, &aes_win, &dum, app.aes_global) == 0) + return result; + + while( aes_win) + { + if( mt_wind_get( aes_win, WF_OWNER, &aes_id, &status, &next, &dum, app.aes_global) == 0) + break; + + if( ( aes_id != id) || ( status == 0)) + { + aes_win = next; + continue; + } + + result = 1; + break; + } + + return result; +} + + + +/*==================================================================================* + * app_data_search: * + * Make a list of all the loaded application and add it in the global * + * application list if necessary. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void app_data_search( void) +{ + char name[9], name_shown[MAXNAMLEN]; + app_data *scan = root, *tmp = NULL; + int16 lenght, i, id, pid, type, count = 0, ap_cout, name_shown_width, old_id_by_win, old_id_by_menu; + static int16 id_by_win = 0, id_by_menu = 0; + + for( i = 0; mt_appl_search( i, name, &type, &id, app.aes_global); i = 1) + { + // Is an accessory? + if( show_acc == FALSE && ( type & APP_ACCESSORY)) + continue; + + // Is a system app or zTask itself? + if(( type & APP_SYSTEM) || ( id == _AESapid)) + continue; + + count++; + + // Is already listed? + if( app_data_find( id)) + continue; + + if( mt_appl_control( id, APC_INFO, &ap_cout, app.aes_global) == 0) + { + count--; + continue; + } + + // if it's not a accessory, if the application doesn't own a menu bar and if it doesn't own a window, we skip this id. + if(( type != APP_ACCESSORY) && !( ap_cout & APCI_HASMBAR) && !app_have_wind( id)) + { + count--; + continue; + } + + // We setup the name to show in the case + mt_appl_search( -id, name_shown, &type, &pid, app.aes_global); + + trim_start(name_shown); + trim_end( name_shown, strlen( name_shown) - 1); + + if( strcmp( "XaSYS", name_shown) == 0) + { + count--; + continue; + } + + lenght = strlen( name_shown); + + if( lenght > 4) + { + char *extention = name_shown + lenght - 4; + + // If the application's name has an extention ( like "xxx.app"), we remove it + if( *extention == '.') + *extention = '\0'; + } + + name_shown_width = get_text_width( name_shown); + + if( name_shown_width > ( app_width - 6)) + name_shown_width = name_shorter( app_width - 6, name_shown); + + app_data_attach( name, name_shown, id, pid, name_shown_width); + } + + if( count != app_nbr) + { + while( scan) + { + if( mt_appl_find( scan->name, app.aes_global) == -1) + { + id = scan->id; + scan = scan->next; + app_data_delete( id); + continue; + } + + scan = scan->next; + } + } + + old_id_by_win = id_by_win; + old_id_by_menu = id_by_menu; + + id_by_win = find_top_app_by_window(); + id_by_menu = mt_menu_bar( NULL, MENU_INQUIRE, app.aes_global); + + id = 0; + + if(( old_id_by_win != id_by_win) && ( old_id_by_menu == id_by_menu)) + id = id_by_win; + else if(( old_id_by_win == id_by_win) && ( old_id_by_menu != id_by_menu)) + id = id_by_menu; + else if(( old_id_by_win != id_by_win) && ( old_id_by_menu != id_by_menu)) + id = id_by_menu; + + if( id) + { + tmp = app_data_find( id); + + if( tmp != selected) + { + old_selected = selected; + selected = tmp; + } + } +} + diff --git a/sources/z-tools/trunk/ztask/app.h b/sources/z-tools/trunk/ztask/app.h new file mode 100644 index 0000000..6cfbf17 --- /dev/null +++ b/sources/z-tools/trunk/ztask/app.h @@ -0,0 +1,9 @@ +extern app_data *root, *selected, *old_selected; +extern int16 app_nbr; + +extern int16 app_data_attach( char *name, int16 id); +extern void app_data_delete( int16 id); +extern app_data *app_data_find( int16 id); +extern void app_data_search( void); + + diff --git a/sources/z-tools/trunk/ztask/color_selector.c b/sources/z-tools/trunk/ztask/color_selector.c new file mode 100644 index 0000000..1004579 --- /dev/null +++ b/sources/z-tools/trunk/ztask/color_selector.c @@ -0,0 +1,192 @@ +#include "general.h" + +static int16 xw, yw, ww, hw, color_by_line; +static int16 selected_color; +static int16 object_parent; + +extern WINDOW *pref_dialog_win; +extern int tmp_button_off_background, tmp_button_off_light_color, tmp_button_off_dark_color, +tmp_button_off_text_color, tmp_button_off_text_shadow_color, tmp_button_on_background, +tmp_button_on_light_color, tmp_button_on_dark_color, tmp_button_on_text_color, +tmp_button_on_text_shadow_color, tmp_geek_area_color, tmp_geek_area_dark_line, +tmp_geek_area_light_line, tmp_app_width, tmp_cpu_bar_color, +tmp_tt_bar_color, tmp_st_bar_color, tmp_geek_area_text_color; + +static void CDECL timer_function( WINDOW *win, int16 buff[8]) +{ + if( !IS_IN( evnt.mx, evnt.my, xw, yw, ww, hw)) + ApplWrite( _AESapid, WM_DESTROY, win->handle, 0, 0, 0, 0); +} + + +static void CDECL win_mouse_event( WINDOW *win, int16 buff[8]) +{ + int16 x, y, pxy[2]; + int color = 0; + + for( y = 0, pxy[1] = yw + 1; y < color_by_line; y++, pxy[1] += 11) + { + for( x = 0, pxy[0] = xw + 1; x < color_by_line; x++, pxy[0] += 11, color++) + { + if( IS_IN( evnt.mx, evnt.my, pxy[0], pxy[1], 9, 9)) + { + switch( object_parent) + { + case PREFS_ON_BACK: + tmp_button_on_background = color; + break; + + case PREFS_ON_LINE1: + tmp_button_on_light_color = color; + break; + + case PREFS_ON_LINE2: + tmp_button_on_dark_color = color; + break; + + case PREFS_ON_TEXT1: + tmp_button_on_text_color = color; + break; + + case PREFS_ON_TEXT2: + tmp_button_on_text_shadow_color = color; + break; + + case PREFS_OFF_BACK: + tmp_button_off_background = color; + break; + + case PREFS_OFF_LINE1: + tmp_button_off_light_color = color; + break; + + case PREFS_OFF_LINE2: + tmp_button_off_dark_color = color; + break; + + case PREFS_OFF_TEXT1: + tmp_button_off_text_color = color; + break; + + case PREFS_OFF_TEXT2: + tmp_button_off_text_shadow_color = color; + break; + + case PREFS_GEEK_BACK: + tmp_geek_area_color = color; + break; + + case PREFS_GEEK_LINE1: + tmp_geek_area_light_line = color; + break; + + case PREFS_GEEK_LINE2: + tmp_geek_area_dark_line = color; + break; + + case PREFS_GEEK_RAM1: + tmp_st_bar_color = color; + break; + + case PREFS_GEEK_RAM2: + tmp_tt_bar_color = color; + break; + + case PREFS_GEEK_CPU: + tmp_cpu_bar_color = color; + break; + + case PREFS_GEEK_TEXT: + tmp_geek_area_text_color = color; + break; + } + + break; + } + } + } + + ApplWrite( _AESapid, WM_DESTROY, win->handle, 0, 0, 0, 0); + ObjcDraw( OC_FORM, pref_dialog_win, PREFS_PREVIEW, 1); +} + + +static void CDECL win_redraw_event( WINDOW *win, int16 buff[8]) +{ + int16 x, y, pxy[4], xy[10], color = 0; + + pxy[0] = xw; + pxy[1] = yw; + pxy[2] = pxy[0] + ww - 1; + pxy[3] = pxy[1] + hw - 1; + + vsf_color( win->graf->handle, WHITE); + v_bar( win->graf->handle, pxy); + + vsl_color( win->graf->handle, BLACK); + + for( y = 0, pxy[1] = yw + 1; y < color_by_line; y++, pxy[1] += 11) + { + for( x = 0, pxy[0] = xw + 1; x < color_by_line; x++, pxy[0] += 11, color++) + { + pxy[2] = pxy[0] + 9; + pxy[3] = pxy[1] + 9; + + vsf_color( win->graf->handle, color); + v_bar( win->graf->handle, pxy); + + xy[0] = pxy[0]; + xy[1] = pxy[1]; + xy[2] = xy[0]; + xy[3] = xy[1] + 9; + xy[4] = xy[0] + 9; + xy[5] = xy[3]; + xy[6] = xy[4]; + xy[7] = xy[1]; + xy[8] = xy[0]; + xy[9] = xy[1]; + + v_pline( win->graf->handle, 5, xy); + + if( color == selected_color) + { + xy[0] = pxy[0] - 1; + xy[1] = pxy[1] - 1; + xy[2] = xy[0]; + xy[3] = xy[1] + 11; + xy[4] = xy[0] + 11; + xy[5] = xy[3]; + xy[6] = xy[4]; + xy[7] = xy[1]; + xy[8] = xy[0]; + xy[9] = xy[1]; + + v_pline( win->graf->handle, 5, xy); + } + } + } +} + + +void vdi_color_selector( int16 x, int16 y, int16 color_selected, int16 parent_object) +{ + WINDOW *win = WindCreate( 0, app.x, app.y, app.w, app.h); + + EvntAttach( win, WM_REDRAW, win_redraw_event); + EvntAttach( win, WM_XBUTTON, win_mouse_event); + + color_by_line = (( app.nplanes < 8) ? 4 : 16); + selected_color = color_selected; + object_parent = parent_object; + + if( app.nplanes == 4) + WindCalc( WC_BORDER, win, x, y, 45, 45, &xw, &yw, &ww, &hw); + else + WindCalc( WC_BORDER, win, x, y, 177, 177, &xw, &yw, &ww, &hw); + + WindSet( win, WF_BEVENT, BEVENT_MODAL, 0, 0, 0); + EvntAttach( win, WM_XTIMER, timer_function); + WindOpen( win, xw, yw, ww, hw); + WindGet( win, WF_WORKXYWH, &xw, &yw, &ww, &hw); +} + diff --git a/sources/z-tools/trunk/ztask/cpu.c b/sources/z-tools/trunk/ztask/cpu.c new file mode 100644 index 0000000..31c0714 --- /dev/null +++ b/sources/z-tools/trunk/ztask/cpu.c @@ -0,0 +1,151 @@ +#include "general.h" + +char buf[2048]; + +extern uint32 total_stram; +extern uint32 total_ttram; + + + +/* returns current cpu usage in percent */ +inline int16 cpu_get_usage( void) +{ + static int32 pre_used = 0, pre_total = 0; + int16 usage = 0; + int32 mcpu, mnice, msystem, midle, used = 0, total = 0; + FILE *fp; + + if ( !( fp = fopen("U:/kern/stat", "r"))) + return usage; + + fread( buf, 1, 2048, fp); + + fclose(fp); + + sscanf( buf, "%*s %ld %ld %ld %ld", &mcpu, &mnice, &msystem, &midle); + + used = mcpu + msystem + mnice; + total = used + midle; + + /* calc CPU usage */ + if( total - pre_total > 0) + usage = ( int16)(( 20 * ( double)( used - pre_used)) / ( double)( total - pre_total)); + + if( usage < 0) + usage = 0; + + pre_used = used; + pre_total = total; + + return usage; +} + + +void get_total_ram( void) +{ + size_t bytes_read; + char *match; + FILE *fp; + + total_stram = 0; + total_ttram = 0; + + if ( !( fp = fopen("U:/kern/meminfo", "r"))) + return; + + bytes_read = fread( buf, 1, 2048, fp); + + fclose(fp); + + if( bytes_read == 0) + return; + + match = strstr( buf, "FastTotal"); + + if( match == NULL) + return; + + sscanf( match, "FastTotal: %ld", &total_ttram); + + match = strstr( buf, "CoreTotal"); + + if( match == NULL) + return; + + sscanf( match, "CoreTotal: %ld", &total_stram); +} + + +inline void get_free_ram( uint32 *st_ram, uint32 *tt_ram) +{ + size_t bytes_read; + uint32 free_ram; + char *match; + FILE *fp; + + *tt_ram = 0; + *st_ram = 0; + + if ( !( fp = fopen("U:/kern/meminfo", "r"))) + return; + + bytes_read = fread( buf, 1, 2048, fp); + + fclose(fp); + + if( bytes_read == 0) + return; + + match = strstr( buf, "FastFree"); + + if( match == NULL) + return; + + sscanf( match, "FastFree: %lu", &free_ram); + + *tt_ram = free_ram; + + match = strstr( buf, "CoreFree"); + + if( match == NULL) + return; + + sscanf( match, "CoreFree: %lu", &free_ram); + + *st_ram = free_ram; +} + + + +inline void get_info_by_pid( int pid, char *name, char *ram_usage, uint32 *cpu_time) +{ + size_t bytes_read; + char *s, *t; + uint32 user_time, system_time; + int32 ram; + + FILE *fp; + + sprintf( buf, "U:/kern/%d/stat", pid); + + if ( !( fp = fopen( buf, "r"))) + return; + + bytes_read = fread( buf, 1, 2048, fp); + + fclose(fp); + + if( bytes_read == 0) + return; + + s = strchr ( buf, '(') + 1; + t = strchr ( buf, ')'); + strncpy( name, s, t - s); + name[t - s] = '\0'; + + sscanf( t + 2, "%*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %lu %lu %*d %*d %*d %*d %*u %*d %*u %*u %ld", &user_time, &system_time, &ram); + + sprintf( ram_usage, "%ld kB", ram >> 10); + + *cpu_time = user_time + system_time; +} diff --git a/sources/z-tools/trunk/ztask/cpu.h b/sources/z-tools/trunk/ztask/cpu.h new file mode 100644 index 0000000..d6ec06c --- /dev/null +++ b/sources/z-tools/trunk/ztask/cpu.h @@ -0,0 +1,9 @@ +extern inline int16 cpu_get_usage( void); +extern void get_total_ram( void); +extern inline void get_info_by_pid( int pid, char *name, char *ram_usage, uint32 *cpu_time); +extern inline void get_free_ram( uint32 *st_Ram, uint32 *tt_ram); + + + + + diff --git a/sources/z-tools/trunk/ztask/debug.c b/sources/z-tools/trunk/ztask/debug.c new file mode 100644 index 0000000..fd2b23b --- /dev/null +++ b/sources/z-tools/trunk/ztask/debug.c @@ -0,0 +1,32 @@ +#include "general.h" +#ifdef DEBUG +#include +#endif + +/*==================================================================================* + * void zdebug: * + * print debug information in 'wout' window. * + *----------------------------------------------------------------------------------* + * input: * + * ... -> text and parameter are the same that sandard "printf" function. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void zdebug( const char *format, ...) +{ +#ifdef DEBUG + va_list args; + char fo_buff[255], *p; + + va_start( args, format); + vsprintf( fo_buff, format, args); + p = fo_buff; + va_end( args); + + wout_printf("%s\n", p); +#endif +} + + + diff --git a/sources/z-tools/trunk/ztask/font_8.h b/sources/z-tools/trunk/ztask/font_8.h new file mode 100644 index 0000000..cb6999a --- /dev/null +++ b/sources/z-tools/trunk/ztask/font_8.h @@ -0,0 +1,154 @@ +/* MY_FONT8: Fonte 8*8 'non monospac‚e'. */ +/* Version 1.0 (c) Eric Reboux 1997. */ + +static short ofwf[256] = /* tableau espacements des caractŠres */ +{ + 0, 7, 7, 7, 7, 8, 8, 8, 7, 8, 7, 7, 7, 7, 6, 7, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, + 3, 3, 5, 7, 6, 6, 7, 3, 4, 4, 6, 6, 3, 6, 2, 5, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 2, 3, 4, 5, 4, 6, + 7, 6, 6, 6, 6, 5, 5, 6, 6, 2, 5, 6, 5, 7, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 3, 5, 3, 6, 6, + 3, 5, 5, 5, 5, 5, 3, 5, 5, 4, 4, 5, 4, 8, 5, 5, + 5, 5, 4, 5, 3, 5, 5, 6, 6, 5, 6, 5, 2, 5, 7, 6, + 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 6, 6, + 5, 8, 8, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 5, + 5, 4, 5, 5, 5, 6, 5, 5, 6, 7, 7, 8, 8, 3, 7, 7, + 5, 5, 8, 7, 8, 8, 6, 6, 6, 6, 5, 4, 8, 8, 8, 8, + 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 6, 8, + 7, 6, 6, 8, 7, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 8, 8, 6, 7, 5, 5, 4, 7, 5, 5, 5, 6 +}; + +static short my_font_8[1280] = /* Tableau des donn‚es de la fonte */ +{ + 0x0018, 0x3C7E, 0x1818, 0x1800, 0x0018, 0x1818, 0x7E3C, 0x1800, + 0x0008, 0x0C7E, 0x7E0C, 0x0800, 0x0010, 0x307E, 0x7E30, 0x1000, + 0x3C99, 0xC3E7, 0xC399, 0x3C00, 0xFFFF, 0xFEFC, 0xF9F3, 0xE700, + 0xE7C3, 0x993C, 0x99C3, 0xE700, 0x0002, 0x068C, 0xD870, 0x2000, + 0x7EC3, 0x9195, 0x9981, 0xC37E, 0x183C, 0x3C3C, 0x7E10, 0x3810, + 0x000E, 0x0B08, 0x0838, 0x7830, 0xF080, 0xDC90, 0x9810, 0x1000, + 0x6080, 0x9C92, 0x7C12, 0x1200, 0x0A0A, 0x0A1A, 0x1A32, 0xF2E2, + 0xA0A0, 0xA0B0, 0xB098, 0x9E8E, 0x3844, 0x4400, 0x4444, 0x3800, + 0x0404, 0x0400, 0x0404, 0x0400, 0x3804, 0x0438, 0x4040, 0x3800, + 0x7008, 0x0870, 0x0808, 0x7000, 0x4444, 0x4438, 0x0404, 0x0400, + 0x3840, 0x4038, 0x0404, 0x3800, 0x3840, 0x4038, 0x4444, 0x3800, + 0x7008, 0x0800, 0x0808, 0x0800, 0x3844, 0x4438, 0x4444, 0x3800, + 0x3844, 0x4438, 0x0404, 0x3800, 0x0000, 0x7804, 0x7844, 0x3800, + 0x7040, 0x7040, 0x7C10, 0x1C00, 0x0F1F, 0x3F30, 0x3020, 0x3C2E, + 0xE0F0, 0xD808, 0x0808, 0x78A8, 0x2216, 0x1B0C, 0x0F5C, 0x7370, + 0x0850, 0xB050, 0xA020, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x4040, 0x4040, 0x4000, 0x4000, 0x4848, 0x0000, 0x0000, 0x0000, + 0x0024, 0x7E24, 0x247E, 0x2400, 0x103C, 0x5038, 0x1478, 0x1000, + 0x0048, 0x0810, 0x1020, 0x2400, 0x1824, 0x1830, 0x4A44, 0x3A00, + 0x2020, 0x4000, 0x0000, 0x0000, 0x1020, 0x4040, 0x4040, 0x2010, + 0x4020, 0x1010, 0x1010, 0x2040, 0x0028, 0x107C, 0x1028, 0x0000, + 0x0010, 0x107C, 0x1010, 0x0000, 0x0000, 0x0000, 0x0020, 0x2040, + 0x0000, 0x007C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4000, + 0x0808, 0x1010, 0x2020, 0x4040, 0x3844, 0x4444, 0x4444, 0x3800, + 0x1030, 0x1010, 0x1010, 0x3800, 0x3844, 0x0408, 0x1020, 0x7C00, + 0x7C08, 0x1038, 0x0444, 0x3800, 0x0818, 0x2848, 0x7C08, 0x0800, + 0x7C40, 0x7804, 0x0444, 0x3800, 0x1820, 0x4078, 0x4444, 0x3800, + 0x7C04, 0x0408, 0x1010, 0x1000, 0x3844, 0x4438, 0x4444, 0x3800, + 0x3844, 0x443C, 0x0408, 0x3000, 0x0000, 0x4000, 0x0040, 0x0000, + 0x0000, 0x2000, 0x0020, 0x2040, 0x0010, 0x2040, 0x2010, 0x0000, + 0x0000, 0x7800, 0x7800, 0x0000, 0x0040, 0x2010, 0x2040, 0x0000, + 0x3844, 0x0408, 0x1000, 0x1000, 0x3C42, 0x5A52, 0x5C40, 0x3E00, + 0x1028, 0x4444, 0x7C44, 0x4400, 0x7844, 0x4478, 0x4444, 0x7800, + 0x3844, 0x4040, 0x4044, 0x3800, 0x7048, 0x4444, 0x4448, 0x7000, + 0x7840, 0x4070, 0x4040, 0x7800, 0x7840, 0x4070, 0x4040, 0x4000, + 0x3844, 0x404C, 0x4444, 0x3800, 0x4444, 0x447C, 0x4444, 0x4400, + 0x4040, 0x4040, 0x4040, 0x4000, 0x0808, 0x0808, 0x0848, 0x3000, + 0x4448, 0x5060, 0x5048, 0x4400, 0x4040, 0x4040, 0x4040, 0x7800, + 0x4266, 0x5A42, 0x4242, 0x4200, 0x4464, 0x544C, 0x4444, 0x4400, + 0x3844, 0x4444, 0x4444, 0x3800, 0x7844, 0x4478, 0x4040, 0x4000, + 0x3844, 0x4444, 0x5448, 0x3400, 0x7844, 0x4478, 0x5048, 0x4400, + 0x3844, 0x4038, 0x0444, 0x3800, 0x7C10, 0x1010, 0x1010, 0x1000, + 0x4444, 0x4444, 0x4444, 0x3800, 0x4444, 0x4444, 0x2828, 0x1000, + 0x4141, 0x4149, 0x2A2A, 0x1400, 0x4444, 0x2810, 0x2844, 0x4400, + 0x4444, 0x4428, 0x1010, 0x1000, 0x7C04, 0x0810, 0x2040, 0x7C00, + 0x6040, 0x4040, 0x4040, 0x6000, 0x4040, 0x2020, 0x1010, 0x0808, + 0x6020, 0x2020, 0x2020, 0x6000, 0x1028, 0x4400, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x7C00, 0x4040, 0x2000, 0x0000, 0x0000, + 0x0000, 0x3008, 0x3848, 0x3800, 0x4040, 0x7048, 0x4848, 0x7000, + 0x0000, 0x3048, 0x4048, 0x3000, 0x0808, 0x3848, 0x4848, 0x3800, + 0x0000, 0x3048, 0x7840, 0x3800, 0x3040, 0x4060, 0x4040, 0x4000, + 0x0000, 0x3848, 0x4838, 0x0870, 0x4040, 0x7048, 0x4848, 0x4800, + 0x2000, 0x6020, 0x2020, 0x7000, 0x1000, 0x1010, 0x1010, 0x5020, + 0x4040, 0x4850, 0x6050, 0x4800, 0x6020, 0x2020, 0x2020, 0x7000, + 0x0000, 0x7649, 0x4949, 0x4900, 0x0000, 0x7048, 0x4848, 0x4800, + 0x0000, 0x3048, 0x4848, 0x3000, 0x0000, 0x7048, 0x4848, 0x7040, + 0x0000, 0x3848, 0x4848, 0x3808, 0x0000, 0x5060, 0x4040, 0x4000, + 0x0000, 0x3840, 0x3008, 0x7000, 0x4040, 0x6040, 0x4040, 0x2000, + 0x0000, 0x4848, 0x4848, 0x3800, 0x0000, 0x4848, 0x4850, 0x2000, + 0x0000, 0x4444, 0x5438, 0x2800, 0x0000, 0x4428, 0x1028, 0x4400, + 0x0000, 0x4848, 0x4838, 0x0870, 0x0000, 0x7C08, 0x1020, 0x7C00, + 0x1820, 0x2040, 0x2020, 0x1800, 0x4040, 0x4040, 0x4040, 0x4040, + 0x6010, 0x1008, 0x1010, 0x6000, 0x0020, 0x724E, 0x0400, 0x0000, + 0x0010, 0x2828, 0x447C, 0x0000, 0x3844, 0x4040, 0x4438, 0x1020, + 0x4800, 0x4848, 0x4848, 0x3800, 0x1020, 0x3048, 0x7840, 0x3800, + 0x3048, 0x3008, 0x3848, 0x3800, 0x2800, 0x3008, 0x3848, 0x3800, + 0x1008, 0x3008, 0x3848, 0x3800, 0x1010, 0x3008, 0x3848, 0x3800, + 0x0030, 0x4840, 0x4830, 0x1060, 0x1028, 0x3048, 0x7840, 0x3800, + 0x2800, 0x3048, 0x7840, 0x3800, 0x2010, 0x3048, 0x7840, 0x3800, + 0x5000, 0x6020, 0x2020, 0x7000, 0x2050, 0x6020, 0x2020, 0x7000, + 0x2010, 0x6020, 0x2020, 0x7000, 0x2800, 0x1028, 0x447C, 0x4400, + 0x1000, 0x1028, 0x447C, 0x4400, 0x1020, 0x7840, 0x7040, 0x7800, + 0x0000, 0x3E09, 0x3F48, 0x3E00, 0x1F38, 0x484E, 0x7848, 0x4F00, + 0x3048, 0x3048, 0x4848, 0x3000, 0x4800, 0x3048, 0x4848, 0x3000, + 0x2010, 0x3048, 0x4848, 0x3000, 0x3048, 0x0048, 0x4848, 0x3800, + 0x2010, 0x0048, 0x4848, 0x3800, 0x4800, 0x4848, 0x4838, 0x0870, + 0x2800, 0x3844, 0x4444, 0x3800, 0x4400, 0x4444, 0x4444, 0x3800, + 0x1038, 0x5450, 0x5438, 0x1000, 0x1824, 0x2078, 0x2020, 0x7800, + 0x4444, 0x3810, 0x7C10, 0x1000, 0x1824, 0x4478, 0x4444, 0x7840, + 0x1820, 0x2070, 0x2020, 0x4000, 0x1020, 0x3008, 0x3848, 0x3800, + 0x2040, 0x0060, 0x2020, 0x7000, 0x1020, 0x0030, 0x4848, 0x3000, + 0x1020, 0x0048, 0x4848, 0x3800, 0x2850, 0x0070, 0x4848, 0x4800, + 0x3458, 0x0064, 0x544C, 0x4400, 0x0030, 0x0838, 0x4838, 0x0078, + 0x0030, 0x4848, 0x4830, 0x0078, 0x1000, 0x1020, 0x4044, 0x3800, + 0x0000, 0x0000, 0x1E10, 0x1000, 0x0000, 0x0000, 0x7808, 0x0800, + 0x4244, 0x4816, 0x2142, 0x0700, 0x4244, 0x4816, 0x2A4F, 0x0200, + 0x0040, 0x0040, 0x4040, 0x4040, 0x0012, 0x2448, 0x2412, 0x0000, + 0x0048, 0x2412, 0x2448, 0x0000, 0x2850, 0x0030, 0x0878, 0x3800, + 0x2850, 0x0030, 0x4848, 0x3000, 0x1D22, 0x262A, 0x3222, 0x5C00, + 0x0000, 0x1A24, 0x3C24, 0x5800, 0x0000, 0x3E49, 0x4F48, 0x3E00, + 0x3F48, 0x484E, 0x4848, 0x3F00, 0x1008, 0x1028, 0x447C, 0x4400, + 0x3458, 0x1028, 0x447C, 0x4400, 0x3458, 0x0038, 0x4444, 0x3800, + 0x2400, 0x0000, 0x0000, 0x0000, 0x1020, 0x4000, 0x0000, 0x0000, + 0x2070, 0x2020, 0x0000, 0x0000, 0x3A4A, 0x4A4A, 0x3A0A, 0x0A0A, + 0x3C42, 0x99A1, 0xA199, 0x423C, 0x3C42, 0xB9A5, 0xB9A5, 0x423C, + 0xEA4E, 0x4A4A, 0x0000, 0x0000, 0x2400, 0x6424, 0x2474, 0x0418, + 0x7424, 0x2424, 0x2474, 0x0418, 0x0000, 0x1038, 0x7C10, 0x1010, + 0x1010, 0x107C, 0x3810, 0x0000, 0x0010, 0x18FC, 0x1810, 0x0000, + 0x0008, 0x183F, 0x1808, 0x0000, 0x1010, 0x101F, 0x0000, 0x0000, + 0x0000, 0x00F0, 0x1010, 0x1010, 0x1010, 0x10F0, 0x0000, 0x0000, + 0x0000, 0x001F, 0x1010, 0x1010, 0x0000, 0x00FF, 0x0000, 0x0000, + 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x10FF, 0x1010, 0x1010, + 0x1010, 0x101F, 0x1010, 0x1010, 0x0000, 0x00FF, 0x1010, 0x1010, + 0x1010, 0x10F0, 0x1010, 0x1010, 0x1010, 0x10FF, 0x0000, 0x0000, + 0x0010, 0x181C, 0x1C18, 0x1000, 0x0008, 0x1838, 0x3818, 0x0800, + 0x0024, 0x343C, 0x3C34, 0x2400, 0x0024, 0x2C3C, 0x3C2C, 0x2400, + 0x0048, 0x6C7E, 0x7E6C, 0x4800, 0x0012, 0x367E, 0x7E36, 0x1200, + 0x0010, 0x387C, 0x007C, 0x0000, 0x007C, 0x7C7C, 0x7C7C, 0x0000, + 0x0038, 0x7C7C, 0x7C38, 0x0000, 0x3C42, 0x8181, 0x8250, 0x3810, + 0x1054, 0x9282, 0x8244, 0x3800, 0x0004, 0x0404, 0x247C, 0x2000, + 0x0609, 0x1C22, 0x221C, 0x4830, 0x0000, 0x1028, 0x4400, 0x0000, + 0x0036, 0x4949, 0x3600, 0x0000, 0x0000, 0x324C, 0x484C, 0x3200, + 0x1824, 0x4478, 0x4444, 0x7840, 0x7C24, 0x2020, 0x2020, 0x7000, + 0x0001, 0x3E54, 0x1414, 0x1400, 0x7E22, 0x1008, 0x1022, 0x7E00, + 0x001C, 0x3048, 0x4848, 0x3000, 0x0000, 0x2424, 0x2424, 0x3A40, + 0x0004, 0x3850, 0x1010, 0x1000, 0x3810, 0x3844, 0x4438, 0x1038, + 0x0038, 0x447C, 0x4444, 0x3800, 0x0038, 0x4444, 0x4428, 0x6C00, + 0x3020, 0x1038, 0x4444, 0x3800, 0x0408, 0x3854, 0x5438, 0x2040, + 0x1038, 0x5454, 0x5438, 0x1000, 0x3C60, 0x407C, 0x4060, 0x3C00, + 0x386C, 0x4444, 0x4444, 0x4400, 0x007C, 0x007C, 0x007C, 0x0000, + 0x0010, 0x107C, 0x1010, 0x007C, 0x0020, 0x1008, 0x1020, 0x007C, + 0x0008, 0x1020, 0x1008, 0x007C, 0x0609, 0x0808, 0x0808, 0x0808, + 0x0808, 0x0808, 0x0808, 0x4830, 0x0010, 0x007C, 0x0010, 0x0000, + 0x0032, 0x4C00, 0x324C, 0x0000, 0x3048, 0x4830, 0x0000, 0x0000, + 0x3078, 0x7830, 0x0000, 0x0000, 0x0000, 0x0000, 0x3030, 0x0000, + 0x0006, 0x0808, 0x6828, 0x1000, 0x3048, 0x4848, 0x0000, 0x0000, + 0x3048, 0x1020, 0x7800, 0x0000, 0x7008, 0x3008, 0x7000, 0x0000, + 0xFE00, 0x0000, 0x0000, 0x0000 +}; diff --git a/sources/z-tools/trunk/ztask/general.h b/sources/z-tools/trunk/ztask/general.h new file mode 100644 index 0000000..fc309c5 --- /dev/null +++ b/sources/z-tools/trunk/ztask/general.h @@ -0,0 +1,120 @@ +/* + * zbar. + * Copyright (c) 2005 Zorro ( zorro270@yahoo.fr) + * + * This application is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "types2b.h" +#include "prefs.h" +#include "ztask.rsh" + +/* Option */ + +#ifndef MAXNAMLEN + #define MAXNAMLEN 255 +#endif + +#ifndef MAX_PATH + #define MAX_PATH 1024 +#endif + +/* xfont text attrib. */ +#define BOLD 0x01 +#define LIGHT 0x02 +#define ITALIC 0x04 +#define ULINE 0x08 +#define INVERSE 0x10 +#define SHADOW 0x20 +#define MONOSPACE 0x40 + +#define POPUP_ITEM 64 + +#define BOLD 0x01 +#define LIGHT 0x02 +#define ITALIC 0x04 +#define ULINE 0x08 +#define INVERSE 0x10 +#define SHADOW 0x20 +#define MONOSPACE 0x40 + +#define F_HIDE 1 +#define F_QUIT 2 +#define F_KILL 3 +#define F_TASKMANAGER 4 +#define F_PREFERENCES 5 +#define F_SHUTDOWN 6 +#define F_QUIT_ZBAR 7 + +typedef struct _app_data +{ + int16 id, pid; + char name[9]; + char name_shown[MAXNAMLEN]; + int16 name_shown_width; + int16 x_pos, y_pos; + struct _app_data *next; +} app_data; + + +typedef struct +{ + char item_name[POPUP_ITEM][64]; + RECT16 item_pos[POPUP_ITEM]; + int16 icon[POPUP_ITEM]; + int16 selectable[POPUP_ITEM]; + int16 function[POPUP_ITEM]; + int16 item_nbr; + int16 selected, old_selected; + int16 x_pos, y_pos, w_pos, h_pos; + app_data *entry; + WINDOW *win; +} popup_data; + + +typedef struct _process +{ + int pid; + char cpu_usage[5]; + char ram_usage[30]; + char name[MAXNAMLEN]; + uint32 cpu_time; + int16 ram_usage_txt_width; + int16 y_pos; + struct _process *next; +} process; + + +extern void zdebug( const char *format, ...); +extern OBJECT *get_tree( int16 obj_index); +extern char *get_string( int16 str_index); +extern void shutdown_dialog( void); +extern void quit_dialog( void); +extern void pref_dialog( void); + + + diff --git a/sources/z-tools/trunk/ztask/gmem.c b/sources/z-tools/trunk/ztask/gmem.c new file mode 100644 index 0000000..e34d14f --- /dev/null +++ b/sources/z-tools/trunk/ztask/gmem.c @@ -0,0 +1,247 @@ +#include "general.h" +#include "gmem.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef DEBUG + +typedef struct _GMemHdr +{ + int size; + int index; + struct _GMemHdr *next; +} GMemHdr; + +#define gMemHdrSize (( sizeof(GMemHdr) + 7) & ~7) +#define gMemTrlSize 4 +#define gMemDeadVal 0xFFFFFFFFUL + +/* round data size so trailer will be aligned */ +#define gMemDataSize(size) ((((size) + gMemTrlSize - 1) / gMemTrlSize) * gMemTrlSize) + +#define gMemNLists 64 +#define gMemListShift 4 +#define gMemListMask (gMemNLists - 1) +static GMemHdr *gMemList[gMemNLists] = { + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL +}; + +static int gMemIndex = 0; +static int gMemAlloc = 0; + +#endif /* DEBUG */ + +void *gmalloc(int size) +{ +#ifdef DEBUG + int size1; + char *mem; + GMemHdr *hdr; + void *data; + int lst; + unsigned long *trl, *p; + + if (size <= 0) + return NULL; + + size1 = gMemDataSize(size); + + mem = (char *)malloc(size1 + gMemHdrSize + gMemTrlSize); + + if ( mem == NULL) + { + zdebug( "Out of memory"); + return NULL; + } + + hdr = (GMemHdr *)mem; + data = (void *)(mem + gMemHdrSize); + trl = (unsigned long *)(mem + gMemHdrSize + size1); + hdr->size = size; + hdr->index = gMemIndex++; + lst = ((int)hdr >> gMemListShift) & gMemListMask; + hdr->next = gMemList[lst]; + gMemList[lst] = hdr; + ++gMemAlloc; + + for (p = (unsigned long *)data; p <= trl; ++p) + *p = gMemDeadVal; + + return data; +#else + void *p; + + if (size <= 0) + return NULL; + + p = malloc(size); + + if ( p == NULL) + { + zdebug( "Out of memory"); + return NULL; + } + + return p; +#endif +} + +void *grealloc(void *p, int size) +{ +#ifdef DEBUG + GMemHdr *hdr; + void *q; + int oldSize; + + if (size <= 0) + { + if (p) + gfree(p); + return NULL; + } + if (p) + { + hdr = (GMemHdr *)((char *)p - gMemHdrSize); + oldSize = hdr->size; + q = gmalloc(size); + memcpy(q, p, size < oldSize ? size : oldSize); + gfree(p); + } + else + { + q = gmalloc(size); + } + return q; +#else + void *q; + + if (size <= 0) + { + if (p) + free(p); + return NULL; + } + + if (p) + q = realloc( p, size); + else + q = malloc(size); + + if (!q) + { + zdebug( "Out of memory"); + return NULL; + } + return q; +#endif +} + +void gfree(void *p) +{ +#ifdef DEBUG + int size; + GMemHdr *hdr; + GMemHdr *prevHdr, *q; + int lst; + unsigned long *trl, *clr; + + if (p) + { + hdr = (GMemHdr *)((char *)p - gMemHdrSize); + lst = ((int)hdr >> gMemListShift) & gMemListMask; + + for (prevHdr = NULL, q = gMemList[lst]; q; prevHdr = q, q = q->next) + { + if ( q == hdr) + break; + } + + if( q) + { + if (prevHdr) + prevHdr->next = hdr->next; + else + gMemList[lst] = hdr->next; + + --gMemAlloc; + size = gMemDataSize(hdr->size); + trl = (unsigned long *)((char *)hdr + gMemHdrSize + size); + + if (*trl != gMemDeadVal) + { + zdebug( "Overwrite past end of block %d at address %p", hdr->index, p); + } + + for (clr = (unsigned long *)hdr; clr <= trl; ++clr) + *clr = gMemDeadVal; + + free(hdr); + } + else + { + zdebug( "Attempted to free bad address %p", p); + } + } +#else + if (p) + free(p); +#endif +} + +void gMemReport( void) +{ +#ifdef DEBUG + FILE *inffile; + GMemHdr *p; + int lst; + + if (( inffile = fopen( "C:\\ztkdebug.txt", "wb+")) == NULL) + return; + + fprintf( inffile, "%d memory allocations in all\n", gMemIndex); + + if( gMemAlloc > 0) + { + fprintf( inffile, "%d memory blocks left allocated:\n", gMemAlloc); + fprintf( inffile, " index size\n"); + fprintf( inffile, "-------- --------\n"); + + for (lst = 0; lst < gMemNLists; ++lst) + { + for (p = gMemList[lst]; p; p = p->next) + fprintf( inffile, "%8d %8d\n", p->index, p->size); + } + } + else + { + fprintf( inffile, "No memory blocks left allocated\n"); + } + + fprintf( inffile, "--= End =--"); + + fclose( inffile); +#endif +} + + +char *copyString(char *s) +{ + char *s1; + + s1 = (char *)gmalloc(strlen(s) + 1); + strcpy(s1, s); + return s1; +} + +#ifdef __cplusplus +} +#endif diff --git a/sources/z-tools/trunk/ztask/gmem.h b/sources/z-tools/trunk/ztask/gmem.h new file mode 100644 index 0000000..30960b5 --- /dev/null +++ b/sources/z-tools/trunk/ztask/gmem.h @@ -0,0 +1,19 @@ +#ifndef GMEM_H +#define GMEM_H + +#ifdef __cplusplus +extern "C" { +#endif + +extern void *gmalloc(int size); +extern void *grealloc(void *p, int size); +extern void gfree(void *p); +extern void gMemReport( void); +char *copyString(char *s); +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/sources/z-tools/trunk/ztask/history.txt b/sources/z-tools/trunk/ztask/history.txt new file mode 100644 index 0000000..6ff961f --- /dev/null +++ b/sources/z-tools/trunk/ztask/history.txt @@ -0,0 +1,22 @@ +22 March 2006: BETA2 +==================== + +News: +----- +- Preference panel added. +- With Xaaes, "XaSys" is not more listed as a GEM process. + + +Bugs fixes: +----------- +- The first drawn of the process list in the Task Manager + was corrupted. +- Some littles bugs fixed. + + + + +14 March 2006: BETA1 +====================== + +- First public release. diff --git a/sources/z-tools/trunk/ztask/main.c b/sources/z-tools/trunk/ztask/main.c new file mode 100644 index 0000000..609cc22 --- /dev/null +++ b/sources/z-tools/trunk/ztask/main.c @@ -0,0 +1,125 @@ +#include "general.h" +#include "gmem.h" +#include "app.h" +#include "cpu.h" +#include "process.h" +#include + +extern int16 cpu_history[100]; +extern void main_win( void); + +OBJECT *get_tree( int16 obj_index) +{ + OBJECT *tree; + RsrcGaddr( NULL, 0, obj_index, &tree); + return tree; +} + + +char *get_string( int16 str_index) +{ + char *txt; + rsrc_gaddr( 5, str_index, &txt); + return txt; +} + + +void applexit( WINDOW *w, short buff[8]) +{ + WINDOW *last_closed = NULL; + + if( EvntFind( NULL, WM_XTIMER)) + EvntDelete( NULL, WM_XTIMER); + + /* Close all windows */ + while( wglb.first) + { + if (last_closed != wglb.first) + { + ApplWrite( _AESapid, WM_DESTROY, wglb.first->handle, 0, 0, 0, 0); + last_closed = wglb.first; /* to prevent sending toons of WM_CLOSED messages to each window */ + } + + if( EvntWindom( MU_MESAG | MU_TIMER) & MU_TIMER) /* MU_TIMER event catched ? */ + last_closed = NULL; /* then WM_CLOSED message has been lost ! it should be resent */ + } + + prefs_write(); + + while( root != NULL) + app_data_delete( root->id); + + while( process_root != NULL) + process_delete( process_root->pid); + + RsrcXtype( 0, NULL, 0); + RsrcFree(); + + ApplExit(); + gMemReport(); + exit( 0); +} + + +int main( int argc, char *argv[]) +{ + int16 i, dum, app_long_name; + int32 mint = 0; + + ApplInit(); + + if( app.nplanes < 4) + { + ( void)FormAlert( 1 , "[1][Sorry, zTask needs minimum a 16 colors display][Quit]"); + ApplExit(); + exit( 0); + } + + if( Getcookie( C_MiNT, ( long*)&mint) != 0) + { + ( void)FormAlert( 1 , "[1][Sorry, zTask works only with MiNT][Quit]"); + ApplExit(); + exit( 0); + } + + mt_appl_getinfo( AES_EXTENDED, &dum, &dum, &app_long_name, &dum, app.aes_global); + + if( app_long_name <= 0) + { + ( void)FormAlert( 1 , "[1][AES 4.x needed!][Quit]"); + ApplExit(); + exit( 0); + } + + if( !RsrcLoad( "ztask.rsc")) + { + ( void)FormAlert( 1 , "[1][ztask.rsc not found!][Quit]"); + ApplExit(); + exit( 0); + } + + RsrcXtype( RSRC_XTYPE, NULL, 0); + + prefs_read(); + + get_total_ram(); + + evnt.timer = 20L; + evnt.bclick = 258; + evnt.bmask = 3; + evnt.bstate = 0; + + EvntAttach( NULL, AP_TERM, applexit); + + for( i = 0; i < 101;) + cpu_history[i++] = 100; + + main_win(); + + for(;;) + EvntWindom( MU_MESAG|MU_TIMER|MU_KEYBD|MU_BUTTON); + + // applexit(); + return 0; +} + diff --git a/sources/z-tools/trunk/ztask/popup.c b/sources/z-tools/trunk/ztask/popup.c new file mode 100644 index 0000000..e24c53f --- /dev/null +++ b/sources/z-tools/trunk/ztask/popup.c @@ -0,0 +1,233 @@ +#include "general.h" +#include "app.h" +#include "string.h" +#include "win.h" +#include "taskman.h" +#include + +popup_data popup; +extern WINDOW *app_bar; + + +void CDECL popup_delete( WINDOW *win, int16 buff[8]) +{ + WindDelete( win); + popup.win = NULL; + + if( menu_enabled == TRUE) + { + menu_enabled = FALSE; + draw_page( app_bar, root->x_pos - 24, root->y_pos, 24, 23); + } +} + + +void process_popup_item( WINDOW *win, int16 buff[8]) +{ + if( popup.selected < 0) + return; + + switch( popup.function[popup.selected]) + { + case F_SHUTDOWN: + shutdown_dialog(); + break; + + case F_TASKMANAGER: + taskman_dialog(); + break; + + case F_QUIT_ZBAR: + quit_dialog(); + break; + + case F_KILL: + Pkill( popup.entry->pid, SIGKILL); + mt_evnt_timer( 100L, app.aes_global); + break; + + case F_PREFERENCES: + pref_dialog(); + break; + + case F_QUIT: + ApplWrite( popup.entry->id, AP_TERM, 0, 0, 0, 0, 0); + mt_evnt_timer( 100L, app.aes_global); + break; + + default: + break; + } + + popup_delete( win, buff); +} + + +int16 popup_item_under_mouse( void) +{ + int16 i, ok, result = -1; + + for( i = 0; i < popup.item_nbr; i++) + { + ok = IS_IN( evnt.mx, evnt.my, popup.item_pos[i].x1, popup.item_pos[i].y1, popup.item_pos[i].x2, popup.item_pos[i].y2); + + if( ok) + { + if( popup.selectable[i] == TRUE) + result = i; + + break; + } + } + + return result; +} + + + +static void CDECL popup_redraw( WINDOW *win, int16 buff[8]) +{ + int16 pxy[6], i, y, title_color, title_shadow; + + pxy[0] = popup.x_pos; + pxy[1] = popup.y_pos; + pxy[2] = pxy[0] + popup.w_pos - 1; + pxy[3] = pxy[1] + popup.h_pos - 1; + + vsf_color( win->graf->handle, button_off_background); + v_bar( win->graf->handle, pxy); + + pxy[5] = pxy[1]; + pxy[1] = pxy[3]; + pxy[4] = pxy[2]; + + vsl_color( win->graf->handle, button_off_dark_color); + v_pline( win->graf->handle, 3, pxy); + + pxy[4] = pxy[2]; + pxy[2] = pxy[0]; + pxy[3] = popup.y_pos; + pxy[5] = pxy[3]; + + vsl_color( win->graf->handle, button_off_light_color); + v_pline( win->graf->handle, 3, pxy); + + pxy[0] = popup.x_pos + 1; + pxy[1] = popup.y_pos + 1; + pxy[2] = pxy[0] + popup.w_pos - 3; + + for( i = 0, y = popup.y_pos + 7; i < popup.item_nbr; i++, y += 18, pxy[1] += 18) + { + popup.item_pos[i].x1 = pxy[0]; + popup.item_pos[i].x2 = popup.w_pos; + popup.item_pos[i].y1 = pxy[1]; + + if( popup.item_name[i][0] == '\0') + { + int16 xy[4] = { pxy[0] + 1, pxy[1] + 5, pxy[2] - 1, pxy[1] + 5}; + + v_pline( win->graf->handle, 2, xy); + + xy[1]--; + xy[3]--; + + vsl_color( win->graf->handle, button_off_dark_color); + v_pline( win->graf->handle, 2, xy); + + y -= 9; + pxy[1] -= 9; + popup.item_pos[i].y2 = 9; + + continue; + } + + popup.item_pos[i].y2 = 18; + + if( i == popup.selected) + { + pxy[3] = pxy[1] + 17; + vsf_color( win->graf->handle, button_on_background); + v_bar( win->graf->handle, pxy); + title_color = button_on_text_color; + title_shadow = button_on_text_shadow_color; + } + else + { + title_color = button_off_text_color; + title_shadow = button_off_text_shadow_color; + } + + if( popup.icon[i] > -1) + { + icons[popup.icon[i]].ob_x = popup.x_pos + x_space; + icons[popup.icon[i]].ob_y = pxy[1] + 2; + + mt_objc_draw( icons, popup.icon[i], 1, win->graf->clip.g_x, win->graf->clip.g_y, win->graf->clip.g_w, win->graf->clip.g_h, app.aes_global); + + draw_text( win->graf->handle, icons[popup.icon[i]].ob_x + 17 + x_space, y + 1, title_shadow, popup.item_name[i]); + draw_text( win->graf->handle, icons[popup.icon[i]].ob_x + 16 + x_space, y, title_color, popup.item_name[i]); + } + else + { + draw_text( win->graf->handle, popup.x_pos + x_space + 1, y + 1, title_shadow, popup.item_name[i]); + draw_text( win->graf->handle, popup.x_pos + x_space, y, title_color, popup.item_name[i]); + } + } +} + + +void open_popup( app_data *entry) +{ + int16 i, lenght, zbarx, zbary, dum; + + WindGet( app_bar, WF_CURRXYWH, &zbarx, &zbary, &dum, &dum); + + if( entry) + popup.x_pos = entry->x_pos - 1; + else + popup.x_pos = zbarx; + + popup.h_pos = 5; + popup.selected = -1; + popup.old_selected = -1; + + for( popup.w_pos = 0, i = 0; i < popup.item_nbr; i++) + { + if( popup.item_name[i][0] == '\0') + { + popup.h_pos += 9; + continue; + } + + lenght = get_text_width( popup.item_name[i]); + + if( popup.icon[i] > -1) + lenght += 16 + x_space; + + if( lenght > popup.w_pos) + popup.w_pos = lenght; + + popup.h_pos += 18; + } + + popup.w_pos += ( x_space * 3); + popup.w_pos = MAX( popup.w_pos, app_width + 1); + + while( popup.x_pos + popup.w_pos > app.x + app.w) + popup.x_pos--; + + popup.entry = entry; + popup.win = WindCreate( 0, app.x, app.y, app.w, app.h); + + EvntAttach( popup.win, WM_DESTROY, popup_delete); + EvntAttach( popup.win, WM_REDRAW, popup_redraw); + EvntAttach( popup.win, WM_XBUTTON, process_popup_item); + + popup.y_pos = zbary - popup.h_pos + 1; + + WindOpen( popup.win, popup.x_pos, popup.y_pos, popup.w_pos, popup.h_pos); +// WindSet( popup.win, WF_BEVENT, BEVENT_MODAL, 0, 0, 0); + WindGet( popup.win, WF_WORKXYWH, &popup.x_pos, &popup.y_pos, &popup.w_pos, &popup.h_pos); +} + + diff --git a/sources/z-tools/trunk/ztask/popup.h b/sources/z-tools/trunk/ztask/popup.h new file mode 100644 index 0000000..2e01970 --- /dev/null +++ b/sources/z-tools/trunk/ztask/popup.h @@ -0,0 +1,8 @@ +extern popup_data popup; +extern void open_popup( app_data *entry); +extern int16 popup_item_under_mouse( void); +extern void popup_delete( WINDOW *win); + + + + diff --git a/sources/z-tools/trunk/ztask/pref_panel.c b/sources/z-tools/trunk/ztask/pref_panel.c new file mode 100644 index 0000000..884ba79 --- /dev/null +++ b/sources/z-tools/trunk/ztask/pref_panel.c @@ -0,0 +1,614 @@ +#include "general.h" +#include "win.h" +#include "string.h" +#include "app.h" + +int tmp_button_off_background, tmp_button_off_light_color, tmp_button_off_dark_color, +tmp_button_off_text_color, tmp_button_off_text_shadow_color, tmp_button_on_background, +tmp_button_on_light_color, tmp_button_on_dark_color, tmp_button_on_text_color, +tmp_button_on_text_shadow_color, tmp_geek_area_color, tmp_geek_area_dark_line, +tmp_geek_area_light_line, tmp_app_width, tmp_cpu_bar_color, +tmp_tt_bar_color, tmp_st_bar_color, tmp_show_clock, tmp_clock_us, +tmp_show_system_info, tmp_show_acc, tmp_geek_area_text_color; +static void *thumb = NULL; +int *tmp; +static int16 xy[10], tmp_cpu_x, tmp_tt_x, tmp_st_x, tmp_clock_x, tmp_geek_area_width, tmp_y_text_pos, +tmp_x_pos, tmp_y_pos, tmp_w_pos, tmp_geek_area_x, text_width, x; +static OBJECT *dial = NULL; +WINDOW *pref_dialog_win = NULL; + +extern void vdi_color_selector( int16 xw, int16 yw, int16 color_selected, int16 parent_object); + + +static void CDECL pref_dialog_cancel_event( WINDOW *win, int obj, int mode, void *data) +{ + ObjcChange( OC_FORM, win, obj, NORMAL, TRUE); + ApplWrite( _AESapid, WM_DESTROY, win->handle, 0, 0, 0, 0); + pref_dialog_win = NULL; +} + +static void CDECL pref_dialog_ok_event( WINDOW *win, int obj, int mode, void *data) +{ + ObjcChange( OC_FORM, win, obj, NORMAL, TRUE); + ApplWrite( _AESapid, WM_DESTROY, win->handle, 0, 0, 0, 0); + pref_dialog_win = NULL; + + button_off_background = tmp_button_off_background; + button_off_light_color = tmp_button_off_light_color; + button_off_dark_color = tmp_button_off_dark_color; + button_off_text_color = tmp_button_off_text_color; + button_off_text_shadow_color = tmp_button_off_text_shadow_color; + button_on_background = tmp_button_on_background; + button_on_light_color = tmp_button_on_light_color; + button_on_dark_color = tmp_button_on_dark_color; + button_on_text_color = tmp_button_on_text_color; + button_on_text_shadow_color = tmp_button_on_text_shadow_color; + geek_area_text_color = tmp_geek_area_text_color; + geek_area_color = tmp_geek_area_color; + geek_area_dark_line = tmp_geek_area_dark_line; + geek_area_light_line = tmp_geek_area_light_line; + app_width = tmp_app_width; + cpu_bar_color = tmp_cpu_bar_color; + tt_bar_color = tmp_tt_bar_color; + st_bar_color = tmp_st_bar_color; + show_clock = tmp_show_clock; + clock_us = tmp_clock_us; + show_system_info = tmp_show_system_info; + + + if( show_acc != tmp_show_acc) + { + while( root != NULL) + app_data_delete( root->id); + + show_acc = tmp_show_acc; + app_data_search(); + } + else + show_acc = tmp_show_acc; + + set_component_position(); + + w_pos = geek_area_width + ( app_nbr * app_width) + 24; + + while( w_pos > app.w) + w_pos -= app_width; + + x_pos = app.x + ( app.w - w_pos); + w_pos -= 1; + + WindSet( app_bar, WF_WORKXYWH, x_pos, y_pos, w_pos, h_pos); + + // Xaaes bug... with this AES, WindSet( win, WF_CURRXYWH,... doesn't redraw the taskbar. + draw_page( app_bar, x_pos, y_pos, w_pos, h_pos); +} + + +static void CDECL click_on_color( WINDOW *win, int obj, int mode, void *data) +{ + int16 y, color_selection_width, selected_color = 0; + + switch( obj) + { + case PREFS_ON_BACK: + selected_color = ( int16)tmp_button_on_background; + break; + + case PREFS_ON_LINE1: + selected_color = ( int16)tmp_button_on_light_color; + break; + + case PREFS_ON_LINE2: + selected_color = ( int16)tmp_button_on_dark_color; + break; + + case PREFS_ON_TEXT1: + selected_color = ( int16)tmp_button_on_text_color; + break; + + case PREFS_ON_TEXT2: + selected_color = ( int16)tmp_button_on_text_shadow_color; + break; + + case PREFS_OFF_BACK: + selected_color = ( int16)tmp_button_off_background; + break; + + case PREFS_OFF_LINE1: + selected_color = ( int16)tmp_button_off_light_color; + break; + + case PREFS_OFF_LINE2: + selected_color = ( int16)tmp_button_off_dark_color; + break; + + case PREFS_OFF_TEXT1: + selected_color = ( int16)tmp_button_off_text_color; + break; + + case PREFS_OFF_TEXT2: + selected_color = ( int16)tmp_button_off_text_shadow_color; + break; + + case PREFS_GEEK_BACK: + selected_color = ( int16)tmp_geek_area_color; + break; + + case PREFS_GEEK_LINE1: + selected_color = ( int16)tmp_geek_area_light_line; + break; + + case PREFS_GEEK_LINE2: + selected_color = ( int16)tmp_geek_area_dark_line; + break; + + case PREFS_GEEK_RAM1: + selected_color = ( int16)tmp_st_bar_color; + break; + + case PREFS_GEEK_RAM2: + selected_color = ( int16)tmp_tt_bar_color; + break; + + case PREFS_GEEK_CPU: + selected_color = ( int16)tmp_cpu_bar_color; + break; + + case PREFS_GEEK_TEXT: + selected_color = ( int16)tmp_geek_area_text_color; + break; + } + + mt_objc_offset( dial, obj, &x, &y, app.aes_global); + + if( app.nplanes == 4) + color_selection_width = 45; + else + color_selection_width = 177; + + while( x + color_selection_width + 2 > app.w) + x--; + + while( y + color_selection_width + 2 > app.h) + y--; + + vdi_color_selector( x, y, selected_color, ( int16)obj); +} + +static void CDECL pref_dialog_default_event( WINDOW *win, int obj, int mode, void *data) +{ + if( app.nplanes < 8) + { + tmp_button_off_light_color = WHITE; + tmp_button_off_dark_color = LBLACK; + tmp_button_off_text_color = BLACK; + tmp_button_off_text_shadow_color = WHITE; + tmp_button_on_background = LBLACK; + tmp_button_on_light_color = LWHITE; + tmp_button_on_dark_color = BLACK; + tmp_button_on_text_color = BLACK; + tmp_button_on_text_shadow_color = LWHITE; + tmp_geek_area_text_color = BLACK; + tmp_geek_area_color = LWHITE; + tmp_geek_area_dark_line = LBLACK; + tmp_geek_area_light_line = WHITE; + tmp_cpu_bar_color = CYAN; + tmp_tt_bar_color = BLUE; + tmp_st_bar_color = RED; + } + else + { + tmp_button_off_background = 8; + tmp_button_off_light_color = 250; + tmp_button_off_dark_color = 252; + tmp_button_off_text_color = 255; + tmp_button_off_text_shadow_color = 250; + tmp_button_on_background = 252; + tmp_button_on_light_color = 8; + tmp_button_on_dark_color = 144; + tmp_button_on_text_color = 1; + tmp_button_on_text_shadow_color = 251; + tmp_geek_area_text_color = 1; + tmp_geek_area_color = 252; + tmp_geek_area_dark_line = 144; + tmp_geek_area_light_line = 250; + tmp_app_width = 72; + tmp_cpu_bar_color = 146; + tmp_tt_bar_color = 73; + tmp_st_bar_color = 106; + } + + if( FormThbGet( thumb, 0) == PREFS_COLOR) + { + ObjcDraw( OC_FORM, win, PREFS_PANEL1, 3); + ObjcDraw( OC_FORM, win, PREFS_COLOR, 1); + } + + ObjcChange( OC_FORM, win, obj, NORMAL, TRUE); +} + + +static void CDECL draw_preview( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y; + xy[2] = pblk->pb_x + pblk->pb_w - 1; + xy[3] = pblk->pb_y + pblk->pb_h - 1; + + vsf_color( win->graf->handle, LCYAN); + v_bar( win->graf->handle, xy); + + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y; + xy[2] = pblk->pb_x; + xy[3] = pblk->pb_y + pblk->pb_h - 1; + xy[4] = pblk->pb_x + pblk->pb_w - 1; + xy[5] = xy[3]; + xy[6] = xy[4]; + xy[7] = pblk->pb_y; + xy[8] = pblk->pb_x; + xy[9] = pblk->pb_y; + + vsl_color( win->graf->handle, BLACK); + v_pline( win->graf->handle, 5, xy); + + x = x_space + 2; + + if( tmp_show_system_info) + { + tmp_cpu_x = x; + x += ( bar_width + 2); + + tmp_st_x = x; + x += ( bar_width + 2); + + tmp_tt_x = x; + x += ( bar_width + x_space); + } + + if( tmp_show_clock == TRUE) + { + tmp_clock_x = x; + + if( tmp_clock_us == FALSE) + text_width = get_text_width( "22:37:05"); + else + text_width = get_text_width( "10:37:05 PM"); + + x += ( text_width + x_space); + } + + tmp_geek_area_width = x + 1; + + tmp_y_text_pos = pblk->pb_y + pblk->pb_h - 15; + + tmp_w_pos = tmp_geek_area_width + ( 2 * tmp_app_width) + 23; + tmp_x_pos = pblk->pb_x + ( pblk->pb_w - tmp_w_pos) - 1; + tmp_y_pos = pblk->pb_y + pblk->pb_h - 22; + + + tmp_geek_area_x = tmp_x_pos + tmp_w_pos - tmp_geek_area_width; + + /* we draw the menu area */ + xy[0] = tmp_x_pos; + xy[1] = tmp_y_pos; + xy[2] = xy[0] + 23; + xy[3] = xy[1] + 20; + + + vsf_color( win->graf->handle, ( int16)tmp_button_off_background); + v_bar( win->graf->handle, xy); + + xy[1] = xy[3]; + xy[2] = xy[0]; + xy[3] = tmp_y_pos; + xy[4] = xy[0] + 22; + xy[5] = tmp_y_pos; + + vsl_color( win->graf->handle, ( int16)tmp_button_off_light_color); + v_pline( win->graf->handle, 3, xy); + + xy[0] = xy[4] + 1; + xy[1] = tmp_y_pos; + xy[2] = xy[0]; + xy[3] = xy[1] + 20; + xy[4] = tmp_x_pos; + xy[5] = xy[3]; + + vsl_color( win->graf->handle, ( int16)tmp_button_off_dark_color); + v_pline( win->graf->handle, 3, xy); + +// icons[ICONS_MENU].ob_x = xw + 4; +// icons[ICONS_MENU].ob_y = y_pos + 2; + +// mt_objc_draw( icons, ICONS_MENU, 1, win->graf->clip.g_x, win->graf->clip.g_y, win->graf->clip.g_w, win->graf->clip.g_h, app.aes_global); + + tmp_x_pos += 24; + + xy[0] = tmp_x_pos; + xy[1] = tmp_y_pos; + xy[2] = xy[0] + tmp_app_width - 1; + xy[3] = xy[1] + 20; + + vsf_color( win->graf->handle, ( int16)tmp_button_on_background); + v_bar( win->graf->handle, xy); + + xy[1] = xy[3]; + xy[2] = xy[0]; + xy[3] = tmp_y_pos; + xy[4] = xy[0] + tmp_app_width - 2; + xy[5] = tmp_y_pos; + + vsl_color( win->graf->handle, ( int16)tmp_button_on_dark_color); + v_pline( win->graf->handle, 3, xy); + + xy[0] = xy[4] + 1; + xy[1] = tmp_y_pos; + xy[2] = xy[0]; + xy[3] = xy[1] + 20; + xy[4] = tmp_x_pos; + xy[5] = xy[3]; + + vsl_color( win->graf->handle, ( int16)tmp_button_on_light_color); + v_pline( win->graf->handle, 3, xy); + + draw_text( win->graf->handle, tmp_x_pos + 21, tmp_y_text_pos + 1, ( int16)tmp_button_on_text_shadow_color, "Dummy"); + draw_text( win->graf->handle, tmp_x_pos + 20, tmp_y_text_pos, ( int16)tmp_button_on_text_color, "Dummy"); + + tmp_x_pos += tmp_app_width; + + xy[0] = tmp_x_pos; + xy[1] = tmp_y_pos; + xy[2] = xy[0] + tmp_app_width - 1; + xy[3] = xy[1] + 20; + + vsf_color( win->graf->handle, ( int16)tmp_button_off_background); + v_bar( win->graf->handle, xy); + + xy[1] = xy[3]; + xy[2] = xy[0]; + xy[3] = tmp_y_pos; + xy[4] = xy[0] + tmp_app_width - 2; + xy[5] = tmp_y_pos; + + vsl_color( win->graf->handle, ( int16)tmp_button_off_light_color); + v_pline( win->graf->handle, 3, xy); + + xy[0] = xy[4] + 1; + xy[1] = tmp_y_pos; + xy[2] = xy[0]; + xy[3] = xy[1] + 20; + xy[4] = tmp_x_pos; + xy[5] = xy[3]; + + vsl_color( win->graf->handle, ( int16)tmp_button_off_dark_color); + v_pline( win->graf->handle, 3, xy); + + draw_text( win->graf->handle, tmp_x_pos + 21, tmp_y_text_pos + 1, ( int16)tmp_button_off_text_shadow_color, "Dummy"); + draw_text( win->graf->handle, tmp_x_pos + 20, tmp_y_text_pos, ( int16)tmp_button_off_text_color, "Dummy"); + + tmp_x_pos += tmp_app_width; + + + + /* draw the "geek" area */ + xy[0] = tmp_x_pos + 2; + xy[1] = tmp_y_pos + 2; + xy[2] = xy[0] + tmp_geek_area_width - 6; + xy[3] = xy[1] + 16; + + vsf_color( win->graf->handle, ( int16)tmp_geek_area_color); + v_bar( win->graf->handle, xy); + + xy[0] = tmp_x_pos; + xy[1] = tmp_y_pos; + xy[2] = xy[0]; + xy[3] = xy[1] + 20; + xy[4] = xy[2] + tmp_geek_area_width - 2; + xy[5] = xy[3]; + xy[6] = xy[4]; + xy[7] = xy[1]; + xy[8] = xy[0]; + xy[9] = xy[1]; + + vsl_color( win->graf->handle, ( int16)tmp_button_off_background); + v_pline( win->graf->handle, 5, xy); + + xy[0]++; + xy[1] = xy[3] - 1; + xy[2] = xy[0]; + xy[3] = tmp_y_pos + 1; + xy[4]--; + xy[5] = xy[3]; + + vsl_color( win->graf->handle, ( int16)tmp_geek_area_dark_line); + v_pline( win->graf->handle, 3, xy); + + xy[2] = xy[4]; + xy[3] = xy[1]; + xy[5] = tmp_y_pos + 2; + + vsl_color( win->graf->handle, ( int16)tmp_geek_area_light_line); + v_pline( win->graf->handle, 3, xy); + + + /* draw the cpu % in the "geek" area */ + if( tmp_show_system_info) + { + /* the CPU usage */ + xy[0] = tmp_cpu_x + tmp_geek_area_x; + xy[1] = tmp_y_pos + 3; + xy[2] = xy[0] + bar_width - 1; + xy[3] = xy[1] + 14; + + vsf_color( win->graf->handle, BLACK); + v_bar( win->graf->handle, xy); + + xy[0] = xy[0] + 1; + xy[2] = xy[2] - 1; + xy[3] = tmp_y_pos + 16; + xy[1] = tmp_y_pos + 9; + + vsf_color( win->graf->handle, ( int16)tmp_cpu_bar_color); + v_bar( win->graf->handle, xy); + + /* the STRAM usage */ + xy[0] = tmp_st_x + tmp_geek_area_x; + xy[1] = tmp_y_pos + 3; + xy[2] = xy[0] + bar_width - 1; + xy[3] = xy[1] + 14; + + vsf_color( win->graf->handle, BLACK); + v_bar( win->graf->handle, xy); + + xy[0] = xy[0] + 1; + xy[2] = xy[2] - 1; + xy[3] = tmp_y_pos + 16; + xy[1] = tmp_y_pos + 9; + + vsf_color( win->graf->handle, ( int16)tmp_st_bar_color); + v_bar( win->graf->handle, xy); + + xy[0] = tmp_tt_x + tmp_geek_area_x; + xy[1] = tmp_y_pos + 3; + xy[2] = xy[0] + bar_width - 1; + xy[3] = xy[1] + 14; + + vsf_color( win->graf->handle, BLACK); + v_bar( win->graf->handle, xy); + + + xy[0] = xy[0] + 1; + xy[2] = xy[2] - 1; + xy[3] = tmp_y_pos + 16; + xy[1] = tmp_y_pos + 9; + + vsf_color( win->graf->handle, ( int16)tmp_tt_bar_color); + v_bar( win->graf->handle, xy); + } + + if( tmp_show_clock == TRUE) + { + if( tmp_clock_us == FALSE) + draw_text( win->graf->handle, tmp_clock_x + tmp_geek_area_x, tmp_y_text_pos, (int16)tmp_geek_area_text_color, "22:37:05"); + else + draw_text( win->graf->handle, tmp_clock_x + tmp_geek_area_x, tmp_y_text_pos, (int16)tmp_geek_area_text_color, "10:37:05 PM"); + } +} + + +static void CDECL draw_color_case( WINDOW *win, PARMBLK *pblk, void *data) +{ + tmp = ( int*)data; + + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y; + xy[2] = xy[0] + 127; + xy[3] = xy[1] + 127; + + vsf_color( win->graf->handle, ( int16)*tmp); + v_bar( win->graf->handle, xy); + + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y; + xy[2] = pblk->pb_x; + xy[3] = pblk->pb_y + pblk->pb_h - 1; + xy[4] = pblk->pb_x + pblk->pb_w - 1; + xy[5] = xy[3]; + xy[6] = xy[4]; + xy[7] = pblk->pb_y; + xy[8] = pblk->pb_x; + xy[9] = pblk->pb_y; + + vsl_color( win->graf->handle, BLACK); + v_pline( win->graf->handle, 5, xy); +} + + +void pref_dialog( void) +{ + int frms[] = { PREFS_PANEL1, PREFS_PANEL2}; + int buts[] = { PREFS_COLOR, PREFS_MISC}; + + if( pref_dialog_win != NULL) + return; + + dial = get_tree( PREFS); + + tmp_button_off_background = button_off_background; + tmp_button_off_light_color = button_off_light_color; + tmp_button_off_dark_color = button_off_dark_color; + tmp_button_off_text_color = button_off_text_color; + tmp_button_off_text_shadow_color = button_off_text_shadow_color; + tmp_button_on_background = button_on_background; + tmp_button_on_light_color = button_on_light_color; + tmp_button_on_dark_color = button_on_dark_color; + tmp_button_on_text_color = button_on_text_color; + tmp_button_on_text_shadow_color = button_on_text_shadow_color; + tmp_geek_area_text_color = geek_area_text_color; + tmp_geek_area_color = geek_area_color; + tmp_geek_area_dark_line = geek_area_dark_line; + tmp_geek_area_light_line = geek_area_light_line; + tmp_app_width = app_width; + tmp_cpu_bar_color = cpu_bar_color; + tmp_tt_bar_color = tt_bar_color; + tmp_st_bar_color = st_bar_color; + tmp_show_clock = show_clock; + tmp_clock_us = clock_us; + tmp_show_system_info = show_system_info; + tmp_show_acc = show_acc; + + + if( ( pref_dialog_win = FormCreate( dial, NAME|MOVER, NULL, "Preferences", NULL, TRUE, FALSE)) == NULL) + return; + + dial = FORM( pref_dialog_win); + + thumb = FormThumb( pref_dialog_win, frms, buts, 2); + + RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_ON_BACK, draw_color_case, &tmp_button_on_background); + RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_ON_LINE1, draw_color_case, &tmp_button_on_light_color); + RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_ON_LINE2, draw_color_case, &tmp_button_on_dark_color); + RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_ON_TEXT1, draw_color_case, &tmp_button_on_text_color); + RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_ON_TEXT2, draw_color_case, &tmp_button_on_text_shadow_color); + RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_OFF_BACK, draw_color_case, &tmp_button_off_background); + RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_OFF_LINE1, draw_color_case, &tmp_button_off_light_color); + RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_OFF_LINE2, draw_color_case, &tmp_button_off_dark_color); + RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_OFF_TEXT1, draw_color_case, &tmp_button_off_text_color); + RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_OFF_TEXT2, draw_color_case, &tmp_button_off_text_shadow_color); + RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_GEEK_BACK, draw_color_case, &tmp_geek_area_color); + RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_GEEK_LINE1, draw_color_case, &tmp_geek_area_light_line); + RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_GEEK_LINE2, draw_color_case, &tmp_geek_area_dark_line); + RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_GEEK_RAM1, draw_color_case, &tmp_st_bar_color); + RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_GEEK_RAM2, draw_color_case, &tmp_tt_bar_color); + RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_GEEK_CPU, draw_color_case, &tmp_cpu_bar_color); + RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_GEEK_TEXT, draw_color_case, &tmp_geek_area_text_color); + RsrcUserDraw( OC_FORM, pref_dialog_win, PREFS_PREVIEW, draw_preview, NULL); + + ObjcAttachFormFunc( pref_dialog_win, PREFS_OK, pref_dialog_ok_event, NULL); + ObjcAttachFormFunc( pref_dialog_win, PREFS_CANCEL, pref_dialog_cancel_event, NULL); + ObjcAttachFormFunc( pref_dialog_win, PREFS_DEFAULT, pref_dialog_default_event, NULL); + ObjcAttachFormFunc( pref_dialog_win, PREFS_ON_BACK, click_on_color, NULL); + ObjcAttachFormFunc( pref_dialog_win, PREFS_ON_LINE1, click_on_color, NULL); + ObjcAttachFormFunc( pref_dialog_win, PREFS_ON_LINE2, click_on_color, NULL); + ObjcAttachFormFunc( pref_dialog_win, PREFS_ON_TEXT1, click_on_color, NULL); + ObjcAttachFormFunc( pref_dialog_win, PREFS_ON_TEXT2, click_on_color, NULL); + ObjcAttachFormFunc( pref_dialog_win, PREFS_OFF_BACK, click_on_color, NULL); + ObjcAttachFormFunc( pref_dialog_win, PREFS_OFF_LINE1, click_on_color, NULL); + ObjcAttachFormFunc( pref_dialog_win, PREFS_OFF_LINE2, click_on_color, NULL); + ObjcAttachFormFunc( pref_dialog_win, PREFS_OFF_TEXT1, click_on_color, NULL); + ObjcAttachFormFunc( pref_dialog_win, PREFS_OFF_TEXT2, click_on_color, NULL); + ObjcAttachFormFunc( pref_dialog_win, PREFS_GEEK_BACK, click_on_color, NULL); + ObjcAttachFormFunc( pref_dialog_win, PREFS_GEEK_LINE1, click_on_color, NULL); + ObjcAttachFormFunc( pref_dialog_win, PREFS_GEEK_LINE2, click_on_color, NULL); + ObjcAttachFormFunc( pref_dialog_win, PREFS_GEEK_RAM1, click_on_color, NULL); + ObjcAttachFormFunc( pref_dialog_win, PREFS_GEEK_RAM2, click_on_color, NULL); + ObjcAttachFormFunc( pref_dialog_win, PREFS_GEEK_CPU, click_on_color, NULL); + ObjcAttachFormFunc( pref_dialog_win, PREFS_GEEK_TEXT, click_on_color, NULL); + + ObjcAttachVar( OC_FORM, pref_dialog_win, PREFS_SHOW_US_CLOCK, &tmp_clock_us, 1); + ObjcAttachVar( OC_FORM, pref_dialog_win, PREFS_SHOW_ACC, &tmp_show_acc, 1); + ObjcAttachVar( OC_FORM, pref_dialog_win, PREFS_SYSTEM_INFO, &tmp_show_system_info, 1); + ObjcAttachVar( OC_FORM, pref_dialog_win, PREFS_SHOW_CLOCK, &tmp_show_clock, 1); +} + diff --git a/sources/z-tools/trunk/ztask/preference.c b/sources/z-tools/trunk/ztask/preference.c new file mode 100644 index 0000000..bd4395c --- /dev/null +++ b/sources/z-tools/trunk/ztask/preference.c @@ -0,0 +1,392 @@ +#include "general.h" +#include "win.h" +#include "string.h" + +int tmp_button_off_background, tmp_button_off_light_color, tmp_button_off_dark_color, +tmp_button_off_text_color, tmp_button_off_text_shadow_color, tmp_button_on_background, +tmp_button_on_light_color, tmp_button_on_dark_color, tmp_button_on_text_color, +tmp_button_on_text_shadow_color, tmp_geek_area_color, tmp_geek_area_dark_line, +tmp_geek_area_light_line, tmp_app_width, tmp_cpu_bar_color, +tmp_tt_bar_color, tmp_st_bar_color, tmp_show_clock, tmp_clock_us, +tmp_show_system_info, tmp_show_acc; + +int *tmp; +static int16 xy[10], tmp_cpu_x, tmp_tt_x, tmp_st_x, tmp_clock_x, tmp_geek_area_width, tmp_y_text_pos, +tmp_x_pos, tmp_y_pos, tmp_w_pos, tmp_geek_area_x, text_width, x; +static OBJECT *dial = NULL; + + +static void CDECL pref_dialog_cancel_event( WINDOW *win, int obj, int mode, void *data) +{ + ObjcChange( OC_FORM, win, obj, NORMAL, TRUE); +} + +static void CDECL pref_dialog_ok_event( WINDOW *win, int obj, int mode, void *data) +{ + ObjcChange( OC_FORM, win, obj, NORMAL, TRUE); + ApplWrite( _AESapid, WM_DESTROY, win->handle, 0, 0, 0, 0); +} + + +static void CDECL draw_preview( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y; + xy[2] = pblk->pb_x + pblk->pb_w - 1; + xy[3] = pblk->pb_y + pblk->pb_h - 1; + + vsf_color( win->graf->handle, LCYAN); + v_bar( win->graf->handle, xy); + + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y; + xy[2] = pblk->pb_x; + xy[3] = pblk->pb_y + pblk->pb_h - 1; + xy[4] = pblk->pb_x + pblk->pb_w - 1; + xy[5] = xy[3]; + xy[6] = xy[4]; + xy[7] = pblk->pb_y; + xy[8] = pblk->pb_x; + xy[9] = pblk->pb_y; + + vsl_color( win->graf->handle, BLACK); + v_pline( win->graf->handle, 5, xy); + + x = x_space + 2; + + if( tmp_show_system_info) + { + tmp_cpu_x = x; + x += ( bar_width + 2); + + tmp_st_x = x; + x += ( bar_width + 2); + + tmp_tt_x = x; + x += ( bar_width + x_space); + } + + if( tmp_show_clock == TRUE) + { + tmp_clock_x = x; + + if( tmp_clock_us == FALSE) + text_width = get_text_width( "22:37:05"); + else + text_width = get_text_width( "10:37:05 PM"); + + x += ( text_width + x_space); + } + + tmp_geek_area_width = x + 1; + + tmp_y_text_pos = pblk->pb_y + pblk->pb_h - 15; + + tmp_w_pos = tmp_geek_area_width + ( 2 * tmp_app_width) + 23; + tmp_x_pos = pblk->pb_x + ( pblk->pb_w - tmp_w_pos) - 1; + tmp_y_pos = pblk->pb_y + pblk->pb_h - 22; + + + tmp_geek_area_x = tmp_x_pos + tmp_w_pos - tmp_geek_area_width; + + /* we draw the menu area */ + xy[0] = tmp_x_pos; + xy[1] = tmp_y_pos; + xy[2] = xy[0] + 23; + xy[3] = xy[1] + 20; + + + vsf_color( win->graf->handle, ( int16)tmp_button_off_background); + v_bar( win->graf->handle, xy); + + xy[1] = xy[3]; + xy[2] = xy[0]; + xy[3] = tmp_y_pos; + xy[4] = xy[0] + 22; + xy[5] = tmp_y_pos; + + vsl_color( win->graf->handle, ( int16)tmp_button_off_light_color); + v_pline( win->graf->handle, 3, xy); + + xy[0] = xy[4] + 1; + xy[1] = tmp_y_pos; + xy[2] = xy[0]; + xy[3] = xy[1] + 20; + xy[4] = tmp_x_pos; + xy[5] = xy[3]; + + vsl_color( win->graf->handle, ( int16)tmp_button_off_dark_color); + v_pline( win->graf->handle, 3, xy); + +// icons[ICONS_MENU].ob_x = xw + 4; +// icons[ICONS_MENU].ob_y = y_pos + 2; + +// mt_objc_draw( icons, ICONS_MENU, 1, win->graf->clip.g_x, win->graf->clip.g_y, win->graf->clip.g_w, win->graf->clip.g_h, app.aes_global); + + tmp_x_pos += 24; + + xy[0] = tmp_x_pos; + xy[1] = tmp_y_pos; + xy[2] = xy[0] + tmp_app_width - 1; + xy[3] = xy[1] + 20; + + vsf_color( win->graf->handle, ( int16)tmp_button_on_background); + v_bar( win->graf->handle, xy); + + xy[1] = xy[3]; + xy[2] = xy[0]; + xy[3] = tmp_y_pos; + xy[4] = xy[0] + tmp_app_width - 2; + xy[5] = tmp_y_pos; + + vsl_color( win->graf->handle, ( int16)tmp_button_on_dark_color); + v_pline( win->graf->handle, 3, xy); + + xy[0] = xy[4] + 1; + xy[1] = tmp_y_pos; + xy[2] = xy[0]; + xy[3] = xy[1] + 20; + xy[4] = tmp_x_pos; + xy[5] = xy[3]; + + vsl_color( win->graf->handle, ( int16)tmp_button_on_light_color); + v_pline( win->graf->handle, 3, xy); + + draw_text( win->graf->handle, tmp_x_pos + 21, tmp_y_text_pos + 1, ( int16)tmp_button_on_text_shadow_color, "Dummy"); + draw_text( win->graf->handle, tmp_x_pos + 20, tmp_y_text_pos, ( int16)tmp_button_on_text_color, "Dummy"); + + tmp_x_pos += tmp_app_width; + + xy[0] = tmp_x_pos; + xy[1] = tmp_y_pos; + xy[2] = xy[0] + tmp_app_width - 1; + xy[3] = xy[1] + 20; + + vsf_color( win->graf->handle, ( int16)tmp_button_off_background); + v_bar( win->graf->handle, xy); + + xy[1] = xy[3]; + xy[2] = xy[0]; + xy[3] = tmp_y_pos; + xy[4] = xy[0] + tmp_app_width - 2; + xy[5] = tmp_y_pos; + + vsl_color( win->graf->handle, ( int16)tmp_button_off_light_color); + v_pline( win->graf->handle, 3, xy); + + xy[0] = xy[4] + 1; + xy[1] = tmp_y_pos; + xy[2] = xy[0]; + xy[3] = xy[1] + 20; + xy[4] = tmp_x_pos; + xy[5] = xy[3]; + + vsl_color( win->graf->handle, ( int16)tmp_button_off_dark_color); + v_pline( win->graf->handle, 3, xy); + + draw_text( win->graf->handle, tmp_x_pos + 21, tmp_y_text_pos + 1, ( int16)tmp_button_off_text_shadow_color, "Dummy"); + draw_text( win->graf->handle, tmp_x_pos + 20, tmp_y_text_pos, ( int16)tmp_button_off_text_color, "Dummy"); + + tmp_x_pos += tmp_app_width; + + + + /* draw the "geek" area */ + xy[0] = tmp_x_pos + 2; + xy[1] = tmp_y_pos + 2; + xy[2] = xy[0] + tmp_geek_area_width - 6; + xy[3] = xy[1] + 16; + + vsf_color( win->graf->handle, ( int16)tmp_geek_area_color); + v_bar( win->graf->handle, xy); + + xy[0] = tmp_x_pos; + xy[1] = tmp_y_pos; + xy[2] = xy[0]; + xy[3] = xy[1] + 20; + xy[4] = xy[2] + tmp_geek_area_width - 2; + xy[5] = xy[3]; + xy[6] = xy[4]; + xy[7] = xy[1]; + xy[8] = xy[0]; + xy[9] = xy[1]; + + vsl_color( win->graf->handle, ( int16)tmp_button_off_background); + v_pline( win->graf->handle, 5, xy); + + xy[0]++; + xy[1] = xy[3] - 1; + xy[2] = xy[0]; + xy[3] = tmp_y_pos + 1; + xy[4]--; + xy[5] = xy[3]; + + vsl_color( win->graf->handle, ( int16)tmp_geek_area_dark_line); + v_pline( win->graf->handle, 3, xy); + + xy[2] = xy[4]; + xy[3] = xy[1]; + xy[5] = tmp_y_pos + 2; + + vsl_color( win->graf->handle, ( int16)tmp_geek_area_light_line); + v_pline( win->graf->handle, 3, xy); + + + /* draw the cpu % in the "geek" area */ + if( tmp_show_system_info) + { + /* the CPU usage */ + xy[0] = tmp_cpu_x + tmp_geek_area_x; + xy[1] = tmp_y_pos + 3; + xy[2] = xy[0] + bar_width - 1; + xy[3] = xy[1] + 14; + + vsf_color( win->graf->handle, BLACK); + v_bar( win->graf->handle, xy); + + xy[0] = xy[0] + 1; + xy[2] = xy[2] - 1; + xy[3] = tmp_y_pos + 16; + xy[1] = tmp_y_pos + 9; + + vsf_color( win->graf->handle, ( int16)tmp_cpu_bar_color); + v_bar( win->graf->handle, xy); + + /* the STRAM usage */ + xy[0] = tmp_st_x + tmp_geek_area_x; + xy[1] = tmp_y_pos + 3; + xy[2] = xy[0] + bar_width - 1; + xy[3] = xy[1] + 14; + + vsf_color( win->graf->handle, BLACK); + v_bar( win->graf->handle, xy); + + xy[0] = xy[0] + 1; + xy[2] = xy[2] - 1; + xy[3] = tmp_y_pos + 16; + xy[1] = tmp_y_pos + 9; + + vsf_color( win->graf->handle, ( int16)tmp_st_bar_color); + v_bar( win->graf->handle, xy); + + xy[0] = tmp_tt_x + tmp_geek_area_x; + xy[1] = tmp_y_pos + 3; + xy[2] = xy[0] + bar_width - 1; + xy[3] = xy[1] + 14; + + vsf_color( win->graf->handle, BLACK); + v_bar( win->graf->handle, xy); + + + xy[0] = xy[0] + 1; + xy[2] = xy[2] - 1; + xy[3] = tmp_y_pos + 16; + xy[1] = tmp_y_pos + 9; + + vsf_color( win->graf->handle, ( int16)tmp_tt_bar_color); + v_bar( win->graf->handle, xy); + } + + if( tmp_show_clock == TRUE) + { + if( tmp_clock_us == FALSE) + draw_text( win->graf->handle, tmp_clock_x + tmp_geek_area_x, tmp_y_text_pos, BLACK, "22:37:05"); + else + draw_text( win->graf->handle, tmp_clock_x + tmp_geek_area_x, tmp_y_text_pos, BLACK, "10:37:05 PM"); + } +} + + +static void CDECL draw_color_case( WINDOW *win, PARMBLK *pblk, void *data) +{ + tmp = ( int*)data; + + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y; + xy[2] = xy[0] + 127; + xy[3] = xy[1] + 127; + + vsf_color( win->graf->handle, ( int16)*tmp); + v_bar( win->graf->handle, xy); + + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y; + xy[2] = pblk->pb_x; + xy[3] = pblk->pb_y + pblk->pb_h - 1; + xy[4] = pblk->pb_x + pblk->pb_w - 1; + xy[5] = xy[3]; + xy[6] = xy[4]; + xy[7] = pblk->pb_y; + xy[8] = pblk->pb_x; + xy[9] = pblk->pb_y; + + vsl_color( win->graf->handle, BLACK); + v_pline( win->graf->handle, 5, xy); +} + + +void pref_dialog( void) +{ + WINDOW *win; + int frms[] = { PREFS_PANEL1, PREFS_PANEL2}; + int buts[] = { PREFS_COLOR, PREFS_MISC}; + + dial = get_tree( PREFS); + + tmp_button_off_background = button_off_background; + tmp_button_off_light_color = button_off_light_color; + tmp_button_off_dark_color = button_off_dark_color; + tmp_button_off_text_color = button_off_text_color; + tmp_button_off_text_shadow_color = button_off_text_shadow_color; + tmp_button_on_background = button_on_background; + tmp_button_on_light_color = button_on_light_color; + tmp_button_on_dark_color = button_on_dark_color; + tmp_button_on_text_color = button_on_text_color; + tmp_button_on_text_shadow_color = button_on_text_shadow_color; + tmp_geek_area_color = geek_area_color; + tmp_geek_area_dark_line = geek_area_dark_line; + tmp_geek_area_light_line = geek_area_light_line; + tmp_app_width = app_width; + tmp_cpu_bar_color = cpu_bar_color; + tmp_tt_bar_color = tt_bar_color; + tmp_st_bar_color = st_bar_color; + tmp_show_clock = show_clock; + tmp_clock_us = clock_us; + tmp_show_system_info = show_system_info; + tmp_show_acc = show_acc; + + + if( ( win = FormCreate( dial, NAME|MOVER, NULL, "Preferences", NULL, TRUE, FALSE)) == NULL) + return; + + dial = FORM( win); + + FormThumb( win, frms, buts, 2); + + RsrcUserDraw( OC_FORM, win, PREFS_ON_BACK, draw_color_case, &tmp_button_on_background); + RsrcUserDraw( OC_FORM, win, PREFS_ON_LINE1, draw_color_case, &tmp_button_on_light_color); + RsrcUserDraw( OC_FORM, win, PREFS_ON_LINE2, draw_color_case, &tmp_button_on_dark_color); + RsrcUserDraw( OC_FORM, win, PREFS_ON_TEXT1, draw_color_case, &tmp_button_on_text_color); + RsrcUserDraw( OC_FORM, win, PREFS_ON_TEXT2, draw_color_case, &tmp_button_on_text_shadow_color); + RsrcUserDraw( OC_FORM, win, PREFS_OFF_BACK, draw_color_case, &tmp_button_off_background); + RsrcUserDraw( OC_FORM, win, PREFS_OFF_LINE1, draw_color_case, &tmp_button_off_light_color); + RsrcUserDraw( OC_FORM, win, PREFS_OFF_LINE2, draw_color_case, &tmp_button_off_dark_color); + RsrcUserDraw( OC_FORM, win, PREFS_OFF_TEXT1, draw_color_case, &tmp_button_off_text_color); + RsrcUserDraw( OC_FORM, win, PREFS_OFF_TEXT2, draw_color_case, &tmp_button_off_text_shadow_color); + RsrcUserDraw( OC_FORM, win, PREFS_GEEK_BACK, draw_color_case, &tmp_geek_area_color); + RsrcUserDraw( OC_FORM, win, PREFS_GEEK_LINE1, draw_color_case, &tmp_geek_area_light_line); + RsrcUserDraw( OC_FORM, win, PREFS_GEEK_LINE2, draw_color_case, &tmp_geek_area_dark_line); + RsrcUserDraw( OC_FORM, win, PREFS_GEEK_RAM1, draw_color_case, &tmp_st_bar_color); + RsrcUserDraw( OC_FORM, win, PREFS_GEEK_RAM2, draw_color_case, &tmp_tt_bar_color); + RsrcUserDraw( OC_FORM, win, PREFS_GEEK_CPU, draw_color_case, &tmp_cpu_bar_color); + RsrcUserDraw( OC_FORM, win, PREFS_PREVIEW, draw_preview, NULL); + + WindSet( win, WF_BEVENT, BEVENT_MODAL, 0, 0, 0); + ObjcAttachFormFunc( win, PREFS_OK, pref_dialog_ok_event, NULL); + ObjcAttachFormFunc( win, PREFS_CANCEL, pref_dialog_cancel_event, NULL); + ObjcAttachVar( OC_FORM, win, PREFS_SHOW_US_CLOCK, &tmp_clock_us, 1); + ObjcAttachVar( OC_FORM, win, PREFS_SHOW_ACC, &tmp_show_acc, 1); + ObjcAttachVar( OC_FORM, win, PREFS_SYSTEM_INFO, &tmp_show_system_info, 1); + ObjcAttachVar( OC_FORM, win, PREFS_SHOW_CLOCK, &tmp_show_clock, 1); +} + diff --git a/sources/z-tools/trunk/ztask/prefs.c b/sources/z-tools/trunk/ztask/prefs.c new file mode 100644 index 0000000..70f81ff --- /dev/null +++ b/sources/z-tools/trunk/ztask/prefs.c @@ -0,0 +1,354 @@ +#include "general.h" + +int button_off_background = 8; +int button_off_light_color = 250; +int button_off_dark_color = 252; +int button_off_text_color = 255; +int button_off_text_shadow_color = 250; +int button_on_background = 252; +int button_on_light_color = 8; +int button_on_dark_color = 144; +int button_on_text_color = 1; +int button_on_text_shadow_color = 251; +int geek_area_text_color = 1; +int geek_area_color = 252; +int geek_area_dark_line = 144; +int geek_area_light_line = 250; +int app_width = 72; +int cpu_bar_color = 146; +int tt_bar_color = 73; +int st_bar_color = 106; +int show_clock = TRUE; +int clock_us = FALSE; +int show_system_info = TRUE; +int show_acc = TRUE; + +/* Prototype */ +int prefs_read( void); +int prefs_write( void); + + +/*==================================================================================* + * prefs_read: * + * Reads the content of the INF file an put it in the preference global variables. * + *----------------------------------------------------------------------------------* + * returns: 0 if error * + *==================================================================================*/ +int prefs_read( void) +{ + char filename[256] = ""; + char unknown_s[256] = ""; + FILE *inffile; + int32 filepos; + char *env_home; + int16 len; + boolean valid_entry_found; + + shel_envrn( &env_home, "HOME="); + + /* Home directory exist? */ + if ( env_home != NULL) + { + strcpy( filename, env_home); + len = ( int16)strlen( filename); + + if ((filename[len - 1] != '\\') && (filename[len - 1] != '/')) + { + strcat( filename, "\\"); + } + + strcat( filename, "ztask.inf"); + + if (( inffile = fopen( filename, "rb+")) != NULL) + goto loop; + + } + + /* With ftell, we MUST open the file in binary mode and not in text mode !!! */ + if (( inffile = fopen( "ztask.inf", "rb+")) == NULL) + { + if( app.nplanes < 8) + { + button_off_light_color = WHITE; + button_off_dark_color = LBLACK; + button_off_text_color = BLACK; + button_off_text_shadow_color = WHITE; + button_on_background = LBLACK; + button_on_light_color = LWHITE; + button_on_dark_color = BLACK; + button_on_text_color = BLACK; + button_on_text_shadow_color = LWHITE; + geek_area_color = LWHITE; + geek_area_dark_line = LBLACK; + geek_area_light_line = WHITE; + cpu_bar_color = CYAN; + tt_bar_color = BLUE; + st_bar_color = RED; + } + + return( 0); + } + +loop: + + do + { + valid_entry_found = FALSE; + + filepos = ftell( inffile); + + if ( fscanf( inffile, "button_off_background=%d ", &button_off_background) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if (fscanf( inffile, "button_off_light_color=%d ", &button_off_light_color) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "button_off_dark_color=%d ", &button_off_dark_color) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if (fscanf( inffile, "button_off_text_color=%d ", &button_off_text_color) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "button_off_text_shadow_color=%d ", &button_off_text_shadow_color) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "button_on_background=%d ", &button_on_background) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if (fscanf( inffile, "button_on_light_color=%d ", &button_on_light_color) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "button_on_dark_color=%d ", &button_on_dark_color) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if (fscanf( inffile, "button_on_text_color=%d ", &button_on_text_color) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "button_on_text_shadow_color=%d ", &button_on_text_shadow_color) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "geek_area_text_color=%d ", &geek_area_text_color) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + + if ( fscanf( inffile, "geek_area_color=%d ", &geek_area_color) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + + if ( fscanf( inffile, "geek_area_dark_line=%d ", &geek_area_dark_line) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "geek_area_light_line=%d ", &geek_area_light_line) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "app_width=%d ", &app_width) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + + if ( fscanf( inffile, "cpu_bar_color=%d ", &cpu_bar_color) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + + if ( fscanf( inffile, "tt_bar_color=%d ", &tt_bar_color) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "st_bar_color=%d ", &st_bar_color) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "show_clock=%d ", &show_clock) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "clock_us=%d ", &clock_us) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "show_system_info=%d ", &show_system_info) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "show_acc=%d ", &show_acc) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "%s ", unknown_s) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + } while ( valid_entry_found); + + fclose( inffile); + + return( 1); +} + + + +/*==================================================================================* + * prefs_write: * + * Writes the preference variables in the preference file. * + *----------------------------------------------------------------------------------* + * returns: 0 if error * + *==================================================================================*/ +int prefs_write( void) +{ + char filename[256] = "ztask.inf"; + FILE *inffile; + char *env_home; + int16 len; + + shel_envrn( &env_home, "HOME="); + + /* Home directory exist? */ + if ( env_home != NULL) + { + strcpy( filename, env_home); + + len = ( int16)strlen( filename); + + if ((filename[len - 1] != '\\') && (filename[len - 1] != '/')) + strcat( filename, "\\"); + + strcat( filename, "ztask.inf"); + } + + /* With ftell, we MUST open the file in binary mode and not in text mode !!! */ + if (( inffile = fopen( filename, "wb+")) == NULL) + return( 0); + + fprintf( inffile, "button_off_background=%d\r\n", button_off_background); + fprintf( inffile, "button_off_light_color=%d\r\n", button_off_light_color); + fprintf( inffile, "button_off_dark_color=%d\r\n", button_off_dark_color); + fprintf( inffile, "button_off_text_color=%d\r\n", button_off_text_color); + fprintf( inffile, "button_off_text_shadow_color=%d\r\n", button_off_text_shadow_color); + fprintf( inffile, "button_on_background=%d\r\n", button_on_background); + fprintf( inffile, "button_on_light_color=%d\r\n", button_on_light_color); + fprintf( inffile, "button_on_dark_color=%d\r\n", button_on_dark_color); + fprintf( inffile, "button_on_text_color=%d\r\n", button_on_text_color); + fprintf( inffile, "button_on_text_shadow_color=%d\r\n", button_on_text_shadow_color); + fprintf( inffile, "geek_area_text_color=%d\r\n", geek_area_text_color); + fprintf( inffile, "geek_area_color=%d\r\n", geek_area_color); + fprintf( inffile, "geek_area_dark_line=%d\r\n", geek_area_dark_line); + fprintf( inffile, "geek_area_light_line=%d\r\n", geek_area_light_line); + fprintf( inffile, "app_width=%d\r\n", app_width); + fprintf( inffile, "cpu_bar_color=%d\r\n", cpu_bar_color); + fprintf( inffile, "tt_bar_color=%d\r\n", tt_bar_color); + fprintf( inffile, "st_bar_color=%d\r\n", st_bar_color); + fprintf( inffile, "show_clock=%d\r\n", show_clock); + fprintf( inffile, "clock_us=%d\r\n", clock_us); + fprintf( inffile, "show_system_info=%d\r\n", show_system_info); + fprintf( inffile, "show_acc=%d\r\n", show_acc); + fclose( inffile); + + return( 1); +} diff --git a/sources/z-tools/trunk/ztask/prefs.h b/sources/z-tools/trunk/ztask/prefs.h new file mode 100644 index 0000000..4a9c07a --- /dev/null +++ b/sources/z-tools/trunk/ztask/prefs.h @@ -0,0 +1,30 @@ +/* Global variable */ +extern int button_off_background; +extern int button_on_background; +extern int button_on_light_color; +extern int button_off_light_color; +extern int button_on_dark_color; +extern int button_off_dark_color; +extern int button_on_text_color; +extern int button_on_text_shadow_color; +extern int button_off_text_color; +extern int button_off_text_shadow_color; +extern int geek_area_text_color; +extern int geek_area_color; +extern int geek_area_dark_line; +extern int geek_area_light_line; +extern int app_width; +extern int cpu_bar_color; +extern int tt_bar_color; +extern int st_bar_color; +extern int show_clock; +extern int clock_us; +extern int show_system_info; +extern int show_acc; + + +/* Function */ +extern int prefs_read( void); +extern int prefs_write( void); + + diff --git a/sources/z-tools/trunk/ztask/process.c b/sources/z-tools/trunk/ztask/process.c new file mode 100644 index 0000000..3583ea2 --- /dev/null +++ b/sources/z-tools/trunk/ztask/process.c @@ -0,0 +1,230 @@ +#include "general.h" +#include "gmem.h" +#include "string.h" +#include "cpu.h" +#include +#include + +#include +#include +#include +#include +#include +#include + +process *process_root = NULL; +int process_nbr = 0; + + +/*==================================================================================* + * process_attach: * + * attach a entry in the global process list. * + *----------------------------------------------------------------------------------* + * input: * + * pid: The PID of the application. * + *----------------------------------------------------------------------------------* + * returns: * + * the processe created or NULL * + *==================================================================================*/ + +process *process_attach( int pid) +{ + process *new = ( process *)gmalloc( sizeof(process)); + + if( !new) + return NULL; + + new -> pid = pid; + new -> next = process_root; + new->cpu_time = 0; + + process_root = new; + + process_nbr++; + + return new; +} + + +/*==================================================================================* + * process_find_parent: * + * find the parent( previous) entry in the process list. * + *----------------------------------------------------------------------------------* + * input: * + * child: the function returns the parent of this entry. * + *----------------------------------------------------------------------------------* + * returns: * + * the parent entry else the root entry. * + *==================================================================================*/ +process *process_find_parent( process *child) +{ + process *scan = process_root; + + while( scan) + { + if( scan->next != child) + { + scan = scan->next; + continue; + } + + break; + } + + return( scan); +} + + +/*==================================================================================* + * process_delete: * + * Delete an entry in the process list. * + *----------------------------------------------------------------------------------* + * input: * + * pid: the pid of the entry to delete. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void process_delete( int pid) +{ + process *scan = process_root, *parent; + + while( scan) + { + if( scan->pid != pid) + { + scan = scan->next; + continue; + } + + parent = process_find_parent( scan); + + if( parent == NULL) + process_root = scan->next; + else + parent->next = scan->next; + + gfree( scan); + process_nbr--; + break; + } +} + + +/*==================================================================================* + * process_find: * + * Find an entry in the process list. * + *----------------------------------------------------------------------------------* + * input: * + * id: the pid of the entry to find. * + *----------------------------------------------------------------------------------* + * returns: * + * the entry or NULL if not found. * + *==================================================================================*/ +process *process_find( int pid) +{ + process *scan = process_root, *result = NULL; + + while( scan) + { + if( scan->pid != pid) + { + scan = scan->next; + continue; + } + + result = scan; + break; + } + + return( result); +} + + + +/*==================================================================================* + * scan_process: * + * Make a list of all the process and add it in the global process list if * + * necessary. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void scan_process( void) +{ + int pid, count = 0; + uint32 old_cpu_time; + DIR *dir; + char *dirname; + char buf[128]; + struct dirent *de; + process *current_process = NULL, *scan; + clock_t current_t, relative_t; + static clock_t old_t = 0; + + current_t = clock(); + + relative_t = current_t - old_t; + + old_t = current_t; + + if (( dir = opendir( "U:/kern")) == NULL) + return; + + while(( de = readdir( dir)) != NULL) + { + dirname = de->d_name; + + if( dirname[0] != '1' && dirname[0] != '2' && dirname[0] != '3' && dirname[0] != '4' && dirname[0] != '5' + && dirname[0] != '6' && dirname[0] != '7' && dirname[0] != '8' && dirname[0] != '9') + continue; + + count++; + + pid = atoi( dirname); + + current_process = process_find( pid); + + // Is already listed? + if( current_process == NULL) + current_process = process_attach( pid); + + old_cpu_time = current_process->cpu_time; + + get_info_by_pid( pid, current_process->name, current_process->ram_usage, ¤t_process->cpu_time); + + sprintf( current_process->cpu_usage, "%lu", ((current_process->cpu_time - old_cpu_time) * 20) / relative_t); + + current_process->ram_usage_txt_width = get_text_width( current_process->ram_usage); + } + + closedir( dir); + + if( count != process_nbr) + { + scan = process_root; + + while( scan != NULL) + { + sprintf( buf, "U:/kern/%d", scan->pid); + + if (( dir = opendir( buf)) == NULL) + { + pid = scan->pid; + scan = scan->next; + process_delete( pid); + continue; + } + else + closedir( dir); + + scan = scan->next; + } + } +} + + + diff --git a/sources/z-tools/trunk/ztask/process.h b/sources/z-tools/trunk/ztask/process.h new file mode 100644 index 0000000..9a0c7a9 --- /dev/null +++ b/sources/z-tools/trunk/ztask/process.h @@ -0,0 +1,4 @@ +extern process *process_root; +extern int process_nbr; +extern void process_delete( int pid); +extern void scan_process( void); diff --git a/sources/z-tools/trunk/ztask/quit.c b/sources/z-tools/trunk/ztask/quit.c new file mode 100644 index 0000000..eb10505 --- /dev/null +++ b/sources/z-tools/trunk/ztask/quit.c @@ -0,0 +1,26 @@ +#include "general.h" + +static void quit_dialog_cancel_event( WINDOW *win, int obj, int mode, void *data) +{ + ObjcChange( OC_FORM, win, obj, NORMAL, TRUE); + ApplWrite( _AESapid, WM_DESTROY, win->handle, 0, 0, 0, 0); +} + +static void quit_dialog_ok_event( WINDOW *win, int obj, int mode, void *data) +{ + ObjcChange( OC_FORM, win, obj, NORMAL, TRUE); + ApplWrite( _AESapid, AP_TERM, 0, 0, 0, 0, 0); +} + + +void quit_dialog( void) +{ + WINDOW *win; + + if( ( win = FormCreate( get_tree( QUIT), NAME|MOVER, NULL, "", NULL, TRUE, FALSE)) == NULL) + return; + + WindSet( win, WF_BEVENT, BEVENT_MODAL, 0, 0, 0); + ObjcAttachFormFunc( win, QUIT_YES, quit_dialog_ok_event, NULL); + ObjcAttachFormFunc( win, QUIT_NO, quit_dialog_cancel_event, NULL); +} diff --git a/sources/z-tools/trunk/ztask/shutdown.c b/sources/z-tools/trunk/ztask/shutdown.c new file mode 100644 index 0000000..11d5cf3 --- /dev/null +++ b/sources/z-tools/trunk/ztask/shutdown.c @@ -0,0 +1,34 @@ +#include "general.h" + +static int shutdown_mode = SHUTDOWN_DIAL_HALT; + + +static void shutdown_dialog_cancel_event( WINDOW *win, int obj, int mode, void *data) +{ + ObjcChange( OC_FORM, win, obj, NORMAL, TRUE); + ApplWrite( _AESapid, WM_DESTROY, win->handle, 0, 0, 0, 0); +} + +static void shutdown_dialog_ok_event( WINDOW *win, int obj, int mode, void *data) +{ + ObjcChange( OC_FORM, win, obj, NORMAL, TRUE); + ApplWrite( _AESapid, WM_DESTROY, win->handle, 0, 0, 0, 0); + Shutdown(( long)shutdown_mode); +} + + +void shutdown_dialog( void) +{ + WINDOW *win; + + if( ( win = FormCreate( get_tree( SHUTDOWN_DIAL), NAME|MOVER, NULL, get_string( S_SHUTDOWN), NULL, TRUE, FALSE)) == NULL) + return; + + ObjcAttachVar( OC_FORM, win, SHUTDOWN_DIAL_WARN, &shutdown_mode, 1); + ObjcAttachVar( OC_FORM, win, SHUTDOWN_DIAL_COLD, &shutdown_mode, 2); + ObjcAttachVar( OC_FORM, win, SHUTDOWN_DIAL_HALT, &shutdown_mode, 0); + + ObjcAttachFormFunc( win, SHUTDOWN_DIAL_OK, shutdown_dialog_ok_event, NULL); + ObjcAttachFormFunc( win, SHUTDOWN_DIAL_CANCEL, shutdown_dialog_cancel_event, NULL); +} + diff --git a/sources/z-tools/trunk/ztask/string.c b/sources/z-tools/trunk/ztask/string.c new file mode 100644 index 0000000..ec59165 --- /dev/null +++ b/sources/z-tools/trunk/ztask/string.c @@ -0,0 +1,180 @@ +#include "general.h" +#include "font_8.h" + +void trim_start( char *name) +{ + while( name[0] == ' ') + // memcpy( name, name + 1, strlen( name)); + strcpy( name, name + 1); +} + + +void trim_end( char *name, int16 len) +{ + while( name[len] == ' ') + name[len--] = '\0'; +} + + + +/*==================================================================================* + * zstrncpy: * + * Copy bytes from to , including the terminating \0'-byte. * * + * If is longer than , it will be truncated with a '\0'-byte at * + * position n-1. * + * Example: zstrncpy(b, "string", 1) would put a '\0'-byte at b[0] and * + * return. * + * Basically, think of the as a limiter on the number of bytes at * + * we're allowed to touch, and then fit a string-copying idea on top of that. * + * Works for me, and a lot better than the standard strncpy(), too. * + *----------------------------------------------------------------------------------* + * returns: * + *----------------------------------------------------------------------------------* + * dst: Pointer to destination text. * + * src: Pointer to source text. * + * n: Limiter on the number of bytes at * + *==================================================================================*/ +char *zstrncpy( char *dst, const char *src, size_t n) +{ + register const char *source = src; + register char *dest = dst; + register size_t count = n; + + if( dest && !source && count) + *dest = '\0'; + else if( dest && source && (count >= 1)) + { + for( count--; count > 0 && *source != '\0'; count--) + *dest++ = *source++; + *dest = '\0'; + } + return dst; +} + + + +inline void draw_text_to_buffer( int16 xf, int16 yf, int32 src_line_octets, const char *str, MFDB *bm) +{ + int16 c, character_pixel_skip = 0; + int32 src_line_word = src_line_octets >> 1; + + while ( (c = *str++) != 0) + { + int xpos = xf + character_pixel_skip; + int xpos_octet = xpos >> 3; + register int pixel_shift = xpos - ( xpos_octet << 3); + register char *character = (char*)&my_font_8[(c - 1) << 2]; + register int i; + + if( pixel_shift == 0) + { + register char *dest = bm->fd_addr + ( yf * src_line_octets) + xpos_octet; + + for( i = 0; i < 8; i++) + { + *dest = *character++; + dest += src_line_octets; + } + } + else + { + register short *dest = ( short*)( bm->fd_addr + ( yf * src_line_octets) + xpos_octet); + + for( i = 0; i < 8; i++) + { + *dest |= (( *character++) << 8) >> pixel_shift; + dest += src_line_word; + } + } + + character_pixel_skip += ofwf[c]; + } +} + + +void draw_text( int16 vdih, int16 xf, int16 yf, int16 color, const char *str) +{ + MFDB pic, screen = {0}; + short fx_mem[16], sys_pxy[8] = { 0, 0, 0, 7, xf, yf, 0, yf + 7}, c, char_width, tcolor[2] = { color, WHITE}; + + pic.fd_addr = fx_mem; + pic.fd_w = 16; + pic.fd_h = 8; + pic.fd_wdwidth = 1; + pic.fd_stand = 0; + pic.fd_nplanes = 1; + + while ( (c = *str++) != 0) + { + register char *model = (char*)&my_font_8[(c - 1) << 2] ; + register char *dest = (char*)fx_mem; + + char_width = ofwf[c]; + + memset( fx_mem, 0, 20); + + *dest = *model++; + dest += 2; + *dest = *model++; + dest += 2; + *dest = *model++; + dest += 2; + *dest = *model++; + dest += 2; + *dest = *model++; + dest += 2; + *dest = *model++; + dest += 2; + *dest = *model++; + dest += 2; + *dest = *model; + + sys_pxy[2] = char_width - 1; + sys_pxy[6] = sys_pxy[4] + sys_pxy[2]; + + /*vdi*/ + vrt_cpyfm( vdih, 2, sys_pxy, &pic, &screen, tcolor); + + sys_pxy[4] += char_width; + } +} + + + +inline int16 get_text_width( const char *str) +{ + register int16 c, text_width = 0; + + while ( (c = *str++) != 0) + { + text_width += ofwf[c]; + } + + return text_width; +} + + +int16 name_shorter( int16 max_size, char *str) +{ + int16 len, current_len; + + len = ( int16) strlen( str) - 1; + + do + { + str[len - 3] = '.'; + str[len - 2] = '.'; + str[len - 1] = '.'; + str[len] = '\0'; + + len--; + + current_len = get_text_width( str); + + } while ( ( current_len >= max_size) && ( len > 0)); + + return current_len; +} + + + diff --git a/sources/z-tools/trunk/ztask/string.h b/sources/z-tools/trunk/ztask/string.h new file mode 100644 index 0000000..62ec801 --- /dev/null +++ b/sources/z-tools/trunk/ztask/string.h @@ -0,0 +1,11 @@ +extern void draw_text( int16 vdih, int16 xf, int16 yf, int16 color, const char *str); +extern inline void draw_text_to_buffer( int16 xf, int16 yf, int32 src_line_octets, const char *str, MFDB *bm); +extern inline int16 get_text_width( const char *str); +extern int16 name_shorter( int16 max_size, char *str); +extern char *zstrncpy( char *dst, const char *src, size_t n); +extern void trim_start( char *name); +extern void trim_end( char *name, int16 len); + + + + diff --git a/sources/z-tools/trunk/ztask/taskman.c b/sources/z-tools/trunk/ztask/taskman.c new file mode 100644 index 0000000..32a5a35 --- /dev/null +++ b/sources/z-tools/trunk/ztask/taskman.c @@ -0,0 +1,612 @@ +#include "general.h" +#include "win.h" +#include "process.h" +#include "gmem.h" +#include "string.h" +#include +#include + +WINDOW *taskman_win = NULL; +static void *thumb = NULL; +process *process_loop, *process_selected = NULL; +MFDB cpu_average_background = {0}, process_list_buffer = {0}; +static int16 wanted_color[2] = { BLACK, LGREEN}, txt_color[2] = { BLACK, WHITE}, selected_txt_color[2] = { BLACK, LWHITE}, xy[8], x, i, ii, dum, res, cpu_history_point[202]; +static OBJECT *dial = NULL; +uint32 old_stram, old_ttram, process_list_buffer_lenght; +int32 uptime, loadaverage[3], updays, tmpdays, uphours, tmphours, upmins, upsecs, ypos, ypos_max; +static MFDB screen = {0}; +float slider_pos = 0.0, slider_step = 0.0; + + +/*==================================================================================* + * int16 init_mfdb: * + * fit a MFDB with the parameters suppplied. * + *----------------------------------------------------------------------------------* + * input: * + * bm -> The MFDB to fit. * + * width -> Image's width. * + * height -> Image's height. * + * planes -> Screen planes or 1 if the image is monochrome. * + *----------------------------------------------------------------------------------* + * returns: * + * '0' if error or the memory size allocated. * + *==================================================================================*/ +uint32 init_mfdb( MFDB *bm, int16 width, int16 height, int16 planes) +{ + uint32 length; + + bm->fd_w = width; + bm->fd_h = height; + bm->fd_wdwidth = ( width >> 4) + (( width % 16) != 0); + bm->fd_stand = 0; + bm->fd_nplanes = planes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + + length = (( (( uint32)bm->fd_wdwidth << 1 ) * ( uint32)bm->fd_nplanes) * ( uint32)bm->fd_h) + 256L; + bm->fd_addr = gmalloc( length); + + if( bm->fd_addr) + return( length - 256); + + bm->fd_addr = NULL; + + return ( 0); +} + + +static void CDECL taskman_win_mouse_event( WINDOW *win, int16 buff[8]) +{ + int16 ob_x, ob_y; + + if( FormThbGet( thumb, 0) != TASK_PROCESS) + return; + + mt_objc_offset( FORM( win), TASK_PROCESS_LIST, &ob_x, &ob_y, app.aes_global); + + if( !IS_IN( evnt.mx, evnt.my, ob_x, ob_y, dial[TASK_PROCESS_LIST].ob_width, dial[TASK_PROCESS_LIST].ob_height)) + return; + + evnt.my -= ( ob_y + 15); + + process_loop = process_root; + + while( process_loop != NULL) + { + if(( process_loop->y_pos > evnt.my) && ( process_loop->y_pos < evnt.my + 13)) + { + process_selected = process_loop; + break; + } + + process_loop = process_loop->next; + } + + if( process_selected) + { + ObjcDraw( OC_FORM, taskman_win, TASK_PROCESS_LIST, 1); + + if( dial[TASK_KILL].ob_state & DISABLED) + { + ObjcChange( OC_FORM, win, TASK_KILL, ~DISABLED, TRUE); + } + } + +} + + +void CDECL draw_process_list( WINDOW *win, PARMBLK *pblk, void *data) +{ + memset( process_list_buffer.fd_addr, 0, process_list_buffer_lenght); + + i = 0; + process_loop = process_root; + + + while( process_loop != NULL) + { + process_loop->y_pos = i - ( ypos * 13); + + if(( process_loop->y_pos >= pblk->pb_h - 12) || ( process_loop->y_pos < 0)) + { + process_loop = process_loop->next; + i += 13; + continue; + } + + draw_text_to_buffer( 2, process_loop->y_pos + 3, process_list_buffer.fd_wdwidth << 1, process_loop->name, &process_list_buffer); + draw_text_to_buffer( 183, process_loop->y_pos + 3, process_list_buffer.fd_wdwidth << 1, process_loop->cpu_usage, &process_list_buffer); + draw_text_to_buffer( pblk->pb_w - ( process_loop->ram_usage_txt_width + 4), process_loop->y_pos + 3, process_list_buffer.fd_wdwidth << 1, process_loop->ram_usage, &process_list_buffer); + + i += 13; + + process_loop = process_loop->next; + } + + xy[0] = 0; + xy[1] = 0; + xy[2] = pblk->pb_w - 1; + xy[3] = pblk->pb_h - 1; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = pblk->pb_x + pblk->pb_w - 1; + xy[7] = pblk->pb_y + pblk->pb_h - 1; + + vrt_cpyfm( win->graf->handle, MD_REPLACE, xy, &process_list_buffer, &screen, txt_color); + + if( process_selected != NULL) + { + if(( process_selected->y_pos >= pblk->pb_h - 12) || ( process_selected->y_pos < 0)) + return; + + xy[0] = 0; + xy[1] = process_selected->y_pos; + xy[2] = pblk->pb_w - 1; + xy[3] = xy[1] + 12; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y + process_selected->y_pos; + xy[6] = pblk->pb_x + pblk->pb_w - 1; + xy[7] = xy[5] + 12; + vrt_cpyfm( win->graf->handle, MD_REPLACE, xy, &process_list_buffer, &screen, selected_txt_color); + } +} + +static void calc_process_slider( WINDOW *win) +{ + int16 max_mover_size; + int16 full_win_size = ypos_max * 13; + + max_mover_size = dial[TASK_VBACK].ob_height; + + dial[TASK_VMOVER].ob_y = 0; + dial[TASK_VMOVER].ob_height = max_mover_size; + + if ( dial[TASK_PROCESS_LIST].ob_height < full_win_size) + { + float factor = ( float)dial[TASK_PROCESS_LIST].ob_height / ( float)full_win_size; + float mover_size = MAX(( float)max_mover_size * factor, 6L); + + slider_pos = 0; + slider_step = ( float)max_mover_size / ( float)ypos_max; + dial[TASK_VMOVER].ob_height = ( int16)( mover_size); + } +} + + + + +static void CDECL taskman_dialog_kill( WINDOW *win, int obj, int mode, void *data) +{ + if( process_selected == NULL) + return; + + Pkill( process_selected->pid, SIGKILL); + ObjcChange( mode, win, obj, ~SELECTED, TRUE); + ObjcChange( mode, win, obj, DISABLED, TRUE); +} + + + +static void CDECL slid_up( WINDOW *win, int obj, int mode, void *data) +{ + ObjcChange( mode, win, obj, SELECTED, TRUE); + + do + { + if ( ypos > 0L) + { + ypos--; + ObjcDraw( OC_FORM, win, TASK_PROCESS_LIST, 1); + slider_pos -= slider_step; + dial[TASK_VMOVER].ob_y = MAX( 0, ( int16)floor( slider_pos)); + ObjcDraw( OC_FORM, win, TASK_VBACK, 2); + mt_evnt_timer( 100L, app.aes_global); + } + graf_mkstate( &dum, &dum, &res, &dum); + + } while( res); + + ObjcChange( mode, win, obj, ~SELECTED, TRUE); +} + + +static void CDECL slid_down( WINDOW *win, int obj, int mode, void *data) +{ + ObjcChange( mode, win, obj, SELECTED, TRUE); + + do + { + if (( ypos < ( ypos_max - dial[TASK_PROCESS_LIST].ob_height / 13)) && ( ypos_max > dial[TASK_PROCESS_LIST].ob_height / 13)) + { + ypos ++; + ObjcDraw( OC_FORM, win, TASK_PROCESS_LIST, 1); + slider_pos += slider_step; + dial[TASK_VMOVER].ob_y = ( int16)floor( slider_pos); + ObjcDraw( OC_FORM, win, TASK_VBACK, 2); + mt_evnt_timer( 100L, app.aes_global); + } + graf_mkstate( &dum, &dum, &res, &dum); + + } while( res); + + ObjcChange( mode, win, obj, ~SELECTED, TRUE); +} + + +static void CDECL slid_vmover( WINDOW *win, int obj, int mode, void *data) +{ + int32 old_ypos = ypos; + + ObjcChange( mode, win, obj, SELECTED, TRUE); + + graf_mouse( FLAT_HAND, NULL); + + while( !wind_update( BEG_MCTRL)); + + res = graf_slidebox( dial, TASK_VBACK, TASK_VMOVER, 1); + + wind_update( END_MCTRL); + + ypos = MAX( 0, ( ypos_max - dial[TASK_PROCESS_LIST].ob_height / 13) * res / 1000L); + + if( old_ypos != ypos) + { + slider_pos = ypos * slider_step; + dial[TASK_VMOVER].ob_y = ( int16)floor( slider_pos); + ObjcDraw( OC_FORM, win, TASK_VBACK, 2); + ObjcDraw( OC_FORM, win, TASK_PROCESS_LIST, 1); + } + + graf_mouse( ARROW, NULL); + + ObjcChange( mode, win, obj, ~SELECTED, TRUE); +} + + + + +static void CDECL draw_cpu_average( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = xy[1] = 0; + xy[2] = 300; + xy[3] = 100; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 300; + xy[7] = xy[5] + 100; + + vrt_cpyfm( win->graf->handle, MD_REPLACE, xy, &cpu_average_background, &screen, wanted_color); + + x = pblk->pb_x; + + for( i = 0, ii = 0; i < 101; x += 3) + { + cpu_history_point[ii++] = x; + cpu_history_point[ii++] = pblk->pb_y + cpu_history[i++]; + } + + vsl_color( win->graf->handle, CYAN); + v_pline( win->graf->handle, 101, cpu_history_point); +} + +static void CDECL draw_name_button( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y; + xy[2] = xy[0] + pblk->pb_w - 1; + xy[3] = xy[1] + pblk->pb_h - 1; + + vsf_color( win->graf->handle, LWHITE); + v_bar( win->graf->handle, xy); + + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y + pblk->pb_h - 1; + xy[2] = xy[0] + pblk->pb_w - 1; + xy[3] = xy[1]; + xy[4] = xy[2]; + xy[5] = pblk->pb_y; + + vsl_color( win->graf->handle, BLACK); + v_pline( win->graf->handle, 3, xy); + + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y + pblk->pb_h - 2; + xy[2] = xy[0] + pblk->pb_w - 2; + xy[3] = xy[1]; + xy[4] = xy[2]; + xy[5] = pblk->pb_y; + + vsl_color( win->graf->handle, LBLACK); + v_pline( win->graf->handle, 3, xy); + + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y + pblk->pb_h - 2; + xy[2] = xy[0]; + xy[3] = pblk->pb_y; + xy[4] = xy[0] + pblk->pb_w - 2; + xy[5] = pblk->pb_y; + + vsl_color( win->graf->handle, WHITE); + v_pline( win->graf->handle, 3, xy); + + draw_text( win->graf->handle, pblk->pb_x + 5, pblk->pb_y + 3, BLACK, "Process name"); + +} + + +static void CDECL draw_cpu_button( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y; + xy[2] = xy[0] + pblk->pb_w - 1; + xy[3] = xy[1] + pblk->pb_h - 1; + + vsf_color( win->graf->handle, LWHITE); + v_bar( win->graf->handle, xy); + + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y + pblk->pb_h - 1; + xy[2] = xy[0] + pblk->pb_w - 1; + xy[3] = xy[1]; + xy[4] = xy[2]; + xy[5] = pblk->pb_y; + + vsl_color( win->graf->handle, BLACK); + v_pline( win->graf->handle, 3, xy); + + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y + pblk->pb_h - 2; + xy[2] = xy[0] + pblk->pb_w - 2; + xy[3] = xy[1]; + xy[4] = xy[2]; + xy[5] = pblk->pb_y; + + vsl_color( win->graf->handle, LBLACK); + v_pline( win->graf->handle, 3, xy); + + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y + pblk->pb_h - 2; + xy[2] = xy[0]; + xy[3] = pblk->pb_y; + xy[4] = xy[0] + pblk->pb_w - 2; + xy[5] = pblk->pb_y; + + vsl_color( win->graf->handle, WHITE); + v_pline( win->graf->handle, 3, xy); + + draw_text( win->graf->handle, pblk->pb_x + 25, pblk->pb_y + 3, BLACK, "CPU"); + +} + +static void CDECL draw_ram_button( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y; + xy[2] = xy[0] + pblk->pb_w - 1; + xy[3] = xy[1] + pblk->pb_h - 1; + + vsf_color( win->graf->handle, LWHITE); + v_bar( win->graf->handle, xy); + + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y + pblk->pb_h - 1; + xy[2] = xy[0] + pblk->pb_w - 1; + xy[3] = xy[1]; +// xy[4] = xy[2]; +// xy[5] = pblk->pb_y; + + vsl_color( win->graf->handle, BLACK); + v_pline( win->graf->handle, 2, xy); + + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y + pblk->pb_h - 2; + xy[2] = xy[0] + pblk->pb_w - 1; + xy[3] = xy[1]; + xy[4] = xy[2]; + xy[5] = pblk->pb_y; + + vsl_color( win->graf->handle, LBLACK); + v_pline( win->graf->handle, 3, xy); + + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y + pblk->pb_h - 2; + xy[2] = xy[0]; + xy[3] = pblk->pb_y; + xy[4] = xy[0] + pblk->pb_w - 2; + xy[5] = pblk->pb_y; + + vsl_color( win->graf->handle, WHITE); + v_pline( win->graf->handle, 3, xy); + + draw_text( win->graf->handle, pblk->pb_x + 33, pblk->pb_y + 3, BLACK, "Memory Usage"); + +} + + +static void CDECL taskman_dialog_close( WINDOW *win, int16 buff[8]) +{ + ApplWrite( _AESapid, WM_DESTROY, win->handle, 0, 0, 0, 0); + +// zdebug( "close"); +} + +static void CDECL taskman_dialog_free_ressource( WINDOW *win, int16 buff[8]) +{ + while( process_root != NULL) + process_delete( process_root->pid); + + if( process_list_buffer.fd_addr) + { + gfree( process_list_buffer.fd_addr); + process_list_buffer.fd_addr = NULL; + } + +// zdebug( "destroy"); + + taskman_win = NULL; + thumb = NULL; +} + +void taskman_timer( void) +{ + int old_process_nbr; + + + switch( FormThbGet( thumb, 0)) + { + case TASK_SYSTEM: + if( old_stram != stram) + { + old_stram = stram; + sprintf( ObjcString( dial, TASK_ST_FREE, NULL), "%ld", stram); + ObjcDraw( OC_FORM, taskman_win, TASK_ST_FREE, 1); + } + + if( old_ttram != ttram) + { + old_ttram = ttram; + sprintf( ObjcString( dial, TASK_TT_FREE, NULL), "%ld", ttram); + ObjcDraw( OC_FORM, taskman_win, TASK_TT_FREE, 1); + } + + ObjcDraw( OC_FORM, taskman_win, TASK_CPU_AVERAGE, 1); + + + Suptime( &uptime, loadaverage); + updays = uptime / 86400; + tmpdays = updays * 86400; + uphours = (uptime - tmpdays) / 3600; + tmphours = uphours * 3600; + upmins = (uptime - tmpdays - tmphours) / 60; + upsecs = (uptime - tmpdays - tmphours - ( upmins * 60)); + + sprintf( ObjcString( dial, TASK_UPTIME, NULL), "%ld days %ld hours %ld minutes %ld secs", updays, uphours, upmins, upsecs); + ObjcDraw( OC_FORM, taskman_win, TASK_UPTIME, 1); + break; + + + case TASK_PROCESS: + old_process_nbr = process_nbr; + scan_process(); + + if( old_process_nbr != process_nbr) + { + ypos = 0; + ypos_max = process_nbr; + calc_process_slider( taskman_win); + ObjcDraw( OC_FORM, taskman_win, TASK_PROCESS_LIST, 1); + ObjcDraw( OC_FORM, taskman_win, TASK_VBACK, 2); + } + else + ObjcDraw( OC_FORM, taskman_win, TASK_PROCESS_LIST, 1); + + if( dial[TASK_LED1].ob_state & SELECTED) + { + ObjcChange( OC_FORM, taskman_win, TASK_LED1, NORMAL, 1); + ObjcChange( OC_FORM, taskman_win, TASK_LED2, SELECTED, 1); + } + else if( dial[TASK_LED2].ob_state & SELECTED) + { + ObjcChange( OC_FORM, taskman_win, TASK_LED2, NORMAL, 1); + ObjcChange( OC_FORM, taskman_win, TASK_LED3, SELECTED, 1); + } + else + { + ObjcChange( OC_FORM, taskman_win, TASK_LED1, SELECTED, 1); + ObjcChange( OC_FORM, taskman_win, TASK_LED3, NORMAL, 1); + } + break; + + default: + break; + } +} + + +void taskman_dialog( void) +{ + BITBLK *image; + + int frms[] = { TASK_PANEL1, TASK_PANEL2, TASK_PANEL3}; + int buts[] = { TASK_PROCESS, TASK_SYSTEM, TASK_NETWORK}; + + if( taskman_win != NULL) + { + return; + } + + process_selected = NULL; + + dial = get_tree( TASK); + + sprintf( ObjcString( dial, TASK_ST_TOTAL, NULL), "%ld", total_stram); + sprintf( ObjcString( dial, TASK_TT_TOTAL, NULL), "%ld", total_ttram); + sprintf( ObjcString( dial, TASK_ST_FREE, NULL), "%ld", stram); + sprintf( ObjcString( dial, TASK_TT_FREE, NULL), "%ld", ttram); + + old_stram = stram; + old_ttram = ttram; + + Suptime( &uptime, loadaverage); + updays = uptime / 86400; + tmpdays = updays * 86400; + uphours = (uptime - tmpdays) / 3600; + tmphours = uphours * 3600; + upmins = (uptime - tmpdays - tmphours) / 60; + upsecs = (uptime - tmpdays - tmphours - ( upmins * 60)); + sprintf( ObjcString( dial, TASK_UPTIME, NULL), "%ld days %ld hours %ld minutes %ld secs", updays, uphours, upmins, upsecs); + + dial[TASK_NETWORK].ob_flags |= HIDETREE; + dial[TASK_KILL].ob_state |= DISABLED; + + if( ( taskman_win = FormCreate( dial, NAME|MOVER|CLOSER, NULL, get_string( S_TASKMAN), NULL, TRUE, FALSE)) == NULL) + return; + + dial = FORM( taskman_win); + + scan_process(); + + { + ypos = 0; + ypos_max = process_nbr; + taskman_win->h_u = 13; + + calc_process_slider( taskman_win); + + ObjcAttachFormFunc( taskman_win, TASK_UP, slid_up, NULL); + ObjcAttachFormFunc( taskman_win, TASK_DOWN, slid_down, NULL); + ObjcAttachFormFunc( taskman_win, TASK_VMOVER, slid_vmover, NULL); + } + + thumb = FormThumb( taskman_win, frms, buts, 3); + + + process_list_buffer_lenght = init_mfdb( &process_list_buffer, dial[TASK_PROCESS_LIST].ob_width, dial[TASK_PROCESS_LIST].ob_height, 1); + + rsrc_gaddr( R_IMAGEDATA, CPU_AVERAGE, &image); + + cpu_average_background.fd_w = 304; + cpu_average_background.fd_h = 101; + cpu_average_background.fd_wdwidth = ( 304 >> 4) + (( 304 % 16) != 0); + cpu_average_background.fd_stand = 0; + cpu_average_background.fd_nplanes = 1; + cpu_average_background.fd_r1 = 0; + cpu_average_background.fd_r2 = 0; + cpu_average_background.fd_r3 = 0; + cpu_average_background.fd_addr = (void*)image->bi_pdata; + + + RsrcUserDraw( OC_FORM, taskman_win, TASK_CPU_AVERAGE, draw_cpu_average, NULL); + RsrcUserDraw( OC_FORM, taskman_win, TASK_PROCESS_LIST, draw_process_list, NULL); + RsrcUserDraw( OC_FORM, taskman_win, TASK_C_NAME, draw_name_button, NULL); + RsrcUserDraw( OC_FORM, taskman_win, TASK_C_CPU, draw_cpu_button, NULL); + RsrcUserDraw( OC_FORM, taskman_win, TASK_C_RAM, draw_ram_button, NULL); + + EvntAttach( taskman_win, WM_CLOSED, taskman_dialog_close); + EvntAdd( taskman_win, WM_XBUTTON, taskman_win_mouse_event, EV_BOT); + EvntAdd( taskman_win, WM_DESTROY, taskman_dialog_free_ressource, EV_TOP); + + ObjcAttachFormFunc( taskman_win, TASK_KILL, taskman_dialog_kill, NULL); +} + diff --git a/sources/z-tools/trunk/ztask/taskman.h b/sources/z-tools/trunk/ztask/taskman.h new file mode 100644 index 0000000..369ae62 --- /dev/null +++ b/sources/z-tools/trunk/ztask/taskman.h @@ -0,0 +1,7 @@ +extern void taskman_dialog( void); +extern void taskman_timer( void); +extern WINDOW *taskman_win; + + + + diff --git a/sources/z-tools/trunk/ztask/types2b.h b/sources/z-tools/trunk/ztask/types2b.h new file mode 100644 index 0000000..9eade7b --- /dev/null +++ b/sources/z-tools/trunk/ztask/types2b.h @@ -0,0 +1,43 @@ +#ifndef __2B_UNIVERSAL_TYPES__ +#define __2B_UNIVERSAL_TYPES__ + +typedef signed char int8; +typedef unsigned char uint8; +typedef signed long int32; +typedef unsigned long uint32; +typedef int32 fix31; + +#ifdef __GNUC__ + typedef signed short int16; + typedef unsigned short uint16; + #define __2B_HAS64_SUPPORT /* Compiler supports 64 Bit Integers */ + typedef signed long long int64; + typedef unsigned long long uint64; +#else /* Compiler doesn't support 64 Bit Integers */ + typedef signed int int16; + typedef unsigned int uint16; + + typedef struct + { + int32 hi; + uint32 lo; + } int64; + + typedef struct + { + int32 hi; + uint32 lo; + } loff_t; + + typedef struct + { + uint32 hi; + uint32 lo; + } uint64; +#endif + + +typedef int32 boolean; + + +#endif /* __2B_UNIVERSAL_TYPES__ */ diff --git a/sources/z-tools/trunk/ztask/win.c b/sources/z-tools/trunk/ztask/win.c new file mode 100644 index 0000000..825b0e0 --- /dev/null +++ b/sources/z-tools/trunk/ztask/win.c @@ -0,0 +1,672 @@ +#include "general.h" +#include "app.h" +#include "cpu.h" +#include "popup.h" +#include "string.h" +#include "taskman.h" + +static clock_t chrono_value, update_time = ( clock_t)( 100L); +int16 cpu_usage = 0; +int32 total_stram = 0; +int32 total_ttram = 0; +uint32 stram = 0; +uint32 ttram = 0; +int16 stram_percent = 0; +int16 ttram_percent = 0; +int16 bar_width = 6; +int16 geek_area_width = 64; +int16 cpu_history[101]; +int16 x_pos, w_pos, y_pos, h_pos, geek_area_x, clock_x, cpu_x, st_x, tt_x; +int16 hcell = 8, dum, y_text_pos, x_space = 5, menu_enabled = FALSE; +char xbios_time[15]; + +WINDOW *app_bar; +OBJECT *icons = NULL; +static void win_mouse_event( WINDOW *win, int16 buff[8]); +static void win_redraw_event( WINDOW *win, int16 buff[8]); + + +static void CDECL timer_function( WINDOW *win, int16 buff[8]) +{ + app_data *tmp; + clock_t current_t; + clock_t relative_t; + time_t curtime; + struct tm *loctime; + int16 old_app_nbr = app_nbr; + static int skip = 0; + + if( popup.win) + { + if( IS_IN( evnt.mx, evnt.my, popup.x_pos, popup.y_pos, popup.w_pos, popup.h_pos + 2)) + { + popup.selected = popup_item_under_mouse(); + + if( popup.selected != popup.old_selected) + { + if( popup.selected >= 0) + draw_page( popup.win, popup.item_pos[popup.selected].x1, popup.item_pos[popup.selected].y1, popup.item_pos[popup.selected].x2, popup.item_pos[popup.selected].y2); + + if( popup.old_selected >= 0) + draw_page( popup.win, popup.item_pos[popup.old_selected].x1, popup.item_pos[popup.old_selected].y1, popup.item_pos[popup.old_selected].x2, popup.item_pos[popup.old_selected].y2); + + popup.old_selected = popup.selected; + } + } + else if( menu_enabled == TRUE) + { + if( !IS_IN( evnt.mx, evnt.my, root->x_pos - 24, root->y_pos, 24, 23)) + popup_delete( popup.win); + } + else if( !IS_IN( evnt.mx, evnt.my, popup.entry->x_pos, popup.entry->y_pos, app_width, 23)) + popup_delete( popup.win); + } + + current_t = clock(); + + relative_t = current_t - chrono_value; + + if( relative_t < update_time) + return; + + chrono_value = current_t; + + cpu_usage = cpu_get_usage(); + + if( skip == 0) + { + memcpy( cpu_history, &cpu_history[1], 200); + cpu_history[100] = 100 - cpu_usage; + + if( show_clock == TRUE) + { + curtime = time( NULL); + loctime = localtime( &curtime); + + if( clock_us == TRUE) + strftime( xbios_time, 12, "%I:%M:%S %p", loctime); + else + strftime( xbios_time, 12, "%H:%M:%S", loctime); + } + + if( show_system_info) + { + get_free_ram( &stram, &ttram); + stram_percent = (int16)(( 100 * stram) / total_stram); + + if( total_ttram != 0) + ttram_percent = (int16)(( 100 * ttram) / total_ttram); + + } + + skip = 1; + + tmp = selected; + + app_data_search(); + + if( old_app_nbr == app_nbr) + { + draw_page( win, geek_area_x + 4, app.y + app.h - 19, geek_area_width - 9, 15); + + if( selected != tmp) + { + if( selected != NULL) + draw_page( win, selected->x_pos, selected->y_pos, app_width, h_pos); + + if( old_selected != NULL) + draw_page( win, old_selected->x_pos, old_selected->y_pos, app_width, h_pos); + } + } + else + { + w_pos = geek_area_width + ( app_nbr * app_width) + 24; + + while( w_pos > app.w) + w_pos -= app_width; + + x_pos = app.x + ( app.w - w_pos); + w_pos -= 1; + + WindSet( win, WF_WORKXYWH, x_pos, y_pos, w_pos, h_pos); + + // Xaaes bug... with this AES, WindSet( win, WF_CURRXYWH,... doesn't redraw the taskbar. + draw_page( win, x_pos, y_pos, w_pos, h_pos); + } + + if( taskman_win != NULL) + taskman_timer(); + + } + else + { + draw_page( win, geek_area_x + 4, app.y + app.h - 19, geek_area_width - 9, 15); + skip = 0; + } +} + + + +static void CDECL win_mouse_event( WINDOW *win, int16 buff[8]) +{ + app_data *scan = root, *tmp = NULL; + +// evnt.nb_click = 0; + + while( scan != NULL) + { + if( scan->x_pos == -1) + continue; + + if( IS_IN( evnt.mx, evnt.my, scan->x_pos, scan->y_pos, app_width, h_pos)) + { + tmp = scan; + break; + } + + scan = scan->next; + } + + + if( tmp != NULL) + { + int16 ap_cout; + + old_selected = selected; + selected = tmp; + + if( old_selected != selected) + { + mt_appl_control( selected->id, APC_INFO, &ap_cout, app.aes_global); + + if( ap_cout & APCI_HIDDEN) + mt_appl_control( selected->id, APC_SHOW, &ap_cout, app.aes_global); + + mt_appl_control( selected->id, APC_TOP, &ap_cout, app.aes_global); + + draw_page( win, selected->x_pos, selected->y_pos, app_width, h_pos); + + if( old_selected != NULL) + draw_page( win, old_selected->x_pos, old_selected->y_pos, app_width, h_pos); + } + } + + if( popup.win) + return; + + /* if we are on the menu icon or on an application item, we open a popup */ + if(( tmp != NULL) && ( evnt.mbut == 2)) + { + char dummy[MAXNAMLEN]; + uint32 dummy_var; + + popup.item_nbr = 0; + + get_info_by_pid((int)tmp->pid, dummy, popup.item_name[popup.item_nbr], &dummy_var); + + popup.selectable[popup.item_nbr] = FALSE; + popup.function[popup.item_nbr] = 0; + popup.icon[popup.item_nbr++] = ICONS_MEM; + + popup.selectable[popup.item_nbr] = FALSE; + popup.function[popup.item_nbr] = 0; + popup.item_name[popup.item_nbr][0] = '\0'; + popup.icon[popup.item_nbr++] = -1; + +/* popup.selectable[popup.item_nbr] = TRUE; + popup.function[popup.item_nbr] = F_HIDE; + strcpy( popup.item_name[popup.item_nbr], get_string( S_HIDE)); + popup.icon[popup.item_nbr++] = -1; +*/ + popup.selectable[popup.item_nbr] = TRUE; + popup.function[popup.item_nbr] = F_QUIT; + strcpy( popup.item_name[popup.item_nbr], get_string( S_QUIT)); + popup.icon[popup.item_nbr++] = -1; + + popup.selectable[popup.item_nbr] = TRUE; + popup.function[popup.item_nbr] = F_KILL; + strcpy( popup.item_name[popup.item_nbr], get_string( S_KILL)); + popup.icon[popup.item_nbr++] = -1; + + open_popup( tmp); + } + else if(( tmp == NULL) && ( evnt.mx < root->x_pos) && ( evnt.mbut == 1)) + { + int16 x, y; + + popup.item_nbr = 0; + + popup.selectable[popup.item_nbr] = TRUE; + popup.function[popup.item_nbr] = F_TASKMANAGER; + strcpy( popup.item_name[popup.item_nbr], get_string( S_TASKMAN)); + popup.icon[popup.item_nbr++] = ICONS_TASK; + + popup.selectable[popup.item_nbr] = TRUE; + popup.function[popup.item_nbr] = F_PREFERENCES; + strcpy( popup.item_name[popup.item_nbr], get_string( S_PREFS)); + popup.icon[popup.item_nbr++] = ICONS_CONFIGURE; + + popup.selectable[popup.item_nbr] = FALSE; + popup.function[popup.item_nbr] = 0; + popup.item_name[popup.item_nbr][0] = '\0'; + popup.icon[popup.item_nbr++] = -1; + + popup.selectable[popup.item_nbr] = TRUE; + popup.function[popup.item_nbr] = F_QUIT_ZBAR; + strcpy( popup.item_name[popup.item_nbr], get_string( S_QUIT)); + popup.icon[popup.item_nbr++] = ICONS_ARROW; + + popup.selectable[popup.item_nbr] = TRUE; + popup.function[popup.item_nbr] = F_SHUTDOWN; + strcpy( popup.item_name[popup.item_nbr], get_string( S_SHUTDOWN)); + popup.icon[popup.item_nbr++] = ICONS_SHUTDOWN; + + menu_enabled = TRUE; + WindGet( win, WF_WORKXYWH, &x, &y, &dum, &dum); + draw_page( win, x, y, 25, 24); + + open_popup( tmp); + } +} + + +static void CDECL win_redraw_event( WINDOW *win, int16 buff[8]) +{ + int16 x_text_pos, xw, pxy[10], background, top_line, lower_line, title_shadow, title_color; + app_data *scan = root; + + xw = x_pos; + + geek_area_x = xw + w_pos - geek_area_width; + + /* we draw the menu area */ + pxy[0] = xw; + pxy[1] = y_pos; + pxy[2] = pxy[0] + 23; + pxy[3] = pxy[1] + h_pos - 1; + + if( menu_enabled == TRUE) + { + background = ( int16)button_on_background; + top_line = ( int16)button_on_dark_color; + lower_line = ( int16)button_on_light_color; + title_color = ( int16)button_on_text_color; + title_shadow = ( int16)button_on_text_shadow_color; + } + else + { + background = ( int16)button_off_background; + top_line = ( int16)button_off_light_color; + lower_line = ( int16)button_off_dark_color; + title_color = ( int16)button_off_text_color; + title_shadow = ( int16)button_off_text_shadow_color; + } + + vsf_color( win->graf->handle, background); + v_bar( win->graf->handle, pxy); + + pxy[1] = pxy[3]; + pxy[2] = pxy[0]; + pxy[3] = y_pos; + pxy[4] = pxy[0] + 22; + pxy[5] = y_pos; + + vsl_color( win->graf->handle, top_line); + v_pline( win->graf->handle, 3, pxy); + + pxy[0] = pxy[4] + 1; + pxy[1] = y_pos; + pxy[2] = pxy[0]; + pxy[3] = pxy[1] + h_pos - 1; + pxy[4] = xw; + pxy[5] = pxy[3]; + + vsl_color( win->graf->handle, lower_line); + v_pline( win->graf->handle, 3, pxy); + + icons[ICONS_MENU].ob_x = xw + 4; + icons[ICONS_MENU].ob_y = y_pos + 2; + + mt_objc_draw( icons, ICONS_MENU, 1, win->graf->clip.g_x, win->graf->clip.g_y, win->graf->clip.g_w, win->graf->clip.g_h, app.aes_global); + + xw += 24; + + + /* We draw the application list */ + while( scan != NULL) + { + if(( pxy[0] + app_width - 2) > geek_area_x) + { + scan->x_pos = -1; + scan->y_pos = -1; + } + else + { + scan->x_pos = xw; + scan->y_pos = y_pos; + xw += app_width; + + pxy[0] = scan->x_pos; + pxy[1] = y_pos; + pxy[2] = pxy[0] + app_width - 1; + pxy[3] = pxy[1] + h_pos - 1; + + if( scan == selected) + { + background = ( int16)button_on_background; + top_line = ( int16)button_on_dark_color; + lower_line = ( int16)button_on_light_color; + title_color = ( int16)button_on_text_color; + title_shadow = ( int16)button_on_text_shadow_color; + } + else + { + background = ( int16)button_off_background; + top_line = ( int16)button_off_light_color; + lower_line = ( int16)button_off_dark_color; + title_color = ( int16)button_off_text_color; + title_shadow = ( int16)button_off_text_shadow_color; + } + + vsf_color( win->graf->handle, background); + v_bar( win->graf->handle, pxy); + + pxy[1] = pxy[3]; + pxy[2] = pxy[0]; + pxy[3] = y_pos; + pxy[4] = pxy[0] + app_width - 2; + pxy[5] = y_pos; + + vsl_color( win->graf->handle, top_line); + v_pline( win->graf->handle, 3, pxy); + + pxy[0] = pxy[4] + 1; + pxy[1] = y_pos; + pxy[2] = pxy[0]; + pxy[3] = pxy[1] + h_pos - 1; + pxy[4] = scan->x_pos; + pxy[5] = pxy[3]; + + vsl_color( win->graf->handle, lower_line); + v_pline( win->graf->handle, 3, pxy); + + x_text_pos = scan->x_pos + (( app_width - scan->name_shown_width) >> 1); + + draw_text( win->graf->handle, x_text_pos + 1, y_text_pos + 1, ( int16)title_shadow, scan->name_shown); + draw_text( win->graf->handle, x_text_pos, y_text_pos, ( int16)title_color, scan->name_shown); + + } + + scan = scan->next; + } + + /* draw the "geek" area */ + pxy[0] = xw + 2; + pxy[1] = y_pos + 2; + pxy[2] = pxy[0] + geek_area_width - 6; + pxy[3] = pxy[1] + h_pos - 5; + + vsf_color( win->graf->handle, geek_area_color); + v_bar( win->graf->handle, pxy); + + pxy[0] = xw; + pxy[1] = y_pos; + pxy[2] = pxy[0]; + pxy[3] = pxy[1] + h_pos - 1; + pxy[4] = pxy[2] + geek_area_width - 2; + pxy[5] = pxy[3]; + pxy[6] = pxy[4]; + pxy[7] = pxy[1]; + pxy[8] = pxy[0]; + pxy[9] = pxy[1]; + + vsl_color( win->graf->handle, ( int16)button_off_background); + v_pline( win->graf->handle, 5, pxy); + + pxy[0]++; + pxy[1] = pxy[3] - 1; + pxy[2] = pxy[0]; + pxy[3] = y_pos + 1; + pxy[4]--; + pxy[5] = pxy[3]; + + vsl_color( win->graf->handle, ( int16)geek_area_dark_line); + v_pline( win->graf->handle, 3, pxy); + + pxy[2] = pxy[4]; + pxy[3] = pxy[1]; + pxy[5] = y_pos + 2; + + vsl_color( win->graf->handle, ( int16)geek_area_light_line); + v_pline( win->graf->handle, 3, pxy); + + + /* draw the cpu % in the "geek" area */ + if( show_system_info) + { + /* the CPU usage */ + pxy[0] = cpu_x + geek_area_x; + pxy[1] = y_pos + 3; + pxy[2] = pxy[0] + bar_width - 1; + pxy[3] = pxy[1] + 14; + + vsf_color( win->graf->handle, BLACK); + v_bar( win->graf->handle, pxy); + + pxy[0] = pxy[0] + 1; + pxy[2] = pxy[2] - 1; + pxy[3] = y_pos + 16; + + if( cpu_usage >= 8) + { + if( cpu_usage >= 99) + pxy[1] = y_pos + 4; + else if( cpu_usage >= 91) + pxy[1] = y_pos + 5; + else if( cpu_usage >= 83) + pxy[1] = y_pos + 6; + else if( cpu_usage >= 75) + pxy[1] = y_pos + 7; + else if( cpu_usage >= 66) + pxy[1] = y_pos + 8; + else if( cpu_usage >= 58) + pxy[1] = y_pos + 9; + else if( cpu_usage >= 50) + pxy[1] = y_pos + 10; + else if( cpu_usage >= 41) + pxy[1] = y_pos + 11; + else if( cpu_usage >= 33) + pxy[1] = y_pos + 12; + else if( cpu_usage >= 25) + pxy[1] = y_pos + 13; + else if( cpu_usage >= 16) + pxy[1] = y_pos + 14; + else + pxy[1] = y_pos + 15; + + vsf_color( win->graf->handle, ( int16)cpu_bar_color); + v_bar( win->graf->handle, pxy); + } + + /* the STRAM usage */ + pxy[0] = st_x + geek_area_x; + pxy[1] = y_pos + 3; + pxy[2] = pxy[0] + bar_width - 1; + pxy[3] = pxy[1] + 14; + + vsf_color( win->graf->handle, BLACK); + v_bar( win->graf->handle, pxy); + + + pxy[0] = pxy[0] + 1; + pxy[2] = pxy[2] - 1; + pxy[3] = y_pos + 16; + + if( stram_percent >= 8) + { + if( stram_percent >= 99) + pxy[1] = y_pos + 4; + else if( stram_percent >= 91) + pxy[1] = y_pos + 5; + else if( stram_percent >= 83) + pxy[1] = y_pos + 6; + else if( stram_percent >= 75) + pxy[1] = y_pos + 7; + else if( stram_percent >= 66) + pxy[1] = y_pos + 8; + else if( stram_percent >= 58) + pxy[1] = y_pos + 9; + else if( stram_percent >= 50) + pxy[1] = y_pos + 10; + else if( stram_percent >= 41) + pxy[1] = y_pos + 11; + else if( stram_percent >= 33) + pxy[1] = y_pos + 12; + else if( stram_percent >= 25) + pxy[1] = y_pos + 13; + else if( stram_percent >= 16) + pxy[1] = y_pos + 14; + else + pxy[1] = y_pos + 15; + + vsf_color( win->graf->handle, ( int16)st_bar_color); + v_bar( win->graf->handle, pxy); + } + + /* the TTRAM usage */ + + if( total_ttram != 0) + { + pxy[0] = tt_x + geek_area_x; + pxy[1] = y_pos + 3; + pxy[2] = pxy[0] + bar_width - 1; + pxy[3] = pxy[1] + 14; + + vsf_color( win->graf->handle, BLACK); + v_bar( win->graf->handle, pxy); + + + pxy[0] = pxy[0] + 1; + pxy[2] = pxy[2] - 1; + pxy[3] = y_pos + 16; + + if( ttram_percent >= 8) + { + if( ttram_percent >= 99) + pxy[1] = y_pos + 4; + else if( ttram_percent >= 91) + pxy[1] = y_pos + 5; + else if( ttram_percent >= 83) + pxy[1] = y_pos + 6; + else if( ttram_percent >= 75) + pxy[1] = y_pos + 7; + else if( ttram_percent >= 66) + pxy[1] = y_pos + 8; + else if( ttram_percent >= 58) + pxy[1] = y_pos + 9; + else if( ttram_percent >= 50) + pxy[1] = y_pos + 10; + else if( ttram_percent >= 41) + pxy[1] = y_pos + 11; + else if( ttram_percent >= 33) + pxy[1] = y_pos + 12; + else if( ttram_percent >= 25) + pxy[1] = y_pos + 13; + else if( ttram_percent >= 16) + pxy[1] = y_pos + 14; + else + pxy[1] = y_pos + 15; + + vsf_color( win->graf->handle, ( int16)tt_bar_color); + v_bar( win->graf->handle, pxy); + } + } + } + + + /* draw the clock in the "geek" area */ + if( show_clock == TRUE) + { + draw_text( win->graf->handle, clock_x + geek_area_x, y_text_pos, (int16)geek_area_text_color, xbios_time); + } +} + + +void set_component_position( void) +{ + int16 text_width, x = x_space + 2; + + if( show_system_info) + { + cpu_x = x; + x += ( bar_width + 2); + + if( total_ttram != 0) + { + st_x = x; + x += ( bar_width + 2); + + tt_x = x; + x += ( bar_width + x_space); + } + else + { + st_x = x; + x += ( bar_width + x_space); + + tt_x = x; + } + } + + if( show_clock == TRUE) + { + clock_x = x; + + if( clock_us == FALSE) + text_width = get_text_width( "00:00:00"); + else + text_width = get_text_width( "00:00:00 PM"); + + x += ( text_width + x_space); + } + + geek_area_width = x + 1; + y_text_pos = app.y + app.h - 14; +} + + +void main_win( void) +{ + chrono_value = clock(); + + rsrc_gaddr( 0, ICONS, &icons); + popup.win = NULL; + + app_bar = WindCreate( 0, app.x, app.y, app.w, app.h); + + EvntAttach( app_bar, WM_REDRAW, win_redraw_event); + EvntAttach( app_bar, WM_XBUTTON, win_mouse_event); + + set_component_position(); + app_data_search(); + + w_pos = geek_area_width + ( app_nbr * app_width) + 24; + + while( w_pos > app.w) + w_pos -= app_width; + + x_pos = app.x + ( app.w - w_pos); + w_pos -= 1; + y_pos = app.y + app.h - 21; + + + WindCalc( WC_BORDER, app_bar, x_pos, y_pos, w_pos, 22, &x_pos, &y_pos, &w_pos, &h_pos); + + WindSet( app_bar, WF_BEVENT, BEVENT_WORK, 0, 0, 0); + WindOpen( app_bar, x_pos, y_pos, w_pos, h_pos); + EvntAttach( app_bar, WM_XTIMER, timer_function); + WindGet( app_bar, WF_WORKXYWH, &x_pos, &y_pos, &w_pos, &h_pos); + + h_pos = 21; +} + diff --git a/sources/z-tools/trunk/ztask/win.h b/sources/z-tools/trunk/ztask/win.h new file mode 100644 index 0000000..0bc6c5b --- /dev/null +++ b/sources/z-tools/trunk/ztask/win.h @@ -0,0 +1,20 @@ +extern int16 cpu_usage; +extern int32 total_stram; +extern int32 total_ttram; +extern uint32 stram; +extern uint32 ttram; +extern int16 bar_width; +extern int16 geek_area_width; +extern int16 geek_area_border_width; +extern int16 hcell, x_space; +extern int16 x_pos, w_pos, y_pos, h_pos; + +extern WINDOW *app_bar; +extern OBJECT *icons; +extern int16 x_space, menu_enabled; +extern int16 cpu_history[100]; + +extern void set_component_position( void); + + + diff --git a/sources/z-tools/trunk/ztask/ztask.hrd b/sources/z-tools/trunk/ztask/ztask.hrd new file mode 100644 index 0000000..a3e87b5 Binary files /dev/null and b/sources/z-tools/trunk/ztask/ztask.hrd differ diff --git a/sources/z-tools/trunk/ztask/ztask.rsc b/sources/z-tools/trunk/ztask/ztask.rsc new file mode 100644 index 0000000..74b370c Binary files /dev/null and b/sources/z-tools/trunk/ztask/ztask.rsc differ diff --git a/sources/z-tools/trunk/ztask/ztask.rsh b/sources/z-tools/trunk/ztask/ztask.rsh new file mode 100644 index 0000000..10149e0 --- /dev/null +++ b/sources/z-tools/trunk/ztask/ztask.rsh @@ -0,0 +1,102 @@ + /* Resource C-Header-File v1.95 fr ResourceMaster ab v2.06 by ARDISOFT */ + +#define ICONS 0 /* form/dial */ +#define ICONS_CPU 3 /* CICON in tree ICONS */ +#define ICONS_MEM 4 /* CICON in tree ICONS */ +#define ICONS_ARROW 5 /* CICON in tree ICONS */ +#define ICONS_NET 6 /* CICON in tree ICONS */ +#define ICONS_LED 7 /* CICON in tree ICONS */ +#define ICONS_MENU 8 /* CICON in tree ICONS */ +#define ICONS_SHUTDOWN 9 /* CICON in tree ICONS */ +#define ICONS_CONFIGURE 1 /* CICON in tree ICONS */ +#define ICONS_TASK 2 /* CICON in tree ICONS */ + +#define SHUTDOWN_DIAL 1 /* form/dial */ +#define SHUTDOWN_DIAL_OK 1 /* BUTTON in tree SHUTDOWN_DIAL */ +#define SHUTDOWN_DIAL_WARN 3 /* BUTTON in tree SHUTDOWN_DIAL */ +#define SHUTDOWN_DIAL_COLD 4 /* BUTTON in tree SHUTDOWN_DIAL */ +#define SHUTDOWN_DIAL_HALT 5 /* BUTTON in tree SHUTDOWN_DIAL */ +#define SHUTDOWN_DIAL_CANCEL 6 /* BUTTON in tree SHUTDOWN_DIAL */ + +#define TASK 2 /* form/dial */ +#define TASK_PANEL3 1 /* BUTTON in tree TASK */ +#define TASK_PANEL2 3 /* BUTTON in tree TASK */ +#define TASK_CPU_AVERAGE 5 /* BOX in tree TASK */ +#define TASK_CPU 6 /* CICON in tree TASK */ +#define TASK_ST_TOTAL 9 /* TEXT in tree TASK */ +#define TASK_TT_TOTAL 11 /* TEXT in tree TASK */ +#define TASK_ST_FREE 13 /* TEXT in tree TASK */ +#define TASK_TT_FREE 15 /* TEXT in tree TASK */ +#define TASK_UPTIME 17 /* BOXTEXT in tree TASK */ +#define TASK_MEM 18 /* CICON in tree TASK */ +#define TASK_SHUTDOWN 19 /* CICON in tree TASK */ +#define TASK_PANEL1 20 /* BUTTON in tree TASK */ +#define TASK_BOX_00 21 /* BOX in tree TASK */ +#define TASK_UP 22 /* CICON in tree TASK */ +#define TASK_DOWN 23 /* CICON in tree TASK */ +#define TASK_VBACK 24 /* BOX in tree TASK */ +#define TASK_VMOVER 25 /* BOX in tree TASK */ +#define TASK_KILL 26 /* BUTTON in tree TASK */ +#define TASK_PROCESS_LIST 28 /* BOX in tree TASK */ +#define TASK_C_NAME 32 /* BOX in tree TASK */ +#define TASK_C_CPU 33 /* BOX in tree TASK */ +#define TASK_C_RAM 34 /* BOX in tree TASK */ +#define TASK_LED1 35 /* CICON in tree TASK */ +#define TASK_LED2 36 /* CICON in tree TASK */ +#define TASK_LED3 37 /* CICON in tree TASK */ +#define TASK_PROCESS 29 /* BUTTON in tree TASK */ +#define TASK_SYSTEM 30 /* BUTTON in tree TASK */ +#define TASK_NETWORK 31 /* BUTTON in tree TASK */ + +#define QUIT 3 /* form/dial */ +#define QUIT_NO 4 /* BUTTON in tree QUIT */ +#define QUIT_YES 5 /* BUTTON in tree QUIT */ + +#define PREFS 4 /* form/dial */ +#define PREFS_PANEL2 1 /* BUTTON in tree PREFS */ +#define PREFS_SYSTEM_INFO 2 /* BUTTON in tree PREFS */ +#define PREFS_SHOW_ACC 3 /* BUTTON in tree PREFS */ +#define PREFS_SHOW_US_CLOCK 10 /* BUTTON in tree PREFS */ +#define PREFS_SHOW_CLOCK 11 /* BUTTON in tree PREFS */ +#define PREFS_PANEL1 12 /* BUTTON in tree PREFS */ +#define PREFS_PREVIEW 14 /* BOX in tree PREFS */ +#define PREFS_OFF_BACK 17 /* BOX in tree PREFS */ +#define PREFS_OFF_LINE2 19 /* BOX in tree PREFS */ +#define PREFS_OFF_LINE1 20 /* BOX in tree PREFS */ +#define PREFS_OFF_TEXT1 22 /* BOX in tree PREFS */ +#define PREFS_OFF_TEXT2 23 /* BOX in tree PREFS */ +#define PREFS_ON_BACK 26 /* BOX in tree PREFS */ +#define PREFS_ON_LINE2 28 /* BOX in tree PREFS */ +#define PREFS_ON_LINE1 29 /* BOX in tree PREFS */ +#define PREFS_ON_TEXT1 31 /* BOX in tree PREFS */ +#define PREFS_ON_TEXT2 32 /* BOX in tree PREFS */ +#define PREFS_GEEK_BACK 35 /* BOX in tree PREFS */ +#define PREFS_GEEK_LINE2 37 /* BOX in tree PREFS */ +#define PREFS_GEEK_LINE1 38 /* BOX in tree PREFS */ +#define PREFS_GEEK_RAM1 40 /* BOX in tree PREFS */ +#define PREFS_GEEK_CPU 41 /* BOX in tree PREFS */ +#define PREFS_GEEK_RAM2 43 /* BOX in tree PREFS */ +#define PREFS_GEEK_TEXT 50 /* BOX in tree PREFS */ +#define PREFS_COLOR 44 /* BUTTON in tree PREFS */ +#define PREFS_MISC 45 /* BUTTON in tree PREFS */ +#define PREFS_OK 46 /* BUTTON in tree PREFS */ +#define PREFS_CANCEL 47 /* BUTTON in tree PREFS */ +#define PREFS_DEFAULT 48 /* BUTTON in tree PREFS */ + +#define S_SHUTDOWN 0 /* Free string */ + +#define S_PREFS 1 /* Free string */ + +#define S_TASKMAN 2 /* Free string */ + +#define S_KILL 3 /* Free string */ + +#define S_QUIT 4 /* Free string */ + +#define S_HIDE 5 /* Free string */ + +#define S_SCREENSHOT 6 /* Free string */ + +#define F_SHOW 7 /* Free string */ + +#define CPU_AVERAGE 0 /* Free image */ diff --git a/sources/z-tools/trunk/ztask/ztask.rsm b/sources/z-tools/trunk/ztask/ztask.rsm new file mode 100644 index 0000000..3968d79 --- /dev/null +++ b/sources/z-tools/trunk/ztask/ztask.rsm @@ -0,0 +1,95 @@ +ResourceMaster v3.5 +#C 5@8@1@0@ +#N 99@32@AZAaza___ _@AZAaza090___ _@@_@ +#FoHRD@rsm2out@HRD@hrd@@@[HRD-File@0@ +#FoC-Header@rsm2out@C-Header@rsh@@@[C-Header@0@ +#R 0@0@3@1@3@1@ +#M 2001011@0@7728@580@ +#T 0@2@ICONS@@10@@ +#O 3@33@CPU@@ +#O 4@33@MEM@@ +#O 5@33@ARROW@@ +#O 6@33@NET@@ +#O 7@33@LED@@ +#O 8@33@MENU@@ +#O 9@33@SHUTDOWN@@ +#O 1@33@CONFIGURE@@ +#O 2@33@TASK@@ +#T 1@2@SHUTDOWN_DIAL@@7@@ +#O 1@26@OK@@ +#O 3@26@WARN@@ +#O 4@26@COLD@@ +#O 5@26@HALT@@ +#O 6@26@CANCEL@@ +#T 2@2@TASK@@38@@ +#O 1@26@PANEL3@@ +#O 3@26@PANEL2@@ +#O 5@20@CPU_AVERAGE@@ +#O 6@33@CPU@@ +#O 9@21@ST_TOTAL@@ +#O 11@21@TT_TOTAL@@ +#O 13@21@ST_FREE@@ +#O 15@21@TT_FREE@@ +#O 17@22@UPTIME@@ +#O 18@33@MEM@@ +#O 19@33@SHUTDOWN@@ +#O 20@26@PANEL1@@ +#O 21@20@BOX_00@@ +#O 22@33@UP@@ +#O 23@33@DOWN@@ +#O 24@20@VBACK@@ +#O 25@20@VMOVER@@ +#O 26@26@KILL@@ +#O 28@20@PROCESS_LIST@@ +#O 32@20@C_NAME@@ +#O 33@20@C_CPU@@ +#O 34@20@C_RAM@@ +#O 35@33@LED1@@ +#O 36@33@LED2@@ +#O 37@33@LED3@@ +#O 29@26@PROCESS@@ +#O 30@26@SYSTEM@@ +#O 31@26@NETWORK@@ +#T 3@2@QUIT@@6@@ +#O 4@26@NO@@ +#O 5@26@YES@@ +#T 4@2@PREFS@@51@@ +#O 1@26@PANEL2@@ +#O 2@26@SYSTEM_INFO@@ +#O 3@26@SHOW_ACC@@ +#O 10@26@SHOW_US_CLOCK@@ +#O 11@26@SHOW_CLOCK@@ +#O 12@26@PANEL1@@ +#O 14@20@PREVIEW@@ +#O 17@20@OFF_BACK@@ +#O 19@20@OFF_LINE2@@ +#O 20@20@OFF_LINE1@@ +#O 22@20@OFF_TEXT1@@ +#O 23@20@OFF_TEXT2@@ +#O 26@20@ON_BACK@@ +#O 28@20@ON_LINE2@@ +#O 29@20@ON_LINE1@@ +#O 31@20@ON_TEXT1@@ +#O 32@20@ON_TEXT2@@ +#O 35@20@GEEK_BACK@@ +#O 37@20@GEEK_LINE2@@ +#O 38@20@GEEK_LINE1@@ +#O 40@20@GEEK_RAM1@@ +#O 41@20@GEEK_CPU@@ +#O 43@20@GEEK_RAM2@@ +#O 50@20@GEEK_TEXT@@ +#O 44@26@COLOR@@ +#O 45@26@MISC@@ +#O 46@26@OK@@ +#O 47@26@CANCEL@@ +#O 48@26@DEFAULT@@ +#S 0@5@S_SHUTDOWN@@ +#S 1@5@S_PREFS@@ +#S 2@5@S_TASKMAN@@ +#S 3@5@S_KILL@@ +#S 4@5@S_QUIT@@ +#S 5@5@S_HIDE@@ +#S 6@5@S_SCREENSHOT@@ +#S 7@5@F_SHOW@@ +#I 0@6@CPU_AVERAGE@@ +#c 8983@ diff --git a/sources/z-tools/trunk/zview/Makefile b/sources/z-tools/trunk/zview/Makefile new file mode 100644 index 0000000..3fb8183 --- /dev/null +++ b/sources/z-tools/trunk/zview/Makefile @@ -0,0 +1,80 @@ +CC = m68k-atari-mint-gcc +CXX = m68k-atari-mint-g++ +AR = m68k-atari-mint-ar +RANLIB = m68k-atari-mint-ranlib +STACK = m68k-atari-mint-stack +STRIP = m68k-atari-mint-strip -s +FLAGS = m68k-atari-mint-flags -r +DEBUG = # -DDEBUG +COMPRESS = upx -9 +STACKSIZE = 512k +OPTIMISATION = -g -O2 -fomit-frame-pointer +#CPU = -mcpu=5475 +CPU = -m68020-60 +DEBUG_LIB = # -lwout +XPDF_LIBS = -Lpdf/fofi -lfofi -Lpdf/goo -lGoo -Lpdf/splash -lsplash +XPDF_INCS = -Ipdf -Ipdf/goo -Ipdf/splash +LIB = -lfreetype $(DEBUG_LIB) -lwindom1 -lldgclient -lgem -lz +CFLAGS = $(DEBUG) $(CPU) $(OPTIMISATION) $(XPDF_INCS) -Wall -Wshadow -Wno-pointer-sign +CXXFLAGS = $(CFLAGS) + +FILE_OBJ = file/sort.o file/file.o file/delete.o file/rename.o file/count.o +EDIT_OBJ = zedit/char.o zedit/edit.o zedit/zedit.o +VDI_OBJ = zvdi/p2c.o zvdi/color.o zvdi/dither.o zvdi/raster.o zvdi/raster_resize.o zvdi/pixel.o zvdi/vdi.o +CATALOG_OBJ = catalog/catalog_slider.o catalog/catalog_size.o catalog/catalog_other_event.o \ + catalog/catalog_keyb.o catalog/catalog_mouse.o catalog/catalog_iconify.o \ + catalog/catalog_icons.o catalog/catalog_entry.o catalog/catalog_mini_entry.o \ + catalog/catalog_popup.o catalog/catalog.o +PDF_OBJ = pdf/xpdf/Annot.o pdf/xpdf/Array.o pdf/xpdf/BuiltinFont.o pdf/xpdf/BuiltinFontTables.o \ + pdf/xpdf/Catalog.o pdf/xpdf/CharCodeToUnicode.o pdf/xpdf/CMap.o pdf/xpdf/Decrypt.o pdf/xpdf/Dict.o pdf/xpdf/Error.o \ + pdf/xpdf/FontEncodingTables.o pdf/xpdf/Function.o pdf/xpdf/Gfx.o pdf/xpdf/GfxFont.o pdf/xpdf/GfxState.o \ + pdf/xpdf/GlobalParams.o pdf/xpdf/JArithmeticDecoder.o pdf/xpdf/JBIG2Stream.o pdf/xpdf/JPXStream.o \ + pdf/xpdf/Lexer.o pdf/xpdf/Link.o pdf/xpdf/NameToCharCode.o pdf/xpdf/Object.o pdf/xpdf/Outline.o pdf/xpdf/OutputDev.o \ + pdf/xpdf/Page.o pdf/xpdf/Parser.o pdf/xpdf/SecurityHandler.o pdf/xpdf/PDFDoc.o pdf/xpdf/PDFDocEncoding.o pdf/xpdf/PSTokenizer.o \ + pdf/xpdf/SplashOutputDev.o pdf/xpdf/Stream.o pdf/xpdf/TextOutputDev.o pdf/xpdf/UnicodeMap.o \ + pdf/xpdf/UnicodeTypeTable.o pdf/xpdf/XRef.o pdf/pdflib.o pdf/xpdf/OptionalContent.o + +OBJ = $(PDF_OBJ) $(CATALOG_OBJ) $(FILE_OBJ) $(EDIT_OBJ) $(VDI_OBJ) \ + custom_font.o infobox.o pref_dialog.o zaes.o wintimer.o av_prot.o chrono.o plugins.o mfdb.o \ + txt_data.o pdf_load.o pic_load.o pic_save.o pic_resize.o resample.o save_dialog.o menu.o prefs.o full_scr.o winpdf.o winimg.o \ + debug.o progress.o ztext.o close_modal.o jpg_dialog.o tiff_dialog.o main.o + +PROGRAM = zview.app + + +all: pdf $(PROGRAM) stack strip compress + +$(PROGRAM): $(OBJ) + $(CXX) $(CPU) $(OPTIMISATION) -o $@ $(OBJ) $(XPDF_LIBS) $(LIB) + + +XPDF_VERSION = 3.03 +xpdf-${XPDF_VERSION}.tar.gz: + wget ftp://ftp.foolabs.com/pub/xpdf/xpdf-${XPDF_VERSION}.tar.gz + +pdf: xpdf-${XPDF_VERSION}.tar.gz + tar xzf xpdf-${XPDF_VERSION}.tar.gz && mv xpdf-${XPDF_VERSION} pdf && \ + cd $@ && \ + cat ../howto_build/xpdf-${XPDF_VERSION}-zview.patch | patch -p1 && \ + CFLAGS='-O2 -fomit-frame-pointer $(CPU)' CXXFLAGS='-O2 -fomit-frame-pointer $(CPU)' ./configure --with-freetype2-includes=$$HOME/gnu-tools/m68k-atari-mint/include/freetype2 --without-x --host=m68k-atari-mint && \ + make && \ + cd .. && touch $@ + +strip: + $(STRIP) $(PROGRAM) + +stack: + $(STACK) -S $(STACKSIZE) $(PROGRAM) + +compress: + $(COMPRESS) $(PROGRAM) + $(FLAGS) $(PROGRAM) + +clean_zview: + rm -f *~ *.o *.app zvdi/*.o zedit/*.o file/*.o catalog/*.o + +clean_pdf: + make -C pdf clean && rm pdf/*.o + +clean: + rm -f *~ *.o *.app zvdi/*.o zedit/*.o file/*.o catalog/*.o diff --git a/sources/z-tools/trunk/zview/_dist/doc/copying.gpl b/sources/z-tools/trunk/zview/_dist/doc/copying.gpl new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/sources/z-tools/trunk/zview/_dist/doc/copying.gpl @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/sources/z-tools/trunk/zview/_dist/doc/history.txt b/sources/z-tools/trunk/zview/_dist/doc/history.txt new file mode 100644 index 0000000..8bd0710 --- /dev/null +++ b/sources/z-tools/trunk/zview/_dist/doc/history.txt @@ -0,0 +1,272 @@ +XX November 2011: 1.0 +===================== + +News: +----- + +Bug fixes: +---------- +- Umlauts in PDF catalog +- Crash in IMG plugin +- A hidden memory bug, no visible effects (it seems) but better have it + fixed :) +- Long standing bugs in DSP/NF JPEG decoder fixed (no crash anymore with MP + plus the file is correctly written) +- "Show hidden files" works also with Unix hidden files (prefixed with a dot) +- Regardless of "Show common files" option, folder icons are always shown +- PDF files are treated as images (i.e. always shown) + +Known bugs: +----------- +- NONE! :) + +01 November 2011: BETA8 +======================= + +News: +----- +- First release after 6 years, Zorro seems to be away from the Atari platform :( +- Recompilation of zView + all codecs against latest libraries with the latest + gcc (everything for 68020-60), in theory you should get better compatibility, + less crashes and higher speed :) +- mem.ldg is no longer needed, it has no real meaning for zView +- The application is FireBee-ready, I've done some test builds for ACP guys and + it did run! +- updated nfjpeg.prg and jpegd.prg (maybe it helps, maybe not :)) + +Bugs fixes: +----------- +- Two or three crashes under FreeMiNT, bugs in LDG and Windom libraries + +Know bug: +--------- +- On aranym, with the DSP cookie installed, some stranges problems append + when we write a JPG (and there's a crash win memory protection) + + +25 December 2005: BETA7a +======================== + +- A version of zview compatible with MagiC OS is provided in the "MagiC" +folder. + + +24 December 2005: BETA7 +======================= + +News: +----- +- PDF: + * Huge quality improvement in the PDF font rendering (Atari specific). + * Zoom function added. + * Code upgraded to xpdf 3.01pl1( 2005-dec-01). +- Complete EXIF 2.21 support for JPEG image( now, you can see various + usefull informations like when the picture was taken, if the flash of your + camera was fired or not, the model of your cam, etc...). +- Now, zView can extract the thumbnails embedded inside JPEG images created + with a digital photo-cam. + That means than the thumbnail creation is 20 times faster if the JPEG was + created with a camera. +- News options added: + * Skip drive( it's faster to skip the check of the CD-ROM drive for +example). + * Smooth Thumbnail: now, you can smooth the thumbnails with various +method. + That is very slow and only available on true color or near true color + display but the result are perfect( specialy with the lanczos +computation). + * PDF font antialiasing ON/OFF. + * Fit the PDF to the window. +- Utilisation of an embedded font to have the same look on any computers. +- Animated interlaced Gif and animated Gif with transparency now supported. +- More zoom levels for the pictures( 25, 50, 100, 150 and 200%, previoulsy: + 50, 100, and 200%). +- Some function's shortcuts added to the toolbars. + + +Bugs fixes: +----------- +- Many fixes in the PDF code( PDF rotated, problems with some fonts, etc..). +- Missing horizontal SLIDER computation in the PDF and image window. +- Little memory leak corrected in the multi-timer function. +- A memory block was not freed in the file_rename function. +- Some redraw fixed ( PDF bookmark, etc...). +- Others littles bugs fixed. + + +Know bug: +--------- +- On aranym, with the DSP cookie installed, some stranges problems append + when we write a JPG. + + + +5 August 2005: BETA6 +==================== + +News: +----- +- For compatibility with the PDF code, zview is now under GPL licence. +- Animation support added. + The first format benefitting of that is the animated GIF( SPACE key for + pause/resume). +- PDF read support( You will need a lot of memory to read a PDF). +- Reservoir Dogs Godpaint write and read support. +- Zoom available with the window's toolbar or the '+' and '-' keys. +- Documentation and desktop icon added by Sacha Uhlig, many thanks to him ! +- French translation by Cyril Lefebvre, thanks to him ! +- Now, we can save from an interlaced picture. +- The scrolling in the picture's window and the redraw function are a + little bit faster. +- Custom font added for the Exif Panel to see more lines. +- 'VDI-Enhancer' from the Behne Bros provided in the "goodies" folder. + Install it if you use the standard Atari VDI without NVDI/fVDI/etc.. +- Others littles changes like Control+U to close the window instead of + Control+W ( standard), menubar desactivation when we load a picture, + 'out of memory' warning in full screen code, etc... + + +Bugs fixes: +----------- +- Remove unecessary redraws of the menu bar when we scroll the window and + in the browser window when this one is opened. +- Now, when you enter in a directory and you go back again, the old + directory remains selected. the code was there but it was wrong. +- Static MDFB struct. were freed in 'winimg' and full screen code ! +- The 1 plane pictures and icon were not correctly drawn in fullscreen mode + and in the browser's toolbar. +- The progress bar was one pixel too wide and high. +- Problem with 1 bits degas picture corrected. +- Now, the background in full screen mode is always black. +- In the Gif codec, a crash occured if the picture's text data was greater + that 255 lines. +- Uncorrect translation in the GUI ( octets -> bytes, etc...). + + +Know bug: +--------- +- On aranym, with the DSP cookie installed, some stranges problems append + when we write a JPG. +- Various animated GIF are badly rendered. +- With some rare PDF, the fonts are outlined. +- The decoding of PDF with big pictures inside is very slow ( not really a + bug but this code must be rewrote). + + + +20 february 2005: BETA5 +======================= + +News: +----- +- 68000, 68020 without FPU and 68020-60 version of the codecs and binaries + available. +- Full screen mode with automatic picture resize if this one is bigger that + the screen. ( F10 shortcut) +- Another cool feature: when a window is iconified, zview show a thumbnail + of the picture inside. +- With the last Aranym from CVS, the JPG pictures are decoded natively with + the host CPU !! ( to use this feature, "nfjpeg.prg" in your 'auto' folder + before MiNT). Many thanks to Patrice Mandin for his work on Aranym ! +- The DSP and the main JPG codecs are now merged in only one codec. + If the brainstorm's cookie is detected and you haven't a 68060, the JPG is + decoded with the DSP, else the CPU routine is used. +- Support of DEGAS compressed added ( PC1,PC2,PC3). +- Others littles changes like recompilation of all the codecs with the last + GCC, the possibility to move the about box with Xaaes, informations about + the licence, etc... + + +Bugs fixes: +----------- +- Many problems on others OS that MiNT are corrected, for exemple, the + plugins were not loaded if this ones were in the global folder + ( aka "LDGPATH/codecs") under TOS and MagiC, etc etc... +- Problems with some degas images fixed. +- With the DSP, JPG pictures not multiple of 16 were badly decoded. +- In planes < 8 bits, the toolbar's icons was not shown. +- VDI's EDDI check at the start. +- Zview saves the browser's coordinates when we quit the application. + Now, this coordinates are not saved if this window is iconified ( for + prevent bad browser coordinate on next relaunch). +- Others littles bugs fixes like with the menu bar handling, error messages + not correct, etc etc... + + + +23 december 2004: BETA4 +======================= + +News: +----- +- The plugins are now in "codecs" directory, this one must be installed in + "c:/gemsys/ldg/codecs" because some applications will use it. +- Read & Write codecs for TIFF added. ( almost all variants supported !!!) +- Read codecs for FAX added. +- Read codecs for Eureka RAW data added. +- Degas codecs read also Degas Elite uncompressed image now + ( Thanks for the documentation Adam!). +- The encoder and decoder are now in the same plugin. +- Navigator frame scrolling optimised. +- Some internal change in picture to screen convertion. + + +Bugs fixes: +----------- +- Extra check for reverse pixel byte added to support 15, 16, 24 and 32 bits + mode of some weired Hades VDI driver ( for Falcon NOVA card also). +- Picture with 4 characters extention ( like "*.jpeg" or "*.tiff") are now + handled correctly. + + + +25 november 2004: BETA3 +======================= + +News: +----- +- zView goes to LGPL. +- TGA read plugin added( 15, 16, 24, 32 bits normal and compressed). +- BMP read plugin added( 1, 4, 8, 24 bits non compressed). +- JPG read plugin with DSP added. ( move JPG.LDG from '/dsp' + to '/plugin/decoder' and install jpgd.prg in your auto folder). +- Option panel for the jpg encoder added... with this one, you can + set the image quality wanted, progressive and grayscale mode. +- The image viewer provides now a Info bar with basic information like + resolution, color bits and image type. +- Add delete function in the menu bar. +- MEM.LDG from dominique Bereziat is now used for memory allocation + ( more safe for MagiC system). +- The dithering routine is now better for 8 and 4 bits resolution. +- Handle of multi-pages Image format; first step for the fax and PDF + reading. +- Menu "history" activated. +- the "jpe" image are now decoded with the JPG plugin. + + +Bugs fixes: +----------- +- Some XGEM picture from old french application with non standard data caused + a crash under MagiC.. Now the line buffer is greater to avoid overflow. +- Bugs fixe in the alpha code in PNG plugin. +- The numpad key was not usable for rename a file. +- redraw issue when the slider was used and a part of the window was outside + the screen area. +- The information dialog returned 0 colors for 24 bits img picture. +- Little bug fixe in rename function. +- When you renamed a folder, the change was not done in the tree browser. +- The use of a specific MiNT function ( Fxattr) made that the neochrome and + degas picture wasn't displayed under plain TOS. +- Fixe a little problem of allignement of the text in catalog tree when we + change the font. +- Fixe a bug that occurs when we deleted a folder in a "very depth" folder... + It was not deleted in the tree catalog. +- Fixe a bug in the infobox, the '/0' null character was not put when the + picture comes from fileselector, shame on me. + + + +28 october 2004: BETA2 +====================== + +- First public release. diff --git a/sources/z-tools/trunk/zview/_dist/doc/zView.hyp b/sources/z-tools/trunk/zview/_dist/doc/zView.hyp new file mode 100644 index 0000000..42c9b5d Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/doc/zView.hyp differ diff --git a/sources/z-tools/trunk/zview/_dist/fonts/d050000l.pfb b/sources/z-tools/trunk/zview/_dist/fonts/d050000l.pfb new file mode 100644 index 0000000..4a3c386 Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/fonts/d050000l.pfb differ diff --git a/sources/z-tools/trunk/zview/_dist/fonts/n019003l.pfb b/sources/z-tools/trunk/zview/_dist/fonts/n019003l.pfb new file mode 100644 index 0000000..ff60555 Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/fonts/n019003l.pfb differ diff --git a/sources/z-tools/trunk/zview/_dist/fonts/n019004l.pfb b/sources/z-tools/trunk/zview/_dist/fonts/n019004l.pfb new file mode 100644 index 0000000..aec380a Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/fonts/n019004l.pfb differ diff --git a/sources/z-tools/trunk/zview/_dist/fonts/n019023l.pfb b/sources/z-tools/trunk/zview/_dist/fonts/n019023l.pfb new file mode 100644 index 0000000..876cda8 Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/fonts/n019023l.pfb differ diff --git a/sources/z-tools/trunk/zview/_dist/fonts/n019024l.pfb b/sources/z-tools/trunk/zview/_dist/fonts/n019024l.pfb new file mode 100644 index 0000000..4799040 Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/fonts/n019024l.pfb differ diff --git a/sources/z-tools/trunk/zview/_dist/fonts/n021003l.pfb b/sources/z-tools/trunk/zview/_dist/fonts/n021003l.pfb new file mode 100644 index 0000000..cbae7ed Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/fonts/n021003l.pfb differ diff --git a/sources/z-tools/trunk/zview/_dist/fonts/n021004l.pfb b/sources/z-tools/trunk/zview/_dist/fonts/n021004l.pfb new file mode 100644 index 0000000..47f8fd5 Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/fonts/n021004l.pfb differ diff --git a/sources/z-tools/trunk/zview/_dist/fonts/n021023l.pfb b/sources/z-tools/trunk/zview/_dist/fonts/n021023l.pfb new file mode 100644 index 0000000..aa9ff5f Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/fonts/n021023l.pfb differ diff --git a/sources/z-tools/trunk/zview/_dist/fonts/n021024l.pfb b/sources/z-tools/trunk/zview/_dist/fonts/n021024l.pfb new file mode 100644 index 0000000..2d19d94 Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/fonts/n021024l.pfb differ diff --git a/sources/z-tools/trunk/zview/_dist/fonts/n022003l.pfb b/sources/z-tools/trunk/zview/_dist/fonts/n022003l.pfb new file mode 100644 index 0000000..0cadce7 Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/fonts/n022003l.pfb differ diff --git a/sources/z-tools/trunk/zview/_dist/fonts/n022004l.pfb b/sources/z-tools/trunk/zview/_dist/fonts/n022004l.pfb new file mode 100644 index 0000000..f1da612 Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/fonts/n022004l.pfb differ diff --git a/sources/z-tools/trunk/zview/_dist/fonts/n022023l.pfb b/sources/z-tools/trunk/zview/_dist/fonts/n022023l.pfb new file mode 100644 index 0000000..107a513 Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/fonts/n022023l.pfb differ diff --git a/sources/z-tools/trunk/zview/_dist/fonts/n022024l.pfb b/sources/z-tools/trunk/zview/_dist/fonts/n022024l.pfb new file mode 100644 index 0000000..8b7c24f Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/fonts/n022024l.pfb differ diff --git a/sources/z-tools/trunk/zview/_dist/fonts/s050000l.pfb b/sources/z-tools/trunk/zview/_dist/fonts/s050000l.pfb new file mode 100644 index 0000000..d0505e4 Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/fonts/s050000l.pfb differ diff --git a/sources/z-tools/trunk/zview/_dist/goodies/Enhancer/Docs/English/Enhancer.txt b/sources/z-tools/trunk/zview/_dist/goodies/Enhancer/Docs/English/Enhancer.txt new file mode 100644 index 0000000..b8d132c --- /dev/null +++ b/sources/z-tools/trunk/zview/_dist/goodies/Enhancer/Docs/English/Enhancer.txt @@ -0,0 +1,20 @@ +VDI-Enhancer V1.00 +================== + + VDI-Enhancer extends the ATARI VDI with new VDI functions for managing + off-screen bitmaps and with the function vq_scrninfo(). + + In addition it replaces on Falcons in High-color mode (or True- color as + it is called by ATARI :-) the non-working function v_get_pixel(). + +Installation: +============= + To install Enhancer, you have to copy it into your AUTO folder. If you + use SPDOGDOS, Enhancer must be physically after SPDOGDOS. + +Note: +===== + Enhancer shouldn't be used with NVDI because the provided functions + already exists in NVDI 2.5 and older NVDI versions do not support + monochrome bitmaps when working with color modes. + diff --git a/sources/z-tools/trunk/zview/_dist/goodies/Enhancer/Docs/German/Enhancer.txt b/sources/z-tools/trunk/zview/_dist/goodies/Enhancer/Docs/German/Enhancer.txt new file mode 100644 index 0000000..992f9fc --- /dev/null +++ b/sources/z-tools/trunk/zview/_dist/goodies/Enhancer/Docs/German/Enhancer.txt @@ -0,0 +1,89 @@ +VDI-Enhancer V1.00 +================== + + Der Enhancer erweitert das ATARI-VDI um die neuen VDI-Funktionen zur + Verwaltung von Off-Screen-Bitmaps und um die Funktion vq_scrninfo(). + + Auáerdem hat der Enhancer den angenehmen Effekt, die auf Falcons im + High-Color-Modus (bzw. True-Color, wie ATARI es zu nennen pflegt :-), + nicht funktionierende Funktion v_get_pixel() zu ersetzen. + +Installation: +============= + Um den Enhancer zu installieren, mssen Sie ihn nur in den AUTO-Ordner + kopieren. Er muž, falls SPDOGDOS vorhanden ist, im AUTO-Ordner + physikalisch dahinter liegen. + +Hinweise: +========= + Der Enhancer sollte nicht mit NVDI zusammen benutzt werden, da die von + ihm bereitgestellten Funktionen in NVDI 2.5 schon existieren und in + „lteren NVDI-Versionen keine monochromen Bitmaps im Farbbetrieb + untersttzt werden. + +Beschreibung: +============= + Der VDI-Enhancer erweitert in der jetzigen Form das ATARI-VDI oder dazu + kompatible Bildschirmtreiber um die Funktionen v_opnbm() (OPEN BITMAP) + und v_clsbm() (CLOSE BITMAP) zum Verwalten und Bearbeiten von + Off-Screen-Bitmaps. + + Mittels dieser beiden Funktionen ist es m”glich, Off-Screen-Bitmaps im + ger„teabh„ngigen Format mit der Farbtiefe der jeweiligen Aufl”sung und + beliebiger Breite und H”he zu bearbeiten. Dadurch kann man VDI-Ausgaben + auf einem Hintergrundschirm vornehmen und anschliežend dessen Inhalt + ohne Benutzung von vr_trnfm() auf den sichtbaren Bildschirm kopieren. + Bei einigen Anwendungen fr Off-Screen-Bitmaps ist Farbe nicht + notwendig, bzw. verbraucht unn”tig viel Speicher. Daher kann man auch in + Farbaufl”sungen mit v_opnbm() monochrome Bitmaps anlegen. + + Auáerdem bietet der Enhancer durch die Funktion vq_scrninfo() + Informationen ber das ger„teabh„ngige Bildschirmformat. Diese Funktion + drfte fr alle, die z.B. Farbbilder sichern, hilfreich sein. + +Cookies und XBRA-Kennung: +========================= + Der Enhancer installiert ebenso wie NVDI einen Cookie mit der Kennung + 'EdDI'. Das auf diese Kennung folgende Langwort ist die Adresse eines + Funktionsdispatchers, der mit der Funktionsnummer in Register d0 + aufgerufen wird. Der Aufruf erfolgt nach den Pure C-Konventionen + (Register d0-d2/a0-a1 und der Stack werden zur Parameterbergabe + benutzt). + + Bisher existiert nur die Funktion 0, die als Funktionsresultat eine + Versionsnummer zurckliefert, anhand er man auf die untersttzten + Funktionen schlieáen kann. + + Ab Version 1.00 ($100 wird zurckgeliefert) sind die Funktionen + v_opnbm(), v_clsbm() und vq_scrninfo() vorhanden. + +Weitergabe des Enhancers und Copyright: +======================================= + + Die Weitergabe des VDI-Enhancers ist unter der Bedingung, daž dieser + Text zusammen mit der Enhancer-Dokumentation mitgegeben wird, + grunds„tzlich erlaubt. Der Vertrieb des Enhancers im Zusammenhang mit + anderen Software-Produkten ist erlaubt, sofern dem Kunden dadurch keine + zus„tzlichen Kosten entstehen und der empfohlene Verkaufspreis dieser + Software 50 DM nicht bersteigt. + + Auch dabei muž dieser Text mitgeliefert werden. Der Verkauf des + VDI-Enhancers ist verboten. Er darf in PD-Sammlungen nur angeboten + werden, wenn der Diskettenpreis unter 10 DM pro Diskette liegt. + + Ein Vertrieb ber CHANNEL VIDEODAT oder „hnliche kommerzielle Systeme + ist untersagt. + + ** Ausnahmen bedrfen einer schriftlichen Genehmigung der Autoren! ** + + Das Copyright verbleibt allein bei den Autoren, Sven & Wilfried Behne + E-Mail: Wilfried Behne @H + Fehlermeldungen und Verbesserungsvorschl„ge k”nnen an diese Adresse + geschickt werden. + +Ausschluž der Haftung: +====================== + + Die Haftung fr unmittelbare und mittelbare Sch„den, Folgesch„den und + Drittsch„den durch die Benutzung des VDI-Enhancers ist ausgeschlossen. + diff --git a/sources/z-tools/trunk/zview/_dist/goodies/Enhancer/Docs/German/Neue_Fkt.txt b/sources/z-tools/trunk/zview/_dist/goodies/Enhancer/Docs/German/Neue_Fkt.txt new file mode 100644 index 0000000..a853861 --- /dev/null +++ b/sources/z-tools/trunk/zview/_dist/goodies/Enhancer/Docs/German/Neue_Fkt.txt @@ -0,0 +1,359 @@ + Neue Funktionen in NVDI 2.50 + ============================ + + Nachfolgend werden in dieser Datei die neuen Funktionen aufgefhrt, die + NVDI fr Bildschirmausgaben anbietet. + +1. Off-Screen Bitmaps +===================== + + Fr viele Anwendungen ist es sehr ntzlich, wenn Zeichenfunktionen nicht + direkt auf den Bildschirm, sondern auf einen nicht sichtbaren Bildschirm + angewendet werden k”nnen. Einen derartigen "versteckten" Bildschirm + nennt man Off-Screen-Bitmap. + Zur Erzeugung von Off-Screen-Bitmaps dient die Funktion OPEN BITMAP. + Man kann ihr entweder die Gr”že eines Bitmap angeben, die Sie allozieren + soll, oder ihr eine Bitmap bergeben. Die Bitmap wird im gleichen Format + wie die des Bildschirms verwaltet, wodurch schnelles Kopieren zwischen + beiden m”glich ist. + Die Funktion CLOSE BITMAP schliežt eine mit OPEN BITMAP erzeugte Bitmap + und gibt gegebenenfalls deren Speicher zurck. + + + OPEN BITMAP (VDI 100, 1) + + void v_opnbm( WORD *work_in, MFDB *bitmap, WORD *handle, WORD *work_out ) + { + pb[1] = work_in; + pb[3] = work_out; + pb[4] = work_out + 45; + + contrl[0] = 100; + contrl[1] = 0; + contrl[3] = 20; + contrl[5] = 1; + *(MFDB *)&contrl[7] = bitmap; + + vdi(); + + *handle = contrl[6]; + pb[1] = intin; + pb[3] = intout; + pb[4] = ptsout; + } + + Bestckung der VDI-Arrays: + + Feldelement | Belegung + ------------------|------------------------------------------- + contrl[0] | 100 Funktionsnummer fr v_opnbm() + contrl[1] | 0 Anzahl der Eintr„ge in ptsin + contrl[2] | 6 Anzahl der Eintr„ge in ptsout + contrl[3] | 20 Anzahl der Eintr„ge in intin + contrl[4] | 45 Anzahl der Eintr„ge in intout + contrl[5] | 1 Unterfunktionsnummer fr v_opnbm() + contrl[6] | handle + contrl[7..8] | bitmap Zeiger auf einen MFDB der Bitmap + | + intin[0..19] | work_in[0..19] + | + intout[0..44] | work_out[0..44] + | + ptsout[0..11] | work_out[45..56] + + + handle: graf_handle() + + work_in[0..10]: wie bei v_opnwk()/v_opnvwk() definiert + work_in[0]: Getrez() + 2 + work_in[11]: Breite -1 (z.B. 1279) + work_in[12]: H”he -1 (z.B. 959) + work_in[13]: Breite eines Pixels in Mikrometern + work_in[14]: H”he eines Pixels in Mikrometern + work_in[15..19]: reserviert, sollte 0 enthalten + + Achtung: Der Eintrag work_in[11] sollte bei Addition von 1 ohne Rest + durch 16 teilbar sein. Andernfalls rundet der VDI-Treiber + auf den n„chsth”heren ohne Rest teilbaren Wert. + + Hinweis: Wird fr Pixelbreite und -H”he 0 angegeben, so werden die + Werte des Bildschirms benutzt. + + work_out[0..1]: wie bei v_opnwk()/v_opnvwk() definiert + work_out[2]: 0 + work_out[3..38]: wie bei v_opnwk()/v_opnvwk() definiert + work_out[39] 0 (keine Hardware-Palette vorhanden, da Bitmap) + work_out[39..56]: wie beiv_opnwk()/v_opnvwk() definiert + + bitmap: Zeiger auf einen MFDB + + Falls bitmap->fd_addr gleich NULL ist, so wird anhand der Gr”žen- + angaben in work_in Speicher fr die Bitmap angefordert (die Bitmap + wird im Gegensatz zu v_opnvwk() gel”scht). + + Um eine Bitmap im ger„tespezifischen Format zu ”ffnen, muž + bitmap->fd_nplanes eine Null oder die Ebenenanzahl des Schirms + enthalten (work_out[4] bei vq_extnd()). Ist bitmap->fd_nplanes 1, + wird eine monochrome Bitmap angelegt. + + Die Eintr„ge des MFDB (fd_addr, fd_w, fd_h, fd_wdwidth, fd_stand, + fd_nplanes) werden vom VDI-Treiber gesetzt und an die aufrufende + Applikation zurckgegeben. Wenn nicht nicht gengend Speicher + vorhanden ist, wird der Inhalt des MFDBs nicht ver„ndert; ein + Null-Handle wird zurckgegeben. + + Wenn bitmap->fd_addr ungleich NULL ist, wird dieser Eintrag als + Zeiger auf eine Bitmap interpretiert. Wenn die Bitmap im + Standardformat vorliegt, wird sie ins ger„tespezifische Format + umgewandelt. Liegt sie schon im ger„tespezifischen Format vor, so + wird sie nicht umgewandelt. Falls die Aufl”sung der Bitmap (d.h. + die Anzahl der Farben und Planes) nicht untersttzt wird, gibt + v_opnbm() ein Null-Handle zurck. + + + CLOSE BITMAP (VDI 101, 1) + + void v_clsbm( WORD handle ) + { + contrl[0] = 101; + contrl[1] = 0; + contrl[3] = 0; + contrl[5] = 1; + contrl[6] = handle; + vdi(); + } + + Bestckung der VDI-Arrays: + + Feldelement | Belegung + ------------------|------------------------------------------- + contrl[0] | 101 Funktionsnummer fr v_clsbm() + contrl[1] | 0 Anzahl der Eintr„ge in ptsin + contrl[2] | 0 Anzahl der Eintr„ge in ptsout + contrl[3] | 0 Anzahl der Eintr„ge in intin + contrl[4] | 0 Anzahl der Eintr„ge in intout + contrl[5] | 1 Unterfunktionsnummer fr v_clsbm() + contrl[6] | handle + + Die Funktion v_clsbm() schliežt die mit handle bezeichnete Bitmap. + Wenn der Speicher beim v_opnbm() vom VDI alloziert wurde, gibt sie + diesen Speicher wieder frei. + + + Rasteroperationen bei Off-Screen-Bitmaps: + ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ + Rasteroperationen zwischen Bildschirm und Off-Screen-Bitmap sollten + grunds„tzlich im ger„tespezifischen Format erfolgen. + Wenn als Ziel einer Rasteroperation eine Off-Screen-Bitmap mit ihrem + MFDB angegeben wird und wenn das zu dieser Bitmap geh”rende Handle + benutzt wird, so wird beim Blitten anhand der ber vs_clip() auf dieser + Workstation eingestellten Koordinaten geclippt. Fr das Kopieren eines + Rasters vom Bildschirm in eine Off-Screen-Bitmap sollte man also das + VDI-Handle dieser Bitmap benutzen. + Ist die Bitmap dagegen Quelle und der Bildschirm Ziel, so sollte man das + Handle der Bildschirm-Workstaion benutzen, da dann das Raster anhand der + Bildschirm-Koordinaten abgeclippt wird. + Wenn man das von v_opnbm() zurckgelieferte Handle einer Bitmap benutzt + und in fd_addr in einem MFDB 0 enth„lt, so werden die Daten der Bitmap + statt dessen benutzt. + + ESCAPES + ------- + Die VDI-Escape-Funktionen (VT52) k”nnen nicht auf einer Bitmap benutzt + werden. Ihr Aufruf wid ignoriert. + + vs_color()/vq_color() + --------------------- + Wenn die Funktion vs_color() mit dem Handle einer Off-Screen-Bitmap + aufgerufen wird, werden die Farben nur dann gesetzt, wenn es sich um + High- oder True-Color handelt. Vq_color() ist ebenfalls nur in High- + oder True-Color sinnvoll - andernfalls ist der Parameter valid -1. + + vst_point() + ----------- + Die Funktion vst_point() und alle anderen Funktionen, die Texth”hen in + Punkten einstellen, reagieren bisher nur dann sinnvoll, wenn die Bitmap + die Ausmaáe des Bildschirms hat. + + v_show_c()/v_hide_c() + --------------------- + Beide Funktionen werden ignoriert, falls sie mit dem Handle einer + Off-Screen-Bitmap aufgerufen werden. Sie beziehen sich nur auf den + Bildschirm und sollten nur vom AES aufgerufen werden. + +2. vq_scrninfo() +================= + + Genauere Angaben ber das Bildschirmformat liefert die Funktion INQUIRE + SCREEN INFORMATION implementiert. Im workout-Array wird angeben, wie das + ger„tespezifische Format aufgebaut ist. + Diese Informationen sind in erster Linie interessant fr Programme, die + - schnell Raster aufbauen (auch in TrueColor) und diese mit vro_cpyfm() + auf den Schirm kopieren m”chten. + - Raster speichern (z.B. XIMGs). + - Raster anzeigen. + + VQ_SCRNINFO( 102, 1 ) + + void vq_scrninfo( WORD handle, WORD *work_out ) + { + pb[3] = work_out; + + intin[0] = 2; + contrl[0] = 102; + contrl[1] = 0; + contrl[3] = 1; + contrl[5] = 1; + contrl[6] = handle; + + vdi(); + + pb[3] = intout; + } + + Bestckung der VDI-Arrays: + + Feldelement | Belegung + ------------------|------------------------------------------- + contrl[0] | 102 Funktionsnummer von vq_scrninfo() + contrl[1] | 0 Anzahl der Eintr„ge in ptsin + contrl[2] | 0 Anzahl der Eintr„ge in ptsout + contrl[3] | 1 Anzahl der Eintr„ge in intin + contrl[4] | 272 Anzahl der Eintr„ge in intout + contrl[5] | 1 Unterfunktionsnummer von vq_scrninfo() + contrl[6] | handle + | + intin[0] | 2 erweiterte Informationen ausgeben + | + intout[0..272] | work_out[0..272] + + + intout[0]: Formatangabe: + 0: Interleaved Planes, wortweise (ATARI Grafik) + 1: Standardformat (komplette Planes) + 2: Packed Pixels + -1: unbekanntes Format; nicht direkt beschreibbar + intout[1]: Verfgbarkeit einer CLUT: + 0: keine CLUT (z.B. TTM 194) + 1: Hardware-CLUT + 2: Software-CLUT (HiColor oder TrueColor) + intout[2]: Anzahl der Ebenen (Bits) pro Pixel + intout[3/4]:Farbanzahl oder 0L (mehr als 2*10^31 Farben) + intout[8]: Anzahl der Bits fr die Rot-Intensit„t + intout[9]: Anzahl der Bits fr die Grn-Intensit„t + intout[10]: Anzahl der Bits fr die Blau-Intensit„t + intout[11]: Anzahl der Bits fr den Alpha-Channel oder „hnliches + intout[12]: Anzahl der Bits fr Genlock + intout[13]: Anzahl der nicht benutzen Bits + + Falls eine Hardware-CLUT (intout[1] == 1) vorhanden ist: + intout[16-271]: Pixelwert des zugeh”rigen VDI-Farbindexes + + Falls HiColor, TrueColor oder „hnliches vorhanden ist: + intout[16..31]: Zuordnung von Bitnummer im Pixel zum Bit der Rotintensit„t + intout[32..47]: Zuordnung von Bitnummer im Pixel zum Bit der Grnintens. + intout[48..63]: Zuordnung von Bitnummer im Pixel zum Bit der Blauintensit„t + intout[64..79]: Zuordnung der Bitnummer fr Alpha-Channel + intout[80..95]: Zuordnung der Bitnummer fr Genlock + intout[96..127]: unbenutzte Bits + intout[128..271]: reserviert (0) + + Beispiele: + ---------- + + In 256 Farben auf dem Falcon wrden folgende Ausgaben erfolgen: + + intout | Wert | Bedeutung + ---------|--------|----------------------------------------------------- + 0 | 0 | Interleaved Planes, wortweise + 1 | 1 | Hardware-CLUT vorhanden + 2 | 8 | 8 Bit pro Pixel + 3/4 | 256 | 256 verschiedene Farben gleichzeitig m”glich + 8 | 6 | 6 Bits fr die Rot-Intensit„t + 9 | 6 | 6 Bits fr die Grn-Intensit„t + 10 | 6 | 6 Bits fr die Blau-Intensit„t + 11 | 0 | kein Bit fr Alpha-Channel + 12 | 0 | kein Bit fr Genlock + 13 | 0 | kein unbenutzes Bit + | | + | | + 16 | 0 | Pixelwert fr VDI-Farbindex 0 + 17 | 255 | Pixelwert fr VDI-Farbindex 1 + 18 | 2 | Pixelwert fr VDI-Farbindex 2 + ... | ... | + 271 | 15 | Pixelwert fr VDI-Farbindex 255 + + In HiColor auf dem Falcon wrden folgende Ausgaben erfolgen: + + intout | Wert | Bedeutung + ---------|--------|----------------------------------------------------- + 0 | 2 | Packed Pixels + 1 | 2 | HiColor bzw. TrueColor + 2 | 16 | 16 Bit pro Pixel + 3/4 | 32768 | 32768 verschiedene Farben gleichzeitig m”glich + 8 | 5 | 5 Bits fr die Rot-Intensit„t + 9 | 5 | 5 Bits fr die Grn-Intensit„t + 10 | 5 | 5 Bits fr die Blau-Intensit„t + 11 | 0 | kein Bit fr Alpha-Channel + 12 | 1 | ein Bit fr Genlock + 13 | 0 | kein unbenutzes Bit + | | + | | + 16 | 11 | Bit 0 der Rot-Intensit„t (niederwertigstes Bit) + | | befindet sich in Bit 11 des Pixels + 17 | 12 | Bit 1 befindet sich in Bit 12 des Pixels + 18 | 13 | ... + 19 | 14 | ... + 20 | 15 | Bit 4 der Rot-Intensit„t (h”chstwertigstes Bit) + | | befindet sich in Bit 15 des Pixels + 21..31 | -1 | Bits werden nicht fr Rot-Intensit„t benutzt + | | + | | + 32 | 6 | Bit 0 der Grn-Intensit„t (niederwertigstes Bit) + | | befindet sich in Bit 6 des Pixels + 33 | 7 | Bit 1 befindet sich in Bit 7 des Pixels + 34 | 8 | ... + 35 | 9 | ... + 36 | 10 | Bit 4 der Grn-Intensit„t (h”chstwertigstes Bit) + | | befindet sich in Bit 10 des Pixels + 37..37 | -1 | Bits werden nicht fr Grn-Intensit„t benutzt + | | + | | + 48 | 0 | Bit 0 der Blau-Intensit„t (niederwertigstes Bit) + | | befindet sich in Bit 0 des Pixels + 49 | 1 | Bit 1 befindet sich in Bit 1 des Pixels + 50 | 2 | ... + 51 | 3 | ... + 52 | 4 | Bit 4 der Blau-Intensit„t (h”chstwertigstes Bit) + | | befindet sich in Bit 4 des Pixels + 53..63 | -1 | Bits werden nicht fr Blau-Intensit„t benutzt + | | + | | + 64..79 | -1 | kein Alpha-Channel + | | + | | + 80 | 5 | Bit fr Genlock + 81..95 | -1 | nicht fr Genlock benutzt + | | + | | + 96..127| -1 | keine unbenutzten Bits + | | + | | + +3. Wie erkennt man, ob die neuen Funktionen vorhanden sind? +=========================================================== + + NVDI installiert (ebenso wie der nur frs ATARI-VDI gedachte Enhancer) + einen Cookie mit der Kennung 'EdDI'. Das auf diese Kennung folgende + Langwort ist die Adresse eines Funktionsdispatchers, der mit der + Funktionsnummer in Register d0 aufgerufen wird. Der Aufruf erfolgt nach + den Pure C-Konventionen (Register d0-d2/a0-a1 und der Stack werden zur + Parameterbergabe benutzt). + + Bisher existiert nur die Funktion 0, die als Funktionsresultat eine + Versionsnummer zurckliefert, anhand er man auf die untersttzten + Funktionen schlieáen kann. + + Ab Version 1.00 ($100 wird zurckgeliefert) sind die Funktionen + v_opnbm(), v_clsbm() und vq_scrninfo() vorhanden. + diff --git a/sources/z-tools/trunk/zview/_dist/goodies/Enhancer/Enhancer.prg b/sources/z-tools/trunk/zview/_dist/goodies/Enhancer/Enhancer.prg new file mode 100644 index 0000000..b6aaff8 Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/goodies/Enhancer/Enhancer.prg differ diff --git a/sources/z-tools/trunk/zview/_dist/goodies/jpegd.prg b/sources/z-tools/trunk/zview/_dist/goodies/jpegd.prg new file mode 100644 index 0000000..7f6e696 Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/goodies/jpegd.prg differ diff --git a/sources/z-tools/trunk/zview/_dist/goodies/nfjpeg.prg b/sources/z-tools/trunk/zview/_dist/goodies/nfjpeg.prg new file mode 100644 index 0000000..165e73d Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/goodies/nfjpeg.prg differ diff --git a/sources/z-tools/trunk/zview/_dist/goodies/zviewicn.rsc b/sources/z-tools/trunk/zview/_dist/goodies/zviewicn.rsc new file mode 100644 index 0000000..d96cdaa Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/goodies/zviewicn.rsc differ diff --git a/sources/z-tools/trunk/zview/_dist/icons/file.god b/sources/z-tools/trunk/zview/_dist/icons/file.god new file mode 100644 index 0000000..4866e48 Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/icons/file.god differ diff --git a/sources/z-tools/trunk/zview/_dist/icons/folder.god b/sources/z-tools/trunk/zview/_dist/icons/folder.god new file mode 100644 index 0000000..a3873d0 Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/icons/folder.god differ diff --git a/sources/z-tools/trunk/zview/_dist/icons/image.god b/sources/z-tools/trunk/zview/_dist/icons/image.god new file mode 100644 index 0000000..2535f0f Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/icons/image.god differ diff --git a/sources/z-tools/trunk/zview/_dist/icons/pdf.god b/sources/z-tools/trunk/zview/_dist/icons/pdf.god new file mode 100644 index 0000000..a3dfcd0 Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/icons/pdf.god differ diff --git a/sources/z-tools/trunk/zview/_dist/icons/prg.god b/sources/z-tools/trunk/zview/_dist/icons/prg.god new file mode 100644 index 0000000..25dbd53 Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/icons/prg.god differ diff --git a/sources/z-tools/trunk/zview/_dist/icons/small.god b/sources/z-tools/trunk/zview/_dist/icons/small.god new file mode 100644 index 0000000..3e85e99 Binary files /dev/null and b/sources/z-tools/trunk/zview/_dist/icons/small.god differ diff --git a/sources/z-tools/trunk/zview/_dist/readme.1st b/sources/z-tools/trunk/zview/_dist/readme.1st new file mode 100644 index 0000000..43210cd --- /dev/null +++ b/sources/z-tools/trunk/zview/_dist/readme.1st @@ -0,0 +1,9 @@ +This is a maintainance and unofficial release fixing some crashes when running +under FreeMiNT with memory protection. You don't need to install anything, +however if you want to make new plugins usable for other applications, copy +"codecs" directory into c:\gemsys\ldg (or any other location you use for LDG +modules). + +Miro Kropacek +Bratislava/Slovakia +01.11.2011 diff --git a/sources/z-tools/trunk/zview/av_prot.c b/sources/z-tools/trunk/zview/av_prot.c new file mode 100644 index 0000000..78a57b1 --- /dev/null +++ b/sources/z-tools/trunk/zview/av_prot.c @@ -0,0 +1,36 @@ +#include "general.h" +#include "pic_load.h" +#include "winimg.h" + +/* Prototype */ +void va_start( void); + + +/*==================================================================================* + * void va_start: * + * Handle the VA_START message from the server. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void va_start( void) +{ + char *p = *(char **) &evnt.buff[3]; + + if( p) + { + p = AvStrfmt( 1, p); + + /* yes, I know, it's strange to reput the menubar here + but if we don't do it, on MagiC, the menubar is not active after + a VA_START :( */ + MenuBar( get_tree( MENU_BAR), 1); + + WindView( p); + free( p); + } +} diff --git a/sources/z-tools/trunk/zview/av_prot.h b/sources/z-tools/trunk/zview/av_prot.h new file mode 100644 index 0000000..2d46d5a --- /dev/null +++ b/sources/z-tools/trunk/zview/av_prot.h @@ -0,0 +1,2 @@ +void va_start( void); + diff --git a/sources/z-tools/trunk/zview/catalog/catalog.c b/sources/z-tools/trunk/zview/catalog/catalog.c new file mode 100644 index 0000000..259fd30 --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog.c @@ -0,0 +1,1115 @@ +#include "../general.h" +#include "../prefs.h" +#include "../file/file.h" +#include "../file/delete.h" +#include "catalog_entry.h" +#include "catalog_mini_entry.h" +#include "../zedit/zedit.h" +#include "../ztext.h" +#include "../mfdb.h" +#include "../infobox.h" +#include "../menu.h" +#include "../txt_data.h" +#include "../custom_font.h" +#include "catalog_icons.h" +#include "catalog_keyb.h" +#include "catalog_mouse.h" +#include "catalog_slider.h" +#include "catalog_size.h" +#include "catalog_iconify.h" +#include "catalog_other_event.h" + +/* Global variable */ +int16 border_size = 5; +int16 old_browser_size = 200; +int16 old_preview_area_size = 200; +int16 old_border_size = 5; +int16 x_space = 5; +int16 y_space = 4; +int16 hcell = 8; +int16 need_frame_slider = 0; +int16 draw_frame_slider = 1; +OBJECT *frame_slider_root; + +/* local variable */ +static int16 dum, xw, yw, ww, hw; + + +/* Prototype */ +static void WinCatalog_Close( WINDOW *win); +static void WinCatalog_Redraw( WINDOW *wind); +static void WinCatalog_Tool( WINDOW *win); +void WinCatalog_Refresh( WINDOW *win); +int WindMakePreview_needed( WINDOW *win); +void WindMakePreview( WINDOW *win); +int WinCatalog( void); +void WinCatalog_filelist_redraw( void); +void WinCatalog_set_thumbnails_size( WINDOW *win); + + +extern void save_dialog( const char *fullfilename); + +/*==================================================================================* + * int WindMakePreview_needed: * + * Look if a preview making is needed. * + *----------------------------------------------------------------------------------* + * input: * + * win -> Pointer to the target window * + *----------------------------------------------------------------------------------* + * returns: * + * '1' if needed else '0' * + *==================================================================================*/ + +int WindMakePreview_needed( WINDOW *win) +{ + int16 i, h; + WINDICON *wicones = ( WINDICON *)DataSearch( win, WD_ICON); + + WindGet ( win, WF_WORKXYWH, &dum, &dum, &dum, &h); + + for (i = 0 ; i < wicones->nbr_icons ; i++) + { + if ( icon_is_visible( &wicones->entry[i], h) == FALSE) + continue; + + if ( ( wicones->entry[i].type == ET_IMAGE) && ( wicones->entry[i].preview.page == 0)) + return( 1); + } + return ( 0); +} + + + +/*==================================================================================* + * void WindMakePreview: * + * Create picture's preview for each visible picture files in the folder. * + * If preview is already done, we skip it. * + * If preview making is impossible, we change the file's type from ET_IMAGE * + * to ET_FILE. * + *----------------------------------------------------------------------------------* + * input: * + * win -> Pointer to the target window * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void WindMakePreview( WINDOW *win) +{ + int16 i, h; + char extention[4]; + WINDICON *wicones = ( WINDICON *)DataSearch( win, WD_ICON); + + draw_frame_slider = 0; + + WindGet ( win, WF_WORKXYWH, &dum, &dum, &dum, &h); + + graf_mouse( BUSYBEE, NULL); + + for (i = 0 ; i < wicones->nbr_icons ; i++) + { + + if ( icon_is_visible( &wicones->entry[i], h) == FALSE) + continue; + + if ( ( wicones->entry[i].type == ET_IMAGE) && ( wicones->entry[i].preview.page == 0)) + { + wicones->entry[i].preview.view_mode = preview_mode; + wicones->entry[i].preview.progress_bar = 0; + + // MenuDisable(); + + /* get the file extention */ + strcpy ( extention, wicones->entry[i].name + strlen( wicones->entry[i].name) - 3); + str2upper( extention); + + if( pic_load( wicones->entry[i].name, extention, &wicones->entry[i].preview)) + redraw_icon( win, &wicones->entry[i]); + else + wicones->entry[i].type = ET_FILE; + } + + // evnt_timer( 100L); + } + + draw_frame_slider = 1; + graf_mouse( ARROW, NULL); + // MenuEnable(); +} + + + +/*==================================================================================* + * WINDOW *WinCatalog: * + * Create the Window and bind the severals event for it. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * '0' if error, else '1'. * + *==================================================================================*/ + +int WinCatalog( void) +{ + WINDICON *wicones; + OBJECT *menu; + int16 w, h; + + if ( win_catalog) + return( 0); + + if ( !icons_init()) + { + errshow( "", NO_ICON); + applexit(); + } + + if ( ( wicones = ( WINDICON *) gmalloc( sizeof( WINDICON))) == NULL) + { + errshow( "", ENOMEM); + return( 0); + } + + if ( ( win_catalog = WindCreate( WINATTRIB, app.x, app.y, app.w, app.h)) == NULL) + { + gfree( wicones); + errshow( "", ALERT_WINDOW); + return( 0); + } + + + /* Set some wicones's parameters */ + wicones -> case_h = thumbnail[thumbnail_size][1] + hcell + y_space + y_space + y_space; + + if ( show_size) + wicones -> case_h += hcell + y_space; + + wicones -> case_w = thumbnail[thumbnail_size][0] + ( x_space << 1); + wicones -> nbr_icons = 0; + wicones -> edit = NULL; + wicones -> h_u = 18; /* 1 + mini_entry's icon + 1 */ + wicones -> ypos = 0; + wicones -> ypos_max = 1; + + DataAttach( win_catalog, WD_ICON, wicones); + + if ( !scan_mini_drv( win_catalog)) + { + zdebug( "can't scan the drive"); + gfree( wicones); + DataDelete( win_catalog, WD_ICON); + WindDelete( win_catalog); + return( 0); + } + + check_mini_dir( wicones->nbr_child, wicones->root); + + if( !scan_dir( win_catalog, "C:\\")) + { + zdebug( "can't scan the dir"); + WinCatalog_Close( win_catalog); + return( 0); + } + + EvntAttach( win_catalog, WM_REDRAW, WinCatalog_Redraw); + EvntAttach( win_catalog, WM_DESTROY, WinCatalog_Close); + EvntAttach( win_catalog, WM_SIZED, WinCatalog_Size); + EvntAttach( win_catalog, WM_ARROWED, WinCatalog_Arrow); + EvntAttach( win_catalog, WM_UPPAGE, WinCatalog_UpPage); + EvntAttach( win_catalog, WM_DNPAGE, WinCatalog_DownPage); + EvntAttach( win_catalog, WM_UPLINE, WinCatalog_UpLine); + EvntAttach( win_catalog, WM_DNLINE, WinCatalog_DownLine); + EvntAttach( win_catalog, WM_VSLID , WinCatalog_VSlide); + EvntAttach( win_catalog, WM_FULLED, WinCatalog_Fulled); +// EvntAttach( win_catalog, AP_DRAGDROP, WinCatalog_DragDrop); + EvntAdd( win_catalog, WM_ICONIFY, catalog_iconify, EV_TOP); + EvntAdd( win_catalog, WM_UNICONIFY, catalog_uniconify, EV_TOP); + EvntAdd( win_catalog, WM_TOPPED, WinCatalog_top, EV_BOT); + EvntAdd( win_catalog, WM_BOTTOMED, WinCatalog_bottom, EV_BOT); + + EvntAttach( win_catalog, WM_XBUTTON, WinCatalog_Mouse); + EvntAttach( win_catalog, WM_XKEYBD, WinCatalog_Keyb); + + WindSetStr( win_catalog, WF_NAME, wicones->directory); + WindSetPtr( win_catalog, WF_TOOLBAR, get_tree( TOOLBAR), WinCatalog_Tool); + WindSetStr( win_catalog, WF_ICONDRAW, draw_window_iconified); + + WindCalc( WC_BORDER, win_catalog, 0, 0, wicones->case_w + border_size + browser_frame_width, wicones->case_h, &dum, &dum, &w, &h); + + /* Set win's parameters */ + win_catalog -> h_min = h; + win_catalog -> w_min = w; + win_catalog -> h_max = app.h; + win_catalog -> w_max = app.w; + win_catalog -> h_u = wicones -> case_h; + win_catalog -> w_u = wicones -> case_w; + win_catalog -> tool.root[TOOLBAR_BACK].ob_width = app.w; + + /* install userdraw for the toolbar */ + RsrcUserDraw ( OC_TOOLBAR, win_catalog, TOOLBAR_UP, draw_icon_up, NULL); + RsrcUserDraw ( OC_TOOLBAR, win_catalog, TOOLBAR_RELOAD, draw_icon_reload, NULL); + RsrcUserDraw ( OC_TOOLBAR, win_catalog, TOOLBAR_BIG, draw_icon_greater, NULL); + RsrcUserDraw ( OC_TOOLBAR, win_catalog, TOOLBAR_SMALL, draw_icon_smaller, NULL); + RsrcUserDraw ( OC_TOOLBAR, win_catalog, TOOLBAR_PRINT, draw_icon_printer, NULL); + RsrcUserDraw ( OC_TOOLBAR, win_catalog, TOOLBAR_OPEN, draw_icon_open, NULL); + RsrcUserDraw ( OC_TOOLBAR, win_catalog, TOOLBAR_INFO, draw_icon_info, NULL); + RsrcUserDraw ( OC_TOOLBAR, win_catalog, TOOLBAR_DELETE, draw_icon_delete, NULL); + RsrcUserDraw ( OC_TOOLBAR, win_catalog, TOOLBAR_SAVE, draw_icon_save, NULL); + + /* get the frame slider's address */ + rsrc_gaddr( 0, SLIDERS, &frame_slider_root); + + if( !browser_w && !browser_h) + { + browser_x = app.x; + browser_y = app.y; + browser_w = app.w; + browser_h = app.h; + } + + if( !WindOpen( win_catalog, browser_x, browser_y, browser_w, browser_h)) + { + WinCatalog_Close( win_catalog); + errshow( "", ALERT_WINDOW); + return( 0); + } + + + menu = get_tree( MENU_BAR); + + menu_ienable( menu, MENU_BAR_BROWSER, 0); + menu_ienable( menu, MENU_BAR_CLOSE, 1); + menu_ienable( menu, MENU_BAR_SELECT_ALL, 1); + menu_ienable( menu, MENU_BAR_BY_NAME, 1); + menu_ienable( menu, MENU_BAR_BY_SIZE, 1); + menu_ienable( menu, MENU_BAR_BY_DATE, 1); + menu_ienable( menu, MENU_BAR_SHOW_BROWSER, 1); + menu_ienable( menu, MENU_BAR_SHOW, 1); + menu_ienable( menu, MENU_BAR_LONG_THUMB, 1); + menu_ienable( menu, MENU_BAR_LARGE_THUMB, 1); + menu_ienable( menu, MENU_BAR_INFORMATION, 0); + menu_ienable( menu, MENU_BAR_SAVE, 0); + + if( WindMakePreview_needed( win_catalog)) + { + EvntRedraw( win_catalog); + WindMakePreview( win_catalog); + } + + return ( 1); +} + +/*==================================================================================* + * WinCatalog_Close: * + * Destroy the WINDOW *win and free up memory. * + *----------------------------------------------------------------------------------* + * input: * + * win -> Pointer to the target window * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +static void WinCatalog_Close( WINDOW *win) +{ + int16 i; + OBJECT *menu = get_tree( MENU_BAR); + + WINDICON *wicones = ( WINDICON *)DataSearch( win, WD_ICON); + + if( !( win->status & WS_ICONIFY)) + { + WindGet ( win, WF_CURRXYWH, &xw, &yw, &ww, &hw); + + browser_x = xw; + browser_y = yw; + browser_w = ww; + browser_h = hw; + } + + for ( i = 0 ; i < wicones->nbr_icons ; i++) + { + delete_txt_data( &wicones->entry[i].preview); + delete_mfdb( wicones->entry[i].preview.image, 1); + } + + if ( wicones->edit) + edit_free( wicones->edit); + + /* free allocated data structures */ + if ( wicones->nbr_icons > 0) + gfree( wicones->entry); + + if( wicones->root) + { + for ( i = 0; i < wicones->nbr_child; i++) + { + if ( wicones->root[i].nbr_child) + delete_mini_entry_child( &wicones->root[i]); + } + + gfree( wicones->root); + } + + gfree( wicones); + + DataDelete( win, WD_ICON); + + WindDelete( win); + + if( wglb.first) + { + menu_ienable( menu, MENU_BAR_CLOSE, 1); + menu_ienable( menu, MENU_BAR_SAVE, 1); + } + else + { + menu_ienable( menu, MENU_BAR_SAVE, 0); + menu_ienable( menu, MENU_BAR_INFORMATION, 0); + } + + menu_ienable( menu, MENU_BAR_SELECT_ALL, 0); + menu_ienable( menu, MENU_BAR_BY_NAME, 0); + menu_ienable( menu, MENU_BAR_BY_SIZE, 0); + menu_ienable( menu, MENU_BAR_BY_DATE, 0); + menu_ienable( menu, MENU_BAR_SHOW, 0); + menu_ienable( menu, MENU_BAR_SHOW_BROWSER, 0); + menu_ienable( menu, MENU_BAR_DELETE, 0); + menu_ienable( menu, MENU_BAR_LONG_THUMB, 0); + menu_ienable( menu, MENU_BAR_LARGE_THUMB, 0); + menu_ienable( menu, MENU_BAR_BROWSER, 1); + + win_catalog = NULL; +} + + +/*==================================================================================* + * WinCatalog_tool: * + * Toolbar binding. * + *----------------------------------------------------------------------------------* + * input: * + * win -> Pointer to the target window * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +static void WinCatalog_Tool( WINDOW *win) +{ + WINDICON *wicones = ( WINDICON *)DataSearch( win, WD_ICON); + Mini_Entry *old_selected; + char temp[MAX_PATH + 256]; + int16 i; + + WindGet ( win, WF_WORKXYWH, &xw, &yw, &ww, &hw); + + switch( evnt.buff[4]) + { + case TOOLBAR_UP: + if ( !dir_parent( wicones->directory, temp)) + break; + + old_selected = wicones->mini_selected; + wicones->mini_selected = NULL; + + if ( old_selected && browser_frame_width) + redraw_mini_entry( win, old_selected); + + ( void)scan_dir( win, wicones->directory); + WindSetStr ( win, WF_NAME, wicones->directory); + + win->ypos = 0; + + for (i = 0 ; i < wicones->nbr_icons ; i++) + { + if ( strcmp( wicones->entry[i].name, temp) == 0) + { + wicones->first_selected = &wicones->entry[i]; + break; + } + } + + WinCatalog_Refresh( win); + + if ( wicones->first_selected->txt_pos.y2 > hw) + { + while ( wicones->first_selected->txt_pos.y2 > hw) + { + wicones->first_selected->txt_pos.y2 -= win->h_u; + win->ypos++; + } + } + + draw_page( win, xw + browser_frame_width + border_size , yw, ww - ( browser_frame_width + border_size), hw); + WindMakePreview( win); + + break; + + case TOOLBAR_SMALL: + if ( thumbnail_size && thumbnail_size != 4) + { + thumbnail_size--; + + WinCatalog_set_thumbnails_size( win); + + if( thumbnail_size == 6 || thumbnail_size == 2) + ObjcDraw( OC_TOOLBAR, win, TOOLBAR_BIG, 1); + } + break; + + case TOOLBAR_BIG: + if ( thumbnail_size < 7 && thumbnail_size != 3) + { + thumbnail_size++; + + WinCatalog_set_thumbnails_size( win); + + if( thumbnail_size == 1 || thumbnail_size == 5) + ObjcDraw( OC_TOOLBAR, win, TOOLBAR_SMALL, 1); + } + break; + + case TOOLBAR_RELOAD: + ( void)scan_dir( win, wicones->directory); + win->ypos = 0; + draw_page( win, xw + browser_frame_width + border_size , yw + 1, ww - ( browser_frame_width + border_size), hw - 1); + WindMakePreview( win); + break; + + case TOOLBAR_OPEN: + Menu_open_image(); + break; + + case TOOLBAR_INFO: + if( wicones->first_selected) + infobox(); + break; + + case TOOLBAR_SAVE: + if( wicones->first_selected && wicones->first_selected->type == ET_IMAGE) + { + if( wicones->edit) + exit_edit_mode( win, wicones->first_selected); + + strcpy( temp, wicones->directory); + strcat( temp, wicones->first_selected->name); + save_dialog( temp); + break; + } + break; + case TOOLBAR_DELETE: + if( wicones->first_selected) + { + if( wicones->edit) + exit_edit_mode( win, wicones->first_selected); + + delete_entry( win); + + } + break; + + default: + break; + } + + ObjcChange( OC_TOOLBAR, win, evnt.buff[4], NORMAL, 1); +} + + +/*==================================================================================* + * WinCatalog_Refresh: * + * Perform a redraw without draw anything in screen.. usefull for refresh * + * icons positions ( need for various opertaions) * + *----------------------------------------------------------------------------------* + * input: * + * win -> Pointer to the target window * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void WinCatalog_Refresh( WINDOW *win) +{ + int16 icon_w, icon_h, i, x, y, ytext, xtext, lines = 0, width; + + WINDICON *wicones = ( WINDICON *)DataSearch( win, WD_ICON); + + WindGet ( win, WF_WORKXYWH, &xw, &yw, &ww, &hw); + + wicones -> columns = 0; + wicones -> icons_last_line = 0; + + if( browser_frame_width) /* browser active ? */ + { + for ( i = 0 ; i < wicones->nbr_child; i++) + { + lines++; + lines += calc_mini_entry_line( &wicones->root[i]); + } + + wicones -> ypos_max = lines; + + /* compute the frame slider's coordinates even if we don't need it */ + frame_slider_root->ob_x = xw + browser_frame_width - 15; + frame_slider_root->ob_y = yw + 2; + frame_slider_root->ob_height = hw - 3; + frame_slider_root[SLIDERS_BACK].ob_height = hw - 31; + frame_slider_root[SLIDERS_UP].ob_y = frame_slider_root->ob_height - 31; + frame_slider_root[SLIDERS_DOWN].ob_y = frame_slider_root->ob_height - 15; + + calc_mini_entry_slider( wicones, frame_slider_root); + } + + lines = 1; + x = xw + border_size + browser_frame_width; + y = yw - ( ( int16)win->ypos * wicones -> case_h); + + for ( i = 0 ; i < wicones->nbr_icons; i++) + { + if ( ( !show_non_image) && ( wicones->entry[i].type != ET_IMAGE && wicones->entry[i].type != ET_DIR && wicones->entry[i].type != ET_PDF)) + continue; + + if ( x + wicones->case_w > xw + ww) + { + x = xw + border_size + browser_frame_width; + y += wicones -> case_h; /* Jump to next line */ + lines++; + wicones->icons_last_line = 1; + } + else + { + wicones -> icons_last_line++; + if ( wicones -> columns < wicones -> icons_last_line) + wicones -> columns++; + } + + icon_w = wicones->entry[i].preview.page ? wicones->entry[i].preview.image->fd_w : wicones->entry[i].icon->fd_w; + icon_h = wicones->entry[i].preview.page ? wicones->entry[i].preview.image->fd_h : wicones->entry[i].icon->fd_h; + + + ytext = y + thumbnail[thumbnail_size][1] + ( y_space << 1); + + /* save the case position in the structure */ + wicones->entry[i].case_pos.x1 = x - xw; + wicones->entry[i].case_pos.y1 = y - yw; + wicones->entry[i].case_pos.x2 = wicones->entry[i].case_pos.x1 + wicones->case_w; + wicones->entry[i].case_pos.y2 = wicones->entry[i].case_pos.y1 + wicones->case_h; + + if( wicones->edit && check_selected_entry( wicones, &wicones->entry[i])) + { + int16 txt_width = get_text_width( wicones->edit->top->buf); + + width = MAX( txt_width, 16); + + } + else + width = wicones->entry[i].icon_txt_w; + + + xtext = x + (( wicones->case_w - 1 - width) >> 1); + + /* save the text position in the structure */ + wicones->entry[i].txt_pos.x1 = xtext - xw - 2; + wicones->entry[i].txt_pos.y1 = ytext - 1 - yw; + wicones->entry[i].txt_pos.x2 = wicones->entry[i].txt_pos.x1 + width + 4; + wicones->entry[i].txt_pos.y2 = wicones->entry[i].txt_pos.y1 + hcell + 2; + + /* save the icon position in the structure */ + wicones->entry[i].icn_pos.x1 = ( x + (( wicones->case_w - icon_w) >> 1)) - xw; + wicones->entry[i].icn_pos.y1 = ( y + y_space + (( thumbnail[thumbnail_size][1] - icon_h) >> 1) + 1) - yw; + wicones->entry[i].icn_pos.x2 = wicones->entry[i].icn_pos.x1 + icon_w - 1; + wicones->entry[i].icn_pos.y2 = wicones->entry[i].txt_pos.y1; + + x += wicones->case_w; + } + + win -> ypos_max = lines; + win -> xpos_max = wicones->columns; + +} + + +/*==================================================================================* + * WinCatalog_Redraw: * + * redraw event for the WINDOW *win. * + *----------------------------------------------------------------------------------* + * input: * + * win -> Pointer to the target window * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +static void WinCatalog_Redraw( WINDOW *wind) +{ + int16 icon_w, icon_h, i, x, y, xtext, ytext, pxy[4], lines = 0, extent[10]; + RECT16 dst_rect; + WINDICON *wicones = (WINDICON *)DataSearch( wind, WD_ICON); + + WindGet( wind, WF_WORKXYWH, &xw, &yw, &ww, &hw); + + wicones -> columns = 0; + wicones -> icons_last_line = 0; + + if( browser_frame_width) /* browser active ? */ + { + pxy[0] = xw; + pxy[1] = yw; + pxy[2] = pxy[0] + browser_frame_width; + pxy[3] = pxy[1] + hw - 1; + + /* clean browser frame */ + vsf_color( wind->graf.handle, WHITE); + v_bar( wind->graf.handle, pxy); + + wicones -> border_position[0] = browser_frame_width; + wicones -> border_position[1] = browser_frame_width + border_size; + + + /* Draw the 1st frame ( navigation folder) */ + y = 0 - ( ( int16)wicones -> ypos * wicones -> h_u); + + for ( i = 0 ; i < wicones->nbr_child; i++) + { + wicones->root[i].arrow_position.x1 = 3; + wicones->root[i].arrow_position.y1 = y + 3; + wicones->root[i].arrow_position.x2 = wicones->root[i].arrow_position.x1 + 11; + wicones->root[i].arrow_position.y2 = wicones->root[i].arrow_position.y1 + 11; + + wicones->root[i].icon_position.x1 = 15; + wicones->root[i].icon_position.y1 = y + 1; + wicones->root[i].icon_position.x2 = wicones->root[i].icon_position.x1 + 15 + x_space + wicones->root[i].icon_txt_w; + wicones->root[i].icon_position.y2 = wicones->root[i].icon_position.y1 + 15; + + draw_mini_entry( wind, wicones->mini_selected, &wicones->root[i], xw, yw, hw); + + lines++; + y += wicones -> h_u; + + dum = draw_mini_entry_child( wind, wicones->mini_selected, &wicones->root[i], 15, y, xw, yw, hw); + + y += ( dum * wicones -> h_u); + + lines += dum; + } + + wicones -> ypos_max = lines; + + /* Look if we need a frame slider */ + if( ( wicones -> ypos_max * wicones -> h_u) >= hw) + { + if ( draw_frame_slider) + { + frame_slider_root->ob_x = xw + browser_frame_width - 15; + frame_slider_root->ob_y = yw + 2; + frame_slider_root->ob_height = hw - 3; + frame_slider_root[SLIDERS_BACK].ob_height = hw - 31; + frame_slider_root[SLIDERS_UP].ob_y = frame_slider_root->ob_height - 31; + frame_slider_root[SLIDERS_DOWN].ob_y = frame_slider_root->ob_height - 15; + + calc_mini_entry_slider( wicones, frame_slider_root); + objc_draw( frame_slider_root, SLIDERS_BOX, 2, clip.g_x, clip.g_y, clip.g_w, clip.g_h); + } + + need_frame_slider = 1; + } + else + need_frame_slider = 0; + + /* Draw the frame border */ + pxy[0] = pxy[2]; + vsl_color( wind->graf.handle, BLACK); + v_pline( wind->graf.handle, 2, pxy); + + pxy[0]++; + pxy[2] = pxy[0]; + vsl_color( wind->graf.handle, WHITE); + v_pline( wind->graf.handle, 2, pxy); + + pxy[0]++; + pxy[2] = pxy[0]; + vsl_color( wind->graf.handle, LWHITE); + v_pline( wind->graf.handle, 2, pxy); + + pxy[0]++; + pxy[2] = pxy[0]; + v_pline( wind->graf.handle, 2, pxy); + + pxy[0]++; + pxy[2] = pxy[0]; + vsl_color( wind->graf.handle, BLACK); + v_pline( wind->graf.handle, 2, pxy); + + pxy[0]++; + + /* Draw the 2nd frame ( the file) */ + pxy[2] = pxy[0] + ww - ( browser_frame_width + border_size) - 1; + vsf_color( wind->graf.handle, WHITE); + v_bar( wind->graf.handle, pxy); + + pxy[3] = yw; + v_pline( wind->graf.handle, 2, pxy); + pxy[0] = xw; + pxy[2] = pxy[0] + browser_frame_width; + v_pline( wind->graf.handle, 2, pxy); + } + else + { + /* clean browser frame */ + pxy[0] = xw; + pxy[1] = yw; + pxy[2] = pxy[0] + ww - 1; + pxy[3] = pxy[1] + hw - 1; + + vsf_color( wind->graf.handle, WHITE); + v_bar( wind->graf.handle, pxy); + + /* Draw a horizontal line at the window top */ + pxy[3] = pxy[1]; + vsl_color( wind->graf.handle, BLACK); + v_pline( wind->graf.handle, 2, pxy); + } + +// yw++; +// hw--; + + /*----------------------------------------------------------------------*/ + /* MAKE THE FIRST PASS */ + /* WE DRAW ONLY ALL THE ICONS BUT NOT THE TEXT OF THE SELECTED'S ONE */ + /* IF WE DRAW ALL THE TEXTS NOW, THE MULTILINES TEXT AREN'T VISIBLE */ + /*----------------------------------------------------------------------*/ + + /* Draw the folder's content */ + x = xw + border_size + browser_frame_width; + y = yw - ( ( int16)wind->ypos * wicones -> case_h); + lines = 1; + + for ( i = 0 ; i < wicones->nbr_icons; i++) + { + if ( ( !show_non_image) && ( wicones->entry[i].type != ET_IMAGE && wicones->entry[i].type != ET_DIR && wicones->entry[i].type != ET_PDF)) + continue; + + if ( x + wicones->case_w > xw + ww) + { + x = xw + border_size + browser_frame_width; + y += wicones -> case_h; /* Jump to next line */ + lines++; + wicones->icons_last_line = 1; + } + else + { + wicones -> icons_last_line++; + + if ( wicones -> columns < wicones -> icons_last_line) + wicones -> columns++; + } + + icon_w = wicones->entry[i].preview.page ? wicones->entry[i].preview.image->fd_w : wicones->entry[i].icon->fd_w; + icon_h = wicones->entry[i].preview.page ? wicones->entry[i].preview.image->fd_h : wicones->entry[i].icon->fd_h; + + dst_rect.x1 = x + (( wicones->case_w - icon_w) >> 1); + dst_rect.y1 = y + y_space + (( thumbnail[thumbnail_size][1] - icon_h) >> 1) + 1; + dst_rect.x2 = dst_rect.x1 + icon_w - 1; + dst_rect.y2 = dst_rect.y1 + icon_h - 1; + + /* save the case position in the structure */ + wicones->entry[i].case_pos.x1 = x - xw; + wicones->entry[i].case_pos.y1 = y - yw; + wicones->entry[i].case_pos.x2 = wicones->entry[i].case_pos.x1 + wicones->case_w; + wicones->entry[i].case_pos.y2 = wicones->entry[i].case_pos.y1 + wicones->case_h; + + xtext = x + (( wicones->case_w - 1 - wicones->entry[i].icon_txt_w) >> 1); + ytext = y + thumbnail[thumbnail_size][1] + y_space + y_space; + + /* save the text position in the structure */ + wicones->entry[i].txt_pos.x1 = xtext - xw - 2; + wicones->entry[i].txt_pos.y1 = ytext - 1 - yw; + wicones->entry[i].txt_pos.x2 = wicones->entry[i].txt_pos.x1 + wicones->entry[i].icon_txt_w + 4; + wicones->entry[i].txt_pos.y2 = wicones->entry[i].txt_pos.y1 + hcell + 2; + + /* save the icon position in the structure */ + wicones->entry[i].icn_pos.x1 = dst_rect.x1 - xw; + wicones->entry[i].icn_pos.y1 = dst_rect.y1 - yw; + wicones->entry[i].icn_pos.x2 = wicones->entry[i].icn_pos.x1 + icon_w - 1; + wicones->entry[i].icn_pos.y2 = wicones->entry[i].txt_pos.y1; + + if( y < yw || y >= yw + hw) + { + x += wicones->case_w; + continue; + } + + if ( !check_selected_entry( wicones, &wicones->entry[i])) + { + draw_icon( wind->graf.handle, &wicones->entry[i], FALSE, &dst_rect); + draw_text( wind->graf.handle, xtext, ytext, BLACK, wicones->entry[i].name_shown); + vsl_color( wind->graf.handle, LWHITE); + } + else + { + draw_icon( wind->graf.handle, &wicones->entry[i], TRUE, &dst_rect); + } + + /* Draw the case 'contour' */ + pxy[1] = y + 1; + pxy[3] = y + wicones->case_h - 2; + pxy[0] = x + 1; + pxy[2] = x + wicones->case_w - 2; + + extent[0] = pxy[0]; + extent[1] = pxy[1]; + extent[2] = pxy[0]; + extent[3] = pxy[3]; + extent[4] = pxy[2]; + extent[5] = pxy[3]; + extent[6] = pxy[2]; + extent[7] = pxy[1]; + extent[8] = pxy[0]; + extent[9] = pxy[1]; + + v_pline( wind->graf.handle, 5, extent); + vsl_color( wind->graf.handle, BLACK); + + +/* if ( !check_selected_entry( wicones, &wicones->entry[i])) + { + draw_icon( wind->graf.handle, &wicones->entry[i], FALSE, &dst_rect); + draw_text( wind->graf.handle, xtext, ytext, BLACK, wicones->entry[i].name_shown); + } + else + { + pxy[1] = y + 1; + pxy[3] = y + wicones->case_h - 2; + pxy[0] = x + 1; + pxy[2] = x + wicones->case_w - 2; + + extent[0] = pxy[0]; + extent[1] = pxy[1]; + extent[2] = pxy[0]; + extent[3] = pxy[3]; + extent[4] = pxy[2]; + extent[5] = pxy[3]; + extent[6] = pxy[2]; + extent[7] = pxy[1]; + extent[8] = pxy[0]; + extent[9] = pxy[1]; + + v_pline( wind->graf.handle, 5, extent); + + draw_icon( wind->graf.handle, &wicones->entry[i], TRUE, &dst_rect); + } +*/ + + if ( show_size) + { + if ( !S_ISDIR( wicones->entry[i].stat.st_mode)) + { + int16 size_x_pos = x + (( wicones->case_w - 1 - get_text_width( wicones->entry[i].size))>> 1); + draw_text( wind->graf.handle, size_x_pos, ytext + y_space + hcell, LBLACK, wicones->entry[i].size); + } + } + + x += wicones->case_w; + } + + + /*----------------------------------------------------------------------*/ + /* MAKE THE SECOND PASS */ + /* WE DRAW THE TEXT OF THE SELECTED'S ICON AND THE ICONS IN EDIT MODE */ + /*----------------------------------------------------------------------*/ + + /* Draw the folder's content */ + x = xw + border_size + browser_frame_width; + y = yw - ( ( int16)wind->ypos * wicones -> case_h); + + + for ( i = 0 ; i < wicones->nbr_icons; i++) + { + if ( ( !show_non_image) && ( wicones->entry[i].type != ET_IMAGE && wicones->entry[i].type != ET_DIR && wicones->entry[i].type != ET_PDF)) + continue; + + if ( x + wicones->case_w > xw + ww) + { + x = xw + border_size + browser_frame_width; + y += wicones -> case_h; /* Jump to next line */ + } + + if( y < yw || y >= yw + hw) + { + x += wicones->case_w; + continue; + } + + ytext = y + thumbnail[thumbnail_size][1] + ( y_space << 1); + + if ( check_selected_entry( wicones, &wicones->entry[i])) /* Look if the icon is selected */ + { + pxy[1] = wicones->entry[i].txt_pos.y1 + yw; + pxy[3] = wicones->entry[i].txt_pos.y2 + yw; + + if( wicones->edit) + { + int16 hc, xc; + int16 txt_width = get_text_width( wicones->edit->top->buf); + int16 width = MAX( txt_width, 16); + + xtext = x + (( wicones->case_w - 1 - txt_width) >> 1); + + pxy[0] = x + (( wicones->case_w - 1 - width) >> 1) - 2; + pxy[2] = pxy[0] + width + 4; + vsf_color( wind->graf.handle, LWHITE); + v_bar( wind->graf.handle, pxy); + + extent[0] = pxy[0]; + extent[1] = pxy[1]; + extent[2] = pxy[0]; + extent[3] = pxy[3]; + extent[4] = pxy[2]; + extent[5] = pxy[3]; + extent[6] = pxy[2]; + extent[7] = pxy[1]; + extent[8] = pxy[0]; + extent[9] = pxy[1]; + + v_pline( wind->graf.handle, 5, extent); + + draw_text( wind->graf.handle, xtext, ytext, BLACK, wicones->edit->top->buf); + + cursor_position( wind, &xc, &dum, &dum, &hc); + + pxy[0] += 3 + xc - xw; + pxy[2] = pxy[0]; + pxy[1] = ytext + 1; + pxy[3] = pxy[1] + hc - 2; + + v_pline( wind->graf.handle, 2, pxy); + + /* save the text position in the structure */ + wicones->entry[i].txt_pos.x1 = xtext - 2 - xw; + wicones->entry[i].txt_pos.y1 = ytext - 1 - yw; + wicones->entry[i].txt_pos.x2 = wicones->entry[i].txt_pos.x1 + width + 4; + wicones->entry[i].txt_pos.y2 = wicones->entry[i].txt_pos.y1 + hcell + 2; + } + else + { + xtext = x + (( wicones->case_w - 1 - wicones->entry[i].icon_txt_w)>> 1); + + pxy[0] = xtext - 1; + pxy[2] = pxy[0] + wicones->entry[i].icon_txt_w + 2; + + vsf_color( wind->graf.handle, LBLACK); + v_bar( wind->graf.handle, pxy); + + draw_text( wind->graf.handle, xtext, ytext, WHITE, wicones->entry[i].name_shown); + } + } + + x += wicones->case_w; + } + + + wind -> ypos_max = lines; + wind -> xpos_max = wicones->columns; + + WindSlider ( wind, VSLIDER); +} + + + +/*==================================================================================* + * void WinCatalog_filelist_redraw: * + * Deselect all the icons, exit edition mode and Redraw the entire window... * + * usefull, for exemple, after a WM_FULLED message. * + * We delete also the timer if exist. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void WinCatalog_filelist_redraw( void) +{ + WINDICON *wicones = (WINDICON *)DataSearch( win_catalog, WD_ICON); + + if ( wicones->edit) + exit_edit_mode( win_catalog, wicones->first_selected); + + if ( wicones->first_selected) + { + while ( wicones->first_selected) + remove_selected_entry( wicones, wicones->first_selected); + } + + win_catalog->ypos = 0; + + WindGet ( win_catalog, WF_WORKXYWH, &xw, &yw, &ww, &hw); + draw_page( win_catalog, xw + browser_frame_width + border_size , yw, ww - ( browser_frame_width + border_size), hw); + WindMakePreview( win_catalog); + +} + +/*==================================================================================* + * void WinCatalog_set_thumbnails_size: * + * Set new thumbnails's size, resize the window if necessary and redraw it * + *----------------------------------------------------------------------------------* + * input: * + * win -> Pointer to the target window * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void WinCatalog_set_thumbnails_size( WINDOW *win) +{ + int16 x, y, w, h; + WINDICON *wicones = (WINDICON *)DataSearch( win_catalog, WD_ICON); + + Entry *entry = wicones->first_selected; + + WindGet ( win, WF_WORKXYWH, &xw, &yw, &ww, &hw); + + if ( wicones->edit) + exit_edit_mode( win, wicones->first_selected); + + wicones -> case_w = thumbnail[thumbnail_size][0] + ( x_space << 1); + wicones -> case_h = thumbnail[thumbnail_size][1] + hcell + y_space + y_space + y_space;; + + if ( show_size) + wicones -> case_h += hcell + y_space; + + WindCalc( WC_BORDER, win, xw, yw, wicones->case_w + border_size + browser_frame_width, wicones->case_h, &x, &y, &w, &h); + + win -> h_min = h; + win -> w_min = w; + win -> h_u = wicones -> case_h; + win -> w_u = wicones -> case_w; + win -> ypos = 0; + + ( void)scan_dir( win, wicones->directory); + wicones->first_selected = entry; + + if( ( w > ww) && ( h > hw)) + { + wind_set( win->handle, WF_CURRXYWH, x, y, win -> w_min, win -> h_min); + WindGet ( win, WF_WORKXYWH, &xw, &yw, &ww, &hw); + } + else if ( w > ww) + { + WindGet( win, WF_CURRXYWH, &dum, &dum, &dum, &h); + wind_set( win->handle, WF_CURRXYWH, x, y, w, h); + WindGet ( win, WF_WORKXYWH, &xw, &yw, &ww, &hw); + } + else if ( h > hw) + { + WindGet( win, WF_CURRXYWH, &dum, &dum, &w, &dum); + wind_set( win->handle, WF_CURRXYWH, x, y, w, h); + WindGet ( win, WF_WORKXYWH, &xw, &yw, &ww, &hw); + } + + draw_page( win, xw + browser_frame_width + border_size , yw + 1, ww - ( browser_frame_width + border_size), hw - 1); + + WindMakePreview( win); +} diff --git a/sources/z-tools/trunk/zview/catalog/catalog.h b/sources/z-tools/trunk/zview/catalog/catalog.h new file mode 100644 index 0000000..a4b6eb0 --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog.h @@ -0,0 +1,19 @@ +extern int WinCatalog( void); +extern void WinCatalog_Close( WINDOW *win); +extern void WinCatalog_Refresh( WINDOW *wind); +extern void WindMakePreview( WINDOW *win); +extern int WindMakePreview_needed( WINDOW *win); +extern void WinCatalog_filelist_redraw( void); +extern void WinCatalog_set_thumbnails_size( WINDOW *win); + +extern int16 old_browser_size; +extern int16 old_preview_area_size; +extern int16 x_space; +extern int16 y_space; +extern int16 hcell; +extern int16 border_size; +extern int16 old_border_size; +extern int16 need_frame_slider; +extern int16 draw_frame_slider; +extern OBJECT *frame_slider_root; + diff --git a/sources/z-tools/trunk/zview/catalog/catalog_entry.c b/sources/z-tools/trunk/zview/catalog/catalog_entry.c new file mode 100644 index 0000000..3134c05 --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_entry.c @@ -0,0 +1,91 @@ +#include "../general.h" + +/* Prototype */ +void add_selected_entry( WINDICON *wicones, Entry *entry); +void remove_selected_entry( WINDICON *wicones, Entry *entry); +boolean check_selected_entry( WINDICON *wicones, Entry *entry); +void remove_all_selected_entry( WINDICON *wicones); +int16 return_entry_nbr( WINDICON *wicones, Entry *entry); + + +void add_selected_entry( WINDICON *wicones, Entry *entry) +{ + Entry *ptr = wicones->first_selected; + + if ( ptr == NULL) + wicones->first_selected = entry; + else + { + while( ptr->next_selected) + ptr = ptr->next_selected; + + ptr->next_selected = entry; + } +} + + +void remove_selected_entry( WINDICON *wicones, Entry *entry) +{ + Entry* ptr = wicones->first_selected; + + if ( ptr == entry) + wicones->first_selected = ptr->next_selected; + else + { + while ( ptr->next_selected) + { + if ( ptr->next_selected == entry) + break; + else + ptr = ptr->next_selected; + } + + if ( ptr->next_selected == entry) + ptr->next_selected = ptr->next_selected->next_selected; + } + + entry->next_selected = NULL; +} + + +boolean check_selected_entry( WINDICON *wicones, Entry *entry) +{ + Entry* ptr = wicones->first_selected; + + if ( ptr == NULL) + return FALSE; + + if ( ptr == entry) + return TRUE; + + while ( ptr->next_selected) + { + if ( ptr->next_selected == entry) + return TRUE; + else + ptr = ptr->next_selected; + } + return FALSE; +} + + +void remove_all_selected_entry( WINDICON *wicones) +{ + while( wicones->first_selected) + wicones->first_selected = wicones->first_selected->next_selected; +} + + +int16 return_entry_nbr( WINDICON *wicones, Entry *entry) +{ + int16 i; + + if ( entry == NULL) + return ( -1); + + for ( i = 0 ; i < wicones->nbr_icons; i++) + if ( entry == &wicones->entry[i]) + break; + + return i; +} diff --git a/sources/z-tools/trunk/zview/catalog/catalog_entry.h b/sources/z-tools/trunk/zview/catalog/catalog_entry.h new file mode 100644 index 0000000..c8f2f9d --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_entry.h @@ -0,0 +1,6 @@ +extern void add_selected_entry( WINDICON *wicones, Entry *entry); +extern void remove_selected_entry( WINDICON *wicones, Entry *entry); +extern boolean check_selected_entry( WINDICON *wicones, Entry *entry); +extern void remove_all_selected_entry( WINDICON *wicones); +extern int16 return_entry_nbr( WINDICON *wicones, Entry *entry); + diff --git a/sources/z-tools/trunk/zview/catalog/catalog_iconify.c b/sources/z-tools/trunk/zview/catalog/catalog_iconify.c new file mode 100644 index 0000000..9a4c344 --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_iconify.c @@ -0,0 +1,38 @@ +#include "../general.h" + + +/*==================================================================================* + * void catalog_iconify: * + * Function changes the window's name when the catalog window is iconified. * + *----------------------------------------------------------------------------------* + * input: * + * win -> the window to handle. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void catalog_iconify( WINDOW *win) +{ + WindSetStr( win, WF_NAME, "Zview"); +} + + +/*==================================================================================* + * void catalog_uniconify: * + * Function restore the window's name when the catalog window is uniconified. * + *----------------------------------------------------------------------------------* + * input: * + * win -> the window to handle. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void catalog_uniconify( WINDOW *win) +{ + WINDICON *wicones = ( WINDICON *)DataSearch( win, WD_ICON); + + WindSetStr( win, WF_NAME, wicones->directory); +} + diff --git a/sources/z-tools/trunk/zview/catalog/catalog_iconify.h b/sources/z-tools/trunk/zview/catalog/catalog_iconify.h new file mode 100644 index 0000000..0a57bf5 --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_iconify.h @@ -0,0 +1,3 @@ +extern void catalog_iconify( WINDOW *win); +extern void catalog_uniconify( WINDOW *win); + diff --git a/sources/z-tools/trunk/zview/catalog/catalog_icons.c b/sources/z-tools/trunk/zview/catalog/catalog_icons.c new file mode 100644 index 0000000..d7b77c4 --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_icons.c @@ -0,0 +1,416 @@ +#include "../general.h" +#include "../ztext.h" +#include "../mfdb.h" +#include "catalog_entry.h" +#include "../plugins.h" + +/* Global variable */ +IMAGE icon_image; +IMAGE icon_file; +IMAGE icon_folder; +IMAGE icon_prg; +IMAGE icon_pdf; + +IMAGE small_icon; + +MFDB mini_hdd = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_folder = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_big = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_big_on = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_small = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_small_on = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_forward = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_forward_on = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_back = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_back_on = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_up = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_up_on = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_reload = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_reload_on = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_printer = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_printer_on = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_info = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_info_on = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_find = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_find_on = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_delete = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_delete_on = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_fullscreen = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_fullscreen_on = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_open = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_open_on = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_save = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; +MFDB mini_save_on = { NULL, 16, 16, 1, 0, 1, 0, 0, 0}; + +/* local variable */ +static uint16 initialised = 0; + +/* extern variable */ +extern int16 draw_frame_slider; + +/* Prototype */ +void icons_exit(void); +int16 icons_init( void); +void set_entry_icon( Entry *entry); +void redraw_icon( WINDOW *win, Entry *entry); +void draw_icon( int16 handle, Entry *entry, boolean selected, RECT16 *dst_rect); +boolean icon_is_visible( Entry *entry, int16 window_height); +int16 redraw_icon_border( WINDOW *win, Entry *entry, int16 selected); + + +/*==================================================================================* + * void icons_exit: * + * Free the memories previously allocated for the icon and pattern. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void icons_exit(void) +{ + if ( initialised != 0) + { + ( void)delete_mfdb( small_icon.image, small_icon.page); + ( void)delete_mfdb( icon_pdf.image, icon_pdf.page); + ( void)delete_mfdb( icon_prg.image, icon_prg.page); + ( void)delete_mfdb( icon_file.image, icon_file.page); + ( void)delete_mfdb( icon_image.image, icon_image.page); + ( void)delete_mfdb( icon_folder.image, icon_folder.page); + } + initialised = 0; +} + + +/*==================================================================================* + * int16 icons_init: * + * Initializes default icons and pattern. * + * May be called any number of times. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * 0 if error else 1. * + *==================================================================================*/ + +int16 icons_init( void) +{ + uint16 *small_icon_buffer_addr; + uint32 small_icon_buffer_size; + initialised += 1; + + if ( initialised == 1) + { + icon_image.view_mode = full_size; + icon_file.view_mode = full_size; + icon_folder.view_mode = full_size; + icon_prg.view_mode = full_size; + icon_pdf.view_mode = full_size; + + icon_image.progress_bar = 0; + icon_file.progress_bar = 0; + icon_folder.progress_bar = 0; + icon_prg.progress_bar = 0; + icon_pdf.progress_bar = 0; + + + small_icon.view_mode = full_size; + small_icon.progress_bar = 0; + + + if ( !pic_load( "icons\\folder.god","GOD", &icon_folder) || + !pic_load( "icons\\image.god", "GOD", &icon_image) || + !pic_load( "icons\\file.god", "GOD", &icon_file) || + !pic_load( "icons\\prg.god", "GOD", &icon_prg) || + !pic_load( "icons\\pdf.god", "GOD", &icon_pdf) || + !pic_load( "icons\\small.god", "GOD", &small_icon)) + { + icons_exit(); + return( 0); + } + } + + small_icon_buffer_addr = ( uint16*)small_icon.image[0].fd_addr; + small_icon_buffer_size = app.nplanes << 4; + + mini_hdd.fd_nplanes = app.nplanes; + mini_hdd.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_folder.fd_nplanes = app.nplanes; + mini_folder.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_big.fd_nplanes = app.nplanes; + mini_big.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_big_on.fd_nplanes = app.nplanes; + mini_big_on.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_small.fd_nplanes = app.nplanes; + mini_small.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_small_on.fd_nplanes= app.nplanes; + mini_small_on.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_forward.fd_nplanes = app.nplanes; + mini_forward.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_forward_on.fd_nplanes = app.nplanes; + mini_forward_on.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_back.fd_nplanes = app.nplanes; + mini_back.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_back_on.fd_nplanes = app.nplanes; + mini_back_on.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_up.fd_nplanes = app.nplanes; + mini_up.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_up_on.fd_nplanes = app.nplanes; + mini_up_on.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_reload.fd_nplanes = app.nplanes; + mini_reload.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_reload_on.fd_nplanes = app.nplanes; + mini_reload_on.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_printer.fd_nplanes = app.nplanes; + mini_printer.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_printer_on.fd_nplanes = app.nplanes; + mini_printer_on.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_info.fd_nplanes = app.nplanes; + mini_info.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_info_on.fd_nplanes = app.nplanes; + mini_info_on.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_find.fd_nplanes = app.nplanes; + mini_find.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_find_on.fd_nplanes = app.nplanes; + mini_find_on.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_delete.fd_nplanes = app.nplanes; + mini_delete.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_delete_on.fd_nplanes= app.nplanes; + mini_delete_on.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_fullscreen.fd_nplanes= app.nplanes; + mini_fullscreen.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_fullscreen_on.fd_nplanes= app.nplanes; + mini_fullscreen_on.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_open.fd_nplanes = app.nplanes; + mini_open.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_open_on.fd_nplanes = app.nplanes; + mini_open_on.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_save.fd_nplanes = app.nplanes; + mini_save.fd_addr = ( void*)small_icon_buffer_addr; + + small_icon_buffer_addr += small_icon_buffer_size; + mini_save_on.fd_nplanes = app.nplanes; + mini_save_on.fd_addr = ( void*)small_icon_buffer_addr; + + return( 1); +} + + +/*==================================================================================* + * void set_entry_icon: * + * Set the entry's icon. * + *----------------------------------------------------------------------------------* + * input: * + * entry -> pointer to the entry to set * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void set_entry_icon( Entry *entry) +{ + int16 i, j, c = 0; + char extention[4], plugin[4]; + + strcpy( extention, entry->name + strlen( entry->name) - 3); + + str2upper( extention); + + if ( S_ISDIR( entry->stat.st_mode)) + { + entry->type = ET_DIR; + entry->icon = icon_folder.image; + return; + } + + + if(( strncmp ( extention, "TTP", 3) == 0) + || ( strncmp ( extention, "TOS", 3) == 0) + || ( strncmp ( extention, "GTP", 3) == 0) + || ( strncmp ( extention, "PRG", 3) == 0) + || ( strncmp ( extention, "APP", 3) == 0)) + { + entry->type = ET_PRG; + entry->icon = &icon_prg.image[0]; + return; + } + + if( strncmp ( extention, "PDF", 3) == 0) + { + entry->type = ET_PDF; + entry->icon = &icon_pdf.image[0]; + return; + } + + + for( i = 0; i < plugins_nbr; i++, c = 0) + { + for( j = 0; j < codecs[i]->user_ext; j++) + { + plugin[0] = codecs[i]->infos[c++]; + plugin[1] = codecs[i]->infos[c++]; + plugin[2] = codecs[i]->infos[c++]; + + if( strncmp ( extention, plugin, 3) == 0) + { + entry->type = ET_IMAGE; + entry->icon = &icon_image.image[0]; + return; + } + } + } + + entry->type = ET_FILE; + entry->icon = &icon_file.image[0]; +} + + +/*==================================================================================* + * void redraw_icon: * + * send a redraw event at the entry's position. * + *----------------------------------------------------------------------------------* + * input: * + * win -> the target window. * + * entry -> the icon to be redraw. * + *----------------------------------------------------------------------------------* + * returns: - * + *==================================================================================*/ + +void redraw_icon( WINDOW *win, Entry *entry) +{ + int16 xw, yw, hw, x, y, w, h; + + WindGet ( win, WF_WORKXYWH, &xw, &yw, &w, &hw); + + x = entry->case_pos.x1 - 2; + y = entry->case_pos.y1 - 1; + w = entry->case_pos.x2 - x + 4; + h = entry->case_pos.y2 - y + 2; + + x += xw; + y += yw; + + if (( y + entry->case_pos.y2 > yw) && ( y < yw + hw)) + { + draw_frame_slider = 0; + draw_page( win, x, y, w, h); + draw_frame_slider = 1; + } +} + + +/*==================================================================================* + * void draw_icon: * + * draw a icon. * + *----------------------------------------------------------------------------------* + * input: * + * handle -> the target VDI handle. * + * entry -> the icon entry to be draw. * + * selected -> the icon is selected or not. * + * dst_rect -> Destination Bitmap for the icon. * + *----------------------------------------------------------------------------------* + * returns: - * + *==================================================================================*/ + +void draw_icon( int16 handle, Entry *entry, boolean selected, RECT16 *dst_rect) +{ + MFDB *icon = ( entry->preview.page ? &entry->preview.image[0] : entry->icon), + screen = {0}; + int16 xy[8], color[2] = { BLACK, WHITE}; + + + /* Source Rectangle */ + xy[0] = 0; + xy[1] = 0; + xy[2] = icon->fd_w - 1; + xy[3] = icon->fd_h - 1; + + /* destination Rectangle */ + xy[4] = dst_rect->x1; + xy[5] = dst_rect->y1; + xy[6] = dst_rect->x2; + xy[7] = dst_rect->y2; + + + if ( icon->fd_nplanes == 1) + vrt_cpyfm( handle, MD_REPLACE, xy, icon, &screen, color); + else + vro_cpyfm( handle, S_ONLY, xy, icon, &screen); +} + + +/*==================================================================================* + * boolean icon_is_visible: * + * check if the icon is visible. * + *----------------------------------------------------------------------------------* + * input: * + * entry -> the icon entry to be checked. * + * window_height -> the window height. * + *----------------------------------------------------------------------------------* + * returns: TRUE if visible else FALSE. * + *==================================================================================*/ + +boolean icon_is_visible( Entry *entry, int16 window_height) +{ + if ( ( entry->case_pos.y2 > 1) && ( entry->case_pos.y1 < window_height)) + return TRUE; + + return FALSE; +} + + diff --git a/sources/z-tools/trunk/zview/catalog/catalog_icons.h b/sources/z-tools/trunk/zview/catalog/catalog_icons.h new file mode 100644 index 0000000..4d0efe7 --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_icons.h @@ -0,0 +1,43 @@ +extern int16 icons_init( void); +extern void icons_exit(void); +extern void set_entry_icon( Entry *entry); +extern void redraw_icon( WINDOW *wind, Entry *entry); +extern void draw_icon( int16 handle, Entry *entry, boolean selected, RECT16 *dst_rect); +extern boolean icon_is_visible( Entry *entry, int16 window_height); + +extern IMAGE icon_image; +extern IMAGE icon_file; +extern IMAGE icon_folder; +extern IMAGE icon_tos; +extern IMAGE icon_pdf; + +extern MFDB mini_hdd; +extern MFDB mini_folder; +extern MFDB mini_big; +extern MFDB mini_big_on; +extern MFDB mini_small; +extern MFDB mini_small_on; +extern MFDB mini_forward; +extern MFDB mini_forward_on; +extern MFDB mini_back; +extern MFDB mini_back_on; +extern MFDB mini_up; +extern MFDB mini_up_on; +extern MFDB mini_reload; +extern MFDB mini_reload_on; +extern MFDB mini_printer; +extern MFDB mini_printer_on; +extern MFDB mini_info; +extern MFDB mini_info_on; +extern MFDB mini_find; +extern MFDB mini_find_on; +extern MFDB mini_delete; +extern MFDB mini_delete_on; +extern MFDB mini_fullscreen; +extern MFDB mini_fullscreen_on; +extern MFDB mini_open; +extern MFDB mini_open_on; +extern MFDB mini_save; +extern MFDB mini_save_on; + + diff --git a/sources/z-tools/trunk/zview/catalog/catalog_keyb.c b/sources/z-tools/trunk/zview/catalog/catalog_keyb.c new file mode 100644 index 0000000..c231c41 --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_keyb.c @@ -0,0 +1,465 @@ +#include "../general.h" +#include "../prefs.h" +#include "../zedit/zedit.h" +#include "../file/file.h" +#include "../file/count.h" +#include "../file/delete.h" +#include "../file/rename.h" +#include "../ztext.h" +#include "catalog_entry.h" +#include "catalog_mini_entry.h" +#include "catalog_icons.h" +#include "../pic_load.h" +#include "../winimg.h" +#include "catalog.h" +#include "../mfdb.h" +#include "../custom_font.h" + +/* local constant */ +static const char allowed_char[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ‚Šˆ‰‡€¡‹Œ—–£… ƒ„†‘”¤’¥0123456789 &\"'(Ý!)-_`œ^[]*{},?;.:/=+%#|@~<>"; +char fullname[MAX_PATH+MAXNAMLEN]; + +/* Prototype */ +void WinCatalog_Keyb( WINDOW *win); + +// extern boolean create_icon( const char *filename, MFDB *icon, MFDB *icon_selected, MFDB *icon_mask); + +/*==================================================================================* + * void WinCatalog_Keyb: * + * this function handle the keyboard event for the main frame in the * + * catalog ( the entries). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The window to handle. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void WinCatalog_Keyb( WINDOW *win) +{ + WINDICON *wicones = (WINDICON *)DataSearch( win, WD_ICON); + Mini_Entry *old_selected; + Entry *old_entry = wicones->first_selected; + int16 res, selection, x, y, w, h, i; + char old_dir[128] = ""; + + switch ( evnt.keybd >> 8) + { + case SC_UPARW: + case SC_DWARW: + case SC_LFARW: + case SC_RTARW: + case SC_RETURN: + case SC_ENTER: + case SC_HOME: + if( wicones->first_selected) + { + if( wicones->first_selected->next_selected) + { + Entry *entry_ptr; + + while( wicones->first_selected->next_selected) + { + entry_ptr = wicones->first_selected->next_selected; + remove_selected_entry( wicones, wicones->first_selected->next_selected); + redraw_icon( win, entry_ptr); + } + return; + } + } + break; + default: + break; + } + + WindGet ( win, WF_WORKXYWH, &x, &y, &w, &h); + + if ( !wicones->edit) + { + res = selection = return_entry_nbr( wicones, wicones->first_selected); + + switch ( evnt.keybd >> 8) + { + case SC_UPARW: + if ( selection == -1) + selection = 0; + else if ( selection >= wicones->columns) + selection = selection - wicones->columns; + + goto common; + + case SC_DWARW: + if ( selection == -1) + selection = 0; + else if ( selection < wicones->nbr_icons - wicones->icons_last_line && selection + wicones->columns < wicones->nbr_icons) + selection = selection + wicones->columns; + + goto common; + + case SC_LFARW: + if ( selection == -1) + selection = 0; + else if ( selection > 0) + selection--; + + goto common; + + case SC_RTARW: + if ( selection == -1) + selection = 0; + else if ( selection < wicones->nbr_icons - 1) + selection++; + + common: + + if ( wicones->entry[selection].icn_pos.y1 < 0) + { + if ( wicones->entry[selection].icn_pos.y1 + wicones->case_h >= 0) + { + wicones->first_selected = &wicones->entry[selection]; + + if ( res >= 0) + redraw_icon( win, &wicones->entry[res]); + + snd_arrw( win, WA_UPLINE); + /* WindMakePreview( win); */ + } + else + { + while ( wicones->entry[selection].icn_pos.y1 <= 0) + { + if ( win->ypos == 0) + break; + + wicones->entry[selection].icn_pos.y1 += wicones->case_h; + win->ypos--; + } + + draw_page( win, x + browser_frame_width + border_size , y, w - ( browser_frame_width + border_size), h); + WindMakePreview( win); + goto end_case; + } + } + else if ( wicones->entry[selection].icn_pos.y2 > h) + { + if ( wicones->entry[selection].icn_pos.y2 - wicones->case_h <= h) + { + wicones->first_selected = &wicones->entry[selection]; + + snd_arrw( win, WA_DNLINE); + + if ( res >= 0) + redraw_icon( win, &wicones->entry[res]); + + redraw_icon( win, wicones->first_selected); + } + else + { + while ( wicones->entry[selection].icn_pos.y2 >= h) + { + if ( win->ypos == win->ypos_max) + break; + + wicones->entry[selection].icn_pos.y2 -= wicones->case_h; + win->ypos++; + } + draw_page( win, x + browser_frame_width + border_size , y, w - ( browser_frame_width + border_size), h); + WindMakePreview( win); + goto end_case; + } + } + else if ( res != selection) + { + wicones->first_selected = &wicones->entry[selection]; + + if ( res >= 0) + redraw_icon( win, &wicones->entry[res]); + + redraw_icon( win, wicones->first_selected); + } + + end_case: + + break; + + case SC_RETURN: + case SC_ENTER: + if( !wicones->first_selected) + break; + else if ( wicones->entry[selection].type == ET_DIR) + { + Mini_Entry *old_selected_mini_entry = wicones->mini_selected; + + wicones->mini_selected = NULL; + + if ( old_selected_mini_entry && browser_frame_width) + redraw_mini_entry( win, old_selected_mini_entry); + + strcat( wicones->directory, wicones->entry[selection].name); + ( void)scan_dir( win, wicones->directory); + WindSetStr ( win, WF_NAME, wicones->directory); + wicones->first_selected = NULL; + win->ypos = 0; + + draw_page( win, x + browser_frame_width + border_size , y, w - ( browser_frame_width + border_size), h); + WindMakePreview( win); + } + else if ( ( wicones->entry[selection].type == ET_IMAGE && wicones->entry[selection].preview.page) || wicones->entry[selection].type == ET_PDF) + { + strcpy( fullname, wicones->directory); + strcat( fullname, wicones->entry[selection].name); + WindView( fullname); + } + break; + + case SC_HOME: + if ( !dir_parent( wicones->directory, old_dir)) + break; + + old_selected = wicones->mini_selected; + wicones->mini_selected = NULL; + + if ( old_selected) + redraw_mini_entry( win, old_selected); + + ( void)scan_dir( win, wicones->directory); + + WindSetStr ( win, WF_NAME, wicones->directory); + win->ypos = 0; + + for (i = 0 ; i < wicones->nbr_icons ; i++) + if ( !strcmp( wicones->entry[i].name, old_dir)) + { + wicones->first_selected = &wicones->entry[i]; + break; + } + + WinCatalog_Refresh( win); + + if ( wicones->first_selected->txt_pos.y2 > h) + while ( wicones->first_selected->txt_pos.y2 + wicones->case_h > h) + { + wicones->first_selected->txt_pos.y2 -= wicones->case_h; + win->ypos++; + } + + draw_page( win, x + browser_frame_width + border_size , y, w - ( browser_frame_width + border_size), h); + WindMakePreview( win); + + break; + + + case SC_DEL: + if ( wicones->first_selected) + delete_entry( win); + break; + +/* case SC_F1: + { + Entry *entry_ptr = wicones->first_selected; + + while( entry_ptr) + { + zdebug( "entry = %s", entry_ptr); + entry_ptr = entry_ptr->next_selected; + } + zdebug( "---"); + } + break; + + + + case SC_F3: + { + MFDB nicon, nicon_selected, icon_mask, screen = {0}; + int16 xy[8], fvdi = 1; + + if( create_icon( "c://1.gif", &nicon, &nicon_selected, &icon_mask)) + { + int16 color[2], blitmode; + + xy[0] = 0; + xy[1] = 0; + xy[2] = nicon.fd_w - 1; + xy[3] = nicon.fd_h - 1; + + xy[4] = 40; + xy[5] = 40; + xy[6] += nicon.fd_w - 1; + xy[7] += nicon.fd_h - 1; + + vro_cpyfm( app.handle, S_ONLY, xy, &nicon, &screen); + + xy[4] += nicon.fd_w - 1; + xy[6] += nicon.fd_h - 1; + + vro_cpyfm( app.handle, S_ONLY, xy, &nicon_selected, &screen); + + xy[4] += nicon.fd_w - 1; + xy[6] += nicon.fd_h - 1; + + color[0] = WHITE; + color[1] = BLACK; + + vrt_cpyfm( app.handle, MD_REPLACE, xy, &icon_mask, &screen, color); + + + xy[4] += nicon.fd_w - 1; + xy[6] += nicon.fd_h - 1; + + blitmode = app.nplanes > 8 ? S_AND_D : S_OR_D; + + if( fvdi) + { + color[0] = WHITE; + color[1] = BLACK; + vrt_cpyfm( app.handle, 4, xy, &icon_mask, &screen, color); + } + else + { + color[0] = BLACK; + color[1] = WHITE; + vrt_cpyfm( app.handle, MD_TRANS, xy, &icon_mask, &screen, color); + } + + vro_cpyfm( app.handle, S_OR_D, xy, &nicon, &screen); + + delete_mfdb( &nicon); + delete_mfdb( &nicon_selected); + delete_mfdb( &icon_mask); + + } + else + zdebug("error"); + } + break; + + case SC_F4: + { + int16 mode = mode2logic( T_TRANSPARENT); + + zdebug( "%i", mode); + } + */ + default: + break; + } + + if( !( wicones->first_selected)) + { + menu_ienable( get_tree( MENU_BAR), MENU_BAR_INFORMATION, 0); + menu_ienable( get_tree( MENU_BAR), MENU_BAR_SAVE, 0); + menu_ienable( get_tree( MENU_BAR), MENU_BAR_DELETE, 0); + + if( old_entry) + { + ObjcDraw( OC_TOOLBAR, win, TOOLBAR_DELETE, 1); + ObjcDraw( OC_TOOLBAR, win, TOOLBAR_INFO, 1); + + if( old_entry->type == ET_IMAGE) + ObjcDraw( OC_TOOLBAR, win, TOOLBAR_SAVE, 1); + } + } + else + { + if( wicones->first_selected->type == ET_IMAGE) + menu_ienable( get_tree( MENU_BAR), MENU_BAR_SAVE, 1); + + menu_ienable( get_tree( MENU_BAR), MENU_BAR_DELETE, 1); + menu_ienable( get_tree( MENU_BAR), MENU_BAR_INFORMATION, 1); + + if( !old_entry) + { + if( wicones->first_selected->type == ET_IMAGE) + ObjcDraw( OC_TOOLBAR, win, TOOLBAR_SAVE, 1); + + ObjcDraw( OC_TOOLBAR, win, TOOLBAR_DELETE, 1); + ObjcDraw( OC_TOOLBAR, win, TOOLBAR_INFO, 1); + } + else if(( wicones->first_selected->type != old_entry->type) && ( wicones->first_selected->type == ET_IMAGE || old_entry->type == ET_IMAGE)) + ObjcDraw( OC_TOOLBAR, win, TOOLBAR_SAVE, 1); + } + } + else if ( wicones->edit) + { + Mini_Entry *mini_ptr = NULL; + int16 c = evnt.keybd & 0x00FF; + int16 max_len = ( int16)Dpathconf( wicones->directory, 3); + + switch( evnt.keybd >> 8) + { + case SC_RETURN: + case SC_ENTER: + if ( wicones->first_selected->type == ET_DIR) + { + strcpy( fullname, wicones->directory); + strcat( fullname, wicones->first_selected->name); + strcat( fullname, "\\"); + } + + if( !rename_entry( win, wicones->edit->top->buf)) + { + exit_edit_mode( win, wicones->first_selected); + break; + } + + strcpy( wicones->first_selected->name_shown, wicones->first_selected->name); + + if (( wicones->first_selected->icon_txt_w = get_text_width( wicones->first_selected->name_shown)) >= wicones->case_w - 4) + wicones->first_selected->icon_txt_w = name_shorter( wicones->case_w - 6, wicones->first_selected->name_shown); + + exit_edit_mode( win, wicones->first_selected); + + // Now, we change the name of the dir in the file browser if necessary( left frame). + if ( wicones->first_selected->type != ET_DIR) + break; + + if (( mini_ptr = find_mini_entry_by_path( wicones, fullname)) != NULL) + { + strcpy( mini_ptr->foldername, mini_ptr->parent->foldername); + strcat( mini_ptr->foldername, wicones->first_selected->name); + strcat( mini_ptr->foldername, "\\"); + strcpy( mini_ptr->name, wicones->first_selected->name); + mini_ptr->icon_txt_w = get_text_width( mini_ptr->name); + mini_ptr->icon_position.x2 = mini_ptr->icon_position.x1 + 15 + x_space + mini_ptr->icon_txt_w; + + if( browser_frame_width) + redraw_mini_entry( win, mini_ptr); + } + + break; + + case SC_LFARW: + if ( curs_left( wicones->edit)) + edit_icon_txt( win, wicones->first_selected); + break; + + case SC_RTARW: + if ( curs_right( wicones->edit)) + edit_icon_txt( win, wicones->first_selected); + break; + + case SC_UPARW: + case SC_DWARW: + case SC_ESC: + exit_edit_mode( win, wicones->first_selected); + break; + + case SC_DEL: + curs_right( wicones->edit); + case SC_BACK: + if ( char_del( wicones->edit) != 0) + edit_icon_txt( win, wicones->first_selected); + break; + + default: + if (( wicones->edit->top->len < max_len || wicones->edit->top->len > 10000) && strchr( allowed_char, c)) + { + char_put ( wicones->edit, c); + edit_icon_txt( win, wicones->first_selected); + } + break; + } + } +} diff --git a/sources/z-tools/trunk/zview/catalog/catalog_keyb.h b/sources/z-tools/trunk/zview/catalog/catalog_keyb.h new file mode 100644 index 0000000..46073f8 --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_keyb.h @@ -0,0 +1,2 @@ +extern void WinCatalog_Keyb( WINDOW *win); + diff --git a/sources/z-tools/trunk/zview/catalog/catalog_mini_entry.c b/sources/z-tools/trunk/zview/catalog/catalog_mini_entry.c new file mode 100644 index 0000000..5ff9b5c --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_mini_entry.c @@ -0,0 +1,570 @@ +#include "../general.h" +#include "../prefs.h" +#include "../custom_font.h" +#include "catalog_icons.h" +#include "catalog_entry.h" +#include "../file/file.h" +#include "catalog.h" + +/* Prototype */ +void delete_mini_entry_child( Mini_Entry *entry); +void redraw_mini_entry( WINDOW *win, Mini_Entry *entry); +void draw_mini_entry( WINDOW *win, Mini_Entry *selected, Mini_Entry *entry, int16 xw, int16 yw, int16 hw); +int16 draw_mini_entry_child( WINDOW *win, Mini_Entry *selected, Mini_Entry *entry, int16 x, int16 y, int16 xw, int16 yw, int16 hw); +int find_mini_entry_child_on_mouse( WINDOW *win, Mini_Entry *entry, int16 mouse_x, int16 mouse_y); +Mini_Entry *find_mini_entry_child_by_path( Mini_Entry *parent, char *path); +Mini_Entry *find_mini_entry_by_path( WINDICON *wicones, char *path); +void calc_mini_entry_slider( WINDICON *wicones, OBJECT *slider_root); + +/* extern variable */ +extern int16 need_frame_slider; + + +/*==================================================================================* + * delete_mini_entry_child: * + * Free the memory used by all the 'child' items of a mini entry and put the * + * parent 'nbr_child' counter to zero. * + *----------------------------------------------------------------------------------* + * input: * + * entry = the entry parent. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ + +void delete_mini_entry_child( Mini_Entry *entry) +{ + int i; + + /* if nothing to do, end the function */ + if( entry->child == NULL) + return; + + /* make a loop to see if the childs mini entries have child, if it's true, delete it */ + for ( i = 0; i < entry->nbr_child ; i++) + { + if ( entry->child[i].nbr_child) + delete_mini_entry_child( &entry->child[i]); + } + + /* Free the memory and put the counter to zero */ + gfree( entry->child); + entry->child = NULL; + entry->nbr_child = 0; +} + + +/*==================================================================================* + * redraw_mini_entry: * + * Send a redraw event for a mini_entry in the WINDOW *win. * + *----------------------------------------------------------------------------------* + * input: * + * win = the target window * + * entry = the icon to be redraw * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ + +void redraw_mini_entry( WINDOW *win, Mini_Entry *entry) +{ + int16 xw, yw, hw, x, y, w, h; + + WindGet ( win, WF_WORKXYWH, &xw, &yw, &w, &hw); + + x = entry->arrow_position.x1; + y = entry->icon_position.y1; + w = entry->icon_position.x2 - entry->icon_position.x1 + 20; + h = entry->icon_position.y2 - y + 1; + + x += xw; + y += yw; + + /* send the redraw event only if the mini entry is visible */ + if (( y + entry->icon_position.y2 > yw) && ( y < yw + hw)) + draw_page( win, x, y, MIN( w, browser_frame_width), h); +} + + +/*==================================================================================* + * draw_mini_entry: * + * draw a mini_entry in the WINDOW *win. * + *----------------------------------------------------------------------------------* + * input: * + * handle = the window's VDI handle. * + * selected = the mini_entry to be draw. * + * entry = pointer to the mini_entry selected. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ + +void draw_mini_entry( WINDOW *win, Mini_Entry *selected, Mini_Entry *entry, int16 x, int16 y, int16 h) +{ + MFDB *icon, screen = {0}; + int16 xy[8], xtext, ytext; + + + if( ( entry->icon_position.y1 + y) < y || ( entry->icon_position.y1 + y) >= y + h) + return; + + /* DRAW ARROW IS NEEDED */ + if ( entry->state != UNKNOWN) + { + if ( entry->state == ON) + { + xy[0] = entry->arrow_position.x1 + x; + xy[1] = entry->arrow_position.y1 + 3 + y; + xy[2] = xy[0] + 10; + xy[3] = xy[1]; + xy[4] = xy[0] + 5; + xy[5] = xy[1] + 5; + } + else + { + xy[0] = entry->arrow_position.x1 + x + 4; + xy[1] = entry->arrow_position.y1 + y; + xy[2] = xy[0]; + xy[3] = xy[1] + 10; + xy[4] = xy[0] + 5; + xy[5] = xy[1] + 5; + } + + vsf_color( win->graf.handle, LBLACK); + v_fillarea( win->graf.handle, 3, xy); + } + + + /* DRAW ICON */ + if ( entry->parent) + icon = &mini_folder; + else + { + switch( entry->name[0]) + { + case 'A': + case 'B': + icon = &mini_hdd; + break; + + default: + icon = &mini_hdd; + break; + } + } + + xy[0] = 0; + xy[1] = 0; + xy[2] = 15; + xy[3] = 15; + xy[4] = entry->icon_position.x1 + x; + xy[5] = entry->icon_position.y1 + y; + xy[6] = xy[4] + 15; + xy[7] = xy[5] + 15; + + if ( icon->fd_nplanes == 1) + { + int16 color[2]; + + color[0] = WHITE; + color[1] = BLACK; + + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, icon, &screen, color); + } + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, icon, &screen); + + + /* DRAW TEXT */ + xtext = entry->icon_position.x1 + x + 15 + x_space; /* column x position + arrow + icon + space */ + ytext = entry->icon_position.y1 + y + 4; /* line x postion + 1 + (( line height - font height) / 2) */ + + if ( entry == selected) + { + xy[0] = xtext - 2; + xy[2] = xy[0] + entry->icon_txt_w + 4; + xy[1] = ytext - 1; + xy[3] = xy[1] + hcell + 2; + + vsf_color( win->graf.handle, BLACK); + v_bar( win->graf.handle, xy); + + draw_text( win->graf.handle, xtext, ytext, WHITE, entry->name); + } + else + draw_text( win->graf.handle, xtext, ytext, BLACK, entry->name); +} + + + +/*==================================================================================* + * calc_mini_entry_line: * + * compute the number of line needed for entry's mini_entries's childs. * + *----------------------------------------------------------------------------------* + * input: * + * entry = The parent mini_entry. * + *----------------------------------------------------------------------------------* + * return: * + * number of lines needed * + *==================================================================================*/ + +int16 calc_mini_entry_line( Mini_Entry *entry) +{ + int16 i, lines = 0; + + if( entry->child == NULL) + return lines; + + for ( i = 0; i < entry->nbr_child ; i++) + { + lines++; + lines += calc_mini_entry_line( &entry->child[i]); + } + + return lines; +} + + + +/*==================================================================================* + * draw_mini_entry_child: * + * draw every mini_entry's childs in the WINDOW *win. * + *----------------------------------------------------------------------------------* + * input: * + * win = the window where to draw. * + * selected = pointer to the mini_entry selected. * + * entry = The parent mini_entry. * + * x = x window's position. * + * y = y window's position. * + *----------------------------------------------------------------------------------* + * return: * + * number of lines drawn * + *==================================================================================*/ + +int16 draw_mini_entry_child( WINDOW *win, Mini_Entry *selected, Mini_Entry *entry, int16 x, int16 y, int16 xw, int16 yw, int16 hw) +{ + int16 i, dum, lines = 0; + + if( entry->child == NULL) + return lines; + + for ( i = 0; i < entry->nbr_child ; i++) + { + entry->child[i].arrow_position.x1 = x + 3; + entry->child[i].arrow_position.y1 = y + 3; + entry->child[i].arrow_position.x2 = entry->child[i].arrow_position.x1 + 11; + entry->child[i].arrow_position.y2 = entry->child[i].arrow_position.y1 + 11; + + entry->child[i].icon_position.x1 = x + 15; + entry->child[i].icon_position.y1 = y + 1; + entry->child[i].icon_position.x2 = entry->child[i].icon_position.x1 + 15 + x_space + entry->child[i].icon_txt_w; + entry->child[i].icon_position.y2 = entry->child[i].icon_position.y1 + 15; + + draw_mini_entry( win, selected, &entry->child[i], xw, yw, hw); + lines++; + + y += 18; + + dum = draw_mini_entry_child( win, selected, &entry->child[i], x + 15, y, xw, yw, hw); + + y += ( dum * 18); + + lines += dum; + } + + return lines; +} + + + +/*==================================================================================* + * find_mini_entry_child_on_mouse: * + * Look if the mouse click is on a entry's childs or on childs's arrow. * + * If yes, open the mini_entry if the mouse is on the arrow or enter in the * + * directory seleted and send a redraw event to the main frame if is on the * + * entry itself. * + *----------------------------------------------------------------------------------* + * input: * + * win = the target window. * + * entry = the mini_entry where search for childs'entry selected. * + * mouse_x, mouse_y = the mouse position. * + *----------------------------------------------------------------------------------* + * return: * + * 1 if the mini_entry selected is found or 0. * + *==================================================================================*/ + +int find_mini_entry_child_on_mouse( WINDOW *win, Mini_Entry *entry, int16 mouse_x, int16 mouse_y) +{ + int i; + + if( entry->child == NULL) + return( 0); + + for ( i = 0; i < entry->nbr_child ; i++) + { + if ( entry->child[i].nbr_child > 0) + if ( find_mini_entry_child_on_mouse( win, &entry->child[i], mouse_x, mouse_y)) + return ( 1); + + if (( mouse_x >= entry->child[i].icon_position.x1 && mouse_x <= entry->child[i].icon_position.x2 && mouse_y >= entry->child[i].icon_position.y1 && mouse_y <= entry->child[i].icon_position.y2)) + { + WINDICON *wicones = ( WINDICON *)DataSearch( win, WD_ICON); + + if ( wicones->mini_selected != &entry->child[i]) + { + Mini_Entry *old_selected = wicones->mini_selected; + + wicones->mini_selected = &entry->child[i]; + + if ( old_selected) + redraw_mini_entry( win, old_selected); + + redraw_mini_entry( win, wicones->mini_selected); + + if ( strcmp ( wicones->mini_selected->foldername, wicones->directory) != 0) + { + int16 x, y, w, h; + + if ( wicones->first_selected) + { + while ( wicones->first_selected) + remove_selected_entry( wicones, wicones->first_selected); + } + + graf_mouse( BUSYBEE, NULL); + + ( void)scan_dir( win, wicones->mini_selected->foldername); + WindSetStr ( win, WF_NAME, wicones->directory); + wicones->first_selected = NULL; + win->ypos = 0; + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + draw_page( win, x + browser_frame_width, y, w - browser_frame_width, h); + + graf_mouse( ARROW, NULL); + + WindMakePreview( win); + } + } + return( 1); + } + else if ( entry->child[i].state != UNKNOWN) + { + if (( mouse_x >= entry->child[i].arrow_position.x1 && mouse_x <= entry->child[i].arrow_position.x2 && mouse_y >= entry->child[i].arrow_position.y1 && mouse_y <= entry->child[i].arrow_position.y2)) + { + int16 x, y, h, w; + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + + if ( entry->child[i].state == ON) + { + entry->child[i].state = OFF; + delete_mini_entry_child( &entry->child[i]); + } + else + { + Mini_Entry *selected = &entry->child[i]; + + graf_mouse( BUSYBEE, NULL); + + selected->state = ON; + scan_mini_dir( win, selected); + check_mini_dir( selected->nbr_child, selected->child); + + graf_mouse( ARROW, NULL); + } + + WinCatalog_Refresh( win); + draw_page( win, x, y, browser_frame_width, h); + + return( 1); + } + } + } + return( 0); +} + + + +/*==================================================================================* + * find_mini_entry_child_by_path: * + * find a child mini_entry in parent and return it. * + *----------------------------------------------------------------------------------* + * input: * + * parent = the parent where to search. * + * path = the path of the mini_entry wanted. * + *----------------------------------------------------------------------------------* + * return: * + * A pointer to the mini_entry if found else NULL. * + *==================================================================================*/ + +Mini_Entry *find_mini_entry_child_by_path( Mini_Entry *parent, char *path) +{ + int i; + + Mini_Entry *entry = NULL; + + if( parent->child == NULL) + return NULL; + + /* make a loop to see if the childs mini entries have child, if it's true, check it */ + for ( i = 0; i < parent->nbr_child ; i++) + { + if ( parent->child[i].nbr_child) + { + if ( ( entry = find_mini_entry_child_by_path( &parent->child[i], path))) + return entry; + } + + if ( strcmp ( parent->child[i].foldername, path) == 0) + return &parent->child[i]; + } + + return NULL; +} + + +/*==================================================================================* + * find_mini_entry_by_path: * + * find a mini_entry and return it. * + *----------------------------------------------------------------------------------* + * input: * + * wicones = the WINDICON struct where to search. * + * path = the path of the mini_entry wanted. * + *----------------------------------------------------------------------------------* + * return: * + * A pointer to the mini_entry if found else NULL. * + *==================================================================================*/ + +Mini_Entry *find_mini_entry_by_path( WINDICON *wicones, char *path) +{ + Mini_Entry *entry = NULL; + int16 i; + + for ( i = 0; i < wicones->nbr_child; i++) + { + if ( wicones->root[i].nbr_child) + { + if ( ( entry = find_mini_entry_child_by_path( &wicones->root[i], path))) + return entry; + } + + if ( strcmp ( wicones->root[i].foldername, path) == 0) + return &wicones->root[i]; + } + + return NULL; +} + + + + +/*==================================================================================* + * recalc_mini_entry_child_txt_width: * + * static function called by recalc_mini_entry_txt_width() * + *----------------------------------------------------------------------------------* + * input: * + * wicones = the WINDICON struct where to search. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ + +static void recalc_mini_entry_child_txt_width( Mini_Entry *parent) +{ + int i; + + if( parent->child == NULL) + return; + + /* make a loop to see if the childs mini entries have child, if it's true, make the job */ + for ( i = 0; i < parent->nbr_child; i++) + { + if ( parent->child[i].nbr_child) + recalc_mini_entry_child_txt_width( &parent->child[i]); + + parent->child[i].icon_txt_w = get_text_width( parent->child[i].name); + parent->child[i].icon_position.x2 = parent->child[i].icon_position.x1 + 15 + x_space + parent->child[i].icon_txt_w; + } +} + + +/*==================================================================================* + * recalc_mini_entry_txt_width: * + * After a font change, we need to recalc the mini_entry text width. * + * This function do it. * + *----------------------------------------------------------------------------------* + * input: * + * wicones = the WINDICON struct where to search. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ + +void recalc_mini_entry_txt_width( WINDICON *wicones) +{ + int16 i; + + for ( i = 0; i < wicones->nbr_child; i++) + { + if ( wicones->root[i].nbr_child) + recalc_mini_entry_child_txt_width( &wicones->root[i]); + + wicones->root[i].icon_txt_w = get_text_width( wicones->root[i].name); + + wicones->root[i].icon_position.x2 = wicones->root[i].icon_position.x1 + 15 + x_space + wicones->root[i].icon_txt_w; + } +} + + + +/*==================================================================================* + * calc_mini_entry_slider: * + * compute the frame slider size and coordinate. * + *----------------------------------------------------------------------------------* + * input: * + * wicones = the target WINDICON struct. * + * slider_root = the parent slider OBJECT. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ + +void calc_mini_entry_slider( WINDICON *wicones, OBJECT *slider_root) +{ + int16 max_mover_size = slider_root[SLIDERS_BACK].ob_height; + int16 full_win_size = wicones->ypos_max * wicones->h_u; + int16 win_h = slider_root->ob_height + 3; + + if ( win_h >= full_win_size) + { + wicones -> ypos = 0; + + slider_root[SLIDERS_MOVER].ob_y = 0; + slider_root[SLIDERS_MOVER].ob_height = max_mover_size; + + } + else + { + int16 ligne_reste; + float mover_position = 0L; + float position_step = 0L; + float mover_size = MAX( ( float)max_mover_size * ( ( float)win_h / ( float)full_win_size), 10L); + + if( wicones->ypos) + { + ligne_reste = wicones->ypos_max - ( win_h / wicones->h_u); + position_step = (( float)max_mover_size - mover_size) / ( float)ligne_reste; + mover_position = position_step * ( float)wicones->ypos; + + while( (( int16)mover_size + ( int16)mover_position > max_mover_size) && wicones->ypos > 0) + { + wicones->ypos--; + mover_position -= position_step; + } + } + + slider_root[SLIDERS_MOVER].ob_height = ( int16)mover_size; + slider_root[SLIDERS_MOVER].ob_y = ( int16)mover_position; + } +} diff --git a/sources/z-tools/trunk/zview/catalog/catalog_mini_entry.h b/sources/z-tools/trunk/zview/catalog/catalog_mini_entry.h new file mode 100644 index 0000000..63592e5 --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_mini_entry.h @@ -0,0 +1,10 @@ +extern void delete_mini_entry_child( Mini_Entry *entry); +extern int find_mini_entry_child_on_mouse( WINDOW *win, Mini_Entry *entry, int16 mouse_x, int16 mouse_y); +extern void redraw_mini_entry( WINDOW *win, Mini_Entry *entry); +extern void draw_mini_entry( WINDOW *win, Mini_Entry *selected, Mini_Entry *entry, int16 x, int16 y, int16 h); +extern int16 draw_mini_entry_child( WINDOW *win, Mini_Entry *selected, Mini_Entry *entry, int16 x, int16 y, int16 xw, int16 yw, int16 hw); +extern Mini_Entry *find_mini_entry_by_path( WINDICON *wicones, char *path); +extern Mini_Entry *find_mini_entry_child_by_path( Mini_Entry *parent, char *path); +extern void calc_mini_entry_slider( WINDICON *wicones, OBJECT *slider_root); +extern int16 calc_mini_entry_line( Mini_Entry *entry); +extern void recalc_mini_entry_txt_width( WINDICON *wicones); diff --git a/sources/z-tools/trunk/zview/catalog/catalog_mouse.c b/sources/z-tools/trunk/zview/catalog/catalog_mouse.c new file mode 100644 index 0000000..75366a6 --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_mouse.c @@ -0,0 +1,527 @@ +#include "../general.h" +#include "../ztext.h" +#include "catalog_entry.h" +#include "catalog_mini_entry.h" +#include "../prefs.h" +#include "../infobox.h" +#include "../pic_load.h" +#include "../winimg.h" +#include "../zedit/zedit.h" +#include "../file/file.h" +#include "catalog.h" +#include "catalog_icons.h" +#include "catalog_slider.h" +#include "catalog_popup.h" + +/* Local variable */ +static int16 dum; +extern char fullname[MAX_PATH+MAXNAMLEN]; + +/* Prototype */ +void WinCatalog_Mouse( WINDOW *win); + +/*==================================================================================* + * void WinCatalog_Mouse: * + * this function handle the mouse event for the main frame in the * + * catalog ( the entries). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The window to handle. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void WinCatalog_Mouse( WINDOW *win) +{ + WINDICON *wicones = (WINDICON *)DataSearch( win, WD_ICON); + GRECT mouse; + int16 x, y, w, h, old_x, old_entry = 0, old_y, i = 0, nb_click, in_txt = 0, in_icn = 0, in_frame_border = 0, in_browser = 0; + Entry *entry_ptr = NULL, *old_selected = wicones->first_selected; + EntryType old_type = ET_FILE; + + if( old_selected) + { + old_entry = 1; + + old_type = old_selected->type; + } + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + + mouse.g_x = evnt.mx - x; + mouse.g_y = evnt.my - y; + old_x = evnt.mx; + old_y = evnt.my; + nb_click = evnt.nb_click; + + if ( browser_frame_width && ( mouse.g_x >= wicones->border_position[0] && mouse.g_x <= wicones->border_position[1])) + { /* mouse on frame border */ + in_frame_border = 1; + } + else if ( browser_frame_width && ( mouse.g_x < wicones->border_position[0])) + { /* mouse on browser */ + in_browser = 1; + } + else + { + for ( i = 0 ; i < wicones->nbr_icons ; i++) /* Check if the mouse is over a icon */ + { + /* mouse on text */ + if (( mouse.g_x >= wicones->entry[i].txt_pos.x1 && mouse.g_x <= wicones->entry[i].txt_pos.x2 && mouse.g_y >= wicones->entry[i].txt_pos.y1 && mouse.g_y <= wicones->entry[i].txt_pos.y2)) + { + in_txt = 1; + break; + } + /* click on case to select */ + else if (( mouse.g_x >= wicones->entry[i].case_pos.x1 && mouse.g_x <= wicones->entry[i].case_pos.x2 && mouse.g_y >= wicones->entry[i].case_pos.y1 && mouse.g_y <= wicones->entry[i].case_pos.y2)) + { + in_icn = 1; + break; + } + } + } + + if(( evnt.mkstate & ( K_LSHIFT|K_RSHIFT))) + { + if( wicones->edit) + exit_edit_mode( win, old_selected); + + /* If no icon or text icon are selected, we return */ + if( in_icn || in_txt) + { + if( !check_selected_entry( wicones, &wicones->entry[i])) + add_selected_entry( wicones, &wicones->entry[i]); + else + remove_selected_entry( wicones, &wicones->entry[i]); + + redraw_icon( win, &wicones->entry[i]); + } + } + else if( in_icn) + { + if( wicones->edit) + exit_edit_mode( win, old_selected); + + if( wicones->first_selected) + { + while( wicones->first_selected->next_selected) + { + entry_ptr = wicones->first_selected->next_selected; + remove_selected_entry( wicones, wicones->first_selected->next_selected); + redraw_icon( win, entry_ptr); + } + } + + wicones->first_selected = &wicones->entry[i]; + + if( old_selected != wicones->first_selected) + { + if( old_selected) + redraw_icon( win, old_selected); + + redraw_icon( win, wicones->first_selected); + } +/* + graf_mkstate( &evnt.mx, &evnt.my, &evnt.mbut, &evnt.mkstate); + + if (( evnt.mbut == 1) && ( ( evnt.mx != old_x) || ( evnt.my != old_y))) + move_icon( win, wicones); +*/ + + if ( nb_click == 2 && evnt.mbut == 1) + { + if ( wicones->first_selected->type == ET_DIR) + { + Mini_Entry *old_selected_mini_entry = wicones->mini_selected; + + wicones->mini_selected = NULL; + + if ( old_selected_mini_entry && browser_frame_width) + redraw_mini_entry( win, old_selected_mini_entry); + + strcat( wicones->directory, wicones->entry[i].name); + ( void)scan_dir( win, wicones->directory); + + WindSetStr ( win, WF_NAME, wicones->directory); + wicones->first_selected = NULL; + win->ypos = 0; + + draw_page( win, x + browser_frame_width + border_size , y, w - ( browser_frame_width + border_size), h); + WindMakePreview( win); + } + else if ( ( wicones->first_selected->type == ET_IMAGE && wicones->first_selected->preview.page) || wicones->first_selected->type == ET_PDF) + { + strcpy( fullname, wicones->directory); + strcat( fullname, wicones->first_selected->name); + WindView( fullname); + + // WindView( wicones->first_selected->name); + } + } + else if( evnt.mbut == 2) + { + WinCatalog_Popup( win, wicones); + } + } + else if( in_txt) + { + if( wicones->first_selected) + { + while( wicones->first_selected->next_selected) + { + entry_ptr = wicones->first_selected->next_selected; + remove_selected_entry( wicones, wicones->first_selected->next_selected); + redraw_icon( win, entry_ptr); + } + } + + wicones->first_selected = &wicones->entry[i]; + + if( old_selected != wicones->first_selected) + { + if( old_selected) + { + if( wicones->edit) + exit_edit_mode( win, old_selected); + else + redraw_icon( win, old_selected); + } + + redraw_icon( win, wicones->first_selected); + } + else if( !wicones->edit) + init_edit_mode( win, wicones->first_selected); + } + else if ( in_frame_border && evnt.mbut == 1) + { + int16 last_mouse_x; + + if ( wicones->edit) + exit_edit_mode( win, old_selected); + + graf_mouse( FLAT_HAND, NULL); + + while( !wind_update( BEG_MCTRL)); + + graf_dragbox( border_size, h, x + browser_frame_width, y, x + 100, y, w - ( 100 + win -> w_u), h, &last_mouse_x, &dum ); + + /* Set the new toolbar position */ + if ( last_mouse_x != x + browser_frame_width) + { + int16 ww; + + if ( last_mouse_x < x + 100) + browser_frame_width = 100; + else if ( last_mouse_x > x + ( w - win -> w_u)) + browser_frame_width = w - win -> w_u; + else + browser_frame_width = last_mouse_x - x; + + /* Set new minimum value */ + WindCalc( WC_BORDER, win, 0, 0, wicones->case_w + border_size + browser_frame_width, wicones->case_h, &dum, &dum, &ww, &dum); + win -> w_min = ww; + + /* ensure that the ypos is inferior that it maximum size */ + WinCatalog_Refresh( win); + + i = 0; + + while ( i < win -> ypos_max - h / win -> h_u) + i ++; + + if( win -> ypos > i) + win -> ypos = i; + + EvntRedraw( win); + WindMakePreview( win); + } + + wind_update( END_MCTRL); + + graf_mouse( ARROW, NULL); + } + else if ( in_browser) + { + if ( wicones->edit) + exit_edit_mode( win, old_selected); + + if( need_frame_slider && ( mouse.g_x > browser_frame_width - 15) && ( mouse.g_x < browser_frame_width)) + { + int16 res; + + frame_slider_root->ob_x = x + browser_frame_width - 15; + frame_slider_root->ob_y = y + 2; + + res = objc_find( frame_slider_root, SLIDERS_BOX, 2, evnt.mx, evnt.my); + + if( res != -1) + { + int32 pos, old_ypos = wicones->ypos; + int16 dy, selected_object, page, redraw_arrow_slider = 0; + + switch ( res) + { + case SLIDERS_UP: + if( wicones -> ypos > 0L) + ObjcWindChange( win, frame_slider_root, SLIDERS_UP, frame_slider_root->ob_x, frame_slider_root[SLIDERS_UP].ob_y + y, frame_slider_root[SLIDERS_UP].ob_width + 1, frame_slider_root[SLIDERS_UP].ob_height + 1, SELECTED); + + do + { + if ( wicones -> ypos > 0L) + { + wicones -> ypos--; + move_frame_work( win, -wicones->h_u); + redraw_arrow_slider = 1; + } + + graf_mkstate( &dum, &dum, &res, &dum); + + } while( res); + + if( redraw_arrow_slider) + { + /* We don't call ObjcWindChange to change the up arrow state because it seem not work with userdraw object + ObjcWindChange( win, frame_slider_root, SLIDERS_UP, frame_slider_root->ob_x, frame_slider_root[SLIDERS_UP].ob_y + y, frame_slider_root->ob_width, frame_slider_root->ob_height, ~SELECTED); */ + frame_slider_root[SLIDERS_UP].ob_state &= ~SELECTED; + ObjcWindDraw( win, frame_slider_root, SLIDERS_UP, 1, frame_slider_root->ob_x, frame_slider_root[SLIDERS_UP].ob_y + y, frame_slider_root[SLIDERS_UP].ob_width + 1, frame_slider_root[SLIDERS_UP].ob_height + 1); + } + break; + + case SLIDERS_DOWN: + do + { + if (( wicones -> ypos < wicones -> ypos_max - h / wicones -> h_u) && ( wicones -> ypos_max > h / wicones -> h_u )) + { + if( redraw_arrow_slider == 0) + ObjcWindChange( win, frame_slider_root, SLIDERS_DOWN, frame_slider_root->ob_x, frame_slider_root[SLIDERS_DOWN].ob_y + y, frame_slider_root[SLIDERS_DOWN].ob_width + 1, frame_slider_root[SLIDERS_DOWN].ob_height + 1, SELECTED); + + wicones -> ypos++; + move_frame_work( win, wicones->h_u); + redraw_arrow_slider = 1; + } + + graf_mkstate( &dum, &dum, &res, &dum); + + } while( res); + + if( redraw_arrow_slider) + { + /* We don't call ObjcWindChange to change the up arrow state because it seem not work with userdraw object */ + frame_slider_root[SLIDERS_DOWN].ob_state &= ~SELECTED; + ObjcWindDraw( win, frame_slider_root, SLIDERS_DOWN, 1, frame_slider_root->ob_x, frame_slider_root[SLIDERS_DOWN].ob_y + y, frame_slider_root[SLIDERS_DOWN].ob_width + 1, frame_slider_root[SLIDERS_DOWN].ob_height + 1); + } + break; + + case SLIDERS_MOVER: + if( app.aes4 & AES4_XGMOUSE) + graf_mouse( M_SAVE, 0L); + + graf_mouse( FLAT_HAND, NULL); + + while( !wind_update( BEG_MCTRL)); + + res = graf_slidebox( frame_slider_root, SLIDERS_BACK, SLIDERS_MOVER, 1); + + wind_update( END_MCTRL); + + pos = ( int32)( wicones->ypos_max - h / wicones->h_u) * res / 1000L; + + if ( pos < 0) + pos = 0; + + dy = ( int16)(( pos - wicones->ypos) * wicones->h_u); + + wicones->ypos = pos; + + if( dy && ( old_ypos != wicones->ypos)) + move_frame_work( win, dy); + + if( app.aes4 & AES4_XGMOUSE) + graf_mouse( M_RESTORE, 0L); + + graf_mouse( ARROW,NULL); + + break; + + case SLIDERS_BACK: + objc_offset( frame_slider_root, SLIDERS_MOVER, &dum, &dy); + + dum = ( evnt.my < dy) ? WA_UPPAGE : WA_DNPAGE; + selected_object = ( evnt.my < dy) ? SLIDERS_UP : SLIDERS_DOWN; + + while( !wind_update( BEG_MCTRL)); + + frame_slider_root[selected_object].ob_state |= SELECTED; + + if( dum == WA_DNPAGE) + { + do + { + page = h / wicones -> h_u; + + if ( wicones -> ypos < wicones -> ypos_max - page) + { + wicones -> ypos = MIN( wicones->ypos_max, wicones->ypos) + page; + wicones -> ypos = MIN( wicones -> ypos, wicones -> ypos_max - page); + dy = ( int16) (( wicones->ypos - old_ypos) * wicones->h_u); + move_frame_work( win, dy); + } + + graf_mkstate( &dum, &dum, &res, &dum); + } while( res); + } + else + { + do + { + if ( wicones -> ypos > 0L) + { + pos = MAX( 0L, wicones->ypos - h / wicones->h_u); + dy = ( int16) (( pos - wicones->ypos) * wicones->h_u); + wicones->ypos = pos; + move_frame_work( win, dy); + } + + graf_mkstate( &dum, &dum, &res, &dum); + } while( res); + } + + frame_slider_root[selected_object].ob_state &= ~SELECTED; + + ObjcWindDraw( win, frame_slider_root, selected_object, 1, x, y, w, h); + + wind_update( END_MCTRL); + + break; + + default: + break; + } + } + } + else + { + for ( i = 0; i < wicones->nbr_child; i++) + { + if ( wicones->root[i].nbr_child > 0) + if ( find_mini_entry_child_on_mouse( win, &wicones->root[i], mouse.g_x, mouse.g_y)) + break; + + if (( mouse.g_x >= wicones->root[i].icon_position.x1 && mouse.g_x <= wicones->root[i].icon_position.x2 && mouse.g_y >= wicones->root[i].icon_position.y1 && mouse.g_y <= wicones->root[i].icon_position.y2)) + { + if ( wicones->mini_selected != &wicones->root[i]) + { + Mini_Entry *old_selected_mini_entry = wicones->mini_selected; + wicones->mini_selected = &wicones->root[i]; + + if ( old_selected_mini_entry) + redraw_mini_entry( win, old_selected_mini_entry); + + redraw_mini_entry( win, wicones->mini_selected); + + if ( strcmp ( wicones->mini_selected->foldername, wicones->directory) != 0) + { + while ( wicones->first_selected) + remove_selected_entry( wicones, wicones->first_selected); + + graf_mouse( BUSYBEE, NULL); + + ( void)scan_dir( win, wicones->mini_selected->foldername); + WindSetStr ( win, WF_NAME, wicones->directory); + wicones->first_selected = NULL; + win->ypos = 0; + + draw_page( win, x + browser_frame_width + border_size , y, w - ( browser_frame_width + border_size), h); + + graf_mouse( ARROW, NULL); + + WindMakePreview( win); + } + } + break; + } + else if ( wicones->root[i].state != UNKNOWN) + { + if (( mouse.g_x >= wicones->root[i].arrow_position.x1 && mouse.g_x <= wicones->root[i].arrow_position.x2 && mouse.g_y >= wicones->root[i].arrow_position.y1 && mouse.g_y <= wicones->root[i].arrow_position.y2)) + { + if ( wicones->root[i].state == ON) + { + wicones->root[i].state = OFF; + delete_mini_entry_child( &wicones->root[i]); + } + else + { + Mini_Entry *selected = &wicones->root[i]; + + graf_mouse( BUSYBEE, NULL); + + selected->state = ON; + scan_mini_dir( win, selected); + check_mini_dir( selected->nbr_child, selected->child); + + graf_mouse( ARROW, NULL); + } + + WinCatalog_Refresh( win); + + draw_page( win, x, y , browser_frame_width, h); + + break; + } + } + } + } + } + else if ( !in_txt && !in_icn && !in_browser && !in_frame_border) + { + if ( wicones->edit) + exit_edit_mode( win, old_selected); + + while( wicones->first_selected) + { + entry_ptr = wicones->first_selected; + remove_selected_entry( wicones, wicones->first_selected); + redraw_icon( win, entry_ptr); + } + } + + if( !( wicones->first_selected)) + { + menu_ienable( get_tree( MENU_BAR), MENU_BAR_INFORMATION, 0); + menu_ienable( get_tree( MENU_BAR), MENU_BAR_SAVE, 0); + menu_ienable( get_tree( MENU_BAR), MENU_BAR_DELETE, 0); + + if( old_entry) + { + ObjcDraw( OC_TOOLBAR, win, TOOLBAR_DELETE, 1); + ObjcDraw( OC_TOOLBAR, win, TOOLBAR_INFO, 1); + + if( old_type == ET_IMAGE) + ObjcDraw( OC_TOOLBAR, win, TOOLBAR_SAVE, 1); + } + } + else + { + if( wicones->first_selected->type == ET_IMAGE) + menu_ienable( get_tree( MENU_BAR), MENU_BAR_SAVE, 1); + + menu_ienable( get_tree( MENU_BAR), MENU_BAR_DELETE, 1); + menu_ienable( get_tree( MENU_BAR), MENU_BAR_INFORMATION, 1); + + if( !old_entry) + { + if( wicones->first_selected->type == ET_IMAGE) + ObjcDraw( OC_TOOLBAR, win, TOOLBAR_SAVE, 1); + + ObjcDraw( OC_TOOLBAR, win, TOOLBAR_DELETE, 1); + ObjcDraw( OC_TOOLBAR, win, TOOLBAR_INFO, 1); + } + else if(( wicones->first_selected->type != old_type) && ( wicones->first_selected->type == ET_IMAGE || old_type == ET_IMAGE)) + ObjcDraw( OC_TOOLBAR, win, TOOLBAR_SAVE, 1); + } + + /* a wait loop while the mouse button is pressed */ + while(( evnt.mbut == 1) || ( evnt.mbut == 2)) + graf_mkstate( &evnt.mx, &evnt.my, &evnt.mbut, &evnt.mkstate); +} diff --git a/sources/z-tools/trunk/zview/catalog/catalog_mouse.h b/sources/z-tools/trunk/zview/catalog/catalog_mouse.h new file mode 100644 index 0000000..3652f61 --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_mouse.h @@ -0,0 +1,2 @@ +extern void WinCatalog_Mouse( WINDOW *win) ; + diff --git a/sources/z-tools/trunk/zview/catalog/catalog_other_event.c b/sources/z-tools/trunk/zview/catalog/catalog_other_event.c new file mode 100644 index 0000000..7059fb4 --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_other_event.c @@ -0,0 +1,103 @@ +#include "../general.h" +#include "catalog.h" +#include "../prefs.h" + +/* Prototype */ +void WinCatalog_Fulled( WINDOW *win); +void WinCatalog_top( WINDOW *win); +void WinCatalog_bottom( WINDOW *win); + + +/*==================================================================================* + * void WinCatalog_Fulled: * + * this function handle the WM_FULLED event for the main frame in the * + * catalog ( the entries). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void WinCatalog_Fulled( WINDOW *win) +{ + int16 x, y, w, h; + WINDICON *wicones = (WINDICON *)DataSearch( win, WD_ICON); + + if( win->status & WS_FULLSIZE) + { + wind_get( evnt.buff[3], WF_PREVXYWH, &x, &y, &w, &h); + wind_set( evnt.buff[3], WF_CURRXYWH, x, y, w, h); + } else + wind_set( evnt.buff[3], WF_CURRXYWH, app.x, app.y, win->w_max, win->h_max); + + win->status ^= WS_FULLSIZE; + + win -> ypos = 0; + wicones -> ypos = 0; + + WindSlider( win, VSLIDER); + + WindGet ( win, WF_WORKXYWH, &x, &y, &w, &h); + draw_page( win, x + browser_frame_width + border_size , y, w - ( browser_frame_width + border_size), h); + WindMakePreview( win); +} + + +/*==================================================================================* + * void WinCatalog_top: * + * this function handle the WM_TOPPED event for the main frame in the * + * catalog ( the entries). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void WinCatalog_top( WINDOW *win) +{ + WINDICON *wicones = (WINDICON *)DataSearch( win, WD_ICON); + OBJECT *menu = get_tree( MENU_BAR); + + if( !wicones->first_selected) + { + menu_ienable( menu, MENU_BAR_INFORMATION, 0); + menu_ienable( menu, MENU_BAR_SAVE, 0); + menu_ienable( menu, MENU_BAR_DELETE, 0); + } + else + { + if( wicones->first_selected->type == ET_IMAGE) + menu_ienable( menu, MENU_BAR_SAVE, 1); + + menu_ienable( menu, MENU_BAR_DELETE, 1); + menu_ienable( menu, MENU_BAR_INFORMATION, 1); + } + + menu_ienable( menu, MENU_BAR_SHOW_FULLSCREEN, 0); +} + + +/*==================================================================================* + * void WinCatalog_bottom: * + * this function handle the WM_BOTTOMED event for the main frame in the * + * catalog ( the entries). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void WinCatalog_bottom( WINDOW *win) +{ + win = win; // for prevent compiler warning + menu_ienable( get_tree( MENU_BAR), MENU_BAR_INFORMATION, 0); + menu_ienable( get_tree( MENU_BAR), MENU_BAR_SAVE, 0); + menu_ienable( get_tree( MENU_BAR), MENU_BAR_DELETE, 0); +} + diff --git a/sources/z-tools/trunk/zview/catalog/catalog_other_event.h b/sources/z-tools/trunk/zview/catalog/catalog_other_event.h new file mode 100644 index 0000000..534b4ed --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_other_event.h @@ -0,0 +1,5 @@ +extern void WinCatalog_Fulled( WINDOW *win); +extern void WinCatalog_top( WINDOW *win); +extern void WinCatalog_bottom( WINDOW *win); + + diff --git a/sources/z-tools/trunk/zview/catalog/catalog_popup.c b/sources/z-tools/trunk/zview/catalog/catalog_popup.c new file mode 100644 index 0000000..d23b20d --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_popup.c @@ -0,0 +1,23 @@ +#include "../general.h" +#include "../ztext.h" +#include "../mfdb.h" +#include "catalog_entry.h" +#include "../plugins.h" + + +/*==================================================================================* + * void WinCatalog_Popup: * + * . * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void WinCatalog_Popup( WINDOW *win, WINDICON *wicones) +{ + +} + diff --git a/sources/z-tools/trunk/zview/catalog/catalog_popup.h b/sources/z-tools/trunk/zview/catalog/catalog_popup.h new file mode 100644 index 0000000..094654b --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_popup.h @@ -0,0 +1 @@ +extern void WinCatalog_Popup( WINDOW *win, WINDICON *wicones); diff --git a/sources/z-tools/trunk/zview/catalog/catalog_size.c b/sources/z-tools/trunk/zview/catalog/catalog_size.c new file mode 100644 index 0000000..a01fa27 --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_size.c @@ -0,0 +1,108 @@ +#include "../general.h" +#include "../prefs.h" +#include "catalog_mini_entry.h" +#include "catalog.h" + +/* Prototype */ +void WinCatalog_Size( WINDOW *win); + +/*==================================================================================* + * void WinCatalog_Size: * + * this function handle the WM_SIZED event for the main frame in the * + * catalog ( the entries). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void WinCatalog_Size( WINDOW *win) +{ + int16 dum, x, y, w, h, old_h, rdw_win = 0, rdw_frame = 0; + uint32 old_win_ypos, old_frame_ypos; + WINDICON *wicones = (WINDICON *)DataSearch( win, WD_ICON); + + x = MAX( evnt.buff[6], win -> w_min); + y = MAX( evnt.buff[7], win -> h_min); + + w = MIN( x, win -> w_max); + h = MIN( y, win -> h_max); + + WindGet( win, WF_WORKXYWH, &dum, &dum, &dum, &old_h); + + wind_set( evnt.buff[3], WF_CURRXYWH, evnt.buff[4], evnt.buff[5], w, h); + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + + old_win_ypos = win -> ypos; + old_frame_ypos = wicones -> ypos; + + if( ( uint16)h > wicones -> ypos_max * wicones -> h_u) + wicones -> ypos = 0; + else + wicones -> ypos = MIN( wicones -> ypos, wicones -> ypos_max - h / wicones -> h_u); + + if( ( uint16)h > win -> ypos_max * win -> h_u) + win -> ypos = 0; + else + win -> ypos = MIN( win -> ypos, win -> ypos_max - h / win -> h_u); + + if( old_frame_ypos != wicones -> ypos) + { + rdw_frame = 1; + } + + if( old_win_ypos != win -> ypos) + { + rdw_win = 1; + } + else if ( w >= (( wicones->columns + 1) * wicones->case_w + border_size + browser_frame_width) || w < wicones->columns * wicones->case_w + border_size + browser_frame_width) + { + if ( w < (( wicones->nbr_icons + 1) * wicones->case_w + border_size + browser_frame_width)) + rdw_win = 1; + } + + win->status &= ~WS_FULLSIZE; + + if( rdw_win) + { + draw_page( win, x + browser_frame_width + border_size , y + 1, w - ( browser_frame_width + border_size), h - 1); + + WindMakePreview( win); + } + else if( ( old_h != h) && browser_frame_width) + { + if( rdw_frame) + draw_page( win, x, y + 1, browser_frame_width, h - 1); + else if( ( wicones -> ypos_max * wicones -> h_u) >= h) + { + need_frame_slider = 1; + frame_slider_root->ob_x = x + browser_frame_width - 15; + frame_slider_root->ob_y = y + 2; + frame_slider_root->ob_height = h - 3; + + frame_slider_root[SLIDERS_BACK].ob_height = h - 31; + + frame_slider_root[SLIDERS_UP].ob_y = frame_slider_root->ob_height - 31; + frame_slider_root[SLIDERS_DOWN].ob_y = frame_slider_root->ob_height - 15; + + calc_mini_entry_slider( wicones, frame_slider_root); + + /* check it in the windom source, I'm not sure if the clipping area must be clip.g_x, clip.g_y, clip.g_w, clip.g_h or not */ + ObjcWindDraw( win, frame_slider_root, SLIDERS_BOX, 2, x + browser_frame_width - 15, y, 16, h); + + WindSlider( win, VSLIDER); + } + else /* if( need_frame_slider) */ + { + need_frame_slider = 0; + draw_page( win, x + browser_frame_width - 16 , y + 1, 16, h - 1); + } + } + else if( old_h != h) + { + WindSlider( win, VSLIDER); + } +} diff --git a/sources/z-tools/trunk/zview/catalog/catalog_size.h b/sources/z-tools/trunk/zview/catalog/catalog_size.h new file mode 100644 index 0000000..c4caccf --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_size.h @@ -0,0 +1,2 @@ +extern void WinCatalog_Size( WINDOW *win); + diff --git a/sources/z-tools/trunk/zview/catalog/catalog_slider.c b/sources/z-tools/trunk/zview/catalog/catalog_slider.c new file mode 100644 index 0000000..d859ca0 --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_slider.c @@ -0,0 +1,463 @@ +#include "../general.h" +#include "../prefs.h" +#include "catalog_mini_entry.h" +#include "catalog.h" + + +/* prototype */ +void WinCatalog_Arrow( WINDOW *win); +void WinCatalog_VSlide( WINDOW *win); +void WinCatalog_DownLine( WINDOW *win); +void WinCatalog_UpLine( WINDOW *win); +void WinCatalog_DownPage( WINDOW *win); +void WinCatalog_UpPage( WINDOW *win); +void move_area( int16 handle, GRECT *screen, int16 dx, int16 dy); +void move_main_work( WINDOW *win, int16 xw, int16 yw, int16 ww, int16 hw, int16 dx, int16 dy, int16 first_frame_width, int16 border_width); +void move_frame_work( WINDOW *win, int16 dy); + + +/*==================================================================================* + * void move_area: * + * utility function for the move_*_work functions. * + *----------------------------------------------------------------------------------* + * input: * + * handle -> The vdi handle. * + * screen -> The area coordinate to move. * + * dy -> The step for the move. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void move_area( int16 handle, GRECT *screen, int16 dx, int16 dy) +{ + int16 xy[8]; + MFDB screen_mfdb = {0}; + GRECT g; + + wind_get( 0, WF_CURRXYWH, &g.g_x, &g.g_y, &g.g_w, &g.g_h); + + rc_intersect( &g, screen); + + xy[0] = screen -> g_x; + xy[1] = screen -> g_y; + xy[2] = xy[0] + screen -> g_w - 1; + xy[3] = xy[1] + screen -> g_h - 1; + xy[4] = xy[0] + dx; + xy[5] = xy[1] + dy; + xy[6] = xy[2] + dx; + xy[7] = xy[3] + dy; + + vro_cpyfm( handle, S_ONLY, xy, &screen_mfdb, &screen_mfdb); +} + + + +/*==================================================================================* + * void move_work: * + * this function moves the main frame ( entries) work area of the window. * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + * dy -> The step for the move. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void move_main_work( WINDOW *win, int16 xw, int16 yw, int16 ww, int16 hw, int16 dx, int16 dy, int16 first_frame_width, int16 border_width) +{ + int16 x = xw, y = yw + 1, w = ww, h = hw - 1, absolute_dy, absolute_dx; + GRECT rect, r1, r2, screen; + + absolute_dy = abs( dy); + absolute_dx = abs( dx); + + if ( dx || dy) + { + x += ( first_frame_width + border_width); + w -= ( first_frame_width + border_width); + + while( !wind_update(BEG_UPDATE)); + graf_mouse( M_OFF, 0L); + rc_set( &rect, x, y, w, h); + + wind_get_grect( 0, WF_CURRXYWH, &screen); + wind_get( win -> handle, WF_FIRSTXYWH, &r1.g_x, &r1.g_y, &r1.g_w, &r1.g_h); + + while ( r1.g_w && r1.g_h) + { + if( rc_intersect( &rect, &r1) && rc_intersect( &screen, &r1)) + { + if ( ( absolute_dx < r1.g_w) && ( absolute_dy < r1.g_h)) + { + r2 = r1; /* save */ + + if ( dy > 0) + { + r1.g_y += dy; + r1.g_h -= dy; + } + else + r1.g_h += dy; + + if (dx > 0) + { + r1.g_x += dx; + r1.g_w -= dx; + } + else + r1.g_w += dx; + + move_area( win->graf.handle, &r1, -dx, -dy); + + if (dx) + { + r1 = r2 ; /* restore */ + + if (dx > 0) + { + r1.g_x += r1.g_w - dx; + r1.g_w = dx; + } + else + r1.g_w = - dx; + + if (dy > 0) + r1.g_h -= dy; + else + { + r1.g_y -= dy; + r1.g_h += dy; + } + rc_clip_on( win->graf.handle, &r1); + EvntExec( win, WM_REDRAW); + rc_clip_off( win->graf.handle); + } + + if ( dy) + { + r1 = r2 ; /* restore */ + + if (dy > 0) + { + r1.g_y += r1.g_h - dy; + r1.g_h = dy; + } + else + r1.g_h = -dy; + + rc_clip_on( win->graf.handle, &r1); + EvntExec( win, WM_REDRAW); + rc_clip_off( win->graf.handle); + } + } + else + { + rc_clip_on( win->graf.handle, &r1); + EvntExec( win, WM_REDRAW); + rc_clip_off( win->graf.handle); + } + } + wind_get( win->handle, WF_NEXTXYWH, &r1.g_x, &r1.g_y, &r1.g_w, &r1.g_h); + } + graf_mouse( M_ON, 0L); + wind_update(END_UPDATE); + + if ( dy) + WindSlider( win, VSLIDER); + if ( dx) + WindSlider( win, HSLIDER); + } +} + + + +/*==================================================================================* + * void move_frame_work: * + * this function moves the mini_entry frame work area of the window. * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + * dy -> The step fo the move. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void move_frame_work( WINDOW *win, int16 dy) +{ + int16 x, y, w, h, absolute_dy; + GRECT rect, r1, r2, screen; + + absolute_dy = abs( dy); + + if ( dy) + { + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + y++; + h--; + w = browser_frame_width - 16; + + while( !wind_update(BEG_UPDATE)); + graf_mouse( M_OFF, 0L); + rc_set( &rect, x + 1, y, w, h); + wind_get_grect( 0, WF_CURRXYWH, &screen); + wind_get( win -> handle, WF_FIRSTXYWH, &r1.g_x, &r1.g_y, &r1.g_w, &r1.g_h); + + while ( r1.g_w && r1.g_h) + { + if( rc_intersect( &rect, &r1) && rc_intersect( &screen, &r1)) + { + if ( ( absolute_dy < r1.g_h) ) + { + r2 = r1; /* save */ + + if ( dy > 0) + { + r1.g_y += dy; + r1.g_h -= dy; + } + else + r1.g_h += dy; + + move_area( win->graf.handle, &r1, 0, -dy); + + if ( dy) + { + r1 = r2 ; /* restore */ + + if (dy > 0) + { + r1.g_y += r1.g_h - dy; + r1.g_h = dy; + } + else + r1.g_h = -dy; + + rc_clip_on( win->graf.handle, &r1); + EvntExec( win, WM_REDRAW); + rc_clip_off( win->graf.handle); + } + } + else + { + rc_clip_on( win->graf.handle, &r1); + EvntExec( win, WM_REDRAW); + rc_clip_off( win->graf.handle); + } + } + wind_get( win->handle, WF_NEXTXYWH, &r1.g_x, &r1.g_y, &r1.g_w, &r1.g_h); + } + wind_update(END_UPDATE); + graf_mouse( M_ON, 0L); + + if ( dy) + { + WINDICON *wicones = (WINDICON *)DataSearch( win, WD_ICON); + + need_frame_slider = 1; + calc_mini_entry_slider( wicones, frame_slider_root); + + /* check it in the windom source, I'm not sure if the clipping area must be clip.g_x, clip.g_y, clip.g_w, clip.g_h or not */ + ObjcWindDraw( win, frame_slider_root, SLIDERS_BACK, 2, x + browser_frame_width - 15, y, 16, h - 31); + } + } +} + + +/*==================================================================================* + * void WinCatalog_VSlide: * + * this function handle the WM_VSLID event for the main frame in the * + * catalog ( the entries). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void WinCatalog_VSlide( WINDOW *win) +{ + int32 pos; + int16 x, y, w, h, dy; + int16 old_ypos = win->ypos; + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + pos = ( int32)( win->ypos_max - h / win->h_u) * ( int32)evnt.buff[4] / 1000L; + + if ( pos < 0) + pos = 0; + + dy = ( int16)(( pos - win->ypos) * win->h_u); + win->ypos = ( int16) pos; + + if( dy && ( old_ypos != win->ypos)) + { + move_main_work( win, x, y, w, h, 0, dy, browser_frame_width, border_size); + + /* we look if image are visible and we create the preview */ + WindMakePreview( win); + } +} + + + + + +/*==================================================================================* + * void WinCatalog_DownPage: * + * this function handle the WM_DNPAGE event for the main frame in the * + * catalog ( the entries). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void WinCatalog_DownPage( WINDOW *win) +{ + int16 page, x, y, w, h, dy; + int32 old_pos = win -> ypos; + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + + page = h / win -> h_u; + + if ( win -> ypos < win -> ypos_max - page) + { + win -> ypos = MIN( win->ypos_max, win->ypos) + page; + win -> ypos = MIN( win -> ypos, win -> ypos_max - page); + dy = ( int16) (( win->ypos - old_pos) * win->h_u); + move_main_work( win, x, y, w, h, 0, dy, browser_frame_width, border_size); + + /* After each 'downpage', we look if image are visible and we create the preview */ + WindMakePreview( win); + } +} + + +/*==================================================================================* + * void WinCatalog_UpPage: * + * this function handle the WM_UPPAGE event for the main frame in the * + * catalog ( the entries). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void WinCatalog_UpPage( WINDOW *win) +{ + int32 pos; + int16 x, y, w, h, dy; + + if ( win -> ypos > 0L) + { + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + pos = MAX( 0L, win->ypos - h / win->h_u); + dy = ( int16) (( pos - win->ypos) * win->h_u); + win->ypos = pos; + move_main_work( win, x, y, w, h, 0, dy, browser_frame_width, border_size); + + /* After each 'uppage', we look if image are visible and we create the preview */ + WindMakePreview( win); + } +} + + +/*==================================================================================* + * void WinCatalog_UpLine: * + * this function handle the WM_UPLINE event for the main frame in the * + * catalog ( the entries). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void WinCatalog_UpLine( WINDOW *win) +{ + if ( win -> ypos > 0L) + { + int16 x, y, w, h; + + win->ypos --; + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + move_main_work( win, x, y, w, h, 0, -win->h_u, browser_frame_width, border_size); + + /* After each 'upline', we look if image are visible and we create the preview */ + WindMakePreview( win); + } +} + + +/*==================================================================================* + * void WinCatalog_DownLine: * + * this function handle the WM_DNLINE event for the main frame in the * + * catalog ( the entries). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void WinCatalog_DownLine( WINDOW *win) +{ + int16 x, y, w, h; + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + + if (( win -> ypos < win -> ypos_max - h / win -> h_u) && ( win -> ypos_max > h / win -> h_u )) + { + win -> ypos ++; + move_main_work( win, x, y, w, h, 0, win->h_u, browser_frame_width, border_size); + + /* After each 'downpage', we look if image are visible and we create the preview */ + WindMakePreview( win); + } +} + + +/*==================================================================================* + * void WinCatalog_Arrow: * + * this function handle the WM_ARROWED event for the main frame in the * + * catalog ( the entries). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void WinCatalog_Arrow( WINDOW *win) +{ + switch( evnt.buff[4]) + { + case WA_UPPAGE: + WinCatalog_UpPage( win); + break; + case WA_DNPAGE: + WinCatalog_DownPage( win); + break; + case WA_UPLINE: + WinCatalog_UpLine( win); + break; + case WA_DNLINE: + WinCatalog_DownLine( win); + break; + default: + break; + } +} + diff --git a/sources/z-tools/trunk/zview/catalog/catalog_slider.h b/sources/z-tools/trunk/zview/catalog/catalog_slider.h new file mode 100644 index 0000000..378f8e0 --- /dev/null +++ b/sources/z-tools/trunk/zview/catalog/catalog_slider.h @@ -0,0 +1,11 @@ +extern void WinCatalog_Arrow( WINDOW *win); +extern void WinCatalog_VSlide( WINDOW *win); +extern void WinCatalog_DownLine( WINDOW *win); +extern void WinCatalog_UpLine( WINDOW *win); +extern void WinCatalog_DownPage( WINDOW *win); +extern void WinCatalog_UpPage( WINDOW *win); + +extern void move_main_work( WINDOW *win, int16 xw, int16 yw, int16 ww, int16 hw, int16 dx, int16 dy, int16 first_frame_width, int16 border_width); +extern void move_frame_work( WINDOW *win, int16 dy); +extern void move_area( int16 handle, GRECT *screen, int16 dx, int16 dy); + diff --git a/sources/z-tools/trunk/zview/chrono.c b/sources/z-tools/trunk/zview/chrono.c new file mode 100644 index 0000000..e5eaf5c --- /dev/null +++ b/sources/z-tools/trunk/zview/chrono.c @@ -0,0 +1,49 @@ +#include "general.h" + +/* Prototype */ +void chrono_off( char *info); +void chrono_on( void); + +/* Global variable */ +int32 start_time, end_time; + + +/*==================================================================================* + * void chrono_on: * + * save the current time in 'start_time' global variable. * + *----------------------------------------------------------------------------------* + * input: * + * --- * + *----------------------------------------------------------------------------------* + * return: * + * --- * + *==================================================================================*/ + +void chrono_on( void) +{ + int32 oldssp = Super( 0L); + start_time = *( int32 *)0x4ba; + Super(( void *)oldssp); +} + + +/*==================================================================================* + * void chrono_off: * + * save the current time in 'end_time' global variable and compute the time * + * since the call of the 'chrono_on' function * + *----------------------------------------------------------------------------------* + * input: * + * info -> place where to write the time elapsed. * + *----------------------------------------------------------------------------------* + * return: * + * --- * + *==================================================================================*/ + +void chrono_off( char *info) +{ + int32 oldssp = Super( 0L); + end_time = *( int32 *)0x4ba; + Super(( void *)oldssp); + + sprintf( info ,"%ld.%01ld sec", ( end_time - start_time) / 200L, (( end_time - start_time) % 200L) * 5L); +} diff --git a/sources/z-tools/trunk/zview/chrono.h b/sources/z-tools/trunk/zview/chrono.h new file mode 100644 index 0000000..47cccca --- /dev/null +++ b/sources/z-tools/trunk/zview/chrono.h @@ -0,0 +1,3 @@ +extern void chrono_on( void); +extern void chrono_off( char *info); + diff --git a/sources/z-tools/trunk/zview/close_modal.c b/sources/z-tools/trunk/zview/close_modal.c new file mode 100644 index 0000000..e0b883b --- /dev/null +++ b/sources/z-tools/trunk/zview/close_modal.c @@ -0,0 +1,35 @@ +#include "general.h" + +/* Prototype */ +void close_modal( WINDOW *win); + + +/*==================================================================================* + * void close_modal: * + * special destroy function for modal windows. * + *----------------------------------------------------------------------------------* + * input: * + * win -> the modal window to destroy. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void close_modal( WINDOW *win) +{ + MenuEnable(); + frm_cls( win); +} + + + + + + + + + + + + + diff --git a/sources/z-tools/trunk/zview/close_modal.h b/sources/z-tools/trunk/zview/close_modal.h new file mode 100644 index 0000000..ade92de --- /dev/null +++ b/sources/z-tools/trunk/zview/close_modal.h @@ -0,0 +1,14 @@ +extern void close_modal( WINDOW *win); + + + + + + + + + + + + + diff --git a/sources/z-tools/trunk/zview/copyright b/sources/z-tools/trunk/zview/copyright new file mode 100644 index 0000000..a1ef488 --- /dev/null +++ b/sources/z-tools/trunk/zview/copyright @@ -0,0 +1,503 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/sources/z-tools/trunk/zview/custom_font.c b/sources/z-tools/trunk/zview/custom_font.c new file mode 100644 index 0000000..21ca01d --- /dev/null +++ b/sources/z-tools/trunk/zview/custom_font.c @@ -0,0 +1,241 @@ +#include "general.h" +#include "custom_font.h" + +static MFDB screen = {0}; + +static short ofwf[256] = /* tableau espacements des caractŠres */ +{ + 0, 7, 7, 7, 7, 8, 8, 8, 7, 8, 7, 7, 7, 7, 6, 7, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, + 3, 3, 5, 7, 6, 6, 7, 3, 4, 4, 6, 6, 3, 6, 2, 5, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 2, 3, 4, 5, 4, 6, + 7, 6, 6, 6, 6, 5, 5, 6, 6, 2, 5, 6, 5, 7, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 3, 5, 3, 6, 6, + 3, 5, 5, 5, 5, 5, 3, 5, 5, 4, 4, 5, 4, 8, 5, 5, + 5, 5, 4, 5, 3, 5, 5, 6, 6, 5, 6, 5, 2, 5, 7, 6, + 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 6, 6, + 5, 8, 8, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 5, + 5, 4, 5, 5, 5, 6, 5, 5, 6, 7, 7, 8, 8, 3, 7, 7, + 5, 5, 8, 7, 8, 8, 6, 6, 6, 6, 5, 4, 8, 8, 8, 8, + 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 6, 8, + 7, 6, 6, 8, 7, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 8, 8, 6, 7, 5, 5, 4, 7, 5, 5, 5, 6 +}; + +static short my_font_8[1280] = /* Tableau des donn‚es de la fonte */ +{ + 0x0018, 0x3C7E, 0x1818, 0x1800, 0x0018, 0x1818, 0x7E3C, 0x1800, + 0x0008, 0x0C7E, 0x7E0C, 0x0800, 0x0010, 0x307E, 0x7E30, 0x1000, + 0x3C99, 0xC3E7, 0xC399, 0x3C00, 0xFFFF, 0xFEFC, 0xF9F3, 0xE700, + 0xE7C3, 0x993C, 0x99C3, 0xE700, 0x0002, 0x068C, 0xD870, 0x2000, + 0x7EC3, 0x9195, 0x9981, 0xC37E, 0x183C, 0x3C3C, 0x7E10, 0x3810, + 0x000E, 0x0B08, 0x0838, 0x7830, 0xF080, 0xDC90, 0x9810, 0x1000, + 0x6080, 0x9C92, 0x7C12, 0x1200, 0x0A0A, 0x0A1A, 0x1A32, 0xF2E2, + 0xA0A0, 0xA0B0, 0xB098, 0x9E8E, 0x3844, 0x4400, 0x4444, 0x3800, + 0x0404, 0x0400, 0x0404, 0x0400, 0x3804, 0x0438, 0x4040, 0x3800, + 0x7008, 0x0870, 0x0808, 0x7000, 0x4444, 0x4438, 0x0404, 0x0400, + 0x3840, 0x4038, 0x0404, 0x3800, 0x3840, 0x4038, 0x4444, 0x3800, + 0x7008, 0x0800, 0x0808, 0x0800, 0x3844, 0x4438, 0x4444, 0x3800, + 0x3844, 0x4438, 0x0404, 0x3800, 0x0000, 0x7804, 0x7844, 0x3800, + 0x7040, 0x7040, 0x7C10, 0x1C00, 0x0F1F, 0x3F30, 0x3020, 0x3C2E, + 0xE0F0, 0xD808, 0x0808, 0x78A8, 0x2216, 0x1B0C, 0x0F5C, 0x7370, + 0x0850, 0xB050, 0xA020, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x4040, 0x4040, 0x4000, 0x4000, 0x4848, 0x0000, 0x0000, 0x0000, + 0x0024, 0x7E24, 0x247E, 0x2400, 0x103C, 0x5038, 0x1478, 0x1000, + 0x0048, 0x0810, 0x1020, 0x2400, 0x1824, 0x1830, 0x4A44, 0x3A00, + 0x2020, 0x4000, 0x0000, 0x0000, 0x1020, 0x4040, 0x4040, 0x2010, + 0x4020, 0x1010, 0x1010, 0x2040, 0x0028, 0x107C, 0x1028, 0x0000, + 0x0010, 0x107C, 0x1010, 0x0000, 0x0000, 0x0000, 0x0020, 0x2040, + 0x0000, 0x007C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4000, + 0x0808, 0x1010, 0x2020, 0x4040, 0x3844, 0x4444, 0x4444, 0x3800, + 0x1030, 0x1010, 0x1010, 0x3800, 0x3844, 0x0408, 0x1020, 0x7C00, + 0x7C08, 0x1038, 0x0444, 0x3800, 0x0818, 0x2848, 0x7C08, 0x0800, + 0x7C40, 0x7804, 0x0444, 0x3800, 0x1820, 0x4078, 0x4444, 0x3800, + 0x7C04, 0x0408, 0x1010, 0x1000, 0x3844, 0x4438, 0x4444, 0x3800, + 0x3844, 0x443C, 0x0408, 0x3000, 0x0000, 0x4000, 0x0040, 0x0000, + 0x0000, 0x2000, 0x0020, 0x2040, 0x0010, 0x2040, 0x2010, 0x0000, + 0x0000, 0x7800, 0x7800, 0x0000, 0x0040, 0x2010, 0x2040, 0x0000, + 0x3844, 0x0408, 0x1000, 0x1000, 0x3C42, 0x5A52, 0x5C40, 0x3E00, + 0x1028, 0x4444, 0x7C44, 0x4400, 0x7844, 0x4478, 0x4444, 0x7800, + 0x3844, 0x4040, 0x4044, 0x3800, 0x7048, 0x4444, 0x4448, 0x7000, + 0x7840, 0x4070, 0x4040, 0x7800, 0x7840, 0x4070, 0x4040, 0x4000, + 0x3844, 0x404C, 0x4444, 0x3800, 0x4444, 0x447C, 0x4444, 0x4400, + 0x4040, 0x4040, 0x4040, 0x4000, 0x0808, 0x0808, 0x0848, 0x3000, + 0x4448, 0x5060, 0x5048, 0x4400, 0x4040, 0x4040, 0x4040, 0x7800, + 0x4266, 0x5A42, 0x4242, 0x4200, 0x4464, 0x544C, 0x4444, 0x4400, + 0x3844, 0x4444, 0x4444, 0x3800, 0x7844, 0x4478, 0x4040, 0x4000, + 0x3844, 0x4444, 0x5448, 0x3400, 0x7844, 0x4478, 0x5048, 0x4400, + 0x3844, 0x4038, 0x0444, 0x3800, 0x7C10, 0x1010, 0x1010, 0x1000, + 0x4444, 0x4444, 0x4444, 0x3800, 0x4444, 0x4444, 0x2828, 0x1000, + 0x4141, 0x4149, 0x2A2A, 0x1400, 0x4444, 0x2810, 0x2844, 0x4400, + 0x4444, 0x4428, 0x1010, 0x1000, 0x7C04, 0x0810, 0x2040, 0x7C00, + 0x6040, 0x4040, 0x4040, 0x6000, 0x4040, 0x2020, 0x1010, 0x0808, + 0x6020, 0x2020, 0x2020, 0x6000, 0x1028, 0x4400, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x7C00, 0x4040, 0x2000, 0x0000, 0x0000, + 0x0000, 0x3008, 0x3848, 0x3800, 0x4040, 0x7048, 0x4848, 0x7000, + 0x0000, 0x3048, 0x4048, 0x3000, 0x0808, 0x3848, 0x4848, 0x3800, + 0x0000, 0x3048, 0x7840, 0x3800, 0x3040, 0x4060, 0x4040, 0x4000, + 0x0000, 0x3848, 0x4838, 0x0870, 0x4040, 0x7048, 0x4848, 0x4800, + 0x2000, 0x6020, 0x2020, 0x7000, 0x1000, 0x1010, 0x1010, 0x5020, + 0x4040, 0x4850, 0x6050, 0x4800, 0x6020, 0x2020, 0x2020, 0x7000, + 0x0000, 0x7649, 0x4949, 0x4900, 0x0000, 0x7048, 0x4848, 0x4800, + 0x0000, 0x3048, 0x4848, 0x3000, 0x0000, 0x7048, 0x4848, 0x7040, + 0x0000, 0x3848, 0x4848, 0x3808, 0x0000, 0x5060, 0x4040, 0x4000, + 0x0000, 0x3840, 0x3008, 0x7000, 0x4040, 0x6040, 0x4040, 0x2000, + 0x0000, 0x4848, 0x4848, 0x3800, 0x0000, 0x4848, 0x4850, 0x2000, + 0x0000, 0x4444, 0x5438, 0x2800, 0x0000, 0x4428, 0x1028, 0x4400, + 0x0000, 0x4848, 0x4838, 0x0870, 0x0000, 0x7C08, 0x1020, 0x7C00, + 0x1820, 0x2040, 0x2020, 0x1800, 0x4040, 0x4040, 0x4040, 0x4040, + 0x6010, 0x1008, 0x1010, 0x6000, 0x0020, 0x724E, 0x0400, 0x0000, + 0x0010, 0x2828, 0x447C, 0x0000, 0x3844, 0x4040, 0x4438, 0x1020, + 0x4800, 0x4848, 0x4848, 0x3800, 0x1020, 0x3048, 0x7840, 0x3800, + 0x3048, 0x3008, 0x3848, 0x3800, 0x2800, 0x3008, 0x3848, 0x3800, + 0x1008, 0x3008, 0x3848, 0x3800, 0x1010, 0x3008, 0x3848, 0x3800, + 0x0030, 0x4840, 0x4830, 0x1060, 0x1028, 0x3048, 0x7840, 0x3800, + 0x2800, 0x3048, 0x7840, 0x3800, 0x2010, 0x3048, 0x7840, 0x3800, + 0x5000, 0x6020, 0x2020, 0x7000, 0x2050, 0x6020, 0x2020, 0x7000, + 0x2010, 0x6020, 0x2020, 0x7000, 0x2800, 0x1028, 0x447C, 0x4400, + 0x1000, 0x1028, 0x447C, 0x4400, 0x1020, 0x7840, 0x7040, 0x7800, + 0x0000, 0x3E09, 0x3F48, 0x3E00, 0x1F38, 0x484E, 0x7848, 0x4F00, + 0x3048, 0x3048, 0x4848, 0x3000, 0x4800, 0x3048, 0x4848, 0x3000, + 0x2010, 0x3048, 0x4848, 0x3000, 0x3048, 0x0048, 0x4848, 0x3800, + 0x2010, 0x0048, 0x4848, 0x3800, 0x4800, 0x4848, 0x4838, 0x0870, + 0x2800, 0x3844, 0x4444, 0x3800, 0x4400, 0x4444, 0x4444, 0x3800, + 0x1038, 0x5450, 0x5438, 0x1000, 0x1824, 0x2078, 0x2020, 0x7800, + 0x4444, 0x3810, 0x7C10, 0x1000, 0x1824, 0x4478, 0x4444, 0x7840, + 0x1820, 0x2070, 0x2020, 0x4000, 0x1020, 0x3008, 0x3848, 0x3800, + 0x2040, 0x0060, 0x2020, 0x7000, 0x1020, 0x0030, 0x4848, 0x3000, + 0x1020, 0x0048, 0x4848, 0x3800, 0x2850, 0x0070, 0x4848, 0x4800, + 0x3458, 0x0064, 0x544C, 0x4400, 0x0030, 0x0838, 0x4838, 0x0078, + 0x0030, 0x4848, 0x4830, 0x0078, 0x1000, 0x1020, 0x4044, 0x3800, + 0x0000, 0x0000, 0x1E10, 0x1000, 0x0000, 0x0000, 0x7808, 0x0800, + 0x4244, 0x4816, 0x2142, 0x0700, 0x4244, 0x4816, 0x2A4F, 0x0200, + 0x0040, 0x0040, 0x4040, 0x4040, 0x0012, 0x2448, 0x2412, 0x0000, + 0x0048, 0x2412, 0x2448, 0x0000, 0x2850, 0x0030, 0x0878, 0x3800, + 0x2850, 0x0030, 0x4848, 0x3000, 0x1D22, 0x262A, 0x3222, 0x5C00, + 0x0000, 0x1A24, 0x3C24, 0x5800, 0x0000, 0x3E49, 0x4F48, 0x3E00, + 0x3F48, 0x484E, 0x4848, 0x3F00, 0x1008, 0x1028, 0x447C, 0x4400, + 0x3458, 0x1028, 0x447C, 0x4400, 0x3458, 0x0038, 0x4444, 0x3800, + 0x2400, 0x0000, 0x0000, 0x0000, 0x1020, 0x4000, 0x0000, 0x0000, + 0x2070, 0x2020, 0x0000, 0x0000, 0x3A4A, 0x4A4A, 0x3A0A, 0x0A0A, + 0x3C42, 0x99A1, 0xA199, 0x423C, 0x3C42, 0xB9A5, 0xB9A5, 0x423C, + 0xEA4E, 0x4A4A, 0x0000, 0x0000, 0x2400, 0x6424, 0x2474, 0x0418, + 0x7424, 0x2424, 0x2474, 0x0418, 0x0000, 0x1038, 0x7C10, 0x1010, + 0x1010, 0x107C, 0x3810, 0x0000, 0x0010, 0x18FC, 0x1810, 0x0000, + 0x0008, 0x183F, 0x1808, 0x0000, 0x1010, 0x101F, 0x0000, 0x0000, + 0x0000, 0x00F0, 0x1010, 0x1010, 0x1010, 0x10F0, 0x0000, 0x0000, + 0x0000, 0x001F, 0x1010, 0x1010, 0x0000, 0x00FF, 0x0000, 0x0000, + 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x10FF, 0x1010, 0x1010, + 0x1010, 0x101F, 0x1010, 0x1010, 0x0000, 0x00FF, 0x1010, 0x1010, + 0x1010, 0x10F0, 0x1010, 0x1010, 0x1010, 0x10FF, 0x0000, 0x0000, + 0x0010, 0x181C, 0x1C18, 0x1000, 0x0008, 0x1838, 0x3818, 0x0800, + 0x0024, 0x343C, 0x3C34, 0x2400, 0x0024, 0x2C3C, 0x3C2C, 0x2400, + 0x0048, 0x6C7E, 0x7E6C, 0x4800, 0x0012, 0x367E, 0x7E36, 0x1200, + 0x0010, 0x387C, 0x007C, 0x0000, 0x007C, 0x7C7C, 0x7C7C, 0x0000, + 0x0038, 0x7C7C, 0x7C38, 0x0000, 0x3C42, 0x8181, 0x8250, 0x3810, + 0x1054, 0x9282, 0x8244, 0x3800, 0x0004, 0x0404, 0x247C, 0x2000, + 0x0609, 0x1C22, 0x221C, 0x4830, 0x0000, 0x1028, 0x4400, 0x0000, + 0x0036, 0x4949, 0x3600, 0x0000, 0x0000, 0x324C, 0x484C, 0x3200, + 0x1824, 0x4478, 0x4444, 0x7840, 0x7C24, 0x2020, 0x2020, 0x7000, + 0x0001, 0x3E54, 0x1414, 0x1400, 0x7E22, 0x1008, 0x1022, 0x7E00, + 0x001C, 0x3048, 0x4848, 0x3000, 0x0000, 0x2424, 0x2424, 0x3A40, + 0x0004, 0x3850, 0x1010, 0x1000, 0x3810, 0x3844, 0x4438, 0x1038, + 0x0038, 0x447C, 0x4444, 0x3800, 0x0038, 0x4444, 0x4428, 0x6C00, + 0x3020, 0x1038, 0x4444, 0x3800, 0x0408, 0x3854, 0x5438, 0x2040, + 0x1038, 0x5454, 0x5438, 0x1000, 0x3C60, 0x407C, 0x4060, 0x3C00, + 0x386C, 0x4444, 0x4444, 0x4400, 0x007C, 0x007C, 0x007C, 0x0000, + 0x0010, 0x107C, 0x1010, 0x007C, 0x0020, 0x1008, 0x1020, 0x007C, + 0x0008, 0x1020, 0x1008, 0x007C, 0x0609, 0x0808, 0x0808, 0x0808, + 0x0808, 0x0808, 0x0808, 0x4830, 0x0010, 0x007C, 0x0010, 0x0000, + 0x0032, 0x4C00, 0x324C, 0x0000, 0x3048, 0x4830, 0x0000, 0x0000, + 0x3078, 0x7830, 0x0000, 0x0000, 0x0000, 0x0000, 0x3030, 0x0000, + 0x0006, 0x0808, 0x6828, 0x1000, 0x3048, 0x4848, 0x0000, 0x0000, + 0x3048, 0x1020, 0x7800, 0x0000, 0x7008, 0x3008, 0x7000, 0x0000, + 0xFE00, 0x0000, 0x0000, 0x0000 +}; + + +void draw_text( int16 vdih, int16 xf, int16 yf, int16 color, const char *str) +{ + MFDB pic; + short fx_mem[16], sys_pxy[20], char_width, tcolor[2] = { color, WHITE}; + unsigned short c; + + pic.fd_addr = fx_mem; + pic.fd_w = 16; + pic.fd_h = 8; + pic.fd_wdwidth = 1; + pic.fd_stand = 0; + pic.fd_nplanes = 1; + + sys_pxy[0] = 0; + sys_pxy[1] = 0; + sys_pxy[2] = 0; + sys_pxy[3] = 7; + sys_pxy[4] = xf; + sys_pxy[5] = yf; + sys_pxy[6] = 0; + sys_pxy[7] = yf + 7; + + while ( (c = (unsigned char)*str++) != 0) { + char *model = (char*) &my_font_8[(c - 1) << 2] ; + char *dest = (char*)fx_mem; + + char_width = ofwf[c]; + + memset(fx_mem,0,20); + *dest = *model++; dest+=2; + *dest = *model++; dest+=2; + *dest = *model++; dest+=2; + *dest = *model++; dest+=2; + *dest = *model++; dest+=2; + *dest = *model++; dest+=2; + *dest = *model++; dest+=2; + *dest = *model; + + sys_pxy[2] = char_width - 1; + sys_pxy[6] = sys_pxy[4] + sys_pxy[2]; + + /*vdi*/ + vrt_cpyfm( vdih, 2, sys_pxy, &pic, &screen, tcolor); + + sys_pxy[4] += char_width; + } +} + + +int16 get_text_width( const char *str) +{ + int16 c, text_width = 0; + + while ( (c = *str++) != 0) + { + text_width += ofwf[c]; + } + + return text_width; +} + + +int16 name_shorter( int16 max_size, char *str) +{ + int16 len, current_len; + + len = ( int16) strlen( str) - 1; + + do + { + str[len - 3] = '.'; + str[len - 2] = '.'; + str[len - 1] = '.'; + str[len] = '\0'; + + len--; + + current_len = get_text_width( str); + + } while ( ( current_len >= max_size) && ( len > 0)); + + return current_len; +} diff --git a/sources/z-tools/trunk/zview/custom_font.h b/sources/z-tools/trunk/zview/custom_font.h new file mode 100644 index 0000000..f3c2693 --- /dev/null +++ b/sources/z-tools/trunk/zview/custom_font.h @@ -0,0 +1,17 @@ +#ifndef CFONT_H +#define CFONT_H + +#ifdef __cplusplus +extern "C" { +#endif + +extern void draw_text( int16 vdih, int16 xf, int16 yf, int16 color, const char *str); +extern int16 get_text_width( const char *str); +extern int16 name_shorter( int16 max_size, char *str); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/sources/z-tools/trunk/zview/debug.c b/sources/z-tools/trunk/zview/debug.c new file mode 100644 index 0000000..21ce894 --- /dev/null +++ b/sources/z-tools/trunk/zview/debug.c @@ -0,0 +1,32 @@ +#include "general.h" +#ifdef DEBUG +#include +#endif + +/*==================================================================================* + * void zdebug: * + * print debug information in 'wout' window. * + *----------------------------------------------------------------------------------* + * input: * + * ... -> text and parameter are the same that sandard "printf" function. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void zdebug( const char *format, ...) +{ +#ifdef DEBUG + va_list args; + char fo_buff[255], *p; + + va_start( args, format); + vsprintf( fo_buff, format, args); + p = fo_buff; + va_end( args); + + wout_printf("%s\n", p); +#endif +} + + + diff --git a/sources/z-tools/trunk/zview/file/count.c b/sources/z-tools/trunk/zview/file/count.c new file mode 100644 index 0000000..222e685 --- /dev/null +++ b/sources/z-tools/trunk/zview/file/count.c @@ -0,0 +1,114 @@ +#include "../general.h" +#include "file.h" + +/* Prototype */ +int16 count_files( WINDICON *wicones, fileinfo *file); +int16 count_dir( const char *path, fileinfo *file); + +/*==================================================================================* + * int16 count_dir : * + * Do a recursive file count in a directory. * + *----------------------------------------------------------------------------------* + * input: * + * path -> the path where to search. * + * item -> the adress where to return the number of files. * + * size -> the adress where to return the total size of all the files. * + *----------------------------------------------------------------------------------* + * return: * + * 1 is ok else 0 * + *==================================================================================*/ + +int16 count_dir( const char *path, fileinfo *file) +{ + char old_dir[MAX_PATH]; + DIR *dir; + struct dirent *de; + struct stat file_stat; + + if ( dir_cd( path, old_dir, ( int16)( sizeof old_dir))) + { + if (( dir = opendir( ".")) != NULL) + { + while(( de = readdir( dir)) != NULL) + { + if (( strcmp( de->d_name, ".") == 0) || ( strcmp( de->d_name, "..") == 0)) + continue; + + if ( lstat( de->d_name, &file_stat) != 0) + { + closedir( dir); + dir_cd( old_dir, NULL, 0); + return 0; + } + + if ( S_ISDIR( file_stat.st_mode)) + { + if ( !count_dir( de->d_name, file)) + { + closedir( dir); + dir_cd( old_dir, NULL, 0); + return 0; + } + else + file->item ++; + } + else + { + file->item ++; + file->size += file_stat.st_size; + } + } + closedir( dir); + } + else + return 0; + + dir_cd( old_dir, NULL, 0); + } + else + return 0; + + return 1; +} + + +/*==================================================================================* + * int16 count_files: * + * Do a recursive file count. * + *----------------------------------------------------------------------------------* + * input: * + * wicones -> the target wicones. * + * item -> the adress where to return the number of files. * + * size -> the adress where to return the total size of all the files. * + *----------------------------------------------------------------------------------* + * return: * + * 1 is ok else 0 * + *==================================================================================*/ + +int16 count_files( WINDICON *wicones, fileinfo *file) +{ + Entry *entry = wicones->first_selected; + + file->item = 0L; + file->size = 0L; + + while ( entry) + { + if ( S_ISDIR( entry->stat.st_mode)) + { + if( !count_dir( entry->name, file)) + return 0; + else + file->item ++; + } + else + { + file->item ++; + file->size += entry->stat.st_size; + } + + entry = entry->next_selected; + } + + return 1; +} diff --git a/sources/z-tools/trunk/zview/file/count.h b/sources/z-tools/trunk/zview/file/count.h new file mode 100644 index 0000000..477cdc0 --- /dev/null +++ b/sources/z-tools/trunk/zview/file/count.h @@ -0,0 +1,2 @@ +extern int16 count_files( WINDICON *wicones, fileinfo *file); + diff --git a/sources/z-tools/trunk/zview/file/delete.c b/sources/z-tools/trunk/zview/file/delete.c new file mode 100644 index 0000000..9163047 --- /dev/null +++ b/sources/z-tools/trunk/zview/file/delete.c @@ -0,0 +1,312 @@ +#include "../general.h" +#include "../prefs.h" +#include "../ztext.h" +#include "../close_modal.h" +#include "../catalog/catalog.h" +#include "../catalog/catalog_entry.h" +#include "../catalog/catalog_mini_entry.h" +#include "file.h" +#include "count.h" + + +/* local variable */ +static char size_to_delete[16]; +static uint32 size_deleted; +static uint32 item_deleted; +static uint32 item_to_delete; + +static OBJECT *save_dialog; + +/* prototype */ +boolean delete_file( const char *name, struct stat *file_stat); +boolean delete_dir( WINDOW *win, const char *path); +void delete_entry( WINDOW *win); +void delete_progress( WINDOW *win); + + +/*==================================================================================* + * delete_file: * + * Delete a plain file. This is capable of removing anything that is not a * + * directory. * + *----------------------------------------------------------------------------------* + * returns: TRUE = success, FALSE = error * + *==================================================================================*/ + +boolean delete_file( const char *name, struct stat *file_stat) +{ + if ( unlink( name) != 0) + { + /* If possible, change the file permission for delete it */ + ( void)chmod( name, S_IRWXU); + return unlink( name) == 0 ? TRUE : FALSE; + } + else + return ( TRUE); +} + + +/*==================================================================================* + * delete_dir: * + * Delete a directory. * + *----------------------------------------------------------------------------------* + * returns: TRUE = success, FALSE = error * + *==================================================================================*/ + +boolean delete_dir( WINDOW *win, const char *path) +{ + char old_dir[MAX_PATH]; + DIR *dir; + struct dirent *de; + struct stat file_stat; + + if ( rmdir( path) == 0) + return TRUE; + else + { + if ( dir_cd( path, old_dir, ( int16)( sizeof old_dir))) + { + if (( dir = opendir( ".")) != NULL) + { + while(( de = readdir( dir)) != NULL) + { + if (( strcmp( de->d_name, ".") == 0) || ( strcmp( de->d_name, "..") == 0)) + continue; + + if ( lstat( de->d_name, &file_stat) != 0) + break; + + if ( S_ISDIR( file_stat.st_mode)) + { + if ( delete_dir( win, de->d_name) == FALSE) + break; + else + { + item_deleted++; + delete_progress( win); + } + } + else + { + if ( delete_file( de->d_name, &file_stat) == FALSE) + break; + else + { + item_deleted++; + size_deleted += file_stat.st_size; + delete_progress( win); + } + } + } + closedir( dir); + } + dir_cd( old_dir, NULL, 0); + } + + return rmdir( path) == 0 ? TRUE : FALSE; + } +} + +void delete_progress( WINDOW *win) +{ + static int32 bar_width = 0L; + int32 new_bar_width = ( ( item_deleted * 100L) / item_to_delete) * 3; + int16 pxy[4]; + char tmp[16]; + GRECT rwin, raes; + W_FORM *form = ( W_FORM *)DataSearch( win, WD_WFRM); + + size_to_text( tmp, ( float)size_deleted); + + sprintf( save_dialog[OPERATION_DIAL_INFO].ob_spec.tedinfo->te_ptext, get_string( DELETE_INFO), item_to_delete - item_deleted); + sprintf( save_dialog[OPERATION_DIAL_PROGRESS].ob_spec.tedinfo->te_ptext, get_string( PROGRESS_TXT), tmp, size_to_delete); + + ObjcDraw( OC_FORM, win, OPERATION_DIAL_INFO, 0); + ObjcDraw( OC_FORM, win, OPERATION_DIAL_PROGRESS, 0); + + if (( bar_width == new_bar_width) || !new_bar_width) + return; + + WindGet( win, WF_WORKXYWH, &rwin.g_x, &rwin.g_y, &rwin.g_w, &rwin.g_h); + + bar_width = new_bar_width; + + pxy[0] = rwin.g_x + form->root[OPERATION_DIAL_BAR].ob_x; + pxy[1] = rwin.g_y + form->root[OPERATION_DIAL_BAR].ob_y; + pxy[2] = pxy[0] + bar_width; + pxy[3] = pxy[1] + form->root[OPERATION_DIAL_BAR].ob_height; + + while( !wind_update( BEG_UPDATE)); + graf_mouse( M_OFF, 0L); + wind_get( win->handle, WF_FIRSTXYWH, &raes.g_x, &raes.g_y, &raes.g_w, &raes.g_h); + + while ( raes.g_w && raes.g_h) + { + if( rc_intersect( &rwin, &raes)) + { + rc_clip_on( win->graf.handle, &raes); + + v_bar( win->graf.handle, pxy); + + rc_clip_off( win->graf.handle); + } + + wind_get( win->handle, WF_NEXTXYWH, &raes.g_x, &raes.g_y, &raes.g_w, &raes.g_h); + } + + graf_mouse( M_ON, 0L); + + wind_update( END_UPDATE); +} + + + +void delete_function( WINDOW *win) +{ + WINDICON *wicones = ( WINDICON *)DataSearch( win_catalog, WD_ICON); + Mini_Entry *mini_entry; + fileinfo file; + int16 x, y, w, h, deleted_entry = 0; + + switch( evnt.buff[4]) + { + case OPERATION_DIAL_CANCEL: + ObjcChange( OC_FORM, win, OPERATION_DIAL_CANCEL, ~SELECTED, TRUE); + ApplWrite( app.id, WM_CLOSED, win->handle, 0, 0, 0, 0); + break; + + case OPERATION_DIAL_OK: + ObjcChange( OC_FORM, win, OPERATION_DIAL_OK, ~SELECTED, TRUE); + strcpy( save_dialog[OPERATION_DIAL_INFO].ob_spec.tedinfo->te_ptext, get_string( CALCUL)); + + vsf_color( win->graf.handle, RED); + + if( !count_files( wicones, &file)) + { + ApplWrite( app.id, WM_CLOSED, win->handle, 0, 0, 0, 0); + errshow( "", errno); + return; + } + + item_to_delete = file.item; + + size_deleted = 0L; + item_deleted = 0L; + + size_to_text( size_to_delete, ( float)file.size); + + delete_progress( win); + + while ( wicones->first_selected) + { + if ( S_ISDIR( wicones->first_selected->stat.st_mode)) + { + if ( !delete_dir( win, wicones->first_selected->name)) + { + errshow( wicones->first_selected->name, errno); + break; + } + else + { + deleted_entry++; + item_deleted++; + + delete_progress( win); + + remove_selected_entry( wicones, wicones->first_selected); + + /* the mini_entry returned is the mini_entry parent of the directory deleted + because we give the current directory ( wicones->directory) as parameter */ + if ( ( mini_entry = find_mini_entry_by_path( wicones, wicones->directory))) + { + int16 old_state = mini_entry->state; + + delete_mini_entry_child( mini_entry); + scan_mini_dir( win_catalog, mini_entry); + check_mini_dir( mini_entry->nbr_child, mini_entry->child); + + mini_entry->state = old_state; + + if( mini_entry->state == OFF) + delete_mini_entry_child( mini_entry); + + if ( browser_frame_width) + { + WindGet( win_catalog, WF_WORKXYWH, &x, &y, &w, &h); + draw_page( win_catalog, x, y + mini_entry->arrow_position.y1 - 1, browser_frame_width, h - mini_entry->arrow_position.y1); + } + } + } + } + else + { + if ( !delete_file( wicones->first_selected->name, &wicones->first_selected->stat)) + { + errshow( wicones->first_selected->name, errno); + break; + } + else + { + deleted_entry++; + item_deleted++; + size_deleted += wicones->first_selected->stat.st_size; + + delete_progress( win); + remove_selected_entry( wicones, wicones->first_selected); + } + } + } + ObjcDraw( OC_FORM, win, OPERATION_DIAL_INFO, FALSE); + + close_modal( win); + + if ( deleted_entry) + { + ( void)scan_dir( win_catalog, wicones->directory); + WinCatalog_filelist_redraw(); + ObjcDraw( OC_TOOLBAR, win_catalog, TOOLBAR_DELETE, 1); + ObjcDraw( OC_TOOLBAR, win_catalog, TOOLBAR_INFO, 1); + ObjcDraw( OC_TOOLBAR, win_catalog, TOOLBAR_SAVE, 1); + menu_ienable( get_tree( MENU_BAR), MENU_BAR_DELETE, 0); + menu_ienable( get_tree( MENU_BAR), MENU_BAR_INFORMATION, 0); + menu_ienable( get_tree( MENU_BAR), MENU_BAR_SAVE, 0); + } + + break; + + default: + break; + } +} + + + +/*==================================================================================* + * void delete_entry: * + * Delete all the selected entries in the WINDOW win. * + * A modal dialog box is shown for approve it. * + *----------------------------------------------------------------------------------* + * input: * + * win -> the window's adress to handle. * + *----------------------------------------------------------------------------------* + * return: * + * entries deleted * + *==================================================================================*/ + +void delete_entry( WINDOW *win) +{ + WINDOW *win_save_dialog; + + save_dialog = get_tree( OPERATION_DIAL); + + zstrncpy( save_dialog[OPERATION_DIAL_INFO].ob_spec.tedinfo->te_ptext, get_string( DELETE_ASK), 48); + strcpy( save_dialog[OPERATION_DIAL_PROGRESS].ob_spec.tedinfo->te_ptext, ""); + + win_save_dialog = FormCreate( save_dialog, NAME|MOVER, delete_function, get_string( DELETE_TITLE), NULL, TRUE, FALSE); + + WindSet( win_save_dialog, WF_BEVENT, BEVENT_MODAL, 0, 0, 0); + + EvntAttach( win_save_dialog, WM_CLOSED, close_modal); + + MenuDisable(); +} + diff --git a/sources/z-tools/trunk/zview/file/delete.h b/sources/z-tools/trunk/zview/file/delete.h new file mode 100644 index 0000000..ee537c0 --- /dev/null +++ b/sources/z-tools/trunk/zview/file/delete.h @@ -0,0 +1,2 @@ +extern void delete_entry( WINDOW *win); + diff --git a/sources/z-tools/trunk/zview/file/file.c b/sources/z-tools/trunk/zview/file/file.c new file mode 100644 index 0000000..454973b --- /dev/null +++ b/sources/z-tools/trunk/zview/file/file.c @@ -0,0 +1,439 @@ +/*----------------------------------------------------------------------*/ +/* Files utilities */ +/*----------------------------------------------------------------------*/ +#include "../general.h" +#include "../zedit/zedit.h" +#include "../catalog/catalog_entry.h" +#include "../ztext.h" +#include "../catalog/catalog_icons.h" +#include "../prefs.h" +#include "../mfdb.h" +#include "../txt_data.h" +#include "../custom_font.h" +#include "sort.h" + +#define ALLOC_NDIRENTRIES (4) /* number of entries that should be allocated at once by readdir() */ + +/* Prototype */ +boolean dir_parent( char *dir, char *old_dir); +boolean dir_cd( const char *new_dir, char *old_dir, int16 bufflen); +boolean check_write_perm( const struct stat *file_stat); +boolean scan_dir( WINDOW *win, const char *dirpath); +boolean scan_mini_drv( WINDOW *win); +void check_mini_dir( int16 nbr_child, Mini_Entry *entry); +boolean scan_mini_dir( WINDOW *win, Mini_Entry *parent); + + +/*==================================================================================* + * dir_parent: * + * go to the parent directory. * + *----------------------------------------------------------------------------------* + * returns: TRUE = success, FALSE = if root path ( so, no dir up). * + *----------------------------------------------------------------------------------* + * dir: Pointer to the current directory, the new directory will be * + * returned on the same pointer. * + * old_dir: Pointer on a null string where will be returned the name of the * + * old directory. ( not the full path, only the name) * + *==================================================================================*/ + +boolean dir_parent( char *dir, char *old_dir) +{ + int16 len, i, ii; + + len = ( int16) strlen( dir) - 1; + + if ( len < 3) + return FALSE; + + if ( dir[len] == '\\') + dir[len] = '\0'; + + len--; + i = len; + + while ( dir[i] != '\\') + i--; + + ii = len - i - 1; + + old_dir[ii + 1] = '\0'; + + while ( dir[len] != '\\') + { + old_dir[ii] = dir[len]; + dir[len] = '\0'; + len--; + ii--; + } + + return TRUE; +} + +/*==================================================================================* + * dir_cd: * + * enter to a directory. * + *----------------------------------------------------------------------------------* + * returns: TRUE = success, FALSE = error * + *----------------------------------------------------------------------------------* + * new_dir: The New directory. * + * old_dir: Pointer where save the previous directory. * + * ( If NULL, no storing is done). * + *==================================================================================*/ + +boolean dir_cd( const char *new_dir, char *old_dir, int16 bufflen) +{ + if ( old_dir != NULL) + getcwd( old_dir, bufflen); + + return chdir( new_dir) == 0 ? TRUE : FALSE; +} + + +/*==================================================================================* + * check_write_perm: * + * Do complex WRITE permission check. * + *----------------------------------------------------------------------------------* + * returns: TRUE = ok, FALSE = no * + *----------------------------------------------------------------------------------* + * stat: Entry Stat. * + *==================================================================================*/ + +boolean check_write_perm( const struct stat *file_stat) +{ + uid_t uid = geteuid(); + gid_t gid = getegid(); + + +/* if ( uid == 0) + return TRUE; +*/ + if ( file_stat->st_uid == uid) + return ( file_stat->st_mode & S_IWUSR) ? TRUE : FALSE; + + if ( file_stat->st_gid == gid) + return ( file_stat->st_mode & S_IWGRP) ? TRUE : FALSE; + + return ( file_stat->st_mode & S_IWOTH) ? TRUE : FALSE; +} + + +/*==================================================================================* + * scan_dir: * + * scan the 'dirpath' directory and fit somes entries in 'dirfile'. * + *----------------------------------------------------------------------------------* + * return: TRUE if ok or FALSE if error * + *==================================================================================*/ + +boolean scan_dir( WINDOW *win, const char *dirpath) +{ + short dum, allocated_entries = 0; + Entry *entry; + DIR *dir; + struct dirent *de; + struct stat file_stat; + struct tm *tmt; + WINDICON *dirfile = ( WINDICON *)DataSearch( win, WD_ICON); + + if ( dirfile->nbr_icons) + { + for ( dum = 0; dum < dirfile->nbr_icons; dum++) + { + delete_txt_data( &dirfile->entry[dum].preview); + delete_mfdb( dirfile->entry[dum].preview.image, dirfile->entry[dum].preview.page); + } + + dirfile->nbr_icons = 0; + + gfree( dirfile->entry); + } + + dirfile->first_selected = NULL; + dirfile->entry = NULL; + dirfile->edit = NULL; + + if ( !dir_cd( dirpath, NULL, 0)) + dir_cd( ".", NULL, 0); + + strcpy( dirfile->directory, dirpath); + + dum = ( int16)strlen( dirfile->directory); + + if ( dirfile->directory[dum-1] != '\\') + strcat( dirfile->directory, "\\"); + + if (( dir = opendir( ".")) == NULL) + { + errshow( "dir", errno); + goto abort; + } + + while(( de = readdir( dir)) != NULL) + { + if (( strcmp( de->d_name, ".") == 0) || ( strcmp( de->d_name, "..") == 0)) + continue; + + if ( stat( de->d_name, &file_stat) != 0) + continue; + + if (((( file_stat.st_flags & FA_HIDDEN) != 0) || de->d_name[0] == '.') && !show_hidden) + continue; + + /* allocate new memory for entries if needed */ + if ( dirfile->nbr_icons >= allocated_entries) + { /* allocate new entries */ + if ( dirfile->nbr_icons == 0) + { /* alloc for the first time */ + if (( dirfile->entry = ( Entry *)gmalloc( ALLOC_NDIRENTRIES * sizeof( Entry))) == NULL) + { + errshow( "", ENOMEM); + goto abort; + } + } + else + { /* expand allocated memory */ + if (( entry = ( Entry *)grealloc( dirfile->entry, ( allocated_entries + ALLOC_NDIRENTRIES) * sizeof( Entry))) == NULL) + { + errshow( "", ENOMEM); + goto abort; + } + dirfile->entry = entry; + } + allocated_entries += ALLOC_NDIRENTRIES; + } + /* fill out and add new entry */ + entry = &dirfile->entry[dirfile->nbr_icons]; + entry->preview.image = NULL; + entry->preview.page = 0; + entry->preview.comments = NULL; + entry->next_selected = NULL; + entry->stat = file_stat; + strcpy( entry->name, de->d_name); + zstrncpy( entry->name_shown, de->d_name, 99); + + /* Get Size */ + size_to_text( entry->size, ( float)file_stat.st_size); + /* Get Time */ + tmt = localtime(&file_stat.st_mtime); + strftime( entry->date, 28, "%A %d %B %Y", tmt); + strftime( entry->time, 12, "%H:%M:%S", tmt); + + set_entry_icon( entry); + + /* find if the entry name is bigger than the case width */ + if (( entry->icon_txt_w = get_text_width( entry->name_shown)) >= dirfile->case_w - 4) + entry->icon_txt_w = name_shorter( dirfile->case_w - 6, entry->name_shown); + + dirfile->nbr_icons++; + } + + closedir( dir); + + sort_entries( dirfile); + + return TRUE; + + +abort: + closedir( dir); + + if ( dirfile->nbr_icons > 0) + gfree( dirfile->entry); + return FALSE; +} + + +/*==================================================================================* + * scan_mini_drv: * + * Creates a list with the available drives. * + *----------------------------------------------------------------------------------* + * returns: TRUE if ok, FALSE if any error occured * + *==================================================================================*/ +boolean scan_mini_drv( WINDOW *win) +{ + int current_drv, drv, allocated_entries = 0; + uint32 drives, tmp_d; + Mini_Entry *entry; + WINDICON *dirlist = ( WINDICON *)DataSearch( win, WD_ICON); + + /* initialise directory descriptor */ + dirlist->nbr_child = 0; + dirlist->entry = NULL; + dirlist->mini_selected = NULL; + + /* read contents of directory and build list */ + drives = Drvmap(); + + tmp_d = drives; + + for ( current_drv = 0; current_drv < 32; current_drv++, tmp_d >>= 1) + { + if ( tmp_d & 0x1) + { + drv = 'A' + current_drv; + + if ( strchr( skip_drive, drv)) + continue; + + /* allocate new memory for entries if needed */ + if ( dirlist->nbr_child >= allocated_entries) + { + if ( dirlist->nbr_child == 0) + { + if (( dirlist->root = ( Mini_Entry *)gmalloc( ALLOC_NDIRENTRIES * sizeof( Mini_Entry))) == NULL) + goto abort; + } + else + { + if (( entry = ( Mini_Entry *)grealloc( dirlist->root, ( allocated_entries + ALLOC_NDIRENTRIES) * sizeof( Mini_Entry))) == NULL) + goto abort; + + dirlist->root = entry; + } + allocated_entries += ALLOC_NDIRENTRIES; + } + + /* fill out and add new entry */ + entry = &dirlist->root[dirlist->nbr_child]; + + sprintf( entry->foldername, "%c:\\", drv); + sprintf( entry->name, "%c", drv); + + entry->parent = NULL; + entry->child = NULL; + entry->nbr_child = 0; + entry->icon_txt_w = get_text_width( entry->name); + entry->state = UNKNOWN; + + dirlist->nbr_child++; + } + } + + return TRUE; + +abort: + if ( dirlist->nbr_child > 0) + gfree( dirlist->root); + + errshow( "", ENOMEM); + + return FALSE; +} + + +void check_mini_dir( int16 nbr_child, Mini_Entry *entry) +{ + int16 i, next; + char old_dir[MAX_PATH]; + DIR *dir; + struct dirent *de; + struct stat file_stat; + + for ( i = 0 ; i < nbr_child; i++) + { + next = 0; + + if ( dir_cd( entry[i].foldername, old_dir, ( int)( sizeof old_dir))) + { + if (( dir = opendir( entry[i].foldername)) != NULL) + { + while(( de = readdir( dir)) != NULL && next == 0) + { + if (( strcmp( de->d_name, ".") == 0) || ( strcmp( de->d_name, "..") == 0)) + continue; + + if ( stat( de->d_name, &file_stat) != 0) + continue; + + if ( S_ISDIR( file_stat.st_mode)) + { + next = 1; + entry[i].state = OFF; + } + } + closedir( dir); + } + dir_cd( old_dir, NULL, 0); + } + } +} + + +boolean scan_mini_dir( WINDOW *win, Mini_Entry *parent) +{ + short allocated_entries = 0; + char old_dir[MAX_PATH]; + Mini_Entry *entry; + DIR *dir; + struct dirent *de; + struct stat file_stat; + + + if ( dir_cd( parent->foldername, old_dir, ( int)( sizeof old_dir))) + { + if (( dir = opendir( ".")) != NULL) + { + while(( de = readdir( dir)) != NULL) + { + if (( strcmp( de->d_name, ".") == 0) || ( strcmp( de->d_name, "..") == 0)) + continue; + + if ( stat( de->d_name, &file_stat) != 0) + continue; + + if ( !S_ISDIR( file_stat.st_mode)) + continue; + + if (( file_stat.st_flags & 2) == FA_HIDDEN && !show_hidden) + continue; + + if ( parent->nbr_child >= allocated_entries) + { + if ( parent->nbr_child == 0) + { + if (( parent->child = ( Mini_Entry *)gmalloc( ALLOC_NDIRENTRIES * sizeof( Mini_Entry))) == NULL) + goto abort; + } + else + { + if (( entry = ( Mini_Entry *)grealloc( parent->child, ( allocated_entries + ALLOC_NDIRENTRIES) * sizeof( Mini_Entry))) == NULL) + goto abort; + + parent->child = entry; + } + allocated_entries += ALLOC_NDIRENTRIES; + } + + entry = &parent->child[parent->nbr_child]; + + strcpy( entry->foldername, parent->foldername); + strcat( entry->foldername, de->d_name); + strcat( entry->foldername, "\\"); + strcpy( entry->name, de->d_name); + + entry->parent = parent; + entry->child = NULL; + entry->nbr_child = 0; + entry->icon_txt_w = get_text_width( entry->name); + entry->state = UNKNOWN; + + parent->nbr_child++; + } + closedir( dir); + } + dir_cd( old_dir, NULL, 0); + } + + qsort( parent->child, parent->nbr_child, sizeof( Mini_Entry), cmp_entries_name); + + return TRUE; + + +abort: + closedir( dir); + if ( parent->nbr_child > 0) + gfree( parent->child); + + parent->nbr_child = 0; + + return FALSE; +} diff --git a/sources/z-tools/trunk/zview/file/file.h b/sources/z-tools/trunk/zview/file/file.h new file mode 100644 index 0000000..a45d633 --- /dev/null +++ b/sources/z-tools/trunk/zview/file/file.h @@ -0,0 +1,7 @@ +extern boolean dir_cd( const char *new_dir, char *old_dir, int16 bufflen); +extern boolean dir_parent( char *dir, char *old_dir); +extern boolean check_write_perm( const struct stat *file_stat); +extern boolean scan_dir( WINDOW *win, const char *dirpath); +extern boolean scan_mini_drv( WINDOW *win); +extern void check_mini_dir( int16 nb_child, Mini_Entry *entry); +extern boolean scan_mini_dir( WINDOW *win, Mini_Entry *parent); diff --git a/sources/z-tools/trunk/zview/file/rename.c b/sources/z-tools/trunk/zview/file/rename.c new file mode 100644 index 0000000..7a3b572 --- /dev/null +++ b/sources/z-tools/trunk/zview/file/rename.c @@ -0,0 +1,55 @@ +/*----------------------------------------------------------------------*/ +/* Rename functions */ +/*----------------------------------------------------------------------*/ +#include "../general.h" +#include "../catalog/catalog_icons.h" +#include "file.h" + +/* prototype */ +boolean rename_entry( WINDOW *win, const char *new_name); + + +/*==================================================================================* + * rename_entry: * + * rename a file or directory. * + *----------------------------------------------------------------------------------* + * returns: TRUE = success, FALSE = rename not complete. * + *----------------------------------------------------------------------------------* + * old_name: Pointer to the current file/directory name. * + * new_name: Pointer to the new file/directory name. * + *==================================================================================*/ + +boolean rename_entry( WINDOW *win, const char *new_name) +{ + int16 i; + WINDICON *wicones = (WINDICON *)DataSearch( win, WD_ICON); + + if( strcmp( wicones->first_selected->name, new_name) == 0) /* if name is unchanged, do nothing */ + return FALSE; + + if( strchr( new_name, '/') || strchr( new_name, '\\')) /* disallow attempts to use rename to move files */ + { + errshow( wicones->first_selected->name, INVAL); + return FALSE; + } + + for ( i = 0 ; i < wicones->nbr_icons ; i++) + if ( !strcmp( wicones->entry[i].name, new_name)) + { + errshow( "", E_NAMEEXIST); + return FALSE; + } + + + if ( rename( wicones->first_selected->name, new_name) != 0) + { + errshow( wicones->first_selected->name, errno); + return FALSE; + } + + strcpy( wicones->first_selected->name, new_name); + + set_entry_icon( wicones->first_selected); + + return TRUE; +} diff --git a/sources/z-tools/trunk/zview/file/rename.h b/sources/z-tools/trunk/zview/file/rename.h new file mode 100644 index 0000000..1eb3240 --- /dev/null +++ b/sources/z-tools/trunk/zview/file/rename.h @@ -0,0 +1,2 @@ +extern boolean rename_entry( WINDOW *win, const char *new_name); + diff --git a/sources/z-tools/trunk/zview/file/sort.c b/sources/z-tools/trunk/zview/file/sort.c new file mode 100644 index 0000000..65da849 --- /dev/null +++ b/sources/z-tools/trunk/zview/file/sort.c @@ -0,0 +1,159 @@ +/*----------------------------------------------------------------------*/ +/* Sortring Operations */ +/*------------------- ---------------------------------------------------*/ +#include "..//general.h" +#include "..//ztext.h" +#include "..//prefs.h" + +/* prototype */ +int cmp_entries_name( const void *obj_a, const void *obj_b); +static int cmp_entries_size( const void *obj_a, const void *obj_b); +static int cmp_entries_date( const void *obj_a, const void *obj_b); +static int cmp_entries_dirsbeforefiles(const void *obj_a, const void *obj_b); +int16 sort_entries( WINDICON *dirfile); + + +int cmp_entries_name(const void *obj_a, const void *obj_b) +{ + Entry *entry_a; + Entry *entry_b; + int cmp_val; + char name_a[256]; + char name_b[256]; + + entry_a = (Entry *)obj_a; + entry_b = (Entry *)obj_b; + + strcpy(name_a, entry_a->name); + str2lower(name_a); + strcpy(name_b, entry_b->name); + str2lower(name_b); + + cmp_val = strcmp(name_a, name_b); + + return cmp_val; +} + + +static int cmp_entries_size(const void *obj_a, const void *obj_b) +{ + Entry *entry_a; + Entry *entry_b; + int cmp_val; + int32 size_a; + int32 size_b; + + entry_a = (Entry *)obj_a; + entry_b = (Entry *)obj_b; + + size_a = entry_a->stat.st_size; + size_b = entry_b->stat.st_size; + + if ( size_a < size_b) + cmp_val = -1; + else if ( size_a == size_b) + cmp_val = 0; + else + cmp_val = 1; + + return cmp_val; +} + + +static int cmp_entries_date(const void *obj_a, const void *obj_b) +{ + Entry *entry_a; + Entry *entry_b; + int cmp_val; + int32 date_a; + int32 date_b; + + entry_a = (Entry *)obj_a; + entry_b = (Entry *)obj_b; + + date_a = entry_a->stat.st_mtime; + date_b = entry_b->stat.st_mtime; + + if ( date_a < date_b) + cmp_val = -1; + else if ( date_a == date_b) + cmp_val = 0; + else + cmp_val = 1; + + return cmp_val; +} + + +static int cmp_entries_dirsbeforefiles(const void *obj_a, const void *obj_b) +{ + Entry *entry_a; + Entry *entry_b; + int cmp_val; + + entry_a = (Entry *)obj_a; + entry_b = (Entry *)obj_b; + + + if ( entry_a->type == ET_DIR) + cmp_val = ( ( entry_b->type == ET_DIR) ? 0 : -1); + else + cmp_val = ( ( entry_b->type == ET_DIR) ? 1 : 0); + + return cmp_val; +} + + +int16 sort_entries( WINDICON *dirfile) +{ + int16 nb_of_dirs = 0; + + if ( dirfile->nbr_icons < 2) + return 1; + + switch ( sortingmode) + { + case 0: /* directories before files */ + /* get number of directories */ + qsort(dirfile->entry, dirfile->nbr_icons, sizeof(Entry), cmp_entries_dirsbeforefiles); + while ( (nb_of_dirs < dirfile->nbr_icons) && ( dirfile->entry[nb_of_dirs].type == ET_DIR)) + nb_of_dirs++; + /* sort directories */ + if (nb_of_dirs > 1) + qsort(dirfile->entry, nb_of_dirs, sizeof(Entry), cmp_entries_name); + /* sort files */ + if (dirfile->nbr_icons - nb_of_dirs > 1) + qsort(&dirfile->entry[nb_of_dirs], dirfile->nbr_icons - nb_of_dirs, sizeof(Entry), cmp_entries_name); + break; + + case 1 : + /* get number of directories */ + qsort(dirfile->entry, dirfile->nbr_icons, sizeof(Entry), cmp_entries_dirsbeforefiles); + while ( (nb_of_dirs < dirfile->nbr_icons) && ( dirfile->entry[nb_of_dirs].type == ET_DIR)) + nb_of_dirs++; + /* sort directories */ + if (nb_of_dirs > 1) + qsort(dirfile->entry, nb_of_dirs, sizeof(Entry), cmp_entries_name); + /* sort files */ + if (dirfile->nbr_icons - nb_of_dirs > 1) + qsort(&dirfile->entry[nb_of_dirs], dirfile->nbr_icons - nb_of_dirs, sizeof(Entry), cmp_entries_size); + break; + + case 2 : /* files before directories */ + /* get number of directories */ + qsort(dirfile->entry, dirfile->nbr_icons, sizeof(Entry), cmp_entries_dirsbeforefiles); + while ( (nb_of_dirs < dirfile->nbr_icons) && ( dirfile->entry[nb_of_dirs].type == ET_DIR)) + nb_of_dirs++; + /* sort directories */ + if (nb_of_dirs > 1) + qsort(dirfile->entry, nb_of_dirs, sizeof(Entry), cmp_entries_name); + /* sort files */ + if (dirfile->nbr_icons - nb_of_dirs > 1) + qsort(&dirfile->entry[nb_of_dirs], dirfile->nbr_icons - nb_of_dirs, sizeof(Entry), cmp_entries_date); + break; + + default: + break; + } + return 1; +} diff --git a/sources/z-tools/trunk/zview/file/sort.h b/sources/z-tools/trunk/zview/file/sort.h new file mode 100644 index 0000000..be083b2 --- /dev/null +++ b/sources/z-tools/trunk/zview/file/sort.h @@ -0,0 +1,2 @@ +extern int16 sort_entries( WINDICON *dirfile); +extern int cmp_entries_name(const void *obj_a, const void *obj_b); diff --git a/sources/z-tools/trunk/zview/full_scr.c b/sources/z-tools/trunk/zview/full_scr.c new file mode 100644 index 0000000..ba14911 --- /dev/null +++ b/sources/z-tools/trunk/zview/full_scr.c @@ -0,0 +1,142 @@ +#include "general.h" +#include "pic_load.h" +#include "winimg.h" +#include "mfdb.h" +#include "pic_resize.h" + +int16 full_screen = FALSE; + +/*==================================================================================* + * void restore_screen: * + * Close the form dialog created previously with clear_screen() function and * + * restore the menubar and the mouse. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void restore_screen( void) +{ + form_dial( FMD_FINISH, 0, 0, 1 + app.work_out[0], 1 + app.work_out[1], 0, 0, 1 + app.work_out[0], 1 + app.work_out[1]); + menu_bar( app.menu, 1) ; + v_show_c( app.handle, 0); +} + + +/*==================================================================================* + * void clear_screen: * + * Open a full size form dialog and hide the mouse.. * + * It's the only way that I know for work in pseudo-fullscreen and remain * + * "GEM friendly". * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void clear_screen( void) +{ + int16 xy[8]; + + vswr_mode( app.handle, MD_REPLACE); + form_dial( FMD_START, 0, 0, 1 + app.work_out[0], 1 + app.work_out[1], 0, 0, 1 + app.work_out[0], 1 + app.work_out[1]); + vsf_perimeter( app.handle, 0); + vsf_interior( app.handle, FIS_SOLID); + xy[0] = xy[1] = 0; + xy[2] = app.work_out[0]; + xy[3] = app.work_out[1]; + v_hide_c( app.handle); + vsf_color( app.handle, BLACK); + vr_recfl( app.handle, xy); +} + +/*==================================================================================* + * void clear_screen: * + * Show a MFDB in fullscreen.. We wait for a keyboard event before to release. * + *----------------------------------------------------------------------------------* + * input: * + * img -> The MFDB to show. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void show_fullscreen( WINDATA *windata) +{ + MFDB *out, resized_out = { NULL, app.work_out[0], app.work_out[1], 0, 0, 0, 0, 0, 0}, screen = {0}; + int16 posx, posy, xy[8]; + IMAGE *img = &windata->img; +/* int16 dum; + char info[256]; + */ + + full_screen = TRUE; + + out = &img->image[windata->page_to_show]; + + if( out->fd_w > app.work_out[0] || out->fd_h > app.work_out[1]) + { + if( pic_resize( &img->image[windata->page_to_show], &resized_out) == 0) + { + errshow( "", ENOMEM); + full_screen = FALSE; + return; + } + + out = &resized_out; + } + + clear_screen(); + wind_update(BEG_UPDATE); + + posx = MAX( ( 1 + app.work_out[0] - out->fd_w) >> 1, 0); + posy = MAX( ( 1 + app.work_out[1] - out->fd_h) >> 1, 0); + + if (posx == 0) + xy[2] = app.work_out[0]; + else + xy[2] = out->fd_w - 1; + + if (posy == 0) + xy[3] = app.work_out[1]; + else + xy[3] = out->fd_h - 1; + + xy[0] = 0; + xy[1] = 0; + xy[4] = posx; + xy[5] = posy; + xy[6] = posx + xy[2]; + xy[7] = posy + xy[3]; + + /* draw the image */ + if ( out->fd_nplanes == 1) + { + int16 color[2] = { BLACK, WHITE}; + + vrt_cpyfm( app.handle, MD_REPLACE, xy, out, &screen, color); + } + else + vro_cpyfm( app.handle, S_ONLY, xy, out, &screen); + + /* and now the image's information */ + /* sprintf( info, "%dx%dx%d | %ld colors | %s", img->img_w, img->img_h, img->bits, img->colors, img->info); + + vst_alignment( app.handle, 2, 4, &dum, &dum); + vst_color( app.handle, BLACK); + vst_point( app.handle, 8, &dum, &dum, &dum, &dum); + v_ftext( app.handle, app.work_out[0] - 4, app.work_out[1] - 4, info); + */ + + /* We wait for a keyboard event and after, restore the screen */ + evnt_keybd(); + + if( resized_out.fd_addr != NULL) + gfree( resized_out.fd_addr); + + restore_screen(); + wind_update( END_UPDATE); + full_screen = FALSE; +} diff --git a/sources/z-tools/trunk/zview/full_scr.h b/sources/z-tools/trunk/zview/full_scr.h new file mode 100644 index 0000000..45f1d90 --- /dev/null +++ b/sources/z-tools/trunk/zview/full_scr.h @@ -0,0 +1,5 @@ +extern void restore_screen( void); +extern void clear_screen( void); +extern void show_fullscreen( WINDATA *windata); +extern int16 full_screen; + diff --git a/sources/z-tools/trunk/zview/general.h b/sources/z-tools/trunk/zview/general.h new file mode 100644 index 0000000..13ebb7f --- /dev/null +++ b/sources/z-tools/trunk/zview/general.h @@ -0,0 +1,252 @@ +/* + * zView. + * Copyright (c) 2004-2005 Zorro ( zorro270@yahoo.fr) + * + * This application is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#include "types2b.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "zaes.h" +#include "zedit/libtedit.h" +#include "pdf/goo/gmem.h" +#include "zview.rsh" + +/* Window's Attrib. */ +#define WINATTRIB MOVER|NAME|VSLIDE|MOVER|CLOSER|DNARROW|UPARROW|SIZER|SMALLER|FULLER + +/* Custom data name */ +#define WD_ICON 0x49434F4EL +#define WD_WIMG 0x57494D47L + +/* Custom error code */ +#define E_NAMEEXIST 10001 +#define E_RSC 10002 +#define NO_EDDI 10003 +#define NO_ICON 10004 + +/* custom def */ +#define preview_mode 1 +#define full_size 0 +#define ON 1 +#define OFF 0 +#define UNKNOWN -1 + +/* xfont text attrib. */ +#define BOLD 0x01 +#define LIGHT 0x02 +#define ITALIC 0x04 +#define ULINE 0x08 +#define INVERSE 0x10 +#define SHADOW 0x20 +#define MONOSPACE 0x40 + + +#ifndef MAXNAMLEN + #define MAXNAMLEN 255 +#endif + +#ifndef MAX_PATH + #define MAX_PATH 1024 +#endif + +#define shared_malloc( s) _ldg_malloc( s, ldg_global[2]); +#define shared_realloc( s, b) _ldg_realloc( s, b, ldg_global[2]); +#define shared_free( s) _ldg_free( s, ldg_global[2]); + +/* MACRO */ +#ifndef ABS + #define ABS(val) ( ( ( val) < 0) ? -( val) : ( val)) +#endif + +#ifndef XATTR +typedef struct +{ + uint16 mode; + int32 index; + uint16 dev; + uint16 reserved1; + uint16 nlink; + uint16 uid; + uint16 gid; + int32 size; + int32 blksize; + int32 nblocks; + int16 mtime; + int16 mdate; + int16 atime; + int16 adate; + int16 ctime; + int16 cdate; + int16 attr; + int16 reserved2; + int32 reserved3; + int32 reserved4; +} XATTR; +#endif + +typedef struct +{ + uint32 item; + uint32 size; +} fileinfo; + +typedef enum +{ + ET_DIR, + ET_FILE, + ET_IMAGE, + ET_PDF, + ET_PRG +} EntryType; + + +typedef struct _txt_data +{ + int16 lines; /* Number of lines in the text */ + int16 max_lines_length; /* The length of the greater line ( in nbr char) */ + int8 *txt[256]; +} txt_data; + + +typedef struct +{ + /* Image Info */ + uint16 img_w, img_h; /* original size */ + int16 bits; /* image's colors bits */ + int8 working_time[12]; /* ex: 15,2s */ + uint32 colors; /* Picture colors's number */ + int8 info[38]; /* Information about the image, for ex: "Portable Network Graphic" */ + int8 compression[5]; /* Compression type, ex: "LZW" */ + int16 page; /* Number of page/image in the file */ + uint16 delay[1024]; /* Animation delay in millise. between each frame */ + + txt_data *comments; + + /* Private Data */ + int16 view_mode; /* preview or full size view? */ + int16 progress_bar; /* display the progress bar? */ + + /* Private data for the PDF */ + void *_priv_ptr; + void *_priv_ptr_more; + /* ------------------------ */ + + MFDB *image; /* The Image itself */ +}IMAGE; + + +typedef struct _entry +{ + int8 name[MAXNAMLEN]; /* The real file's name */ + int8 name_shown[100]; /* The file's name shown in the window */ + + struct stat stat; /* Entry's Unix Stat */ + + int8 size[15]; /* File size in human readable format */ + int8 date[28]; /* date of last modification */ + int8 time[12]; /* time of last modification */ + + int16 icon_txt_w; /* Text width for screen output */ + + RECT16 txt_pos; /* text position in the window */ + RECT16 icn_pos; /* icon position in the window */ + RECT16 case_pos; /* case position in the window */ + + EntryType type; /* icon type */ + + IMAGE preview; /* the preview data and picture */ + + MFDB *icon; /* icon */ + + struct _entry *next_selected; + struct _entry *next; + +} Entry; + + + +typedef struct _mini +{ + char foldername[MAX_PATH + MAXNAMLEN]; /* Folder name with the full path */ + char name[MAXNAMLEN]; /* Folder's name shown in the window */ + + RECT16 icon_position; /* text position in the window */ + RECT16 arrow_position; /* icon position in the window */ + + struct _mini *parent; /* the parent entry */ + struct _mini *child; /* the child(s) entry */ + + int16 nbr_child; /* number of valid child's entries */ + int16 icon_txt_w; /* Text width for screen output */ + int16 state; /* Deployed or not ( ON/OFF) */ +} Mini_Entry; + + + + +typedef struct +{ + char directory[MAX_PATH]; /* current directory */ + + /* File browser data */ + int16 border_position[2]; /* frame's border position in the 'x' axe */ + int16 case_w; /* case width */ + int16 case_h; /* case height */ + int16 columns; /* number of columns */ + int16 icons_last_line; /* number of icons in the last line */ + EDIT *edit; /* Text struct for the edition mode */ + Entry *first_selected; /* Pointer to the first icon selected */ + Entry *entry; /* pointer to 'Entry' structur */ + int16 nbr_icons; /* number of valid icons */ + + + /* "Tree view" data */ + Mini_Entry *mini_selected; /* Pointer to 'Mini_Entry' structur */ + Mini_Entry *root; /* Pointer to 'Mini_Entry' structur */ + int16 nbr_child; /* Number of valid child's entries */ + int32 ypos; /* relative data position in the window */ + int32 ypos_max; /* Maximal values of previous variables */ + int16 h_u; /* vertical and horizontal scroll offset */ + +} WINDICON; + + +extern int16 pic_load( const char *file, char *extention, IMAGE *img); +extern void zdebug( const char *format, ...); +extern void applexit( void); + +/* Globals variables */ +extern WINDOW *win_catalog; +extern WINDOW *win_image; +extern char zview_path[MAX_PATH]; +extern int16 mint_os, magic_os; + +/* Windom's function not defined in windom.h */ +extern void frm_cls( WINDOW *win); +extern void snd_rdw( WINDOW *win); +extern void snd_msg( WINDOW *win, int msg, int par1, int par2, int par3, int par4); +extern void draw_page( WINDOW *win, int x, int y, int w, int h); diff --git a/sources/z-tools/trunk/zview/howto_build/howto.txt b/sources/z-tools/trunk/zview/howto_build/howto.txt new file mode 100644 index 0000000..33a92a6 --- /dev/null +++ b/sources/z-tools/trunk/zview/howto_build/howto.txt @@ -0,0 +1,11 @@ +Building zView is a little bit complicated but not that much. + +1. Download & compile & install libfreetype2 (the most recent version is + 2.4.6 in time of writing this, it's proven to work). +2. Download & compile & install windom 1.21.3 after applying the patch. +3. Rename libwindom.a -> libwindom1.a, same for the header file (windom.h -> + windom1.h) +4. Checkout & compile & install ldg (from the official sf.net site). You + must not use the latest stable version (2.33). +5. Edit the path to libfreetype2 in the toplevel Makefile. +6. make diff --git a/sources/z-tools/trunk/zview/howto_build/tiff-3.8.2-mint.patch b/sources/z-tools/trunk/zview/howto_build/tiff-3.8.2-mint.patch new file mode 100644 index 0000000..30b723b --- /dev/null +++ b/sources/z-tools/trunk/zview/howto_build/tiff-3.8.2-mint.patch @@ -0,0 +1,38 @@ +diff -ur tiff-3.8.2/libtiff/Makefile.am tiff-3.8.2-new/libtiff/Makefile.am +--- tiff-3.8.2/libtiff/Makefile.am 2006-03-23 15:31:53.000000000 +0100 ++++ tiff-3.8.2-new/libtiff/Makefile.am 2011-10-24 21:19:02.146076731 +0200 +@@ -108,7 +108,7 @@ + libtiff_la_SOURCES = $(SRCS) + libtiff_la_LDFLAGS = \ + -no-undefined \ +- -version-number $(LIBTIFF_VERSION_INFO) ++ -version-info $(LIBTIFF_VERSION_INFO) + if HAVE_RPATH + libtiff_la_LDFLAGS += $(LIBDIR) + endif +@@ -117,7 +117,7 @@ + libtiffxx_la_SOURCES = $(SRCSXX) + libtiffxx_la_LDFLAGS = \ + -no-undefined \ +- -version-number $(LIBTIFF_VERSION_INFO) ++ -version-info $(LIBTIFF_VERSION_INFO) + if HAVE_RPATH + libtiffxx_la_LDFLAGS += $(LIBDIR) + endif +diff -ur tiff-3.8.2/libtiff/Makefile.in tiff-3.8.2-new/libtiff/Makefile.in +--- tiff-3.8.2/libtiff/Makefile.in 2006-03-23 15:44:45.000000000 +0100 ++++ tiff-3.8.2-new/libtiff/Makefile.in 2011-10-24 21:19:12.932758298 +0200 +@@ -355,11 +355,11 @@ + noinst_HEADERS = $(EXTRA_HDRS) + lib_LTLIBRARIES = libtiff.la $(am__append_2) + libtiff_la_SOURCES = $(SRCS) +-libtiff_la_LDFLAGS = -no-undefined -version-number \ ++libtiff_la_LDFLAGS = -no-undefined -version-info \ + $(LIBTIFF_VERSION_INFO) $(am__append_3) + libtiff_la_LIBADD = $(LIBPORT) + libtiffxx_la_SOURCES = $(SRCSXX) +-libtiffxx_la_LDFLAGS = -no-undefined -version-number \ ++libtiffxx_la_LDFLAGS = -no-undefined -version-info \ + $(LIBTIFF_VERSION_INFO) $(am__append_4) + libtiffxx_la_LIBADD = $(LIBTIFF) $(LIBPORT) + libtiffxx_la_DEPENDENCIES = libtiff.la diff --git a/sources/z-tools/trunk/zview/howto_build/windom-1.21.3.patch b/sources/z-tools/trunk/zview/howto_build/windom-1.21.3.patch new file mode 100644 index 0000000..9391cc5 --- /dev/null +++ b/sources/z-tools/trunk/zview/howto_build/windom-1.21.3.patch @@ -0,0 +1,134 @@ +diff -ruw windom-1.21.3/include/windom.h windom-1.21.3-new/include/windom.h +--- windom-1.21.3/include/windom.h 2004-11-24 22:08:29.000000000 +0100 ++++ windom-1.21.3-new/include/windom.h 2011-10-17 17:13:19.440919410 +0200 +@@ -522,11 +522,7 @@ + int ApplGet ( int mode, ...); + int ApplSet ( int mode, ...); + int ApplName ( char *name, int handle); +-#ifdef __MSHORT__ + int ApplWrite ( int to, int msg, ...); +-#else +-int ApplWrite ( int to, int msg, int b3, int b4, int b5, int b6, int b7); +-#endif + int ApplControl ( int ap_cid, int ap_cwhat); + + /* AV library */ +diff -ruw windom-1.21.3/src/appl_set.c windom-1.21.3-new/src/appl_set.c +--- windom-1.21.3/src/appl_set.c 2004-11-24 22:08:29.000000000 +0100 ++++ windom-1.21.3-new/src/appl_set.c 2011-10-17 17:13:19.440919410 +0200 +@@ -44,10 +44,10 @@ + if( !CONF(app)) return 2; + + va_start( list, mode); +- v1 = va_arg( list, short); +- v2 = va_arg( list, short); +- v3 = va_arg( list, short); +- v4 = va_arg( list, short); ++ v1 = va_arg( list, int); ++ v2 = va_arg( list, int); ++ v3 = va_arg( list, int); ++ v4 = va_arg( list, int); + va_end( list); + + switch( mode) { +diff -ruw windom-1.21.3/src/appl_write.c windom-1.21.3-new/src/appl_write.c +--- windom-1.21.3/src/appl_write.c 2004-11-24 22:08:29.000000000 +0100 ++++ windom-1.21.3-new/src/appl_write.c 2011-10-17 17:13:19.444252608 +0200 +@@ -34,29 +34,6 @@ + + /* A more pratical call to appl_write() */ + +-#ifndef __MSHORT__ +- +-/* en 32bits, on attend des 'int' plutot que '...' (va_args) en parametre */ +-/* car c'est le seul moyen d'‚viter l'utilisation du code genre */ +-/* ApplWrite( to, msg, "tralala"); */ +-/* qui fonctionne uniquement en 16 bits si on utilise va_args */ +- +-int ApplWrite( int to, int msg, int b3, int b4, int b5, int b6, int b7) { +- INT16 buf[8]; +- +- buf[0] = msg; +- buf[1] = app.id; +- buf[2] = 0; +- buf[3] = b3; +- buf[4] = b4; +- buf[5] = b5; +- buf[6] = b6; +- buf[7] = b7; +- return appl_write( to, 16, buf); +-} +- +-#else +- + int ApplWrite( int to, int msg, ...) { + va_list args; + short buf[8]; +@@ -65,13 +42,11 @@ + buf[1] = app.id; + buf[2] = 0; + va_start( args, msg); +- buf[3] = va_arg( args, short); +- buf[4] = va_arg( args, short); +- buf[5] = va_arg( args, short); +- buf[6] = va_arg( args, short); +- buf[7] = va_arg( args, short); ++ buf[3] = va_arg( args, int); ++ buf[4] = va_arg( args, int); ++ buf[5] = va_arg( args, int); ++ buf[6] = va_arg( args, int); ++ buf[7] = va_arg( args, int); + va_end( args); + return appl_write( to, 16, buf); + } +-#endif +- +diff -ruw windom-1.21.3/src/av_init.c windom-1.21.3-new/src/av_init.c +--- windom-1.21.3/src/av_init.c 2004-11-24 22:08:29.000000000 +0100 ++++ windom-1.21.3-new/src/av_init.c 2011-10-17 17:14:40.931886052 +0200 +@@ -73,7 +73,8 @@ + static int av_ping( int status, long idle) { + INT16 msg[8]; + +- ApplWrite( app.avid, AV_PROTOKOLL, status, 0, 0, ADR(__av_name)); ++ strcpy( app.pipe, __av_name); ++ ApplWrite( app.avid, AV_PROTOKOLL, status, 0, 0, ADR(app.pipe)); + if( AvWaitfor( VA_PROTOSTATUS, msg, idle)) { + __av_status[0] = msg[3]; + __av_status[1] = msg[4]; +diff -ruw windom-1.21.3/src/objc_dup.c windom-1.21.3-new/src/objc_dup.c +--- windom-1.21.3/src/objc_dup.c 2004-11-24 22:08:30.000000000 +0100 ++++ windom-1.21.3-new/src/objc_dup.c 2011-10-17 17:13:19.444252608 +0200 +@@ -133,7 +133,7 @@ + case G_TITLE: + mem_adr = __malloc_obspec(&cpy[i],strlen((char*)wparm->wp_spec)+1); + strcpy(mem_adr,(char*)wparm->wp_spec); +- (char*)wparm->wp_spec = mem_adr; ++ wparm->wp_spec = mem_adr; + break; + } + } +diff -ruw windom-1.21.3/src/objc_string.c windom-1.21.3-new/src/objc_string.c +--- windom-1.21.3/src/objc_string.c 2004-11-24 22:08:30.000000000 +0100 ++++ windom-1.21.3-new/src/objc_string.c 2011-10-17 17:13:19.444252608 +0200 +@@ -78,7 +78,7 @@ + case XFREESTR: + user = tree[idx].ob_spec.userblk; + if( put) +- (char*)((W_PARM*)user->ub_parm)->wp_spec = put; ++ ((W_PARM*)user->ub_parm)->wp_spec = put; + return ( (char*)((W_PARM*)user->ub_parm)->wp_spec); + + #ifdef MODIF_XEDIT +diff -ruw windom-1.21.3/src/popup.c windom-1.21.3-new/src/popup.c +--- windom-1.21.3/src/popup.c 2004-11-24 22:08:30.000000000 +0100 ++++ windom-1.21.3-new/src/popup.c 2011-10-17 17:13:19.444252608 +0200 +@@ -87,7 +87,7 @@ + + static void uo_init_type( OBJECT *tree, int index, void *func, + int extype, XUSERBLK * uo) { +- (W_PARM *)(uo -> user . ub_parm) = & ( uo -> w_parm ); ++ uo -> user . ub_parm = & ( uo -> w_parm ); + uo -> user . ub_code = func; + ((W_PARM*)uo -> user . ub_parm) -> wp_type = tree[index].ob_type; + ((W_PARM*)uo -> user . ub_parm) -> wp_spec = tree[index].ob_spec.index; diff --git a/sources/z-tools/trunk/zview/howto_build/xpdf-3.03-zview.patch b/sources/z-tools/trunk/zview/howto_build/xpdf-3.03-zview.patch new file mode 100644 index 0000000..9d98074 --- /dev/null +++ b/sources/z-tools/trunk/zview/howto_build/xpdf-3.03-zview.patch @@ -0,0 +1,559 @@ +--- /dev/null 2011-11-05 17:04:04.509133295 +0100 ++++ new/pdflib.cc 2011-11-05 21:15:20.575216608 +0100 +@@ -0,0 +1,487 @@ ++#include "../general.h" ++#include "../prefs.h" ++#include "../winimg.h" ++#include "aconf.h" ++#include "../custom_font.h" ++#include "goo/gmem.h" ++#include "goo/GString.h" ++#include "goo/GList.h" ++#include "xpdf/GlobalParams.h" ++#include "xpdf/Object.h" ++#include "xpdf/PDFDoc.h" ++#include "splash/SplashBitmap.h" ++#include "splash/Splash.h" ++#include "xpdf/SplashOutputDev.h" ++#include "xpdf/CharTypes.h" ++#include "xpdf/UnicodeMap.h" ++#include "xpdf/Outline.h" ++#include "xpdf/Link.h" ++ ++extern "C" { ++ ++ ++static char latin_to_atari[] = { /*0x00A0*/'*','­','›','œ','*','',17,'Ý','¹','½','¦','®','ª','-','¾', ++'ÿ','ø','ñ','ý','þ','º','æ','¼','ú','*','\'','§','¯','¬','«','*','¨','¶','A','A','·','Ž','','’', ++'€','E','','E','E','I','I','I','I','D','¥','O','O','O','¸','™','x','²','U','U','U','š','Y','*', ++'ž','…',' ','ƒ','°','„','†','‘','‡','Š','‚','ˆ','‰','','¡','Œ','‹','ë','¤','•','¢','“','±','”','ö', ++'³','—','£','–','','y','*','˜'}; ++ ++char pdf_title[256]; ++ ++ ++void delete_bookmark_child( Bookmark *book) ++{ ++ int i; ++ ++ /* if nothing to do, end the function */ ++ if( book->child == NULL) ++ return; ++ ++ /* make a loop to see if the childs mini entries have child, if it's true, delete it */ ++ for ( i = 0; i < book->nbr_child ; i++) ++ { ++ if ( book->child[i].nbr_child) ++ delete_bookmark_child( &book->child[i]); ++ } ++ ++ /* Free the memory and put the counter to zero */ ++ gfree( book->child); ++ book->child = NULL; ++ book->nbr_child = 0; ++} ++ ++ ++int setupOutlineItems( WINDOW * win, PDFDoc *doc, GList *items, UnicodeMap *uMap, Bookmark *book, Bookmark *parent) ++{ ++ OutlineItem *item; ++ GList *kids; ++ LinkAction *link_action; ++ char buf[8], *test; ++ int i, j, n, count, lenght; ++ ++ for (i = 0; i < items->getLength(); ++i) ++ { ++ item = (OutlineItem *)items->get(i); ++ ++ book[i].parent = parent; ++ book[i].child = NULL; ++ book[i].nbr_child = 0; ++ book[i].state = UNKNOWN; ++ book[i].valid = FALSE; ++ ++ link_action = item->getAction(); ++ ++ if( link_action && link_action->getKind () == actionGoTo) ++ { ++ LinkGoTo *link = dynamic_cast (link_action); ++ LinkDest *link_dest = link->getDest(); ++ GString *named_dest = link->getNamedDest (); ++ ++ if (link_dest != NULL) ++ { ++ if (link_dest->isPageRef ()) ++ { ++ Ref page_ref = link_dest->getPageRef (); ++ book[i].linked_page = doc->findPage( page_ref.num, page_ref.gen) - 1; ++ } ++ else ++ { ++ book[i].linked_page = link_dest->getPageNum() - 1; ++ } ++ ++ book[i].valid = TRUE; ++ } ++ else if( named_dest != NULL) ++ { ++ link_dest = doc->findDest (named_dest); ++ ++ if (link_dest->isPageRef ()) ++ { ++ Ref page_ref = link_dest->getPageRef (); ++ book[i].linked_page = doc->findPage( page_ref.num, page_ref.gen) - 1; ++ } ++ else ++ { ++ book[i].linked_page = link_dest->getPageNum () - 1; ++ } ++ ++ delete link_dest; ++ book[i].valid = TRUE; ++ } ++ } ++ ++ if( book[i].valid == FALSE) ++ continue; ++ ++ test = book[i].name; ++ ++ ++ /* Unicode to Latin 1 */ ++ for (j = 0, lenght = 0; j < item->getTitleLength(); ++j) ++ { ++ n = uMap->mapUnicode(item->getTitle()[j], buf, sizeof(buf)); ++ ++ for( count = 0; n > count && lenght < 254; count++) ++ test[lenght++] = buf[count++]; ++ } ++ ++ test[lenght] = '\0'; ++ ++ /* Latin 1 to Atari */ ++ for ( lenght = 0; test[lenght] != '\0'; ++lenght) ++ { ++ if( ( uint8)test[lenght] > 0x9F) ++ { ++ uint8 c = ( uint8)test[lenght] - 0xA0; ++ test[lenght] = latin_to_atari[c]; ++ } ++ } ++ ++ book[i].txt_width = get_text_width( book[i].name); ++ ++ item->open(); ++ ++ if( item->hasKids() && ( kids = item->getKids()) && kids->getLength() > 0) ++ { ++ book[i].nbr_child = kids->getLength(); ++ book[i].child = ( Bookmark*)gmalloc( sizeof( Bookmark) * kids->getLength()); ++ book[i].state = item->isOpen(); ++ ++ if( !setupOutlineItems(win, doc, kids, uMap, book[i].child, book)) ++ { ++ gfree( book[i].child); ++ book[i].child = NULL; ++ book[i].nbr_child = 0; ++ return( 0); ++ } ++ } ++ } ++ return( 1); ++} ++ ++void pdf_build_bookmark( WINDATA *windata, WINDOW *win) ++{ ++ IMAGE *img = &windata->img; ++ PDFDoc *doc = ( PDFDoc*)img->_priv_ptr; ++ Outline *outline; ++ GList *items; ++ int i; ++ ++ outline = doc->getOutline(); ++ ++ if( outline == NULL) ++ return; ++ ++ items = outline->getItems(); ++ ++ if( items == NULL) ++ return; ++ ++ if ( items->getLength() > 0) ++ { ++ windata->root = ( Bookmark*)gmalloc( sizeof( Bookmark) * items->getLength()); ++ ++ if( windata->root == NULL) ++ return; ++ ++ GString *enc = new GString("Latin1"); ++ UnicodeMap *uMap = globalParams->getUnicodeMap(enc); ++ delete enc; ++ ++ windata->nbr_bookmark = items->getLength(); ++ ++ if( !setupOutlineItems( win, doc, items, uMap, windata->root, NULL)) ++ { ++ for ( i = 0; i < windata->nbr_bookmark; i++) ++ { ++ if ( windata->root[i].nbr_child) ++ delete_bookmark_child( &windata->root[i]); ++ } ++ ++ gfree( windata->root); ++ windata->root = NULL; ++ windata->nbr_bookmark = 0; ++ } ++ ++ uMap->decRefCnt(); ++ } ++} ++ ++ ++boolean lib_pdf_load( const char *name, IMAGE *img) ++{ ++ PDFDoc *doc = NULL; ++ SplashColor paperColor; ++ SplashOutputDev *splashOut = NULL; ++ ++ char* aaString = const_cast( pdf_aa ? "yes" : "no"); ++ globalParams->setAntialias( aaString); ++ ++ GString nameString( name); ++ doc = new PDFDoc( &nameString); ++ ++ if (!doc->isOk()) ++ { ++ delete doc; ++ return FALSE; ++ } ++ ++ paperColor[0] = paperColor[1] = paperColor[2] = 0xff; ++ splashOut = new SplashOutputDev( splashModeRGB8, 1, gFalse, paperColor); ++ splashOut->startDoc(doc->getXRef()); ++ ++ img->bits = 24; ++ img->colors = ( 1L << ( uint32)img->bits) - 1; ++ img->page = ( uint16)doc->getNumPages(); ++ img->comments = NULL; ++ img->_priv_ptr = ( void*)doc; ++ img->_priv_ptr_more = ( void*)splashOut; ++ ++ strcpy( ( char*)img->info, "PDF"); ++ strcpy( ( char*)img->compression, "None"); ++ ++ return TRUE; ++} ++ ++ ++ ++void pdf_get_page_size( IMAGE *img, int page, uint16 *width, uint16 *height) ++{ ++ PDFDoc *doc = ( PDFDoc*)img->_priv_ptr; ++ int rotation = doc->getPageRotate( page); ++ ++ if( ( rotation == 90) || ( rotation == 270)) ++ { ++ *width = (uint16)doc->getPageCropHeight( page); ++ *height = (uint16)doc->getPageCropWidth( page); ++ } ++ else ++ { ++ *width = (uint16)doc->getPageCropWidth( page); ++ *height = (uint16)doc->getPageCropHeight( page); ++ } ++} ++ ++ ++void pdf_decode_page( IMAGE *img, int page, double scale) ++{ ++ PDFDoc *doc = ( PDFDoc*)img->_priv_ptr; ++ SplashOutputDev *splashOut = ( SplashOutputDev*)img->_priv_ptr_more; ++ int rotation = doc->getPageRotate( page); ++ ++ if( ( rotation == 90) || ( rotation == 270)) ++ { ++ img->img_w = (uint16)MAX(( doc->getPageCropHeight( page) * scale + 0.5), 1); ++ img->img_h = (uint16)MAX(( doc->getPageCropWidth( page) * scale + 0.5), 1); ++ } ++ else ++ { ++ img->img_w = (uint16)MAX(( doc->getPageCropWidth( page) * scale + 0.5), 1); ++ img->img_h = (uint16)MAX(( doc->getPageCropHeight( page) * scale + 0.5), 1); ++ } ++ ++ doc->displayPage( splashOut, page, 72.0 * scale, 72.0 * scale, 0, gFalse, gTrue, gFalse); ++} ++ ++ ++uint32 *pdf_get_page_addr( IMAGE *img) ++{ ++ SplashOutputDev *splashOut = ( SplashOutputDev*)img->_priv_ptr_more; ++ SplashColorPtr data = splashOut->getBitmap()->getDataPtr(); ++ ++ return ( uint32*)( data); // ( data.rgb8); ++} ++ ++static char *InfoString(Dict *infoDict, char *key, UnicodeMap *uMap) ++{ ++ Object obj; ++ GString *s1; ++ GBool isUnicode; ++ Unicode u; ++ char buf[8]; ++ static char text[256]; ++ int i, n, lenght = 0, count; ++ ++ if (infoDict->lookup(key, &obj)->isString()) ++ { ++ s1 = obj.getString(); ++ ++ if ((s1->getChar(0) & 0xff) == 0xfe && (s1->getChar(1) & 0xff) == 0xff) ++ { ++ isUnicode = gTrue; ++ i = 2; ++ } ++ else ++ { ++ isUnicode = gFalse; ++ i = 0; ++ } ++ ++ while ( i < obj.getString()->getLength()) ++ { ++ if (isUnicode) ++ { ++ u = ((s1->getChar(i) & 0xff) << 8) | (s1->getChar(i+1) & 0xff); ++ i += 2; ++ } ++ else ++ { ++ u = s1->getChar(i) & 0xff; ++ ++i; ++ } ++ ++ n = uMap->mapUnicode(u, buf, sizeof(buf)); ++ ++ count = 0; ++ ++ if(( n + lenght) > 234) ++ { ++ text[lenght] = '\0'; ++ obj.free(); ++ return ( char*)&text; ++ } ++ ++ while( n > count) ++ text[lenght++] = buf[count++]; ++ } ++ } ++ ++ text[lenght] = '\0'; ++ obj.free(); ++ ++ return ( char*)&text; ++} ++ ++static char *InfoDate(Dict *infoDict, char *key) ++{ ++ Object obj; ++ char *s; ++ int year, mon, day, hour, min, sec; ++ struct tm tmStruct; ++ static char buf[256]; ++ ++ if (infoDict->lookup(key, &obj)->isString()) ++ { ++ s = obj.getString()->getCString(); ++ ++ if (s[0] == 'D' && s[1] == ':') ++ { ++ s += 2; ++ } ++ ++ if (sscanf(s, "%4d%2d%2d%2d%2d%2d", &year, &mon, &day, &hour, &min, &sec) == 6) ++ { ++ tmStruct.tm_year = year - 1900; ++ tmStruct.tm_mon = mon - 1; ++ tmStruct.tm_mday = day; ++ tmStruct.tm_hour = hour; ++ tmStruct.tm_min = min; ++ tmStruct.tm_sec = sec; ++ tmStruct.tm_wday = -1; ++ tmStruct.tm_yday = -1; ++ tmStruct.tm_isdst = -1; ++ // compute the tm_wday and tm_yday fields ++ if (mktime(&tmStruct) != (time_t)-1 && strftime(buf, sizeof(buf), "%c", &tmStruct)) ++ { ++ obj.free(); ++ return ( char*)&buf; ++ } ++ } ++ ++ strcpy( buf, s); ++ } ++ else buf[0] = '\0'; ++ ++ obj.free(); ++ return ( char*)&buf; ++} ++ ++void pdf_get_info( IMAGE *img, txt_data *txtdata) ++{ ++ Object info; ++ UnicodeMap *uMap; ++ PDFDoc *doc = ( PDFDoc*)img->_priv_ptr; ++ char *txt; ++ ++ if (!( uMap = globalParams->getTextEncoding())) ++ { ++ pdf_title[0] = '\0'; ++ txtdata->txt[0][0] = '\0'; ++ txtdata->txt[1][0] = '\0'; ++ txtdata->txt[2][0] = '\0'; ++ txtdata->txt[3][0] = '\0'; ++ txtdata->txt[4][0] = '\0'; ++ txtdata->txt[5][0] = '\0'; ++ txtdata->txt[6][0] = '\0'; ++ txtdata->txt[7][0] = '\0'; ++ return; ++ } ++ ++ doc->getDocInfo(&info); ++ ++ if (info.isDict()) ++ { ++ txt = InfoString(info.getDict(), "Title", uMap); ++ sprintf( ( char*)txtdata->txt[0] , "Title: %s", txt); ++ strcpy( pdf_title, txt); ++ txt = InfoString(info.getDict(), "Subject", uMap); ++ sprintf( ( char*)txtdata->txt[1] , "Subject: %s", txt); ++ txt = InfoString(info.getDict(), "Keywords", uMap); ++ sprintf( ( char*)txtdata->txt[2] , "Keywords: %s", txt); ++ txt = InfoString(info.getDict(), "Author", uMap); ++ sprintf( ( char*)txtdata->txt[3] , "Author: %s", txt); ++ txt = InfoString(info.getDict(), "Creator", uMap); ++ sprintf( ( char*)txtdata->txt[4] , "Creator: %s", txt); ++ txt = InfoString(info.getDict(), "Producer", uMap); ++ sprintf( ( char*)txtdata->txt[5] , "Producer: %s", txt); ++// sprintf( ( char*)txtdata->txt[6] , "PDF version: %.1f", doc->getPDFVersion()); ++ ++ txt = InfoDate(info.getDict(), "CreationDate"); ++ sprintf( ( char*)txtdata->txt[6] , "Creation Date: %s", txt); ++ txt = InfoDate(info.getDict(), "ModDate"); ++ sprintf( ( char*)txtdata->txt[7] , "Modification Date: %s", txt); ++ } ++ else ++ { ++ pdf_title[0] = '\0'; ++ txtdata->txt[0][0] = '\0'; ++ txtdata->txt[1][0] = '\0'; ++ txtdata->txt[2][0] = '\0'; ++ txtdata->txt[3][0] = '\0'; ++ txtdata->txt[4][0] = '\0'; ++ txtdata->txt[5][0] = '\0'; ++ txtdata->txt[6][0] = '\0'; ++ txtdata->txt[7][0] = '\0'; ++ } ++ ++ info.free(); ++ uMap->decRefCnt(); ++} ++ ++void pdf_quit( IMAGE *img) ++{ ++ PDFDoc *doc = ( PDFDoc*)img->_priv_ptr; ++ SplashOutputDev *splashOut = ( SplashOutputDev*)img->_priv_ptr_more; ++ ++ delete splashOut; ++ delete doc; ++} ++ ++char *get_pdf_title( void) ++{ ++ return ( char*)&pdf_title; ++} ++ ++boolean pdf_init( char *path) ++{ ++ globalParams = new GlobalParams( NULL); ++ globalParams->setupBaseFonts( path); ++ return TRUE; ++} ++ ++void pdf_exit( void) ++{ ++ delete globalParams; ++} ++ ++} +diff -ruwN _deps/xpdf-3.03/pdflib.h xpdf-3.03/pdflib.h +--- _deps/xpdf-3.03/pdflib.h 1970-01-01 01:00:00.000000000 +0100 ++++ xpdf-3.03/pdflib.h 2011-10-16 22:33:31.870338392 +0200 +@@ -0,0 +1,13 @@ ++boolean lib_pdf_load( const char *name, IMAGE *img); ++void pdf_get_page_size( IMAGE *img, int page, uint16 *width, uint16 *height); ++void pdf_decode_page( IMAGE *img, int page, double scale); ++uint32 *pdf_get_page_addr( IMAGE *img); ++void pdf_quit( IMAGE *img); ++boolean pdf_init( char *path); ++void pdf_exit( void); ++char *get_pdf_title( void) ; ++void pdf_build_bookmark( WINDATA *windata, WINDOW *win); ++void pdf_get_info( IMAGE *img, txt_data *txtdata); ++void delete_bookmark_child( Bookmark *book); ++ ++ +diff -ruwN _deps/xpdf-3.03/xpdf/GlobalParams.cc xpdf-3.03/xpdf/GlobalParams.cc +--- _deps/xpdf-3.03/xpdf/GlobalParams.cc 2011-08-15 23:08:53.000000000 +0200 ++++ xpdf-3.03/xpdf/GlobalParams.cc 2011-10-16 22:33:46.513693391 +0200 +@@ -85,20 +85,20 @@ + const char *t1FileName; + const char *ttFileName; + } displayFontTab[] = { +- {"Courier", "n022003l.pfb", "cour.ttf"}, +- {"Courier-Bold", "n022004l.pfb", "courbd.ttf"}, +- {"Courier-BoldOblique", "n022024l.pfb", "courbi.ttf"}, +- {"Courier-Oblique", "n022023l.pfb", "couri.ttf"}, +- {"Helvetica", "n019003l.pfb", "arial.ttf"}, +- {"Helvetica-Bold", "n019004l.pfb", "arialbd.ttf"}, +- {"Helvetica-BoldOblique", "n019024l.pfb", "arialbi.ttf"}, +- {"Helvetica-Oblique", "n019023l.pfb", "ariali.ttf"}, +- {"Symbol", "s050000l.pfb", NULL}, +- {"Times-Bold", "n021004l.pfb", "timesbd.ttf"}, +- {"Times-BoldItalic", "n021024l.pfb", "timesbi.ttf"}, +- {"Times-Italic", "n021023l.pfb", "timesi.ttf"}, +- {"Times-Roman", "n021003l.pfb", "times.ttf"}, +- {"ZapfDingbats", "d050000l.pfb", NULL}, ++ {"Courier", "fonts\\n022003l.pfb", "cour.ttf"}, ++ {"Courier-Bold", "fonts\\n022004l.pfb", "courbd.ttf"}, ++ {"Courier-BoldOblique", "fonts\\n022024l.pfb", "courbi.ttf"}, ++ {"Courier-Oblique", "fonts\\n022023l.pfb", "couri.ttf"}, ++ {"Helvetica", "fonts\\n019003l.pfb", "arial.ttf"}, ++ {"Helvetica-Bold", "fonts\\n019004l.pfb", "arialbd.ttf"}, ++ {"Helvetica-BoldOblique", "fonts\\n019024l.pfb", "arialbi.ttf"}, ++ {"Helvetica-Oblique", "fonts\\n019023l.pfb", "ariali.ttf"}, ++ {"Symbol", "fonts\\s050000l.pfb", NULL}, ++ {"Times-Bold", "fonts\\n021004l.pfb", "timesbd.ttf"}, ++ {"Times-BoldItalic", "fonts\\n021024l.pfb", "timesbi.ttf"}, ++ {"Times-Italic", "fonts\\n021023l.pfb", "timesi.ttf"}, ++ {"Times-Roman", "fonts\\n021003l.pfb", "times.ttf"}, ++ {"ZapfDingbats", "fonts\\d050000l.pfb", NULL}, + {NULL} + }; + +@@ -110,11 +110,13 @@ + }; + #else + static const char *displayFontDirs[] = { ++ /* + "/usr/share/ghostscript/fonts", + "/usr/local/share/ghostscript/fonts", + "/usr/share/fonts/default/Type1", + "/usr/share/fonts/default/ghostscript", + "/usr/share/fonts/type1/gsfonts", ++ */ + NULL + }; + #endif diff --git a/sources/z-tools/trunk/zview/infobox.c b/sources/z-tools/trunk/zview/infobox.c new file mode 100644 index 0000000..8dbefad --- /dev/null +++ b/sources/z-tools/trunk/zview/infobox.c @@ -0,0 +1,342 @@ +#include "general.h" +#include "ztext.h" +#include "infobox.h" +#include "zedit/zedit.h" +#include "close_modal.h" +#include "pic_load.h" +#include "winimg.h" +#include "file/count.h" +#include "custom_font.h" +#include + +/* Prototype */ +void generic_form_event( WINDOW *win); +void infobox( void); + +static int16 dum, res; +static int16 posy, xy[8], dum; +static uint32 ypos_max, ypos; +float slider_pos = 0.0, slider_step = 0.0; +static OBJECT *infotext; +static txt_data *exif_box; +static OBJECT *slider_root; + +static short vdi_intin[VDI_INTINMAX]; +static short vdi_intout[VDI_INTOUTMAX]; +static short vdi_ptsin[VDI_PTSINMAX]; +static short vdi_ptsout[VDI_PTSOUTMAX]; +static short vdi_control[VDI_CNTRLMAX]; + +static VDIPB vdi_params = { + &vdi_control[0], + &vdi_intin[0], + &vdi_ptsin[0], + &vdi_intout[0], + &vdi_ptsout[0] +}; + +static int my_vsl_color (short handle, short idx) { + vdi_intin[0] = idx; + + vdi_control[0] = 17; + vdi_control[1] = vdi_control[5] = 0; + vdi_control[3] = 1; + vdi_control[6] = handle; + + vdi (&vdi_params); + + return ((int)vdi_intout[0]); +} + +void CDECL draw_exif_info( WINDOW *win, PARMBLK *pblk, void *data) +{ + exif_box = (txt_data *) data; + + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y; + xy[2] = xy[0] + pblk->pb_w - 2; + xy[3] = xy[1] + pblk->pb_h - 1; + + vsf_color( win->graf.handle, WHITE); + v_bar( win->graf.handle, xy); + + xy[0] = pblk->pb_x + pblk->pb_w - 1; + xy[1] = pblk->pb_y; + xy[2] = pblk->pb_x; + xy[3] = pblk->pb_y; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y + pblk->pb_h - 1; + xy[6] = xy[0]; + xy[7] = xy[5]; + + my_vsl_color( win->graf.handle, BLACK); + v_pline( win->graf.handle, 4, xy); + + posy = pblk->pb_y; + + for ( dum = ypos; dum < exif_box->lines; dum++, posy += 12) + { + if( posy >= ( pblk->pb_y + pblk->pb_h - 1)) + break; + + draw_text( win->graf.handle, pblk->pb_x + 3, posy + 3, BLACK, exif_box->txt[dum]); + } +} + + +void calc_exif_slider( WINDOW *win) +{ + int16 max_mover_size; + int16 full_win_size = ypos_max * 12; + + max_mover_size = slider_root[FILE_INFO_VBACK].ob_height; + + slider_root[FILE_INFO_VMOVER].ob_y = 0; + slider_root[FILE_INFO_VMOVER].ob_height = max_mover_size; + + if ( slider_root[FILE_INFO_COMMENT].ob_height < full_win_size) + { + float factor = ( float)slider_root[FILE_INFO_COMMENT].ob_height / ( float)full_win_size; + float mover_size = MAX(( float)max_mover_size * factor, 6L); + + slider_pos = 0; + slider_step = ( float)max_mover_size / ( float)ypos_max; + slider_root[FILE_INFO_VMOVER].ob_height = ( int16)( mover_size); + } +} + + + +static void slid_up( WINDOW *win, int obj_index, int mode) +{ + ObjcChange( mode, win, obj_index, SELECTED, TRUE); + + do + { + if ( ypos > 0L) + { + ypos--; + ObjcDraw( OC_FORM, win, FILE_INFO_COMMENT, 1); + slider_pos -= slider_step; + slider_root[FILE_INFO_VMOVER].ob_y = MAX( 0, ( int16)floor( slider_pos)); + ObjcDraw( OC_FORM, win, FILE_INFO_VBACK, 2); + } + graf_mkstate( &dum, &dum, &res, &dum); + + } while( res); + + ObjcChange( mode, win, obj_index, ~SELECTED, TRUE); +} + + +static void slid_down( WINDOW *win, int obj_index, int mode) +{ + ObjcChange( mode, win, obj_index, SELECTED, TRUE); + + do + { + if (( ypos < ( ypos_max - slider_root[FILE_INFO_COMMENT].ob_height / 12)) && ( ypos_max > slider_root[FILE_INFO_COMMENT].ob_height / 12)) + { + ypos ++; + ObjcDraw( OC_FORM, win, FILE_INFO_COMMENT, 1); + slider_pos += slider_step; + slider_root[FILE_INFO_VMOVER].ob_y = ( int16)floor( slider_pos); + ObjcDraw( OC_FORM, win, FILE_INFO_VBACK, 2); + } + graf_mkstate( &dum, &dum, &res, &dum); + + } while( res); + + ObjcChange( mode, win, obj_index, ~SELECTED, TRUE); +} + + +static void slid_vmover( WINDOW *win, int obj_index, int mode) +{ + int32 old_ypos = ypos; + + ObjcChange( mode, win, obj_index, SELECTED, TRUE); + + graf_mouse( FLAT_HAND, NULL); + + while( !wind_update( BEG_MCTRL)); + + res = graf_slidebox( slider_root, FILE_INFO_VBACK, FILE_INFO_VMOVER, 1); + + wind_update( END_MCTRL); + + ypos = MAX( 0, ( ypos_max - slider_root[FILE_INFO_COMMENT].ob_height / 12) * res / 1000L); + + if( old_ypos != ypos) + { + slider_pos = ypos * slider_step; + slider_root[FILE_INFO_VMOVER].ob_y = ( int16)floor( slider_pos); + ObjcDraw( OC_FORM, win, FILE_INFO_VBACK, 2); + ObjcDraw( OC_FORM, win, FILE_INFO_COMMENT, 1); + } + + graf_mouse( ARROW, NULL); + + ObjcChange( mode, win, obj_index, ~SELECTED, TRUE); +} + + +/*==================================================================================* + * void infobox: * + * Show the infobox for a image or a file. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void infobox( void) +{ + WINDOW *wininfo; + WINDICON *wicones; + WINDATA *windata; + IMAGE *img; + char temp[30]; + float uncompressed_size; + int32 file_size; + int16 name_len; + int frms[] = { FILE_INFO_PANEL1, FILE_INFO_PANEL2, FILE_INFO_PANEL3}; + int buts[] = { FILE_INFO_FILE, FILE_INFO_IMAGE, FILE_INFO_EXIF}; + + infotext = get_tree( FILE_INFO); + + if(( wicones = ( WINDICON *)DataSearch( wglb.front, WD_ICON))) /* See if the target picture is in the catalog window */ + { + Entry *entry = wicones->first_selected; + img = &entry->preview; + file_size = entry->stat.st_size; + + if( wicones->edit) + exit_edit_mode( win_catalog, wicones->first_selected); + + name_len = MIN( 29, strlen( entry->name)); + + zstrncpy( temp, entry->name, name_len+1); + + ObjcStrCpy( infotext, FILE_INFO_NAME, temp); + ObjcStrCpy( infotext, FILE_INFO_DATE, entry->date); + ObjcStrCpy( infotext, FILE_INFO_TIME, entry->time); + + if( entry->type == ET_DIR) + { + fileinfo file; + + graf_mouse( BUSYBEE, NULL); + + if( !count_files( wicones, &file)) + { + errshow( "", errno); + return; + } + + size_to_text( temp, ( float)file.size); + ObjcStrCpy( infotext, FILE_INFO_SIZE, temp); + + graf_mouse( ARROW, NULL); + } + else + ObjcStrCpy( infotext, FILE_INFO_SIZE, entry->size); + + } + else if(( windata = (WINDATA *)DataSearch( wglb.front, WD_DATA))) /* See if the picture is in a "normal" window */ + { + struct stat file_stat; + struct tm *tmt; + int16 path_len, file_len; + int8 *fullname = windata->name; + + img = &windata->img; + file_len = ( int16)strlen( fullname); + path_len = file_len; + + while(( fullname[path_len] != '/') && ( fullname[path_len] != '\\')) + path_len--; + + name_len = MIN( 29, file_len - path_len); + + path_len++; + + zstrncpy( temp, &fullname[path_len], name_len+1); + ObjcStrCpy( infotext, FILE_INFO_NAME, temp); + + lstat( fullname, &file_stat); + file_size = file_stat.st_size; + + size_to_text( temp, ( float)file_stat.st_size); + ObjcStrCpy( infotext, FILE_INFO_SIZE, temp); + + tmt = localtime(&file_stat.st_mtime); + strftime( temp, 28, "%A %d %B %Y", tmt); + ObjcStrCpy( infotext, FILE_INFO_DATE, temp); + + strftime( temp, 12, "%H:%M:%S", tmt); + ObjcStrCpy( infotext, FILE_INFO_TIME, temp); + } + else + return; /* normally, never */ + + + if( img->comments) + infotext[FILE_INFO_EXIF].ob_flags &= ~HIDETREE; + else + infotext[FILE_INFO_EXIF].ob_flags |= HIDETREE; + + if ( img->page) + { + infotext[FILE_INFO_IMAGE].ob_flags &= ~HIDETREE; + + sprintf( infotext[FILE_INFO_COLOR].ob_spec.tedinfo->te_ptext, "%ld", img->colors); + sprintf( infotext[FILE_INFO_WIDTH].ob_spec.tedinfo->te_ptext, "%d", img->img_w); + sprintf( infotext[FILE_INFO_HEIGHT].ob_spec.tedinfo->te_ptext, "%d", img->img_h); + sprintf( infotext[FILE_INFO_PLANES].ob_spec.tedinfo->te_ptext, "%d", img->bits); + sprintf( infotext[FILE_INFO_PAGE].ob_spec.tedinfo->te_ptext, "%d", img->page); + ObjcStrCpy( infotext, FILE_INFO_DEC_TIME, img->working_time); + ObjcStrCpy( infotext, FILE_INFO_COMPRESSION, img->compression); + ObjcStrCpy( infotext, FILE_INFO_INFO, img->info); + + /* Calculate the Image decompressed size */ + uncompressed_size = (((( float)img->img_w / 8.0) + 1) * ( float)img->bits) * ( float)img->img_h; + size_to_text( infotext[FILE_INFO_MEM].ob_spec.tedinfo->te_ptext, uncompressed_size); + + sprintf( infotext[FILE_INFO_RATIO].ob_spec.tedinfo->te_ptext, "%.1f : 1", uncompressed_size / ( float)file_size); + } + else + infotext[FILE_INFO_IMAGE].ob_flags |= HIDETREE; + + wininfo = FormCreate( infotext, NAME|MOVER|CLOSER, NULL, "Information", NULL, TRUE, FALSE); + + FormThumb( wininfo, frms, buts, 3); + + WindSet( wininfo, WF_BEVENT, BEVENT_MODAL, 0, 0, 0); + + EvntAttach( wininfo, WM_CLOSED, close_modal); + + if( img->comments) + { + ypos = 0; + ypos_max = img->comments->lines; + wininfo->h_u = 12; + + slider_root = FORM( wininfo); + + calc_exif_slider( wininfo); + + RsrcUserDraw ( OC_FORM, wininfo, FILE_INFO_COMMENT, draw_exif_info, ( void*)img->comments); + + // draw_exif_info( wininfo); + + ObjcAttach( OC_FORM, wininfo, FILE_INFO_UP, BIND_FUNC, slid_up); + ObjcAttach( OC_FORM, wininfo, FILE_INFO_DOWN, BIND_FUNC, slid_down); + ObjcAttach( OC_FORM, wininfo, FILE_INFO_VMOVER, BIND_FUNC, slid_vmover); + } + + + MenuDisable(); +} + diff --git a/sources/z-tools/trunk/zview/infobox.h b/sources/z-tools/trunk/zview/infobox.h new file mode 100644 index 0000000..688eaaa --- /dev/null +++ b/sources/z-tools/trunk/zview/infobox.h @@ -0,0 +1,29 @@ +typedef struct slider +{ + float min, max; + float sinc, linc; + int ori; /* HORI,VERT*/ + int upd; /* */ + float value; /* valeur courante */ + void (*doslid)( WINDOW *win, int mode, float value, void *data); /* Pas fix‚ sur les sp‚cifs */ + void *data; /* user data for user function */ + int mode; + WINDOW *win; + int up, dn, sld, bsld; +} SLIDER; + +typedef struct +{ + txt_data *txt; + int32 ypos; /* relative data position in the window */ + int32 ypos_max; /* Maximal values of previous variables */ + int16 h_u; /* vertical and horizontal scroll offset */ + int32 xpos; + int32 xpos_max; + int16 w_u; +} exif_box_data; + + +extern void infobox( void); + + diff --git a/sources/z-tools/trunk/zview/jpg_dialog.c b/sources/z-tools/trunk/zview/jpg_dialog.c new file mode 100644 index 0000000..d279802 --- /dev/null +++ b/sources/z-tools/trunk/zview/jpg_dialog.c @@ -0,0 +1,118 @@ +#include "general.h" +#include "prefs.h" +#include "ztext.h" +#include "pic_load.h" +#include "catalog/catalog.h" + +OBJECT *jpg_option_content; +static int16 quality = 90; +static J_COLOR_SPACE color_space = JCS_RGB; +static boolean progressive = FALSE; +static boolean show_preview = FALSE; +void *jpg_option_slider = NULL; + +extern void CDECL ( *set_jpg_option)( int16 set_quality, J_COLOR_SPACE set_color_space, boolean set_progressive); + + +static void jpg_option_close( WINDOW *win) +{ + free( jpg_option_slider); + frm_cls( win); +} + +static void jpg_option_gray_event( WINDOW *win, int16 obj_index) +{ + color_space = ( color_space == JCS_RGB ? JCS_GRAYSCALE : JCS_RGB); + + /* a wait loop while the mouse button is pressed */ + while(( evnt.mbut == 1) || ( evnt.mbut == 2)) + graf_mkstate( &evnt.mx, &evnt.my, &evnt.mbut, &evnt.mkstate); +} + +static void jpg_option_progressive_event( WINDOW *win, int16 obj_index) +{ + progressive = ( progressive == TRUE ? FALSE : TRUE); + + /* a wait loop while the mouse button is pressed */ + while(( evnt.mbut == 1) || ( evnt.mbut == 2)) + graf_mkstate( &evnt.mx, &evnt.my, &evnt.mbut, &evnt.mkstate); +} + +static void jpg_option_show_preview( WINDOW *win, int16 obj_index) +{ + show_preview = ( show_preview == TRUE ? FALSE : TRUE); + + /* a wait loop while the mouse button is pressed */ + while(( evnt.mbut == 1) || ( evnt.mbut == 2)) + graf_mkstate( &evnt.mx, &evnt.my, &evnt.mbut, &evnt.mkstate); +} + +static void jpg_option_ok_event( WINDOW *win, int16 obj_index) +{ + set_jpg_option( quality, color_space, progressive); + + ObjcChange( OC_FORM, win, obj_index, NORMAL, TRUE); + ApplWrite( app.id, WM_CLOSED, win->handle, 0, 0, 0, 0); +} + +static void jpg_option_slider_event( WINDOW *win, int mode, float value) +{ + quality = ( int16)value; + evnt_timer( 50); + sprintf( ObjcString( FORM( win), JPGPREF_PERCENT, NULL), "%d", quality); + ObjcDraw( mode, win, JPGPREF_PERCENT, TRUE); +} + +/*==================================================================================* + * void jpg_option_dialog: * + * Open and handle JPG encoder option dialog. * + *----------------------------------------------------------------------------------* + * input: * + * source_file: the full path name of the source file. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void jpg_option_dialog( char *source_file) +{ +// struct stat file_stat; + WINDOW *win; + + jpg_option_content = get_tree( JPGPREF); + +// stat( source_file, &file_stat); + +// size_to_text( ObjcString( jpg_option_content, JPGPREF_ORIGINAL_SIZE, NULL), ( float)file_stat.st_size); +// sprintf( ObjcString( jpg_option_content, JPGPREF_PERCENT, NULL), "%d", quality); + + jpg_option_content[JPGPREF_SL].ob_x = quality; + + if( ( win = FormCreate( jpg_option_content, NAME|MOVER, NULL, get_string( JPG_OPTION_TITLE), NULL, TRUE, FALSE)) == NULL) + { + WindClose( win); + errshow( "", ALERT_WINDOW); + return; + } + +// RsrcUserDraw ( OC_FORM, win, JPGPREF_ORIGINAL, draw_object_image, NULL); +// RsrcUserDraw ( OC_FORM, win, JPGPREF_RESULT, draw_object_image, NULL); + + WindSet( win, WF_BEVENT, BEVENT_MODAL, 0, 0, 0); + + if( ( jpg_option_slider = SlidCreate( 1, 100, 1, 10, quality, SLD_HORI, SLD_IMME)) == NULL) + { + frm_cls( win); + errshow( "", ENOMEM); + return; + } + + EvntAttach( win, WM_CLOSED, jpg_option_close); + SlidAttach( jpg_option_slider, OC_FORM, win, JPGPREF_LF, JPGPREF_PG, JPGPREF_SL, JPGPREF_RT); + SlidSetFunc( jpg_option_slider, jpg_option_slider_event, NULL); + +// ObjcAttach( OC_FORM, win, JPGPREF_PREVIEW, BIND_FUNC, jpg_option_show_preview); + ObjcAttach( OC_FORM, win, JPGPREF_GRAY, BIND_FUNC, jpg_option_gray_event); + ObjcAttach( OC_FORM, win, JPGPREF_OK, BIND_FUNC, jpg_option_ok_event); + ObjcAttach( OC_FORM, win, JPGPREF_PROGRESSIVE, BIND_FUNC, jpg_option_progressive_event); +} + diff --git a/sources/z-tools/trunk/zview/main.c b/sources/z-tools/trunk/zview/main.c new file mode 100644 index 0000000..cb33b5c --- /dev/null +++ b/sources/z-tools/trunk/zview/main.c @@ -0,0 +1,171 @@ +#include "general.h" +#include "catalog/catalog_icons.h" +#include "menu.h" +#include "prefs.h" +#include "pic_load.h" +#include "winimg.h" +#include "pdf_load.h" +#include "pdf/pdflib.h" +#include "plugins.h" +#include "av_prot.h" +#include "wintimer.h" +#include "zvdi/vdi.h" +#include "catalog/catalog.h" +#include + + +WINDOW *win_catalog = NULL; + +char zview_path[MAX_PATH]; +int16 mint_os = 0, magic_os = 0; + +/*==================================================================================* + * void applexit: * + * The clean "end" function: * + * - Close all the windows. * + * - Free up the memory used by the plugins ( if any), the icons and the rsc * + * file. * + * - Close the windom's av_client function. * + * - Finnish the Application. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void applexit( void) +{ + while( wglb.first) + { + snd_msg( wglb.first, WM_DESTROY, 0, 0, 0, 0); + EvntWindom( MU_MESAG); + } + + EvntDelete( NULL, WM_XTIMER); + + if( pdf_initialised == TRUE) + pdf_exit(); + + ( void)prefs_write(); + + plugins_quit(); + + icons_exit(); + + MenuBar ( NULL, 0); + RsrcXtype( 0, NULL, 0); + RsrcFree(); + AvExit(); + ApplExit(); + #ifdef DEBUG + gMemReport(); + #endif + + exit( 0); +} + +/*==================================================================================* + * void applinit: * + * The global initialisation function: * + * - Initialise the application via Windom ( "ApplInit"). * + * - Inquire if MagiC/MiNT are present and set the good Pdomain(). * + * - Inquire screen's information ( "vdi_init"). * + * - Register the application with the AES ( "menu_register"). * + * - Load the ressource's file and read the application prefs ( "prefs_read"). * + * - Initialise the av_client , the menu bar and load the plugins ( if any). * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +static void applinit( void) +{ + ApplInit(); + + if( !vdi_init()) + { + errshow( "", NO_EDDI); + ApplExit(); + exit( 0); + } + + +/* is it unusefull ? */ + if( _AESnumapps == -1) + menu_register( app.id, " zView "); + + if( !RsrcLoad( "zview.rsc")) + { + errshow( "", E_RSC); + ApplExit(); + exit( 0); + } + + magic_os = vq_magx(); + mint_os = vq_mint(); + + if ( magic_os || mint_os) + { + ( void)Pdomain( 1); + } + + RsrcXtype( RSRC_XTYPE, NULL, 0); + + if( AvInit( "ZVIEW ", A_START|A_QUOTE, 1000 ) >= 0) + EvntAttach( NULL, VA_START, va_start); + + /* Get the current path for the different file loading like icon, etc... */ + zview_path[0] = 'A' + Dgetdrv(); + zview_path[1] = ':'; + Dgetpath( zview_path + 2, 0); + + prefs_read(); + + MenuDesktop(); + + EvntAttach( NULL, AP_TERM, applexit); + + /* Load the plugins.. */ + + if( plugins_init() == 0) + { + errshow( "", NOZCODECS); + applexit(); + } + + TimerInit( 20); + + evnt.bclick = 258; + evnt.bmask = 3; + evnt.bstate = 0; +} + + +/*==================================================================================* + * int main: * + * The main function: * + *----------------------------------------------------------------------------------* + * input: * + * argc, *argv -> the application's parameters. * + *----------------------------------------------------------------------------------* + * returns: * + * 0. * + *==================================================================================*/ + +int main( int argc, char *argv[]) +{ + applinit(); + + if ( argc > 1) + WindView( argv[argc - 1]); + + for(;;) + EvntWindom( MU_MESAG|MU_TIMER|MU_KEYBD|MU_BUTTON); + + return 0; +} diff --git a/sources/z-tools/trunk/zview/menu.c b/sources/z-tools/trunk/zview/menu.c new file mode 100644 index 0000000..185f8ba --- /dev/null +++ b/sources/z-tools/trunk/zview/menu.c @@ -0,0 +1,685 @@ +#include "general.h" +#include "prefs.h" +#include "pic_load.h" +#include "winimg.h" +#include "infobox.h" +#include "close_modal.h" +#include "pref_dialog.h" +#include "full_scr.h" +#include "file/sort.h" +#include "file/delete.h" +#include "catalog/catalog.h" +#include "catalog/catalog_entry.h" +#include "zedit/zedit.h" + +/* Prototype */ +static void MenuHandle( void); +static void Menu_about( void); +void Menu_open_image( void); +static void Menu_preference( void); +static void Menu_file_info( void); +static void Menu_close_win( void); +static void Menu_show_non_image( void); +static void Menu_sort_by_name( void); +static void Menu_sort_by_size( void); +static void Menu_sort_by_date( void); +static void Menu_thumb_size( void); +static void Menu_delete( void); +static void Menu_show_browser( void); +void MenuDesktop( void); + +extern char fullname[MAX_PATH+MAXNAMLEN]; +extern void save_dialog( const char *fullfilename); + + +/*==================================================================================* + * void MenuHandle: * + * Windom function to handle the TOS menubar statut ( selected or not). * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +static void MenuHandle( void) +{ + MenuTnormal( NULL, evnt.buff[3], 1); +} + + +/*==================================================================================* + * void Menu_about: * + * Show the about box. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +static void Menu_about( void) +{ + OBJECT *aboutbox = get_tree( ABOUT); + + WINDOW *winabout = FormCreate( aboutbox, NAME|MOVER|CLOSER, generic_form_event, get_string( ABOUT_TITLE), NULL, TRUE, FALSE); + + /* Set the window modal */ + WindSet( winabout, WF_BEVENT, BEVENT_MODAL, 0, 0, 0); + /* New closer event function */ + EvntAttach( winabout, WM_CLOSED, close_modal); + /* Disable the desktop menu */ + MenuDisable(); +} + + + +/*==================================================================================* + * void Menu_open_image: * + * Handle the "Open" option in the TOS menubar. * + * It opens the file selector and after, it loads the wanted picture * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void Menu_open_image( void) +{ + static char path[MAX_PATH] = "C:\\"; /* Fist usage : current directory */ + char name[MAXNAMLEN] = ""; + + if( FselInput( path, name, "*.*", get_string( LOAD_TITLE), NULL, NULL)) + { + /* if a file is not selected, return */ + if( strcmp ( name, "") == 0) + return; + + strcpy( fullname, path); + strcat( fullname, name); + WindView( fullname); + } +} + + +/*==================================================================================* + * void Menu_file_info: * + * Handle the "Info" option in the TOS menubar. * + * It opens the info's dialog boxe and show various information about the file * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +static void Menu_file_info( void) +{ + infobox(); +} + + +/*==================================================================================* + * void Menu_preference: * + * Handle the "Preference" option in the TOS menubar. * + * It opens the preference's dialog boxe. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +static void Menu_preference( void) +{ + preference_dialog(); +} + + + +/*==================================================================================* + * void Menu_file_save: * + * Handle the "Save as" option in the TOS menubar. * + * It opens the save's dialog boxe. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +static void Menu_file_save( void) +{ + WINDICON *wicones; + WINDATA *windata; + + if(( wicones = ( WINDICON *)DataSearch( wglb.front, WD_ICON))) /* See if the target picture is in the catalog window */ + { + if( !wicones->first_selected || wicones->first_selected->type != ET_IMAGE) + return; + + if( wicones->edit) + exit_edit_mode( win_catalog, wicones->first_selected); + + strcpy( fullname, wicones->directory); + strcat( fullname, wicones->first_selected->name); + save_dialog( fullname); + } + else if(( windata = ( WINDATA *)DataSearch( wglb.front, WD_DATA))) /* See if the picture is in a "normal" window */ + { + save_dialog( windata->name); + } +} + + +/*==================================================================================* + * void Menu_close_win: * + * Handle the "Close Window" option in the TOS menubar. * + * It close the "focused" window. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +static void Menu_close_win( void) +{ + if( wglb.front) + { + ApplWrite( app.id, WM_DESTROY, wglb.front->handle, 0, 0, 0, 0); + } +} + + +/*==================================================================================* + * void Menu_delete: * + * Handle the "delete" option in the TOS menubar. * + * This function delete all selected files and directories. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +static void Menu_delete( void) +{ + WINDICON *wicones; + + if ( !win_catalog) + return; + + wicones = ( WINDICON *)DataSearch( win_catalog, WD_ICON); + + if( wicones->first_selected) + { + if( wicones->edit) + exit_edit_mode( win_catalog, wicones->first_selected); + + delete_entry( win_catalog); + } +} + + + +/*==================================================================================* + * void Menu_select_all: * + * Handle the "Select All" option in the TOS menubar. * + * This function mark as selected all file from the directory active. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +static void Menu_select_all( void) +{ + WINDICON *wicones; + int16 i, x, y, w, h; + + if ( !win_catalog) + return; + + wicones = ( WINDICON *)DataSearch( win_catalog, WD_ICON); + + if( wicones->edit) + exit_edit_mode( win_catalog, wicones->first_selected); + + for ( i = 0 ; i < wicones->nbr_icons; i++) + { + if ( ( !show_non_image) && ( wicones->entry[i].type != ET_IMAGE)) + continue; + + if( !check_selected_entry( wicones, &wicones->entry[i])) + add_selected_entry( wicones, &wicones->entry[i]); + } + + WindGet( win_catalog, WF_WORKXYWH, &x, &y, &w, &h); + + draw_page( win_catalog, x + browser_frame_width + border_size , y, w - ( browser_frame_width + border_size), h); +} + +/*==================================================================================* + * void Menu_show_non_image: * + * Handle the "Show Non-Image" option in the TOS menubar. * + * This function shows common file in the catalog window. * + * So, both the image files and the comon files are shown. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +static void Menu_show_non_image( void) +{ + if ( !show_non_image) + { + MenuIcheck( NULL, MENU_BAR_SHOW, 1); + + show_non_image = 1; + + if( win_catalog) + WinCatalog_filelist_redraw(); + } + else + { + MenuIcheck( NULL, MENU_BAR_SHOW, 0); + + show_non_image = 0; + + if( win_catalog) + WinCatalog_filelist_redraw(); + + WindMakePreview( win_catalog); + } +} + + +/*==================================================================================* + * void Menu_sort_by_name: * + * Handle the "Sort by name" option in the TOS menubar. * + * This function sorts the files in the catalog window in alphabetical order. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +static void Menu_sort_by_name( void) +{ + if ( sortingmode != 0) + { + WINDICON *wicones; + + MenuIcheck( NULL, MENU_BAR_BY_NAME, 1); + MenuIcheck( NULL, MENU_BAR_BY_SIZE, 0); + MenuIcheck( NULL, MENU_BAR_BY_DATE, 0); + + sortingmode = 0; + + if( !win_catalog) + return; + + wicones = ( WINDICON *)DataSearch( win_catalog, WD_ICON); + + sort_entries( wicones); + + WinCatalog_filelist_redraw(); + } +} + + +/*==================================================================================* + * void Menu_sort_by_size: * + * Handle the "Sort by size" option in the TOS menubar. * + * This function sorts the files by size in the catalog window. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +static void Menu_sort_by_size( void) +{ + if ( sortingmode != 1) + { + WINDICON *wicones; + + MenuIcheck( NULL, MENU_BAR_BY_SIZE, 1); + MenuIcheck( NULL, MENU_BAR_BY_DATE, 0); + MenuIcheck( NULL, MENU_BAR_BY_NAME, 0); + + sortingmode = 1; + + if( !win_catalog) + return; + + wicones = ( WINDICON *)DataSearch( win_catalog, WD_ICON); + + sort_entries( wicones); + + WinCatalog_filelist_redraw(); + } +} + + +/*==================================================================================* + * void Menu_sort_by_date: * + * Handle the "Sort by date" option in the TOS menubar. * + * This function sorts the files by date in the catalog window. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +static void Menu_sort_by_date( void) +{ + if ( sortingmode != 2) + { + WINDICON *wicones; + + MenuIcheck( NULL, MENU_BAR_BY_NAME, 0); + MenuIcheck( NULL, MENU_BAR_BY_SIZE, 0); + MenuIcheck( NULL, MENU_BAR_BY_DATE, 1); + + sortingmode = 2; + + if( !win_catalog) + return; + + wicones = ( WINDICON *)DataSearch( win_catalog, WD_ICON); + + sort_entries( wicones); + + WinCatalog_filelist_redraw(); + } +} + + +/*==================================================================================* + * void Menu_fullscreen: * + * Show a picture in fullscreen mode. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +static void Menu_fullscreen( void) +{ + WINDATA *windata; + + if( !wglb.front) + return; + + windata = ( WINDATA *)DataSearch( wglb.front, WD_DATA); + + if( !windata) + return; + + show_fullscreen( windata); +} + + +/*==================================================================================* + * void Menu_show_browser: * + * Handle the "Show Browser" option in the TOS menubar. * + * This function shows the folder's browser frame in the catalog window. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +static void Menu_show_browser( void) +{ + if( browser_frame_width) + { + old_browser_size = browser_frame_width; + old_border_size = border_size; + browser_frame_width = 0; + border_size = 0; + MenuIcheck( NULL, MENU_BAR_SHOW_BROWSER, 0); + } + else + { + browser_frame_width = old_browser_size; + border_size = old_border_size; + MenuIcheck( NULL, MENU_BAR_SHOW_BROWSER, 1); + } + + if( win_catalog) + { + int16 dum, xw, yw, hw, ww, x, y, w, h; + WINDICON *wicones = (WINDICON *)DataSearch( win_catalog, WD_ICON); + + WindGet ( win_catalog, WF_WORKXYWH, &x, &y, &w, &h); + + WindCalc( WC_BORDER, win_catalog, 0, 0, wicones->case_w + border_size + browser_frame_width, wicones->case_h, &dum, &dum, &ww, &dum); + + win_catalog -> w_min = ww; + + if( win_catalog -> w_min > w) + { + WindGet ( win_catalog, WF_CURRXYWH, &xw, &yw, &dum, &hw); + wind_set( win_catalog -> handle, WF_CURRXYWH, xw, yw, ww, hw); + } + + win_catalog->ypos = 0; + + WinCatalog_Refresh( win_catalog); + + if ( wicones->nbr_icons && wicones->first_selected) + { + if( wicones->first_selected->txt_pos.y2 > h) + { + while ( wicones->first_selected->txt_pos.y2 > h) + { + wicones->first_selected->txt_pos.y2 -= win_catalog->h_u; + win_catalog->ypos++; + } + } + } + + draw_page( win_catalog, x, y, w, h); + WindMakePreview( win_catalog); + } +} + + +/*==================================================================================* + * void Menu_show_preview_area: * + * Handle the "Show Preview Area" option in the TOS menubar. * + * This function shows the "preview" frame in the catalog window. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +/* static void Menu_show_preview_area( void) +{ + if( preview_frame_height) + { + old_preview_area_size = preview_frame_height; + preview_frame_height = 0; + MenuIcheck( NULL, MENU_BAR_SHOW_PREVIEW, 0); + } + else + { + preview_frame_height = old_preview_area_size; + MenuIcheck( NULL, MENU_BAR_SHOW_PREVIEW, 1); + } + + if( win_catalog && browser_frame_width) + { + int16 dum, x, y, h; + + WindGet ( win_catalog, WF_WORKXYWH, &x, &y, &dum, &h); + + draw_page( win_catalog, x, y, browser_frame_width + border_size, h); + WindMakePreview( win_catalog); + } +} +*/ + +/*==================================================================================* + * void Menu_thumb_size: * + * Set the thumbnails's size from 4:3 to 3:4 and from 3:4 to 4:3 * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +static void Menu_thumb_size( void) +{ + if ( thumbnail_size > 3) + { + if ( thumbnail_size == 4) thumbnail_size = 0; + else + if ( thumbnail_size == 5) thumbnail_size = 1; + else + if ( thumbnail_size == 6) thumbnail_size = 2; + else thumbnail_size = 3; + + MenuIcheck( NULL, MENU_BAR_LARGE_THUMB, 1); + MenuIcheck( NULL, MENU_BAR_LONG_THUMB, 0); + } + else + { + if ( thumbnail_size == 0) thumbnail_size = 4; + else + if ( thumbnail_size == 1) thumbnail_size = 5; + else + if ( thumbnail_size == 2) thumbnail_size = 6; + else thumbnail_size = 7; + + MenuIcheck( NULL, MENU_BAR_LONG_THUMB, 1); + MenuIcheck( NULL, MENU_BAR_LARGE_THUMB, 0); + } + + if( win_catalog) + WinCatalog_set_thumbnails_size( win_catalog); + +} + + +/*==================================================================================* + * void Menu_show_help: * + * Call StGuide and show "zview.hyp" with it. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +static void Menu_show_help( void) +{ + strcpy( fullname, zview_path); + strcat( fullname, "\\doc\\zview.hyp"); + + CallStGuide( fullname); +} + + +/*==================================================================================* + * void Menu_show_history: * + * Call StGuide and show "history.txt" with it. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +static void Menu_show_history( void) +{ + strcpy( fullname, zview_path); + strcat( fullname, "\\doc\\history.txt"); + + CallStGuide( fullname); +} + + +/*==================================================================================* + * void Menu_sort_by_date: * + * Bind the wanted function with the items in the TOS menubar. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void MenuDesktop( void) +{ + MenuBar ( get_tree( MENU_BAR), 1); + + /* Attach Menu functions */ + ObjcAttach( OC_MENU, NULL, MENU_BAR_OPEN, BIND_FUNC, Menu_open_image); + ObjcAttach( OC_MENU, NULL, MENU_BAR_ABOUT, BIND_FUNC, Menu_about); + ObjcAttach( OC_MENU, NULL, MENU_BAR_QUIT, BIND_FUNC, applexit); + ObjcAttach( OC_MENU, NULL, MENU_BAR_BROWSER, BIND_FUNC, WinCatalog); + ObjcAttach( OC_MENU, NULL, MENU_BAR_CLOSE, BIND_FUNC, Menu_close_win); + ObjcAttach( OC_MENU, NULL, MENU_BAR_SHOW, BIND_FUNC, Menu_show_non_image); + ObjcAttach( OC_MENU, NULL, MENU_BAR_BY_NAME, BIND_FUNC, Menu_sort_by_name); + ObjcAttach( OC_MENU, NULL, MENU_BAR_BY_SIZE, BIND_FUNC, Menu_sort_by_size); + ObjcAttach( OC_MENU, NULL, MENU_BAR_BY_DATE, BIND_FUNC, Menu_sort_by_date); + ObjcAttach( OC_MENU, NULL, MENU_BAR_SHOW_BROWSER, BIND_FUNC, Menu_show_browser); + ObjcAttach( OC_MENU, NULL, MENU_BAR_SELECT_ALL, BIND_FUNC, Menu_select_all); + ObjcAttach( OC_MENU, NULL, MENU_BAR_LARGE_THUMB, BIND_FUNC, Menu_thumb_size); + ObjcAttach( OC_MENU, NULL, MENU_BAR_LONG_THUMB, BIND_FUNC, Menu_thumb_size); + ObjcAttach( OC_MENU, NULL, MENU_BAR_INFORMATION, BIND_FUNC, Menu_file_info); + ObjcAttach( OC_MENU, NULL, MENU_BAR_PREFERENCE, BIND_FUNC, Menu_preference); + ObjcAttach( OC_MENU, NULL, MENU_BAR_SAVE, BIND_FUNC, Menu_file_save); + ObjcAttach( OC_MENU, NULL, MENU_BAR_DELETE, BIND_FUNC, Menu_delete); + ObjcAttach( OC_MENU, NULL, MENU_BAR_HISTORY, BIND_FUNC, Menu_show_history); + ObjcAttach( OC_MENU, NULL, MENU_BAR_GUIDE, BIND_FUNC, Menu_show_help); + ObjcAttach( OC_MENU, NULL, MENU_BAR_SHOW_FULLSCREEN, BIND_FUNC, Menu_fullscreen); + + if( browser_frame_width) + MenuIcheck( NULL, MENU_BAR_SHOW_BROWSER, 1); + +// if( preview_frame_height) +// MenuIcheck( NULL, MENU_BAR_SHOW_PREVIEW, 1); + + if ( show_non_image) + MenuIcheck( NULL, MENU_BAR_SHOW, 1); + + if ( thumbnail_size > 3) + MenuIcheck( NULL, MENU_BAR_LONG_THUMB, 1); + else + MenuIcheck( NULL, MENU_BAR_LARGE_THUMB, 1); + + switch ( sortingmode) + { + case 0: + MenuIcheck( NULL, MENU_BAR_BY_NAME, 1); + break; + + case 1: + MenuIcheck( NULL, MENU_BAR_BY_SIZE, 1); + break; + + case 2: + MenuIcheck( NULL, MENU_BAR_BY_DATE, 1); + break; + } + + + EvntAttach( NULL, MN_SELECTED, MenuHandle); +} diff --git a/sources/z-tools/trunk/zview/menu.h b/sources/z-tools/trunk/zview/menu.h new file mode 100644 index 0000000..434aae5 --- /dev/null +++ b/sources/z-tools/trunk/zview/menu.h @@ -0,0 +1,4 @@ +extern void MenuDesktop( void); +extern void Menu_open_image( void); + + diff --git a/sources/z-tools/trunk/zview/mfdb.c b/sources/z-tools/trunk/zview/mfdb.c new file mode 100644 index 0000000..cacc8aa --- /dev/null +++ b/sources/z-tools/trunk/zview/mfdb.c @@ -0,0 +1,75 @@ +#include "general.h" + + +/* Prototype */ +int16 init_mfdb( MFDB *bm, int16 width, int16 height, int16 planes); +void delete_mfdb( MFDB *bm, int16 nbr); + + +/*==================================================================================* + * int16 init_mfdb: * + * fit a MFDB with the parameters suppplied. * + *----------------------------------------------------------------------------------* + * input: * + * bm -> The MFDB to fit. * + * width -> Image's width. * + * height -> Image's height. * + * planes -> Screen planes or 1 if the image is monochrome. * + *----------------------------------------------------------------------------------* + * returns: * + * '0' if error or the memory size allocated. * + *==================================================================================*/ +int16 init_mfdb( MFDB *bm, int16 width, int16 height, int16 planes) +{ + uint32 length; + + bm->fd_w = width; + bm->fd_h = height; + bm->fd_wdwidth = ( width >> 4) + (( width % 16) != 0); + bm->fd_stand = 0; + bm->fd_nplanes = planes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + + length = (( (( uint32)bm->fd_wdwidth << 1 ) * ( uint32)bm->fd_nplanes) * ( uint32)bm->fd_h) + 256L; + bm->fd_addr = gmalloc( length); + + if( bm->fd_addr) + return( 1); + + bm->fd_addr = NULL; + + return ( 0); +} + + +/*==================================================================================* + * int16 delete_mfdb: * + * free the data of MFDB struct. * + *----------------------------------------------------------------------------------* + * input: * + * bm -> pointer to the MFDB to delete. * + * nbr -> The number of MFDB struct. to delete. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void delete_mfdb( MFDB *bm, int16 nbr) +{ + register int16 i; + + if(( nbr == 0) || ( bm == NULL)) + return; + + for ( i = 0; i < nbr; i++) + { + if ( bm[i].fd_addr == NULL) + continue; + + gfree( bm[i].fd_addr); + } + + gfree( bm); +} + diff --git a/sources/z-tools/trunk/zview/mfdb.h b/sources/z-tools/trunk/zview/mfdb.h new file mode 100644 index 0000000..e1a27c2 --- /dev/null +++ b/sources/z-tools/trunk/zview/mfdb.h @@ -0,0 +1,2 @@ +extern int16 init_mfdb( MFDB *bm, int16 width, int16 height, int16 planes); +extern void delete_mfdb( MFDB *bm, int16 nbr); diff --git a/sources/z-tools/trunk/zview/pdf_load.c b/sources/z-tools/trunk/zview/pdf_load.c new file mode 100644 index 0000000..44db227 --- /dev/null +++ b/sources/z-tools/trunk/zview/pdf_load.c @@ -0,0 +1,224 @@ +#include "general.h" +#include "pic_load.h" +#include "prefs.h" +#include "progress.h" +#include "plugins.h" +#include "mfdb.h" +#include "winimg.h" +#include "chrono.h" +#include "txt_data.h" +#include "zvdi/color.h" +#include "zvdi/raster.h" +#include "zvdi/vdi.h" +#include "pdf/pdflib.h" + + +int16 pdf_initialised = FALSE; + + +/*==================================================================================* + * read_pdf: * + * Read a image and fit the MFDB within IMAGE structur with the data. * + *----------------------------------------------------------------------------------* + * img: The struct. with the MFDB to be fitted. * + * page: The wanted page. * + *----------------------------------------------------------------------------------* + * returns: 0 if error. * + *==================================================================================*/ +int16 read_pdf( IMAGE *img, int16 page, double scale) +{ + DECDATA data; + uint16 *dst; + uint8 *src, *src_prt; + uint32 src_line_size; + uint16 x, y; + + data = ( dec_data *) gmalloc( sizeof( dec_data)); + + if ( !data) + { + errshow( "", ENOMEM); + return ( 0); + } + + data->IncXfx = 0x10000uL; + data->IncYfx = 0x10000uL; + + chrono_on(); + + pdf_decode_page( img, page, scale); + + if( app.nplanes > 8) + data->DthBuf = NULL; + else + { + size_t size = ( img->img_w + 15) * 3; + + data->DthBuf = gmalloc( size); + + if( data->DthBuf == NULL) + { + gfree( data); + errshow( "", ENOMEM); + return ( 0); + } + + memset( data->DthBuf, 0, size); + } + + data->DthWidth = img->img_w; + data->PixMask = img->colors; + + if ( !init_mfdb( &img->image[page - 1], img->img_w, img->img_h, app.nplanes)) + { + if( data->DthBuf) + gfree( data->DthBuf); + + gfree( data); + errshow( "", ENOMEM); + return ( 0); + } + + data->LnSize = img->image[page - 1].fd_wdwidth * app.nplanes; + dst = ( uint16*)img->image[page - 1].fd_addr; + + src_line_size = img->img_w * 3; + + src = ( uint8*)pdf_get_page_addr( img); + src_prt = src; + + /* now, we draw a line around the pdf */ + for( y = 0 ; y < img->img_h ; y++, src_prt += src_line_size) + { + if( y == 0 || y == img->img_h - 1) + { + for( x = 0 ; x < src_line_size ; x += 3) + { + src_prt[x] = 0x00; + src_prt[x + 1] = 0x00; + src_prt[x + 2] = 0x00; + } + } + + src_prt[0] = 0x00; + src_prt[1] = 0x00; + src_prt[2] = 0x00; + + src_prt[src_line_size - 3] = 0x00; + src_prt[src_line_size - 2] = 0x00; + src_prt[src_line_size - 1] = 0x00; + } + + for( y = 0 ; y < img->img_h ; y++, src += src_line_size) + { + data->RowBuf = src; + ( *raster_true)( data, dst); + dst += data->LnSize; + } + + if( data->DthBuf) + gfree( data->DthBuf); + + gfree( data); + + chrono_off( ( char*)img->working_time); + + return( 1); +} + + +double get_scale_value( IMAGE *img, int16 page, uint16 target_width, uint16 target_height) +{ + int fit_pdf_to_win = 3; /* 0 = 100%, 1 = fit width, 2 = fit height, 3 = best fit */ + double w_scale, h_scale, scale; + uint16 doc_width, doc_height; + + pdf_get_page_size( img, page, &doc_width, &doc_height); + + switch( fit_pdf_to_win) + { + case 1: + scale = (double)target_width / doc_width; + break; + + case 2: + scale = (double)target_height / doc_height; + break; + + case 3: + w_scale = (double)target_width / doc_width; + h_scale = (double)target_height / doc_height; + + scale = MIN (w_scale, h_scale); + break; + + default: + scale = 1; + } + + return scale; +} + + +/*==================================================================================* + * pdf_load: * + * initialise and read the first page of a PDF and fill the IMAGE * + * struct. * + *----------------------------------------------------------------------------------* + * file: The file that will be read. * + * img: The IMAGE struct. to be filled. * + *----------------------------------------------------------------------------------* + * returns: '0' if error. * + *==================================================================================*/ + +int16 pdf_load( const char *file, IMAGE *img, uint16 width, uint16 height) +{ + int16 i; + uint16 w = width; + double scale = 1.0; + + if( pdf_initialised == FALSE) + pdf_initialised = pdf_init( zview_path); + + if( lib_pdf_load( file, img) == FALSE) + return( 0); + + if( ( img->image = ( MFDB *)gmalloc( sizeof( MFDB) * img->page)) == NULL) + { + pdf_quit( img); + return ( 0); + } + + for( i = 0 ; i < img->page ; i++) + { + MFDB *mfdb = &img->image[i]; + + mfdb->fd_addr = NULL; + img->delay[i] = 0; + } + + + /* if the pdf owns only one page, we don't need the bookmark's frame */ + if( img->page == 1) + w += 205; + + if( pdf_fit_to_win) + scale = get_scale_value( img, 1, w, height); + + if( !read_pdf( img, 1, scale)) + { + pdf_quit( img); + return ( 0); + } + + if( !init_txt_data( img, 8, 256)) + { + pdf_quit( img); + delete_mfdb( img->image, img->page); + return ( 0); + } + + pdf_get_info( img, img->comments); + + return ( 1); +} diff --git a/sources/z-tools/trunk/zview/pdf_load.h b/sources/z-tools/trunk/zview/pdf_load.h new file mode 100644 index 0000000..0ca77bc --- /dev/null +++ b/sources/z-tools/trunk/zview/pdf_load.h @@ -0,0 +1,4 @@ +extern int16 pdf_initialised; +extern int16 read_pdf( IMAGE *img, int16 page, double scale); +extern int16 pdf_load( const char *file, IMAGE *img, uint16 width, uint16 height); +extern double get_scale_value( IMAGE *img, int16 page, uint16 target_width, uint16 target_height); diff --git a/sources/z-tools/trunk/zview/pic_load.c b/sources/z-tools/trunk/zview/pic_load.c new file mode 100644 index 0000000..cc71fb7 --- /dev/null +++ b/sources/z-tools/trunk/zview/pic_load.c @@ -0,0 +1,352 @@ +#include "general.h" +#include "pic_load.h" +#include "prefs.h" +#include "progress.h" +#include "plugins.h" +#include "mfdb.h" +#include "ztext.h" +#include "chrono.h" +#include "txt_data.h" +#include "zvdi//color.h" +#include "zvdi//raster.h" +#include "zvdi//vdi.h" +#include + +boolean decoder_init_done = FALSE; + + +void ( *raster) ( DECDATA, void *dst); +void ( *raster_cmap) ( DECDATA, void *); +void ( *raster_true) ( DECDATA, void *); +void ( *cnvpal_color) ( IMGINFO, DECDATA); +void ( *raster_gray) ( DECDATA, void *); +void CDECL ( *decoder_quit) ( IMGINFO); +boolean CDECL ( *decoder_init) ( const char *, IMGINFO); +boolean CDECL ( *decoder_read) ( IMGINFO, uint8 *); +void CDECL ( *decoder_get_txt) ( IMGINFO, txt_data *); + +extern int16 smooth_resize( MFDB *source_image, MFDB *resized_image, int resize_algo); + + + +static int16 setup ( IMAGE *img, IMGINFO info, DECDATA data) +{ + int16 i, n_planes = ( ( info->planes == 1 && info->components == 1) ? 1: app.nplanes); + uint16 display_w, display_h; + double precise_x, precise_y, factor; + size_t src_line_size; + + if( img->view_mode && ( info->width > thumbnail[thumbnail_size][0] || info->height > thumbnail[thumbnail_size][1]) && ( !smooth_thumbnail || n_planes < 16)) + { + factor = MAX( ( ( double)info->height / ( double)thumbnail[thumbnail_size][1]), ( ( double)info->width / ( double)thumbnail[thumbnail_size][0])); + precise_x = ( double)info->width / factor; + precise_y = ( double)info->height / factor; + + display_w = ( uint16)( precise_x > 0 ? precise_x : 16); + display_h = ( uint16)( precise_y > 0 ? precise_y : 16); + data->IncXfx = ((( uint32)info->width << 16) + ( display_w >> 1)) / display_w; + data->IncYfx = ((( uint32)info->height << 16) + ( display_h >> 1)) / display_h; + } + else + { + display_w = info->width; + display_h = info->height; + data->IncXfx = 0x10000uL; + data->IncYfx = 0x10000uL; + } + + if( img->view_mode) + /* if we are in preview mode, we decompress only one image */ + img->page = 1; + else + img->page = info->page; + + + if( ( img->image = ( MFDB *)gmalloc( sizeof( MFDB) * img->page)) == NULL) + return( 0); + + + for ( i = 0 ; i < img->page ; i++) + { + if ( !init_mfdb( &img->image[i], display_w, display_h, n_planes)) + return( 0); + } + + if( info->num_comments) + { + /* we initialise the txt_data struct... */ + if( !init_txt_data( img, info->num_comments, info->max_comments_length)) + return ( 0); + + decoder_get_txt( info, img->comments); + } + else + img->comments = NULL; + +// we assume that the pixel size is minimum 8 bits because some GNU libraries return 1 and 4 bits format like 8 bits ones. +// We add also a little more memory for avoid buffer overflow for plugin badly coded. + src_line_size = ( info->width + 64) * info->components; + + data->RowBuf = ( uint8*)gmalloc( src_line_size); + + if( !data->RowBuf) + return ( 0); + + if(( info->planes == 1 && info->components == 1) || app.nplanes > 8) + data->DthBuf = NULL; + else + { + size_t size = ( display_w + 15) * 3; + + if( ( data->DthBuf = gmalloc( size)) == NULL) + return ( 0); + + memset( data->DthBuf, 0, size); + } + + data->DthWidth = display_w; + data->PixMask = ( 1 << info->planes) - 1; + data->LnSize = img->image[0].fd_wdwidth * n_planes; + + if ( info->planes == 1 && info->components == 1) + { + cnvpal_mono( info, data); + raster = raster_mono; + } + else + { + if ( info->indexed_color) + { + ( *cnvpal_color)( info, data); + raster = raster_cmap; + } + else + raster = ( info->components >= 3 ? raster_true : raster_gray); + } + + img->img_w = info->real_width; + img->img_h = info->real_height; + img->colors = info->colors; + img->bits = info->planes; + + strcpy( img->info, info->info); + strcpy( img->compression, info->compression); + + return( 1); +} + + +/*==================================================================================* + * read_img: * + * Read a image and fit the MFDB within IMAGE structur with the data. * + *----------------------------------------------------------------------------------* + * img: The struct. with the MFDB to be fitted. * + * info: The struct. with the line and dither buffer * + *----------------------------------------------------------------------------------* + * returns: - * + *==================================================================================*/ +static inline void read_img ( IMAGE *img, IMGINFO info, DECDATA data) +{ + uint16 *dst; + int16 y_dst, i, y, progress_counter = 0, img_h = info->height; + int32 line_size = data->LnSize, line_to_decode = img_h * img->page; + uint8 *buf = data->RowBuf; + + for ( i = 0; i < img->page; i++) + { + uint32 scale = ( data->IncYfx + 1) >> 1; + y_dst = img->image[0].fd_h; + dst = img->image[i].fd_addr; + + if( info->orientation == DOWN_TO_UP) + { + dst += data->LnSize * ( y_dst - 1); + line_size = -data->LnSize; + } + + info->page_wanted = i; + + for( y = 1; y <= img_h; y++) + { + if( !decoder_read( info, buf)) + return; + + while(( scale >> 16) < y) + { + ( *raster)( data, dst); + dst += line_size; + scale += data->IncYfx; + if (!--y_dst) break; + } + + if( img->progress_bar) + { + progress_counter++; + win_progress(( int16)((( int32)progress_counter * 150L) / line_to_decode)); + } + } + + img->delay[i] = info->delay; + } +} + + + +/*==================================================================================* + * quit_img: * + * Close the image's file and free the line/dither/info buffer. * + *----------------------------------------------------------------------------------* + * info: The struct. to liberate * + *----------------------------------------------------------------------------------* + * returns: - * + *==================================================================================*/ + +void quit_img( IMGINFO info, DECDATA data) +{ + if( decoder_init_done == TRUE) + decoder_quit( info); + + if( data->DthBuf != NULL) + gfree( data->DthBuf); + + if( data->RowBuf != NULL) + gfree( data->RowBuf); + + gfree( data); + gfree( info); + + decoder_init_done = FALSE; +} + + +boolean get_pic_info( const char *file, char *extention, IMGINFO info) +{ + int16 i, j, c = 0; + char plugin[3]; + + /* We check if a plug-ins can do the job */ + for( i = 0; i < plugins_nbr; i++, c = 0) + { + for( j = 0; j < codecs[i]->user_ext; j++) + { + plugin[0] = codecs[i]->infos[c++]; + plugin[1] = codecs[i]->infos[c++]; + plugin[2] = codecs[i]->infos[c++]; + + if( strncmp( extention, plugin, 3) == 0) + { + if ( !( decoder_init = ldg_find( "reader_init", codecs[i])) + || !( decoder_read = ldg_find( "reader_read", codecs[i])) + || !( decoder_quit = ldg_find( "reader_quit", codecs[i])) + || !( decoder_get_txt = ldg_find( "reader_get_txt", codecs[i]))) + { + errshow( codecs[i]->infos, ldg_error()); + return FALSE; + } + + // decoder_get_page_size = ldg_find( "reader_get_page_size", codecs[i]); + + return decoder_init( file, info); + } + } + } + + /* I wish that it will never append ! */ + return FALSE; +} + + +/*==================================================================================* + * pic_load: * + * read a supported picture and fill a IMAGE structure. * + *----------------------------------------------------------------------------------* + * file: The file that will be read. * + * img: The IMAGE struct. that will be filled. * + *----------------------------------------------------------------------------------* + * returns: '0' if error or picture not supported * + *==================================================================================*/ + +int16 pic_load( const char *file, char *extention, IMAGE *img) +{ + IMGINFO info; + DECDATA data; + + info = ( img_info *) gmalloc( sizeof( img_info)); + + if ( !info) + { + errshow( "", ENOMEM); + return( 0); + } + + data = ( dec_data *) gmalloc( sizeof( dec_data)); + + if ( !data) + { + errshow( "", ENOMEM); + gfree( info); + return ( 0); + } + + + + if( img->progress_bar) + win_progress_begin( "Please Wait..."); + + /* We initialise some variables needed by the codecs */ + info->background_color = 0xFFFFFF; + info->thumbnail = img->view_mode; + + chrono_on(); + + if(( decoder_init_done = get_pic_info( file, extention, info)) == FALSE) + { + gfree( data); + gfree( info); + win_progress_end(); + return ( 0); + } + + if( !setup ( img, info, data)) + { + errshow( "", ENOMEM); + quit_img( info, data); + delete_mfdb( img->image, img->page); + win_progress_end(); + return ( 0); + } + + read_img ( img, info, data); + + quit_img( info, data); + + win_progress_end(); + + if( img->view_mode && ( img->image[0].fd_w > thumbnail[thumbnail_size][0] || img->image[0].fd_h > thumbnail[thumbnail_size][1]) && smooth_thumbnail && img->image[0].fd_nplanes >= 16) + { + MFDB resized_image; + double precise_x, precise_y, factor; + uint16 display_w, display_h; + + factor = MAX((( double)img->image[0].fd_h / ( double)thumbnail[thumbnail_size][1]), (( double)img->image[0].fd_w / ( double)thumbnail[thumbnail_size][0])); + precise_x = ( double)img->image[0].fd_w / factor; + precise_y = ( double)img->image[0].fd_h / factor; + display_w = ( uint16)( precise_x > 0 ? precise_x : 16); + display_h = ( uint16)( precise_y > 0 ? precise_y : 16); + + init_mfdb( &resized_image, display_w, display_h, img->image[0].fd_nplanes); + + smooth_resize( &img->image[0], &resized_image, smooth_thumbnail); + + gfree( img->image[0].fd_addr); + + img->image[0].fd_addr = resized_image.fd_addr; + img->image[0].fd_w = resized_image.fd_w; + img->image[0].fd_h = resized_image.fd_h; + img->image[0].fd_wdwidth = resized_image.fd_wdwidth; + } + + chrono_off( img->working_time); + + return ( 1); +} diff --git a/sources/z-tools/trunk/zview/pic_load.h b/sources/z-tools/trunk/zview/pic_load.h new file mode 100644 index 0000000..c4b2ec1 --- /dev/null +++ b/sources/z-tools/trunk/zview/pic_load.h @@ -0,0 +1,96 @@ +#define UP_TO_DOWN 0 +#define DOWN_TO_UP 1 +#define ST_RAM 0 +#define TT_RAM 1 + +typedef enum +{ + JCS_UNKNOWN, /* error/unspecified */ + JCS_GRAYSCALE, /* monochrome */ + JCS_RGB, /* red/green/blue */ + JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */ + JCS_CMYK, /* C/M/Y/K */ + JCS_YCCK /* Y/Cb/Cr/K */ +} J_COLOR_SPACE; + +typedef struct +{ + uint8 red; + uint8 green; + uint8 blue; +} COLOR_MAP; + + +typedef struct _img_info *IMGINFO; + +typedef struct _img_info +{ + /* Data returned by the decoder Picture's initialisation */ + uint16 width; /* Picture width */ + uint16 height; /* Picture Height */ + uint16 components; /* Picture components */ + uint16 planes; /* Picture bits by pixel */ + uint32 colors; /* Picture colors number */ + int16 orientation; /* picture orientation: UP_TO_DOWN or DONW_TO_UP ( ex: TGA) */ + uint16 page; /* Number of page/image in the file */ + uint16 delay; /* Animation delay in 200th sec. between each frame. */ + uint16 num_comments; /* Lines in the file's comment. ( 0 if none) */ + uint16 max_comments_length; /* The length of the greater line in the comment */ + int16 indexed_color; /* Picture has a palette: 0) No 1) Yes */ + int16 memory_alloc; /* where to do the memory allocation for the reader_read + function buffer, possible values are ST_RAM or TT_RAM */ + COLOR_MAP palette[256]; /* Palette in standard RGB format */ + + + /* data send to the codec */ + uint32 background_color; /* The wanted background's color in hexa */ + int16 thumbnail; /* 1 if true else 0. + Some format have thumbnail inside the picture, if 1, we + want only this thumbnail and not the image itself */ + uint16 page_wanted; /* The wanted page to get for the reader_read() function + The first page is 0 and the last is img_info->page - 1 */ + + + /* The following variable are only for Information Prupose, the zview doesn't + use it for decoding routine but only for the information dialog */ + int8 info[40]; /* Picture's info, for ex: "Gif 87a" */ + int8 compression[5]; /* Compression type, ex: "LZW" */ + uint16 real_width; /* Real picture width( if the thumbnail variable is 1) */ + uint16 real_height; /* Ral picture Height( if the thumbnail variable is 1) */ + + + /* Private data for the plugin */ + void *_priv_ptr; + void *_priv_ptr_more; + void *__priv_ptr_more; + + int32 _priv_var; + int32 _priv_var_more; + +} img_info; + + +typedef struct _dec_data *DECDATA; + +typedef struct _dec_data +{ + uint8 *RowBuf; + void *DthBuf; + uint8 *DstBuf; + uint16 DthWidth; + uint16 PixMask; + int32 LnSize; + uint32 IncXfx; + uint32 IncYfx; + uint32 Pixel[256]; +} dec_data; + +extern void ( *raster) ( DECDATA, void *dst); +extern void ( *raster_cmap) ( DECDATA, void *); +extern void ( *raster_true) ( DECDATA, void *); +extern void ( *rasterize_32) ( DECDATA, void *); +extern void ( *cnvpal_color)( IMGINFO, DECDATA); +extern void ( *raster_gray) ( DECDATA, void *); +extern boolean get_pic_info( const char *file, char *extention, IMGINFO info); +extern void quit_img( IMGINFO info, DECDATA data); +extern boolean decoder_init_done; diff --git a/sources/z-tools/trunk/zview/pic_resize.c b/sources/z-tools/trunk/zview/pic_resize.c new file mode 100644 index 0000000..cb72327 --- /dev/null +++ b/sources/z-tools/trunk/zview/pic_resize.c @@ -0,0 +1,138 @@ +#include "general.h" +#include "pic_load.h" +#include "mfdb.h" +#include "zvdi/raster_resize.h" +#include "zvdi/vdi.h" +#include "zvdi/p2c.h" + +void ( *resize)( DECDATA, void *dst); +void ( *my_resize)( DECDATA, void *dst); + +extern int32 plane2packed( int32 no_words, int32 plane_length, int16 no_planes, void *src, void *dst); + +static int16 resize_setup( MFDB *in, MFDB *out, DECDATA data) +{ + uint16 display_w, display_h; + float precise_x, precise_y, factor; + + factor = MAX( ( ( float)in->fd_h / out->fd_h), ( ( float)in->fd_w / out->fd_w)); + precise_x = ( float)in->fd_w / factor; + precise_y = ( float)in->fd_h / factor; + + display_w = ( ( uint16)precise_x > 0 ? ( uint16)precise_x : 16); + display_h = ( ( uint16)precise_y > 0 ? ( uint16)precise_y : 16); + + data->IncXfx = ((( uint32)in->fd_w << 16) + ( display_w >> 1)) / display_w; + data->IncYfx = ((( uint32)in->fd_h << 16) + ( display_h >> 1)) / display_h; + + if ( !init_mfdb( out, display_w, display_h, in->fd_nplanes)) + return ( 0); + + data->RowBuf = in->fd_addr; + + if( planar) + { + data->DstBuf = gmalloc((( uint32)in->fd_wdwidth << 4 ) + 256uL); + + if( data->DstBuf == NULL) + { + delete_mfdb( out, 1); + return ( 0); + } + } + else + data->DstBuf = NULL; + + data->DthWidth = display_w; + data->LnSize = out->fd_wdwidth * out->fd_nplanes; + + if( out->fd_nplanes == 1) + my_resize = resize_mono; + else + my_resize = resize; + + return( 1); +} + + +/*==================================================================================* + * read_img: * + * Read a image and fit the MFDB within IMAGE structur with the data. * + *----------------------------------------------------------------------------------* + * img: The struct. with the MFDB to be fitted. * + * info: The struct. with the line and dither buffer * + *----------------------------------------------------------------------------------* + * returns: - io;p^= * *==================================================================================*/ +static inline void resize_img( MFDB *in, MFDB *out, DECDATA data) +{ + uint16 *dst = out->fd_addr; + int16 y = 0; + int32 in_line_size = (( uint32)in->fd_wdwidth << 1 ) * ( uint32)in->fd_nplanes, + out_line_size = data->LnSize; + uint32 scale = ( data->IncYfx + 1) >> 1; + int16 y_dst = out->fd_h; + + + while ( y < in->fd_h) + { + y++; + + if( planar) + { + if( ( scale >> 16) < y) + planar_to_chunky( data->RowBuf, data->DstBuf, in->fd_w); + } + + while (( scale >> 16) < y) + { + my_resize( data, dst); + dst += out_line_size; + scale += data->IncYfx; + if ( !--y_dst) break; + } + + data->RowBuf += in_line_size; + } +} + + +/*==================================================================================* + * pic_resize: * + * Create a resized MFDB. the wanted size are in out->fd_h and * + * out->fd_w.. the size will be changed later to maintain the aspect * + * ratio. * + *----------------------------------------------------------------------------------* + * in: The src MFDB. * + * img: The target MFDB. * + *----------------------------------------------------------------------------------* + * returns: '0' if error else 1. * + *==================================================================================*/ + +int16 pic_resize( MFDB *in, MFDB *out) +{ + DECDATA data; + + /* 2 planes zoom not available */ + if( in->fd_nplanes == 2) + return ( 0); + + data = ( dec_data *)gmalloc( sizeof( dec_data)); + + if( !data) + return ( 0); + + if( !resize_setup( in, out, data)) + { + free( data); + return ( 0); + } + + resize_img ( in, out, data); + + if( data->DstBuf) + gfree( data->DstBuf); + + gfree( data); + + return ( 1); +} diff --git a/sources/z-tools/trunk/zview/pic_resize.h b/sources/z-tools/trunk/zview/pic_resize.h new file mode 100644 index 0000000..02882db --- /dev/null +++ b/sources/z-tools/trunk/zview/pic_resize.h @@ -0,0 +1,3 @@ +extern void ( *resize)( DECDATA, void *dst); +extern int16 pic_resize( MFDB *in, MFDB *out); + diff --git a/sources/z-tools/trunk/zview/pic_save.c b/sources/z-tools/trunk/zview/pic_save.c new file mode 100644 index 0000000..c6dfc32 --- /dev/null +++ b/sources/z-tools/trunk/zview/pic_save.c @@ -0,0 +1,268 @@ +#include "general.h" +#include "pic_load.h" +#include "prefs.h" +#include "ztext.h" +#include "zvdi//color.h" +#include "zvdi//raster.h" +#include "zvdi//vdi.h" +#include "plugins.h" +#include "progress.h" + +extern void CDECL ( *decoder_quit) ( IMGINFO); +extern boolean CDECL ( *decoder_read) ( IMGINFO, uint8 *); +extern boolean CDECL ( *decoder_init) ( const char *, IMGINFO); +extern void CDECL ( *encoder_quit) ( IMGINFO); +extern boolean CDECL ( *encoder_write) ( IMGINFO, uint8 *); +extern boolean CDECL ( *encoder_init) ( const char *, IMGINFO); + +static boolean encoder_init_done = FALSE; + + + +static int16 setup_encoder ( IMGINFO in_info, IMGINFO out_info, DECDATA data) +{ + size_t src_line_size, dst_line_size; + + data->IncXfx = 0x10000uL; + + src_line_size = ( in_info->width + 15) * in_info->components; + dst_line_size = ( out_info->width + 15) * out_info->components; + + data->RowBuf = ( uint8*)gmalloc( src_line_size); + + if( data->RowBuf == NULL) + return( 0); + + data->DthBuf = NULL; + + /* If the image is inverted like in iNTEL format, we must to decompress + the entire picture before to save it */ + if( in_info->orientation == DOWN_TO_UP) + { + data->DstBuf = ( uint8*)gmalloc( dst_line_size * ( out_info->height + 1)); + } + else + data->DstBuf = ( uint8*)gmalloc( dst_line_size); + + if( data->DstBuf == NULL) + return( 0); + + data->DthWidth = in_info->width; + data->PixMask = ( 1 << in_info->planes) - 1; + data->LnSize = out_info->width * out_info->components; + + switch( out_info->planes) + { + case 24: + if( in_info->planes == 1 && in_info->components == 1) + { + data->Pixel[0] = 0xFFFFFF; + data->Pixel[1] = 0x000000; + raster = raster_24; + } + else if( in_info->indexed_color) + { + cnvpal_true( in_info, data); + raster = raster_24; + } + else + raster = ( in_info->components >= 3 ? dither_24 : gscale_24); + + break; + + default: + return( 0); + } + + return( 1); +} + + +/*==================================================================================* + * read_img: * + * Read a image and fit the MFDB within IMAGE structur with the data. * + *----------------------------------------------------------------------------------* + * img: The struct. with the MFDB to be fitted. * + * info: The struct. with the line and dither buffer * + *----------------------------------------------------------------------------------* + * returns: - * + *==================================================================================*/ +static void write_img( IMGINFO in_info, IMGINFO out_info, DECDATA data) +{ + int16 y, img_h = in_info->height; + uint8 *dst = data->DstBuf; + + in_info->page_wanted = 0; + + if( in_info->orientation == UP_TO_DOWN) + { + for( y = 0; y < img_h; y++) + { + decoder_read( in_info, data->RowBuf); + + ( *raster)( data, dst); + + encoder_write( out_info, dst); + + if( show_write_progress_bar) + win_progress(( int16)((( int32)y * 150L) / img_h)); + } + } + else /* inversed INTEL format */ + { + int16 h = ( img_h << 1); /* image height * 2 . don't worry about this, is only for the progress bar */ + dst += data->LnSize * ( in_info->height - 1); + + /* First pass, we decode the entire image */ + for( y = 0; y < img_h; y++) + { + decoder_read( in_info, data->RowBuf); + + ( *raster)( data, dst); + + dst -= data->LnSize; + + if( show_write_progress_bar) + win_progress(( int16)((( int32)y * 75L) / img_h)); + } + + dst = data->DstBuf; + + /* second pass, we encode it */ + for( ; y < h; y++) + { + encoder_write( out_info, dst); + + dst += data->LnSize; + + if( show_write_progress_bar) + win_progress(( int16)((( int32)y * 75L) / img_h)); + } + } +} + + + +static void exit_pic_save( IMGINFO in_info, IMGINFO out_info, DECDATA data) +{ + if( data->DthBuf) + gfree( data->DthBuf); + + if( data->DstBuf) + gfree( data->DstBuf); + + if( data->RowBuf) + gfree( data->RowBuf); + + if( encoder_init_done) + encoder_quit( out_info); + + if( decoder_init_done) + decoder_quit( in_info); + + gfree( data); + gfree( out_info); + gfree( in_info); + + graf_mouse( ARROW, NULL); + + encoder_init_done = FALSE; + decoder_init_done = FALSE; +} + + +/*==================================================================================* + * pic_load: * + * read a supported picture and fill a IMAGE structure. * + *----------------------------------------------------------------------------------* + * file: The file that will be read. * + * img: The IMAGE struct. that will be filled. * + *----------------------------------------------------------------------------------* + * returns: '0' if error or picture not supported * + *==================================================================================*/ + +int16 pic_save( const char *in_file, const char *out_file) +{ + char extention[4]; + IMGINFO in_info = NULL, out_info = NULL; + DECDATA data = NULL; + + graf_mouse( BUSYBEE, NULL); + + in_info = ( img_info *) gmalloc( sizeof( img_info)); + out_info = ( img_info *) gmalloc( sizeof( img_info)); + data = ( dec_data *) gmalloc( sizeof( dec_data)); + + if ( !in_info || !out_info || !data) + { + if ( data) + gfree( data); + + if ( out_info) + gfree( out_info); + + if ( in_info) + gfree( in_info); + + graf_mouse( ARROW, NULL); + errshow( "", ENOMEM); + return( 0); + } + + data->DthBuf = NULL; + data->DstBuf = NULL; + data->RowBuf = NULL; + + if( show_write_progress_bar) + win_progress_begin( get_string( SAVE_TITLE)); + + /* We initialise some variables needed by the codecs */ + in_info->background_color = 0xFFFFFF; + in_info->thumbnail = FALSE; + + /* get the file extention */ + strcpy ( extention, in_file + strlen( in_file) - 3); + str2upper( extention); + + if(( decoder_init_done = get_pic_info( in_file, extention, in_info)) == FALSE) + { + errshow( in_file, CANT_LOAD_IMG); + exit_pic_save( in_info, out_info, data); + win_progress_end(); + graf_mouse( ARROW, NULL); + return ( 0); + } + + + /* copy information from input's information to output's information struct */ + memcpy( out_info, in_info, sizeof( img_info)); + + if (( encoder_init_done = encoder_init( out_file, out_info)) == FALSE) + { + errshow( NULL, CANT_SAVE_IMG); + exit_pic_save( in_info, out_info, data); + win_progress_end(); + graf_mouse( ARROW, NULL); + return ( 0); + } + + + if( !setup_encoder( in_info, out_info, data)) + { + errshow( NULL, ENOMEM); + exit_pic_save( in_info, out_info, data); + win_progress_end(); + graf_mouse( ARROW, NULL); + return ( 0); + } + + + write_img( in_info, out_info, data); + + exit_pic_save( in_info, out_info, data); + + graf_mouse( ARROW, NULL); + win_progress_end(); + + return ( 1); +} diff --git a/sources/z-tools/trunk/zview/plugins.c b/sources/z-tools/trunk/zview/plugins.c new file mode 100644 index 0000000..bf68573 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins.c @@ -0,0 +1,124 @@ +#include "general.h" +#include "ztext.h" + +/* Prototype */ +int16 plugins_init( void); +void plugins_quit( void); + + +/* LDG function */ +void CDECL( *codec_init)( void) = NULL; + +/* Global variable */ +int16 plugins_nbr = 0; +LDG *codecs[100]; + + +/*==================================================================================* + * void plugins_quit: * + * unload all the codec from memory. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void plugins_quit( void) +{ + int16 i; + + for( i = 0; i < plugins_nbr; i++) + ldg_close( codecs[i], ldg_global); + +} + + +/*==================================================================================* + * void plugins_init: * + * load all the codec to memory. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +int16 plugins_init( void) +{ + char *env_ldg, plugin_dir[MAX_PATH]; + DIR *dir; + LDG_INFOS *cook; + struct dirent *de; + int16 len; + char extention[4]; + + strcpy( plugin_dir, zview_path); + strcat( plugin_dir, "\\codecs"); + + /* We try to find the zcodecs folder in zview directory... */ + if ( chdir( plugin_dir) != 0) + { + shel_envrn( &env_ldg, "LDGPATH="); + + /* ...if this directory doesn't exist, we try to find + the zcodecs folder in the default LDG path, with + the LDG cookie or with the environment variable. */ + + if( ldg_cookie( LDG_COOKIE, ( int32*)&cook)) + strcpy( plugin_dir, cook->path); + else if( env_ldg) + strcpy( plugin_dir, env_ldg); + else + strcpy( plugin_dir, "C:\\gemsys\\ldg\\"); + + len = ( int16)strlen( plugin_dir); + + if( plugin_dir[len-1] != '\\') + strcat( plugin_dir, "\\"); + + strcat( plugin_dir, "codecs"); + + if ( chdir( plugin_dir) != 0) + return( 0); + } + + if (( dir = opendir( ".")) != NULL) + { + while(( de = readdir( dir)) != NULL) + { + if (( strcmp( de->d_name, ".") == 0) || ( strcmp( de->d_name, "..") == 0)) + continue; + + strcpy ( extention, de->d_name + strlen( de->d_name) - 3); + str2lower( extention); + + if( strcmp ( extention, "ldg") == 0) + { + if ( ( codecs[plugins_nbr] = ldg_open( de->d_name, ldg_global))) + { + if ( ( codec_init = ldg_find( "plugin_init", codecs[plugins_nbr]))) + { + codec_init(); + plugins_nbr++; + } + else + { + errshow( de->d_name, ldg_error()); + ldg_close( codecs[plugins_nbr], ldg_global); + } + } + else + { + errshow( de->d_name, ldg_error()); + } + } + } + closedir( dir); + } + + chdir( zview_path); + + return plugins_nbr; +} + diff --git a/sources/z-tools/trunk/zview/plugins.h b/sources/z-tools/trunk/zview/plugins.h new file mode 100644 index 0000000..a0a53f6 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins.h @@ -0,0 +1,5 @@ +extern int16 plugins_init( void); +extern void plugins_quit( void); + +extern LDG *codecs[100]; +extern int16 plugins_nbr; diff --git a/sources/z-tools/trunk/zview/plugins/Makefile b/sources/z-tools/trunk/zview/plugins/Makefile new file mode 100644 index 0000000..dd1547f --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/Makefile @@ -0,0 +1,26 @@ +PLUGINS = \ + bmp \ + degas \ + eureka \ + gif \ + godpaint \ + img \ + jpg \ + neochrome \ + png \ + tga \ + tiff + +default: $(PLUGINS) + +.PHONY: $(PLUGINS) +$(PLUGINS): + $(MAKE) -C $@ $(MAKECMDGOALS) CROSS=yes + +dist: + rm -rf codecs + mkdir codecs + for f in $(PLUGINS); do cp $$f/*.ldg codecs; done + +clean: $(PLUGINS) + rm -f *~ *.ldg diff --git a/sources/z-tools/trunk/zview/plugins/bmp/Makefile b/sources/z-tools/trunk/zview/plugins/bmp/Makefile new file mode 100644 index 0000000..78fef09 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/bmp/Makefile @@ -0,0 +1,13 @@ +STACKSIZE = 64k +OPTIMISATION = -O2 -fomit-frame-pointer -finline-functions +CPU = -m68020-60 +LIB = -lldgserver + +CFLAGS = $(CPU) $(OPTIMISATION) -Wall -I../common +LDFLAGS = -nostdlib + +OBJ = $(LDG_STARTUP_OBJ) bmpldg.o + +PROGRAM = bmp.ldg + +include ../../../common.mak diff --git a/sources/z-tools/trunk/zview/plugins/bmp/bmpldg.c b/sources/z-tools/trunk/zview/plugins/bmp/bmpldg.c new file mode 100644 index 0000000..5d5f91c --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/bmp/bmpldg.c @@ -0,0 +1,365 @@ +#include "zview.h" + +#define fill4B(a) ( ( 4 - ( (a) % 4 ) ) & 0x03) + +boolean CDECL reader_init( const char *name, IMGINFO info); +boolean CDECL reader_read( IMGINFO info, uint8 *buffer); +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata); +void CDECL reader_quit( IMGINFO info); +void CDECL init( void); + +PROC BMPFunc[] = +{ + { "plugin_init", "", init}, + { "reader_init", "", reader_init}, + { "reader_get_txt", "", reader_get_txt}, + { "reader_read", "", reader_read}, + { "reader_quit", "", reader_quit} +}; + + +LDGLIB bmp_plugin = +{ + 0x0200, /* Plugin version */ + 5, /* Number of plugin's functions */ + BMPFunc, /* List of functions */ + "BMP", /* File's type Handled */ + LDG_NOT_SHARED, /* The flags NOT_SHARED is used here.. even if zview plugins are reentrant + and are shareable, we must use this flags because we don't know if the + user has ldg.prg deamon installed on his computer */ + NULL, /* Function called when the plugin is unloaded */ + 1L /* Howmany file type are supported by this plugin */ +}; + + +/*==================================================================================* + * uint32 ToL: * + * Transform a unsigned long from little to big endian. * + *----------------------------------------------------------------------------------* + * input: * + * puffer -> pointer to the little endian long to convert. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +uint32 ToL( uint8 * puffer) +{ + return ( puffer[0] | ( puffer[1] << 8) | ( puffer[2] << 16) | ( puffer[3] << 24)); +} + + +/*==================================================================================* + * uint16 ToS: * + * Transform a unsigned word from little to big endian. * + *----------------------------------------------------------------------------------* + * input: * + * puffer -> pointer to the little endian word to convert. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +uint16 ToS( uint8 *puffer) +{ + return ( puffer[0] | ( puffer[1] << 8)); +} + + +/*==================================================================================* + * boolean CDECL reader_init: * + * Open the file "name", fit the "info" struct. ( see zview.h) and make others * + * things needed by the decoder. * + *----------------------------------------------------------------------------------* + * input: * + * name -> The file to open. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL reader_init( const char *name, IMGINFO info) +{ + uint8 buff[4], header_buffer[50], *line_buffer; + int16 handle, compressed; + uint32 bisize, line_size, skip; + + if ( ( handle = ( int16) Fopen( name, 0)) < 0) + return FALSE; + + if ( Fread( handle, 2, buff) != 2) + { + Fclose( handle); + return FALSE; + } + + if ( buff[0] != 'B' || buff[1] != 'M' ) + { + Fclose( handle); + return FALSE; + } + + if ( Fread( handle, 0x10, header_buffer) != 0x10) + { + Fclose( handle); + return FALSE; + } + + bisize = ToL( &header_buffer[12]); + + if( bisize != 40uL) + { + /* OS/2 BMP No supported */ + Fclose( handle); + return FALSE; + } + else + { + /* Window */ + Fread( handle, 36L, header_buffer); + info->width = (uint16)ToL (&header_buffer[0x00]); + info->height = (uint16)ToL (&header_buffer[0x04]); + info->planes = ToS (&header_buffer[0x0A]); + compressed = (int16)ToL (&header_buffer[0x0C]); + } + + if( compressed) + { + Fclose( handle); + return FALSE; + } + + switch( info->planes) + { + case 1: + line_size = ( info->width >> 3) + ( info->width % 8 ? 1 : 0); + break; + case 4: + line_size = ( info->width >> 1) + info->width % 2; + break; + case 8: + line_size = info->width; + break; + case 24: + line_size = info->width * 3; + break; + default: + Fclose( handle); + return FALSE; + } + + skip = fill4B( line_size); + line_size += skip; + line_buffer = malloc( line_size + 256L); + + if( line_buffer == NULL) + { + Fclose( handle); + return FALSE; + } + + info->real_width = info->width; + info->real_height = info->height; + info->components = ( info->planes == 1 ? 1 : 3); + info->indexed_color = FALSE; + info->memory_alloc = TT_RAM; + info->page = 1; + info->delay = 0; + info->orientation = DOWN_TO_UP; + info->num_comments = 0; + info->max_comments_length = 0; + info->colors = 1uL << (uint32)info->planes; + info->_priv_ptr = ( void*)line_buffer; + info->_priv_var = ( int32)handle; + info->_priv_var_more = ( int32)line_size; + + strcpy( info->info, "Window BitMaP"); + strcpy( info->compression, "None"); + + if( info->planes <= 8) + { + register int16 i; + + for ( i = 0; i < info->colors; i++) + { + Fread( handle, 4L, buff); + info->palette[i].blue = buff[0]; + info->palette[i].green = buff[1]; + info->palette[i].red = buff[2]; + } + } + + return TRUE; +} + + +/*==================================================================================* + * boolean CDECL reader_read: * + * This function fits the buffer with image data * + *----------------------------------------------------------------------------------* + * input: * + * buffer -> The destination buffer. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL reader_read( IMGINFO info, uint8 *buffer) +{ + int16 width, j, k, i, handle = ( int16)info->_priv_var; + uint8 buff[2], *line_buffer = ( uint8*)info->_priv_ptr; + uint32 line_size = info->_priv_var_more; + + if( Fread( handle, line_size, line_buffer) != line_size) + return FALSE; + + switch( info->planes) + { + case 1: + width = info->width >> 3; + + for ( j = 0; j < width; j++) + { + buff[0] = line_buffer[j]; + + for ( k = 0; k < 8; k++) + { + if (buff[0] & 0x80) + *buffer++ = 0xff; + else + *buffer++ = 0x00; + + buff[0] = buff[0] << 1; + } + + } + if ( info->width % 8) + { + buff[0] = line_buffer[j+1]; + + for ( k = 0; k < info->width % 8; k++) + { + if (buff[0] & 0x80) + *buffer++ = 0xff; + else + *buffer++ = 0x00; + + buff[0] = buff[0] << 1; + } + } + break; + + case 4: + width = info->width >> 1; + + for ( j = 0; j < width; j++) + { + buff[1] = line_buffer[j] >> 4; + buff[2] = line_buffer[j] & 0x0f; + *buffer++ = info->palette[buff[1]].red; + *buffer++ = info->palette[buff[1]].green; + *buffer++ = info->palette[buff[1]].blue; + *buffer++ = info->palette[buff[2]].red; + *buffer++ = info->palette[buff[2]].green; + *buffer++ = info->palette[buff[2]].blue; + } + if ( info->width % 2) + { + buff[1] = line_buffer[j+1] >> 4; + *buffer++ = info->palette[buff[1]].red; + *buffer++ = info->palette[buff[1]].green; + *buffer++ = info->palette[buff[1]].blue; + } + break; + + case 8: + for ( j = 0; j < info->width; j++) + { + *buffer++ = info->palette[line_buffer[j]].red; + *buffer++ = info->palette[line_buffer[j]].green; + *buffer++ = info->palette[line_buffer[j]].blue; + } + break; + + case 24: + for ( i = j = 0; j < info->width; j++, i += 3) + { + *buffer++ = line_buffer[i+2]; + *buffer++ = line_buffer[i+1]; + *buffer++ = line_buffer[i]; + } + break; + + default: + return FALSE; + } + + return TRUE; +} + + +/*==================================================================================* + * boolean CDECL reader_get_txt * + * This function , like other CDECL function must be always present. * + * It fills txtdata struct. with the text present in the picture ( if any). * + *----------------------------------------------------------------------------------* + * input: * + * txtdata -> The destination text buffer. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata) +{ + return; +} + + +/*==================================================================================* + * boolean CDECL reader_quit: * + * This function makes the last job like close the file handler and free the * + * allocated memory. * + *----------------------------------------------------------------------------------* + * input: * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_quit( IMGINFO info) +{ + free( info->_priv_ptr); + Fclose( ( int16)info->_priv_var); +} + + +/*==================================================================================* + * boolean CDECL init: * + * First function called from zview, in this one, you can make some internal * + * initialisation. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL init( void) +{ +} + + +/*==================================================================================* + * int main: * + * Main function, his job is to call ldg_init function. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * 0 * + *==================================================================================*/ +int main( void) +{ + ldg_init( &bmp_plugin); + return( 0); +} diff --git a/sources/z-tools/trunk/zview/plugins/bmp/copyright b/sources/z-tools/trunk/zview/plugins/bmp/copyright new file mode 100644 index 0000000..a1ef488 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/bmp/copyright @@ -0,0 +1,503 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/sources/z-tools/trunk/zview/plugins/common/types2b.h b/sources/z-tools/trunk/zview/plugins/common/types2b.h new file mode 100644 index 0000000..26efa53 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/common/types2b.h @@ -0,0 +1,58 @@ +#ifndef __2B_UNIVERSAL_TYPES__ +#define __2B_UNIVERSAL_TYPES__ + +#ifndef HAVE_INTS_DEFINED +typedef signed char int8; +typedef unsigned char uint8; +typedef signed long int32; +typedef unsigned long uint32; +#endif +typedef int32 fix31; + +#ifdef __GNUC__ + #ifndef HAVE_INTS_DEFINED + typedef signed short int16; + typedef unsigned short uint16; + #endif + #define __2B_HAS64_SUPPORT /* Compiler supports 64 Bit Integers */ + typedef signed long long int64; + typedef unsigned long long uint64; + +/* typedef unsigned long long loff_t; */ +#else /* Compiler doesn't support 64 Bit Integers */ + typedef signed int int16; + typedef unsigned int uint16; + + typedef struct + { + int32 hi; + uint32 lo; + } int64; + + typedef struct + { + int32 hi; + uint32 lo; + } loff_t; + + typedef struct + { + uint32 hi; + uint32 lo; + } uint64; +#endif + + +#ifndef HAVE_BOOLEAN + #ifdef __GNUC__ + typedef int boolean; + typedef int BOOL; + #define HAVE_BOOLEAN + #else + typedef int32 boolean; + typedef int32 BOOL; + #define HAVE_BOOLEAN + #endif +#endif + +#endif diff --git a/sources/z-tools/trunk/zview/plugins/common/zview.h b/sources/z-tools/trunk/zview/plugins/common/zview.h new file mode 100644 index 0000000..62cb7e8 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/common/zview.h @@ -0,0 +1,121 @@ +/* + * LDG plugin. + * Copyright (c) 2004-2005 Zorro ( zorro270@yahoo.fr) + * + * This plugin is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This plugin is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include "types2b.h" +#include +#include +#include +#include +#include +#include +#include + +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif + +#ifndef MIN +#define MAX(a,b) ((a)>(b)?(a):(b)) +#define MIN(a,b) ((a)<(b)?(a):(b)) +#endif + +#define M_EXIF 0xE1 +#define UP_TO_DOWN 0 +#define DOWN_TO_UP 1 +#define ST_RAM 0 +#define TT_RAM 1 +#define GOLBAL_ERROR 0 +#define DSP_ERROR 1 +#define PROGRESSIVE_JPG 2 +#define ALL_OK 3 + +typedef struct _img_data +{ + int16 imagecount; + uint16 delay[1024]; + uint8 *image_buf[1024]; +} img_data; + + +typedef struct _txt_data +{ + int16 lines; /* Number of lines in the text */ + int16 max_lines_length; /* The length of the greater line ( in nbr char) */ + int8 *txt[256]; +} txt_data; + + +typedef struct +{ + uint8 red; + uint8 green; + uint8 blue; +} COLOR_MAP; + + +typedef struct _img_info *IMGINFO; + +typedef struct _img_info +{ + /* Data returned by the decoder Picture's initialisation */ + uint16 width; /* Picture width */ + uint16 height; /* Picture Height */ + uint16 components; /* Picture components */ + uint16 planes; /* Picture bits by pixel */ + uint32 colors; /* Picture colors number */ + int16 orientation; /* picture orientation: UP_TO_DOWN or DONW_TO_UP ( ex: TGA) */ + uint16 page; /* Number of page/image in the file */ + uint16 delay; /* Animation delay in 200th sec. between each frame. */ + uint16 num_comments; /* Lines in the file's comment. ( 0 if none) */ + uint16 max_comments_length; /* The length of the greater line in the comment */ + int16 indexed_color; /* Picture has a palette: 0) No 1) Yes */ + int16 memory_alloc; /* where to do the memory allocation for the reader_read + function buffer, possible values are ST_RAM or TT_RAM */ + COLOR_MAP palette[256]; /* Palette in standard RGB format */ + + + /* data send to the codec */ + uint32 background_color; /* The wanted background's color in hexa */ + int16 thumbnail; /* 1 if true else 0. + Some format have thumbnail inside the picture, if 1, we + want only this thumbnail and not the image itself */ + uint16 page_wanted; /* The wanted page to get for the reader_read() function + The first page is 0 and the last is img_info->page - 1 */ + + + /* The following variable are only for Information Prupose, the zview doesn't + use it for decoding routine but only for the information dialog */ + int8 info[40]; /* Picture's info, for ex: "Gif 87a" */ + int8 compression[5]; /* Compression type, ex: "LZW" */ + uint16 real_width; /* Real picture width( if the thumbnail variable is 1) */ + uint16 real_height; /* Ral picture Height( if the thumbnail variable is 1) */ + + + /* Private data for the plugin */ + void *_priv_ptr; + void *_priv_ptr_more; + void *__priv_ptr_more; + + int32 _priv_var; + int32 _priv_var_more; +} img_info; diff --git a/sources/z-tools/trunk/zview/plugins/degas/Makefile b/sources/z-tools/trunk/zview/plugins/degas/Makefile new file mode 100644 index 0000000..978547a --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/degas/Makefile @@ -0,0 +1,13 @@ +STACKSIZE = 64k +OPTIMISATION = -O2 -fomit-frame-pointer -finline-functions +CPU = -m68020-60 +LIB = -lldgserver + +CFLAGS = $(CPU) $(OPTIMISATION) -Wall -I../common +LDFLAGS = -nostdlib + +OBJ = $(LDG_STARTUP_OBJ) degasldg.o + +PROGRAM = degas.ldg + +include ../../../common.mak diff --git a/sources/z-tools/trunk/zview/plugins/degas/copyright b/sources/z-tools/trunk/zview/plugins/degas/copyright new file mode 100644 index 0000000..a1ef488 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/degas/copyright @@ -0,0 +1,503 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/sources/z-tools/trunk/zview/plugins/degas/degasldg.c b/sources/z-tools/trunk/zview/plugins/degas/degasldg.c new file mode 100644 index 0000000..e8ec91b --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/degas/degasldg.c @@ -0,0 +1,427 @@ +#include "zview.h" + +boolean CDECL reader_init( const char *name, IMGINFO info); +boolean CDECL reader_read( IMGINFO info, uint8 *buffer); +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata); +void CDECL reader_quit( IMGINFO info); +void CDECL init( void); + + +PROC DEGASFunc[] = +{ + { "plugin_init", "", init}, + { "reader_init", "", reader_init}, + { "reader_get_txt", "", reader_get_txt}, + { "reader_read", "", reader_read}, + { "reader_quit", "", reader_quit} +}; + + +LDGLIB degas_plugin = +{ + 0x0200, /* Plugin version */ + 5, /* Number of plugin's functions */ + DEGASFunc, /* List of functions */ + "PI1PI2PI3PC1PC2PC3", /* File's type Handled */ + LDG_NOT_SHARED, /* The flags NOT_SHARED is used here.. even if zview plugins are reentrant + and are shareable, we must use this flags because we don't know if the + user has ldg.prg deamon installed on his computer */ + NULL, /* Function called when the plugin is unloaded */ + 6L /* Howmany file type are supported by this plugin */ +}; + +typedef struct +{ + uint16 compression : 1; + uint16 reserved0 : 13; + uint16 resolution : 2; + uint16 palette[16]; +} DEGASHDR; + + + +/*==================================================================================* + * boolean CDECL reader_init: * + * Open the file "name", fit the "info" struct. ( see zview.h) and make others * + * things needed by the decoder. * + *----------------------------------------------------------------------------------* + * input: * + * name -> The file to open. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL reader_init( const char *name, IMGINFO info) +{ + int16 handle; + int32 position, file_size; + DEGASHDR *degas; + + if ( ( handle = ( int16)Fopen( name, 0)) < 0) + return FALSE; + + file_size = Fseek( 0L, handle, 2); + + if( file_size > 33000L) + { + Fclose( handle); + return FALSE; + } + + Fseek( 0L, handle, 0); + + degas = ( DEGASHDR *)malloc( file_size); + + if ( degas == NULL) + { + Fclose( handle); + return FALSE; + } + + if ( Fread( handle, file_size, degas) != file_size) + { + free( degas); + Fclose( handle); + return FALSE; + } + + Fclose( handle); + + info->planes = 1 << ( 2 - degas->resolution); + + switch( info->planes) + { + case 4: + info->width = 320; + info->height = 200; + info->components = 3; + info->indexed_color = TRUE; + info->colors = 16; + break; + + case 2: + info->width = 640; + info->height = 200; + info->components = 3; + info->indexed_color = TRUE; + info->colors = 4; + break; + + case 1: + info->width = 640; + info->height = 400; + info->components = 1; + info->indexed_color = FALSE; + info->colors = 2; + break; + + default: + free( degas); + return FALSE; + } + + position = sizeof( DEGASHDR); + + info->real_width = info->width; + info->real_height = info->height; + info->memory_alloc = TT_RAM; + info->page = 1; + info->delay = 0; + info->orientation = UP_TO_DOWN; + info->num_comments = 0; + info->max_comments_length = 0; + info->_priv_ptr = ( void*)degas; + info->_priv_var_more = position; + + strcpy( info->info, "Degas"); + + if( degas->compression) + { + uint8 *compress_buffer = malloc( 320L); + + if( compress_buffer == NULL) + { + free( degas); + return FALSE; + } + + info->_priv_ptr_more = ( void*)compress_buffer; + + strcpy( info->compression, "Yes"); + } + else + { + strcpy( info->compression, "None"); + info->_priv_ptr_more = NULL; + } + + + if( info->indexed_color) + { + register int16 i; + + for ( i = 0; i < info->colors; i++) + { + info->palette[i].red = ((( degas->palette[i] >> 7) & 0xE) + (( degas->palette[i] >> 11) & 0x1)) * 0x11; + info->palette[i].green = ((( degas->palette[i] >> 3) & 0xE) + (( degas->palette[i] >> 7) & 0x1)) * 0x11; + info->palette[i].blue = ((( degas->palette[i] << 1) & 0xE) + (( degas->palette[i] >> 3) & 0x1)) * 0x11; + } + } + + return TRUE; +} + + +static int16 read_line( int16 bpl, uint8 *src, uint8 *compress_buffer) +{ + int16 x, n, c; + int16 count = 0; + + /* decompress the line */ + for( x = 0; x < bpl;) + { + n = src[count++]; + + if( n <= 127) /* (n+1) literal bytes */ + { + n++; + + if( x + n > bpl) + return -1; + + do + { + compress_buffer[x++] = src[count++]; + }while ( --n > 0); + } + else /* next byte is repeated (257-n) times */ + { + n = 257 - n; + + if( x + n > bpl) + return -1; + + c = src[count++]; + + do { + compress_buffer[x++] = c; + } while (--n > 0); + } + } + + return count; +} + + + +/*==================================================================================* + * boolean CDECL reader_read: * + * This function fits the buffer with image data * + *----------------------------------------------------------------------------------* + * input: * + * buffer -> The destination buffer. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL reader_read( IMGINFO info, uint8 *buffer) +{ + DEGASHDR *degas = ( DEGASHDR*)info->_priv_ptr; + uint8 *l, *s = ( uint8*)degas + info->_priv_var_more; + uint8 *compress_buffer = ( uint8*)info->_priv_ptr_more; + uint16 x, c, p0, p1, p2, p3; + int16 count; + + if( degas->compression) + { + count = read_line(( info->width * info->planes) >> 3, s, compress_buffer); + + if( count == -1) + return FALSE; + + info->_priv_var_more += count; + + switch( info->planes) + { + case 4: + for( x = 0, l = compress_buffer; x < info->width; l += 2) + { + p0 = (l[ 0] << 8) | l[ 1]; + p1 = (l[ 40] << 8) | l[ 41]; + p2 = (l[ 80] << 8) | l[ 81]; + p3 = (l[120] << 8) | l[121]; + + for ( c = 0; c < 16; c++) + { + buffer[x++] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2) | ((p2 >> 13) & 4) | ((p3 >> 12) & 8); + p0 <<= 1; + p1 <<= 1; + p2 <<= 1; + p3 <<= 1; + } + } + break; + + case 2: + for ( x = 0, l = compress_buffer; x < info->width; l += 2) + { + p0 = (l[0] << 8) | l[1]; + p1 = (l[80] << 8) | l[81]; + + for (c = 0; c < 16; c++) + { + buffer[x++] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2); + p0 <<= 1; + p1 <<= 1; + } + } + break; + + case 1: + for (x = 0, l = compress_buffer; x < info->width; l += 2) + { + p0 = ( l[0] << 8) | l[1]; + + for ( c = 0; c < 16; c++) + { + buffer[x++] = ((p0 >> 15) & 1); + p0 <<= 1; + } + } + break; + } + + return TRUE; + } + + switch( info->planes) + { + case 4: + for( x = 0, l = s; x < info->width; l += 8) + { + p0 = ( l[0] << 8) | l[1]; + p1 = ( l[2] << 8) | l[3]; + p2 = ( l[4] << 8) | l[5]; + p3 = ( l[6] << 8) | l[7]; + + for ( c = 0; c < 16; c++) + { + buffer[x++] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2) | ((p2 >> 13) & 4) | ((p3 >> 12) & 8); + p0 <<= 1; + p1 <<= 1; + p2 <<= 1; + p3 <<= 1; + } + } + info->_priv_var_more += 160; + break; + + case 2: + for ( x = 0, l = s; x < info->width; l += 4) + { + p0 = (l[0] << 8) | l[1]; + p1 = (l[2] << 8) | l[3]; + + for (c = 0; c < 16; c++) + { + buffer[x++] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2); + p0 <<= 1; + p1 <<= 1; + } + } + info->_priv_var_more += 160; + break; + + case 1: + for (x = 0, l = s; x < info->width; l += 2) + { + p0 = ( l[0] << 8) | l[1]; + + for ( c = 0; c < 16; c++) + { + buffer[x++] = ((p0 >> 15) & 1); + p0 <<= 1; + } + } + info->_priv_var_more += 80; + break; + } + + return TRUE; +} + + +/*==================================================================================* + * boolean CDECL reader_get_txt * + * This function , like other CDECL function must be always present. * + * It fills txtdata struct. with the text present in the picture ( if any). * + *----------------------------------------------------------------------------------* + * input: * + * txtdata -> The destination text buffer. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata) +{ + return; +} + + +/*==================================================================================* + * boolean CDECL reader_quit: * + * This function makes the last job like close the file handler and free the * + * allocated memory. * + *----------------------------------------------------------------------------------* + * input: * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_quit( IMGINFO info) +{ + DEGASHDR *degas = ( DEGASHDR*)info->_priv_ptr; + uint8 *compress_buffer = ( uint8*)info->_priv_ptr_more; + + free( degas); + + if( compress_buffer) + free( compress_buffer); +} + + +/*==================================================================================* + * boolean CDECL init: * + * First function called from zview, in this one, you can make some internal * + * initialisation. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL init( void) +{ +} + + +/*==================================================================================* + * int main: * + * Main function, his job is to call ldg_init function. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * 0 * + *==================================================================================*/ +int main( void) +{ + ldg_init( °as_plugin); + return( 0); +} diff --git a/sources/z-tools/trunk/zview/plugins/eureka/Makefile b/sources/z-tools/trunk/zview/plugins/eureka/Makefile new file mode 100644 index 0000000..d85da0b --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/eureka/Makefile @@ -0,0 +1,13 @@ +STACKSIZE = 64k +OPTIMISATION = -O2 -fomit-frame-pointer -finline-functions +CPU = -m68020-60 +LIB = -lldgserver + +CFLAGS = $(CPU) $(OPTIMISATION) -Wall -I../common +LDFLAGS = -nostdlib + +OBJ = $(LDG_STARTUP_OBJ) rawldg.o + +PROGRAM = eureka.ldg + +include ../../../common.mak diff --git a/sources/z-tools/trunk/zview/plugins/eureka/colormap.h b/sources/z-tools/trunk/zview/plugins/eureka/colormap.h new file mode 100644 index 0000000..256945b --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/eureka/colormap.h @@ -0,0 +1,770 @@ +int16 red[]={ 996,0 +,992 +,0 +,0 +,0 +,992 +,992 +,792 +,490 +,490 +,0 +,0 +,0 +,490 +,490 +,996 +,988 +,980 +,973 +,965 +,957 +,949 +,941 +,933 +,925 +,918 +,910 +,902 +,890 +,882 +,875 +,867 +,859 +,851 +,843 +,835 +,827 +,820 +,812 +,804 +,796 +,788 +,780 +,773 +,765 +,757 +,749 +,741 +,733 +,725 +,718 +,710 +,702 +,690 +,682 +,675 +,667 +,659 +,651 +,643 +,635 +,627 +,620 +,612 +,604 +,596 +,588 +,580 +,573 +,565 +,557 +,549 +,541 +,533 +,525 +,518 +,510 +,502 +,490 +,482 +,475 +,467 +,459 +,451 +,443 +,435 +,427 +,420 +,412 +,404 +,396 +,388 +,380 +,373 +,365 +,357 +,365 +,373 +,380 +,388 +,396 +,404 +,412 +,420 +,427 +,435 +,443 +,451 +,459 +,467 +,475 +,482 +,490 +,502 +,510 +,518 +,525 +,533 +,541 +,549 +,557 +,565 +,573 +,580 +,588 +,596 +,604 +,612 +,620 +,627 +,635 +,643 +,651 +,659 +,667 +,675 +,682 +,690 +,702 +,710 +,718 +,725 +,733 +,741 +,749 +,757 +,765 +,773 +,780 +,788 +,796 +,804 +,812 +,820 +,827 +,835 +,843 +,851 +,859 +,867 +,875 +,882 +,890 +,902 +,910 +,918 +,925 +,933 +,941 +,949 +,957 +,965 +,973 +,980 +,988 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +}; + +int16 green[]={996,0 +,0 +,992 +,0 +,992 +,992 +,0 +,792 +,490 +,0 +,490 +,0 +,490 +,490 +,0 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,996 +,988 +,980 +,973 +,965 +,957 +,949 +,941 +,933 +,925 +,918 +,910 +,902 +,890 +,882 +,875 +,867 +,859 +,851 +,843 +,835 +,827 +,820 +,812 +,804 +,796 +,788 +,780 +,773 +,765 +,757 +,749 +,741 +,733 +,725 +,718 +,710 +,702 +,690 +,682 +,675 +,667 +,659 +,651 +,643 +,635 +,627 +,620 +,612 +,604 +,596 +,588 +,580 +,573 +,565 +,557 +,549 +,541 +,533 +,525 +,518 +,510 +,502 +,490 +,482 +,475 +,467 +,459 +,451 +,443 +,435 +,427 +,420 +,412 +,404 +,396 +,388 +,380 +,373 +,365 +,357 +,365 +,373 +,380 +,388 +,396 +,404 +,412 +,420 +,427 +,435 +,443 +,451 +,459 +,467 +,475 +,482 +,490 +,502 +,510 +,518 +,525 +,533 +,541 +,549 +,557 +,565 +,573 +,580 +,588 +,596 +,604 +,612 +,620 +,627 +,635 +,643 +,651 +,659 +,667 +,675 +,682 +,690 +,702 +,710 +,718 +,725 +,733 +,741 +,749 +,757 +,765 +,773 +,780 +,788 +,796 +,804 +,812 +,820 +,827 +,835 +,843 +,851 +,859 +,867 +,875 +,882 +,890 +,902 +,910 +,918 +,925 +,933 +,941 +,949 +,957 +,965 +,973 +,980 +,988 +}; + +int16 blue[]={996,0 +,0 +,0 +,992 +,992 +,0 +,992 +,792 +,490 +,0 +,0 +,490 +,490 +,0 +,490 +,306 +,314 +,322 +,329 +,337 +,345 +,353 +,361 +,369 +,376 +,384 +,392 +,404 +,412 +,420 +,427 +,435 +,443 +,451 +,459 +,467 +,475 +,482 +,490 +,498 +,506 +,514 +,522 +,529 +,537 +,545 +,553 +,561 +,569 +,576 +,584 +,592 +,604 +,612 +,620 +,627 +,635 +,643 +,651 +,659 +,667 +,675 +,682 +,690 +,698 +,706 +,714 +,722 +,729 +,737 +,745 +,753 +,761 +,769 +,776 +,784 +,792 +,804 +,812 +,820 +,827 +,835 +,843 +,851 +,859 +,867 +,875 +,882 +,890 +,898 +,906 +,914 +,922 +,929 +,937 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,945 +,937 +,929 +,922 +,914 +,906 +,898 +,890 +,882 +,875 +,867 +,859 +,851 +,843 +,835 +,827 +,820 +,812 +,804 +,792 +,784 +,776 +,769 +,761 +,753 +,745 +,737 +,729 +,722 +,714 +,706 +,698 +,690 +,682 +,675 +,667 +,659 +,651 +,643 +,635 +,627 +,620 +,612 +,604 +,592 +,584 +,576 +,569 +,561 +,553 +,545 +,537 +,529 +,522 +,514 +,506 +,498 +,490 +,482 +,475 +,467 +,459 +,451 +,443 +,435 +,427 +,420 +,412 +,404 +,392 +,384 +,376 +,369 +,361 +,353 +,345 +,337 +,329 +,322 +,314 +}; diff --git a/sources/z-tools/trunk/zview/plugins/eureka/copyright b/sources/z-tools/trunk/zview/plugins/eureka/copyright new file mode 100644 index 0000000..a1ef488 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/eureka/copyright @@ -0,0 +1,503 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/sources/z-tools/trunk/zview/plugins/eureka/rawldg.c b/sources/z-tools/trunk/zview/plugins/eureka/rawldg.c new file mode 100644 index 0000000..7d57ddf --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/eureka/rawldg.c @@ -0,0 +1,255 @@ +#include "zview.h" +#include "colormap.h" + +boolean CDECL reader_init( const char *name, IMGINFO info); +boolean CDECL reader_read( IMGINFO info, uint8 *buffer); +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata); +void CDECL reader_quit( IMGINFO info); +void CDECL init( void); + + +PROC RAWFunc[] = +{ + { "plugin_init", "", init}, + { "reader_init", "", reader_init}, + { "reader_get_txt", "", reader_get_txt}, + { "reader_read", "", reader_read}, + { "reader_quit", "", reader_quit} +}; + + +LDGLIB raw_plugin = +{ + 0x0200, /* Plugin version */ + 5, /* Number of plugin's functions */ + RAWFunc, /* List of functions */ + "RAW", /* File's type Handled */ + LDG_NOT_SHARED, /* The flags NOT_SHARED is used here.. even if zview plugins are reentrant + and are shareable, we must use this flags because we don't know if the + user has ldg.prg deamon installed on his computer */ + NULL, /* Function called when the plugin is unloaded */ + 1L /* Howmany file type are supported by this plugin */ +}; + + +void swap( uint8 *a, uint8 *b) +{ + uint8 temp; + + temp = *a; + + *a = *b; + + *b = temp; +} + +/*==================================================================================* + * boolean CDECL reader_init: * + * Open the file "name", fit the "info" struct. ( see zview.h) and make others * + * things needed by the decoder. * + *----------------------------------------------------------------------------------* + * input: * + * name -> The file to open. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL reader_init( const char *name, IMGINFO info) +{ + int16 handle; + int32 file_size, palette[768]; + uint8 header[4], *img_buffer; + + if ( ( handle = ( int16)Fopen( name, 0)) < 0) + return FALSE; + + file_size = Fseek( 0L, handle, 2) - 4L; + + Fseek( 0L, handle, 0); + + if ( Fread( handle, 4, header) != 4) + { + Fclose( handle); + return FALSE; + } + + info->planes = 8; + info->width = *((uint16*)&header[0]); + info->height = *((uint16*)&header[2]); + info->colors = 256; + info->components = 3; + info->real_width = info->width; + info->real_height = info->height; + info->memory_alloc = TT_RAM; + info->page = 1; + info->delay = 0; + info->orientation = UP_TO_DOWN; + info->num_comments = 0; + info->max_comments_length = 0; + info->_priv_var = ( uint32)handle; + + if( ( info->width * info->height) == file_size) + { + info->indexed_color = FALSE; + } + else + { + /* 3072 is the palette's size */ + file_size -= 3072; + + if( ( info->width * info->height) != file_size) + { + Fclose( handle); + return FALSE; + } + + info->indexed_color = TRUE; + } + + strcpy( info->info, "Eureka RAW Picture"); + strcpy( info->compression, "None"); + + if( info->indexed_color == TRUE) + { + register int16 i; + + Fread( handle, 3072, palette); + + for ( i = 0; i < info->colors; i++) + { + info->palette[i].red = ( uint8)(( palette[i] >> 24) & 0xffL); + info->palette[i].green = ( uint8)(( palette[i] >> 16) & 0xffL); + info->palette[i].blue = ( uint8)(( palette[i] >> 8 ) & 0xffL); + } + } + else + { + register int16 i; + + info->indexed_color = TRUE; + + for ( i = 0; i < info->colors; i++) + { + info->palette[i].red = ( uint8)((( uint32)red[i] * 255L) / 1000L); + info->palette[i].green = ( uint8)((( uint32)red[i] * 255L) / 1000L); + info->palette[i].blue = ( uint8)((( uint32)red[i] * 255L) / 1000L); + } + } + + img_buffer = ( uint8*)malloc( file_size); + info->_priv_ptr = ( void*)img_buffer; + info->_priv_ptr_more = ( void*)img_buffer; + + if( img_buffer == NULL) + { + Fclose( handle); + return FALSE; + } + + if( Fread( handle, file_size, img_buffer) != file_size) + { + free( img_buffer); + Fclose( handle); + return FALSE; + } + else + { + register uint16 i, j, w = info->width >> 1; + + for( i = 0; i < info->height; i++) + for( j = 0; j < w; j++) + swap( &img_buffer[(uint32)info->width * (uint32)i + (uint32)j], &img_buffer[(uint32)info->width * (uint32)i + (uint32)info->width - 1L - (uint32)j]); + } + + return TRUE; +} + + +/*==================================================================================* + * boolean CDECL reader_read: * + * This function fits the buffer with image data * + *----------------------------------------------------------------------------------* + * input: * + * buffer -> The destination buffer. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL reader_read( IMGINFO info, uint8 *buffer) +{ + memcpy( buffer, ( uint8*)info->_priv_ptr_more, info->width); + info->_priv_ptr_more = ( uint8*)info->_priv_ptr_more + info->width; + + return TRUE; +} + + +/*==================================================================================* + * boolean CDECL reader_get_txt * + * This function , like other CDECL function must be always present. * + * It fills txtdata struct. with the text present in the picture ( if any). * + *----------------------------------------------------------------------------------* + * input: * + * txtdata -> The destination text buffer. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata) +{ + return; +} + + +/*==================================================================================* + * boolean CDECL reader_quit: * + * This function makes the last job like close the file handler and free the * + * allocated memory. * + *----------------------------------------------------------------------------------* + * input: * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_quit( IMGINFO info) +{ + free( ( uint8*)info->_priv_ptr); + Fclose( ( int16)info->_priv_var); +} + + +/*==================================================================================* + * boolean CDECL init: * + * First function called from zview, in this one, you can make some internal * + * initialisation. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL init( void) +{ +} + + +/*==================================================================================* + * int main: * + * Main function, his job is to call ldg_init function. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * 0 * + *==================================================================================*/ +int main( void) +{ + ldg_init( &raw_plugin); + return( 0); +} diff --git a/sources/z-tools/trunk/zview/plugins/gif/Makefile b/sources/z-tools/trunk/zview/plugins/gif/Makefile new file mode 100644 index 0000000..49c3de6 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/gif/Makefile @@ -0,0 +1,13 @@ +STACKSIZE = 64k +OPTIMISATION = -O2 -fomit-frame-pointer +CPU = -m68020-60 +LIB = -lgif -lldgserver + +CFLAGS = $(CPU) $(OPTIMISATION) -Wall -I../common +LDFLAGS = -nostdlib + +OBJ = $(LDG_STARTUP_OBJ) gifldg.o + +PROGRAM = gif.ldg + +include ../../../common.mak diff --git a/sources/z-tools/trunk/zview/plugins/gif/copyright b/sources/z-tools/trunk/zview/plugins/gif/copyright new file mode 100644 index 0000000..a1ef488 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/gif/copyright @@ -0,0 +1,503 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/sources/z-tools/trunk/zview/plugins/gif/gifldg.c b/sources/z-tools/trunk/zview/plugins/gif/gifldg.c new file mode 100644 index 0000000..0f1c6a8 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/gif/gifldg.c @@ -0,0 +1,498 @@ +#include +#include "zview.h" + +/* Prototypes */ +boolean CDECL reader_init( const char *name, IMGINFO info); +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata); +boolean CDECL reader_read( IMGINFO info, uint8 *buffer); +uint8* CDECL reader_get_page_addr( IMGINFO info); +void CDECL reader_quit( IMGINFO info); +void CDECL init( void); + + +PROC GIFFunc[] = +{ + { "plugin_init", "", init}, + { "reader_init", "", reader_init}, + { "reader_get_txt", "", reader_get_txt}, + { "reader_read", "", reader_read}, + { "reader_quit", "", reader_quit} +}; + + +LDGLIB gif_plugin = +{ + 0x0200, /* Plugin version */ + 5, /* Number of plugin's functions */ + GIFFunc, /* List of functions */ + "GIF", /* File's type Handled */ + LDG_NOT_SHARED, /* The flags NOT_SHARED is used here.. even if zview plugins are reentrant + and are shareable, we must use this flags because we don't know if the + user has ldg.prg deamon installed on his computer */ + NULL, /* Function called when the plugin is unloaded */ + 1L /* Howmany file type are supported by this plugin */ +}; + + + +/*==================================================================================* + * void decodecolormap: * + * Convert 8 bits + palette data to standard RGB * + *----------------------------------------------------------------------------------* + * input: * + * src -> The 8 bits source. * + * dst -> The destination where put the RGB data. * + * cm -> The source's colormap. * + * width -> picture's width. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +static inline void decodecolormap( uint8 *src, uint8 *dst, GifColorType *cm, uint16 width, int16 trans_index, uint32 transparent_color, int16 draw_trans) +{ + GifColorType *cmentry; + register uint16 i; + + for( i = 0; i < width; i++) + { + if( src[i] == trans_index) + { + if( draw_trans == FALSE) + { + dst += 3; + continue; + } + + *(dst++) = ( ( transparent_color >> 16) & 0xFF); + *(dst++) = ( ( transparent_color >> 8) & 0xFF); + *(dst++) = ( ( transparent_color) & 0xFF); + } + else + { + cmentry = &cm[src[i]]; + *(dst++) = cmentry->Red; + *(dst++) = cmentry->Green; + *(dst++) = cmentry->Blue; + } + } +} + + +/*==================================================================================* + * boolean CDECL reader_init: * + * Open the file "name", fit the "info" struct. ( see zview.h) and make others * + * things needed by the decoder. * + *----------------------------------------------------------------------------------* + * input: * + * name -> The file to open. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL reader_init( const char *name, IMGINFO info) +{ + static int16 InterlacedOffset[] = { 0, 4, 2, 1 }, InterlacedJumps[] = { 8, 8, 4, 2 }; + int16 i, j, error = 0, transpar = -1, interlace = FALSE, draw_trans = TRUE; + uint16 delaycount = 0; + GifFileType *gif = NULL; + GifRecordType rec; + txt_data comment = { 0,}; + img_data img = { 0,}; + + if ( ( gif = DGifOpenFileName ( name)) == NULL) + return FALSE; + + img.imagecount = 0; + + do + { + if( DGifGetRecordType (gif, &rec) == GIF_ERROR) + { + error = 1; + break; + } + + if ( rec == IMAGE_DESC_RECORD_TYPE) + { + if ( DGifGetImageDesc( gif) == GIF_ERROR) + { + error = 1; + break; + } + else + { + GifImageDesc *dsc = &gif->Image; + ColorMapObject *map = ( dsc->ColorMap ? dsc->ColorMap : gif->SColorMap); + int Row, Col, Width, Height; + int32 line_size; + uint8 *line_buffer = NULL, *img_buffer; + + if( map == NULL) + { + error = 1; + break; + } + + Row = dsc->Top; /* Image Position relative to Screen. */ + Col = dsc->Left; + Width = dsc->Width; + Height = dsc->Height; + + /* if ( Col + Width > gif->SWidth || Row + Height > gif->SWidth) + { + error = 1; + break; + } + */ + info->components = ( map->BitsPerPixel == 1 ? 1 : 3); + info->planes = map->BitsPerPixel; + info->colors = map->ColorCount; + info->width = ( uint16)gif->SWidth; + info->height = ( uint16)gif->SHeight; + line_size = ( int32)gif->SWidth * ( int32)info->components; + + if( dsc->Interlace) + interlace = TRUE; + + img.image_buf[img.imagecount] = ( uint8*)malloc( line_size * ( gif->SHeight + 2)); + img_buffer = img.image_buf[img.imagecount]; + + if( img_buffer == NULL) + { + error = 1; + break; + } + + if( map->BitsPerPixel != 1) + { + line_buffer = ( uint8*)malloc( line_size + 128); + + if( line_buffer == NULL) + { + free( ( void*)img.image_buf[img.imagecount]); + error = 1; + break; + } + } + + if( img.imagecount > 0) + { + /* the transparency is the background picture */ + draw_trans = FALSE; + + if(( Row > 0 && Height < gif->SHeight) || ( Col > 0 && Width < gif->SWidth)) + memcpy( img_buffer, img.image_buf[img.imagecount - 1], line_size * gif->SHeight); + else draw_trans = TRUE; + } + + if( interlace == TRUE) + { + for( i = 0; i < 4; i++) + { + for ( j = Row + InterlacedOffset[i]; j < Row + Height; j += InterlacedJumps[i]) + { + if( map->BitsPerPixel != 1) + { + if( DGifGetLine ( gif, line_buffer, Width) != GIF_OK) + { + error = 1; + free( ( void*)img.image_buf[img.imagecount]); + break; + } + + decodecolormap( line_buffer, &img_buffer[(j * line_size) + (Col * 3)], map->Colors, Width, transpar, info->background_color, draw_trans); + } + else if( DGifGetLine ( gif, &img_buffer[(j * line_size) + Col], Width) != GIF_OK) + { + free( ( void*)img.image_buf[img.imagecount]); + error = 1; + break; + } + } + } + } + else + { + for( i = 0; i < Height; i++, Row++) + { + if( map->BitsPerPixel != 1) + { + if( DGifGetLine( gif, line_buffer, Width) != GIF_OK) + { + error = 1; + free( ( void*)img.image_buf[img.imagecount]); + break; + } + + decodecolormap( line_buffer, &img_buffer[(Row * line_size) + (Col * 3)], map->Colors, Width, transpar, info->background_color, draw_trans); + } + else if( DGifGetLine( gif, &img_buffer[(Row * line_size) + Col], Width) != GIF_OK) + { + free( ( void*)img.image_buf[img.imagecount]); + error = 1; + break; + } + } + } + + if( line_buffer) + { + free( ( void*)line_buffer); + line_buffer = NULL; + } + + img.imagecount++; + } + + if( info->thumbnail == TRUE) + break; + + } + else if ( rec == EXTENSION_RECORD_TYPE) + { + int code; + GifByteType * block; + + if ( DGifGetExtension (gif, &code, &block) == GIF_ERROR) + { + error = 1; + break; + } + else while ( block != NULL) + { + switch( code) + { + case COMMENT_EXT_FUNC_CODE: + if( comment.lines > 254) + break; + + block[block[0]+1] = '\000'; /* Convert gif's pascal-like string */ + comment.txt[comment.lines] = ( int8*)malloc( block[0] + 1); + + if( comment.txt[comment.lines] == NULL) + break; + + strcpy( comment.txt[comment.lines], (char*)block + 1); + comment.max_lines_length = MAX( comment.max_lines_length, ( int16)strlen( comment.txt[comment.lines]) + 1); + comment.lines++; + break; + + case GRAPHICS_EXT_FUNC_CODE: + if( block[1] & 1) + transpar = ( uint16)block[4]; + else + transpar = -1; + + img.delay[delaycount++] = ( block[2] + (block[3] << 8)) << 1; + + break; + /* + In version 2.0 beta Netscape, introduce a special extention for + set a maximum loop playback.. Netscape itself doesn't use it anymore + and play the animation infinitly... so we don't care about it. + + case APPLICATION_EXT_FUNC_CODE: + if( reading_netscape_ext == 0) + { + if( memcmp( block + 1, "NETSCAPE", 8) != 0) + break; + + if( block[0] != 11) + break; + + if( memcmp( block + 9, "2.0", 3) != 0) + break; + + reading_netscape_ext = 1; + } + else + { + if (( block[1] & 7) == 1) + info->max_loop_count = block[2] | ( block[3] << 8); + } + */ + default: + break; + } + + if ( DGifGetExtensionNext (gif, &block) == GIF_ERROR) + { + error = 1; + break; + } + } + } + else break; + } while ( rec != TERMINATE_RECORD_TYPE); + + + if( error) + { + for ( i = 0; i < comment.lines; i++) + { + if( comment.txt[i]) + free( ( void*)comment.txt[i]); + } + + for ( i = 0; i < img.imagecount; i++) + { + if( img.image_buf[i]) + free( ( void*)img.image_buf[i]); + } + + DGifCloseFile ( gif); + return FALSE; + } + + info->real_height = info->height; + info->real_width = info->width; + info->orientation = UP_TO_DOWN; + info->page = img.imagecount; + info->num_comments = comment.lines; + info->max_comments_length = comment.max_lines_length; + info->indexed_color = FALSE; + info->memory_alloc = TT_RAM; + info->_priv_var = 0L; /* page line counter */ + info->_priv_var_more = 0L; /* current page returned */ + info->_priv_ptr = ( void*)&comment; + info->_priv_ptr_more = ( void*)&img; + + strcpy( info->info, "GIF"); + + /*if( gif->Version) + strcat( info->info, "89a"); + else + strcat( info->info, "87a"); + */ + + if( interlace) + strcat( info->info, " (Interlaced)"); + + strcpy( info->compression, "LZW"); + + DGifCloseFile( gif); + + return TRUE; +} + + +/*==================================================================================* + * boolean CDECL reader_get_txt * + * This function , like other CDECL function mus be always present. * + * It fills txtdata struct. with the text present in the picture ( if any). * + *----------------------------------------------------------------------------------* + * input: * + * txtdata -> The destination text buffer. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata) +{ + register int16 i; + txt_data *comment = ( txt_data *)info->_priv_ptr; + + for ( i = 0; i < txtdata->lines; i++) + strcpy( txtdata->txt[i] , comment->txt[i]); +} + + +/*==================================================================================* + * boolean CDECL reader_read: * + * This function fits the buffer with image data * + *----------------------------------------------------------------------------------* + * input: * + * buffer -> The destination buffer. * + * info -> The IMGINFO struct. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL reader_read( IMGINFO info, uint8 *buffer) +{ + img_data *img = ( img_data*)info->_priv_ptr_more; + int32 line_size = ( int32)info->width * ( int32)info->components; + uint8 *line_src; + + if( ( int32)info->page_wanted != info->_priv_var_more) + { + info->_priv_var_more = ( int32)info->page_wanted; + info->_priv_var = 0L; + } + + line_src = &img->image_buf[info->page_wanted][info->_priv_var]; + + info->_priv_var += line_size; + info->delay = img->delay[info->page_wanted]; + + memcpy( buffer, line_src, line_size); + + return TRUE; +} + + + +/*==================================================================================* + * boolean CDECL reader_quit: * + * This function makes the last job like close the file handler and free the * + * allocated memory. * + *----------------------------------------------------------------------------------* + * input: * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_quit( IMGINFO info) +{ + txt_data *comment = ( txt_data *)info->_priv_ptr; + img_data *img = ( img_data *)info->_priv_ptr_more; + register int16 i; + + for ( i = 0; i < comment->lines; i++) + { + if( comment->txt[i]) + free( ( void*)comment->txt[i]); + } + + for ( i = 0; i < img->imagecount; i++) + { + if( img->image_buf[i]) + free( ( void*)img->image_buf[i]); + } +} + + +/*==================================================================================* + * boolean CDECL init: * + * First function called from zview, in this one, you can make some internal * + * initialisation. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL init( void) +{ +} + + +/*==================================================================================* + * int main: * + * Main function, his job is to call ldg_init function. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * 0 * + *==================================================================================*/ +int main( void) +{ + ldg_init( &gif_plugin); + return( 0); +} diff --git a/sources/z-tools/trunk/zview/plugins/godpaint/Makefile b/sources/z-tools/trunk/zview/plugins/godpaint/Makefile new file mode 100644 index 0000000..94f51b4 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/godpaint/Makefile @@ -0,0 +1,13 @@ +STACKSIZE = 64k +OPTIMISATION = -O2 -fomit-frame-pointer -finline-functions +CPU = -m68020-60 +LIB = -lldgserver + +CFLAGS = $(CPU) $(OPTIMISATION) -Wall -I../common +LDFLAGS = -nostdlib + +OBJ = $(LDG_STARTUP_OBJ) godldg.o + +PROGRAM = godpaint.ldg + +include ../../../common.mak diff --git a/sources/z-tools/trunk/zview/plugins/godpaint/copyright b/sources/z-tools/trunk/zview/plugins/godpaint/copyright new file mode 100644 index 0000000..a1ef488 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/godpaint/copyright @@ -0,0 +1,503 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/sources/z-tools/trunk/zview/plugins/godpaint/godldg.c b/sources/z-tools/trunk/zview/plugins/godpaint/godldg.c new file mode 100644 index 0000000..3283896 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/godpaint/godldg.c @@ -0,0 +1,331 @@ +#include "zview.h" + +boolean CDECL reader_init( const char *name, IMGINFO info); +boolean CDECL reader_read( IMGINFO info, uint8 *buffer); +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata); +void CDECL reader_quit( IMGINFO info); +boolean CDECL encoder_init( const char *name, IMGINFO info); +boolean CDECL encoder_write( IMGINFO info, uint8 *buffer); +void CDECL encoder_quit( IMGINFO info); +void CDECL init( void); + + +PROC DEGASFunc[] = +{ + { "plugin_init", "", init}, + { "reader_init", "", reader_init}, + { "reader_get_txt", "", reader_get_txt}, + { "reader_read", "", reader_read}, + { "reader_quit", "", reader_quit}, + { "encoder_init", "", encoder_init}, + { "encoder_write", "", encoder_write}, + { "encoder_quit", "", encoder_quit} +}; + + +LDGLIB godpaint_plugin = +{ + 0x0200, /* Plugin version */ + 8, /* Number of plugin's functions */ + DEGASFunc, /* List of functions */ + "GOD", /* File's type Handled */ + LDG_NOT_SHARED, /* The flags NOT_SHARED is used here.. even if zview plugins are reentrant + and are shareable, we must use this flags because we don't know if the + user has ldg.prg deamon installed on his computer */ + NULL, /* Function called when the plugin is unloaded */ + 1L /* Howmany file type are supported by this plugin */ +}; + +typedef struct +{ + int16 header; + int16 width; + int16 height; +} GODHDR; + + + +/*==================================================================================* + * boolean CDECL reader_init: * + * Open the file "name", fit the "info" struct. ( see zview.h) and make others * + * things needed by the decoder. * + *----------------------------------------------------------------------------------* + * input: * + * name -> The file to open. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL reader_init( const char *name, IMGINFO info) +{ + int16 handle; + int32 file_size; + GODHDR *god; + + if ( ( handle = ( int16)Fopen( name, 0)) < 0) + return FALSE; + + file_size = Fseek( 0L, handle, 2); + + Fseek( 0L, handle, 0); + + god = ( GODHDR *)malloc( file_size); + + if ( god == NULL) + { + Fclose( handle); + return FALSE; + } + + if ( Fread( handle, file_size, god) != file_size) + { + free( god); + Fclose( handle); + return FALSE; + } + + Fclose( handle); + + if( ( god->header != 1024) /* some beta version of godpaint? I don't know but some files have this header */ + && ( god->header != 18228 /* G4 */)) + { + free( god); + return FALSE; + } + + info->planes = 16; + info->real_width = info->width = god->width; + info->real_height = info->height= god->height; + info->components = 3; + info->indexed_color = FALSE; + info->colors = 1L << info->planes; + info->memory_alloc = TT_RAM; + info->page = 1; + info->delay = 0; + info->orientation = UP_TO_DOWN; + info->num_comments = 0; + info->max_comments_length = 0; + info->_priv_ptr = ( void*)god; + info->_priv_var_more = 3; + info->_priv_ptr_more = NULL; + + strcpy( info->info, "Reservoir Gods - Godpaint"); + strcpy( info->compression, "None"); + + return TRUE; +} + + +/*==================================================================================* + * boolean CDECL reader_read: * + * This function fits the buffer with image data * + *----------------------------------------------------------------------------------* + * input: * + * buffer -> The destination buffer. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL reader_read( IMGINFO info, uint8 *buffer) +{ + GODHDR *god = ( GODHDR*)info->_priv_ptr; + uint16 *source = ( uint16*)god + info->_priv_var_more; + int16 i, ii; + + for( i = 0, ii = 0; i < info->width; i++) + { + register uint16 src16 = source[i]; + + buffer[ii++] = (( src16 >> 11) & 0x001F) << 3; + buffer[ii++] = (( src16 >> 5) & 0x003F) << 2; + buffer[ii++] = (( src16) & 0x001F) << 3; + } + + info->_priv_var_more += info->width; + return TRUE; +} + + +/*==================================================================================* + * boolean CDECL reader_get_txt * + * This function , like other CDECL function must be always present. * + * It fills txtdata struct. with the text present in the picture ( if any). * + *----------------------------------------------------------------------------------* + * input: * + * txtdata -> The destination text buffer. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata) +{ + return; +} + + +/*==================================================================================* + * boolean CDECL reader_quit: * + * This function makes the last job like close the file handler and free the * + * allocated memory. * + *----------------------------------------------------------------------------------* + * input: * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_quit( IMGINFO info) +{ + GODHDR *god = ( GODHDR*)info->_priv_ptr; + + free( god); +} + + +/*==================================================================================* + * boolean CDECL encoder_init: * + * Open the file "name", fit the "info" struct. ( see zview.h) and make others * + * things needed by the encoder. * + *----------------------------------------------------------------------------------* + * input: * + * name -> The file to open. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL encoder_init( const char *name, IMGINFO info) +{ + uint16 *line_buffer = NULL; + int8 header_id[2] = "G4"; + int32 file; + + if ( ( file = Fcreate( name, 0)) < 0) + return FALSE; + + line_buffer = ( uint16*) malloc( ( info->width + 1) << 1); + + if ( line_buffer == NULL) + { + Fclose( file); + return FALSE; + } + + /* we test only the first Fwrite.. if it's ok, the others *should* works also */ + if( Fwrite( file, 2, header_id) != 2) + { + free( line_buffer); + Fclose( file); + return FALSE; + } + + Fwrite( file, 2, ( void*)&info->width); + Fwrite( file, 2, ( void*)&info->height); + + + info->planes = 24; /* the wanted input data format.. currently Zview return only 24 bits data, so we make the convertion to 16 bits ourself */ + info->components = 3; + info->colors = 16777215L; + info->orientation = UP_TO_DOWN; + info->indexed_color = FALSE; + info->page = 1; + info->delay = 0; + info->_priv_ptr = line_buffer; + info->_priv_var = file; + info->_priv_ptr_more = NULL; + info->__priv_ptr_more = NULL; + + return TRUE; +} + + +/*==================================================================================* + * boolean CDECLencoder_write: * + * This function write data from buffer to file * + *----------------------------------------------------------------------------------* + * input: * + * buffer -> The source buffer. * + * info -> The IMGINFO struct . * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL encoder_write( IMGINFO info, uint8 *buffer) +{ + uint16 *source = ( uint16*)info->_priv_ptr; + int32 byte_to_write = info->width << 1; + uint16 ii, i; + + for( ii = i = 0; i < info->width; i++, ii += 3) + { + register uint8 *rgb = &buffer[ii]; + + source[i] = (((uint16)rgb[0] & 0xF8) << 8) | (((uint16)rgb[1] & 0xFC) << 3) | ( rgb[2] >> 3); + } + + if( Fwrite( info->_priv_var, byte_to_write, ( uint8*)source) != byte_to_write) + return FALSE; + + return TRUE; +} + + + +/*==================================================================================* + * boolean CDECL encoder_quit: * + * This function makes the last job like close the file handler and free the * + * allocated memory. * + *----------------------------------------------------------------------------------* + * input: * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL encoder_quit( IMGINFO info) +{ + uint8 *buffer = ( uint8*)info->_priv_ptr; + + free( buffer); + Fclose( info->_priv_var); +} + + + + +/*==================================================================================* + * boolean CDECL init: * + * First function called from zview, in this one, you can make some internal * + * initialisation. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL init( void) +{ + /* Make the compiler happy*/ + return; +} + + +/*==================================================================================* + * int main: * + * Main function, his job is to call ldg_init function. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * 0 * + *==================================================================================*/ +int main( void) +{ + ldg_init( &godpaint_plugin); + return( 0); +} diff --git a/sources/z-tools/trunk/zview/plugins/img/Makefile b/sources/z-tools/trunk/zview/plugins/img/Makefile new file mode 100644 index 0000000..6033e1b --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/img/Makefile @@ -0,0 +1,13 @@ +STACKSIZE = 64k +OPTIMISATION = -O2 -fomit-frame-pointer -finline-functions +CPU = -m68020-60 +LIB = -lldgserver + +CFLAGS = $(CPU) $(OPTIMISATION) -Wall -I../common +LDFLAGS = -nostdlib + +OBJ = $(LDG_STARTUP_OBJ) imgldg.o xp32.o + +PROGRAM = img.ldg + +include ../../../common.mak diff --git a/sources/z-tools/trunk/zview/plugins/img/copyright b/sources/z-tools/trunk/zview/plugins/img/copyright new file mode 100644 index 0000000..a1ef488 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/img/copyright @@ -0,0 +1,503 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/sources/z-tools/trunk/zview/plugins/img/img.h b/sources/z-tools/trunk/zview/plugins/img/img.h new file mode 100644 index 0000000..f454650 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/img/img.h @@ -0,0 +1,59 @@ +/*------------------------------------------*/ +/* IMG Structur */ +/*------------------------------------------*/ + +#ifndef __IMG_IMAGE__ +#define __IMG_IMAGE__ + +#define XIMG 0x58494D47 + +typedef struct +{ + int16 version; + int16 length; + int16 planes; + int16 pattern_length; + int16 pix_width; + int16 pix_height; + int16 w; + int16 h; +} IMGHDR; + +#endif + + +typedef struct +{ + uint8 *img_buf; + int32 img_buf_len; + int32 img_buf_offset; + int32 img_buf_used; + uint8 *line_buffer; + int16 pat_len; + int16 line_len; + int32 rest_length; + int32 file_length; + int16 img_buf_valid; +} XIMG_DATA; + +#ifndef __PIC_STRUCT__ +#define __PIC_STRUCT__ + +typedef struct +{ + uint8 red, green, blue; +}RGB; + +typedef struct _picture +{ + int16 file_handle; + int16 width; + int16 height; + int16 planes; + IMGHDR img; + XIMG_DATA info; +} IMG_REF; + +#endif + + diff --git a/sources/z-tools/trunk/zview/plugins/img/imgldg.c b/sources/z-tools/trunk/zview/plugins/img/imgldg.c new file mode 100644 index 0000000..5ea4b16 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/img/imgldg.c @@ -0,0 +1,365 @@ +#include "zview.h" +#include "img.h" + +extern int32 plane2packed24( int32 no_words, int32 plane_length, int16 no_planes, void *src, void *dst, COLOR_MAP *palette); + +boolean CDECL reader_init( const char *name, IMGINFO info); +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata); +boolean CDECL reader_read( IMGINFO info, uint8 *buffer); +void CDECL reader_quit( IMGINFO info); +void CDECL init( void); + + +PROC IMGFunc[] = +{ + { "plugin_init", "", init}, + { "reader_init", "", reader_init}, + { "reader_get_txt", "", reader_get_txt}, + { "reader_read", "", reader_read}, + { "reader_quit", "", reader_quit} +}; + + +LDGLIB img_plugin = +{ + 0x0200, /* Plugin version */ + 5, /* Number of plugin's functions */ + IMGFunc, /* List of functions */ + "IMG", /* File's type Handled */ + LDG_NOT_SHARED, /* The flags NOT_SHARED is used here.. even if zview plugins are reentrant + and are shareable, we must use this flags because we don't know if the + user has ldg.prg deamon installed on his computer */ + NULL, /* Function called when the plugin is unloaded */ + 1L /* Howmany file type are supported by this plugin */ +}; + + + +boolean CDECL reader_init( const char *name, IMGINFO info) +{ + IMG_REF *pic = NULL; + IMGHDR *head = NULL; + XIMG_DATA *imginfo = NULL; + int16 handle, line_width; + int8 identify[6]; + + if ( ( handle = ( int16) Fopen( name, 0)) < 0) + return FALSE; + + pic = ( IMG_REF*)malloc( sizeof( IMG_REF)); + head = &pic->img; + imginfo = &pic->info; + + if( pic == NULL) + { + Fclose( handle); + return FALSE; + } + + if ( Fread( handle, sizeof( IMGHDR), head) != sizeof( IMGHDR)) + { + free( pic); + return FALSE; + } + + if (( head->planes != 1) && ( head->planes != 4) && ( head->planes != 8) && ( head->planes != 24)) + { + free( pic); + Fclose( handle); + return FALSE; + } + + pic->file_handle = handle; + pic->width = head->w; + pic->height = head->h; + pic->planes = head->planes; + + line_width = ((( head->w + 15) & 0xfff0) >> 3 ) * head->planes; + + imginfo->pat_len = head->pattern_length; + imginfo->line_len = ( head->w + 7) >> 3; + imginfo->file_length = Fseek( 0L, handle, 2); + imginfo->img_buf_len = MAX( 8192, line_width << 1); + imginfo->img_buf = ( uint8*)malloc( imginfo->img_buf_len + 256L); + + if ( imginfo->img_buf == NULL) + { + free( pic); + Fclose( handle); + return FALSE; + } + + /* Normally, here, it's the size of the line that we allocate but we prevent buffer + Overflow with some picture saved with french application */ + imginfo->line_buffer = ( uint8*)malloc( imginfo->img_buf_len + 256L); + imginfo->img_buf_valid = 0; + + if ( imginfo->line_buffer == NULL) + { + free( imginfo->img_buf); + free( pic); + Fclose( handle); + return FALSE; + } + + info->real_width = info->width = pic->width; + info->real_height = info->height= pic->height; + info->components = ( pic->planes == 1 ? 1 : 3); + info->planes = pic->planes; + info->orientation = UP_TO_DOWN; + info->colors = 1L << ( uint32)pic->planes; + info->indexed_color = FALSE; /* ( (( pic->planes == 1) || ( pic->planes > 8)) ? 0 : 1); */ + info->memory_alloc = TT_RAM; + info->page = 1; + info->delay = 0; + info->num_comments = 0; + info->_priv_ptr = ( void*)pic; + + strcpy( info->info, "GEM Bitmap "); + strcpy( info->compression, "RLE"); + + /* It a extended IMG ?, if not, return */ + if(( head->length <= ( sizeof( IMGHDR) >> 1)) || ( info->planes > 8)) + return TRUE; + + strcat( info->info, "( eXtended)"); + + Fseek( sizeof( IMGHDR), handle, 0); + Fread( handle, 6, identify); + + if( strcmp ( identify, "XIMG") != 0) + { + free( imginfo->line_buffer); + free( imginfo->img_buf); + free( pic); + Fclose( handle); + return FALSE; + } + else + { + RGB1000 palette[256]; + register int32 pal_len; + register int16 i; + + pal_len = MIN ((( head->length << 1) - 6 - sizeof( IMGHDR)), ( sizeof( RGB1000) << 8)); + + Fread( handle, pal_len, palette); + + for ( i = 0; i < info->colors; i++) + { + register int32 intensity = ( int32)palette[i].blue; + info->palette[i].blue = ( uint8) (((( intensity << 8) - intensity) + 500) / 1000L); + intensity = ( int32)palette[i].green; + info->palette[i].green = ( uint8) (((( intensity << 8) - intensity) + 500) / 1000L); + intensity = ( int32)palette[i].red; + info->palette[i].red = ( uint8) (((( intensity << 8) - intensity) + 500) / 1000L); + } + } + return TRUE; +} + + +void fill_img_buf( IMG_REF *pic) +{ + XIMG_DATA *info = &pic->info; + int32 read = info->img_buf_len; + + if ( read > info->rest_length) + read = info->rest_length; + + info->img_buf_offset = 0; + info->img_buf_used = Fread( pic->file_handle, read, info->img_buf ); + info->rest_length -= info->img_buf_used; +} + + +void refill_img_buf( IMG_REF *pic, int32 read) +{ + XIMG_DATA *info = &pic->info; + + info->img_buf_used -= read; + info->img_buf_offset += read; + + if ( info->img_buf_offset >= ( info->img_buf_len >> 1)) + { + if ( info->img_buf_used > 0) + memcpy( info->img_buf, info->img_buf + info->img_buf_offset, info->img_buf_used); + + read = info->img_buf_offset; + + if ( read > info->rest_length ) + read = info->rest_length; + + read = Fread( pic->file_handle, read, info->img_buf + info->img_buf_used ); + + info->img_buf_used += read; + info->img_buf_offset = 0; + info->rest_length -= read; + } +} + + + +uint8 *unpack_line2( uint8 *img, uint8 *des, int16 pat_len, int16 len) +{ + register int16 i, cnt; + + while ( len > 0) + { + register uint8 tag = *img++; + + if ( tag == 0) + { + cnt = *img++; + + for ( i = 0; i < cnt; i++) + { + register int16 j; + for ( j = 0; j < pat_len; j++) + *des++ = img[j]; + } + + img += pat_len; + cnt *= pat_len; + } + else if ( tag == 0x80 ) + { + cnt = *img++; + + for ( i = 0; i < cnt; i++) + *des++ = *img++; + } + else if (( tag & 0x80 ) == 0) + { + cnt = tag & 0x7f; + + for ( i = 0; i < cnt; i++) + *des++ = 0; + } + else + { + cnt = tag & 0x7f; + + for ( i = 0; i < cnt; i++) + *des++ = 0xff; + } + len -= cnt; + } + return( img); +} + + +uint8 *unpack_line1( uint8 *img, uint8 *des, int16 pat_len, int16 len) +{ + if (( img[0] == 0 ) && ( img[1] == 0 ) && ( img[2] == 0xff)) + { + if ( img[3] > 1) + { + unpack_line2( img + 4, des, pat_len, len); + img[3] -= 1; + return( img); + } + else + return( unpack_line2( img + 4, des, pat_len, len)); + } + else + return( unpack_line2( img, des, pat_len, len)); +} + + +void unpack_line( IMG_REF *pic, uint8 *des) +{ + XIMG_DATA *info = &pic->info; + uint8 *img_line; + int32 read; + + img_line = info->img_buf + info->img_buf_offset; + + read = ( int32) ( unpack_line1( img_line, des, info->pat_len, info->line_len * pic->planes ) - img_line ); + + refill_img_buf( pic, read); +} + + +boolean CDECL reader_read( IMGINFO info, uint8 *buffer) +{ + int16 even_len; + IMG_REF *pic = ( IMG_REF *)info->_priv_ptr; + XIMG_DATA *img_info = &pic->info; + IMGHDR *head = &pic->img; + + + if ( img_info->img_buf_valid == 0) + { + Fseek( head->length << 1, pic->file_handle, 0); + img_info->rest_length = img_info->file_length - ( head->length << 1); + fill_img_buf( pic); + img_info->img_buf_valid = 1; + } + + if( info->planes > 8) + { + unpack_line( pic, buffer); + return TRUE; + } + + even_len = ( img_info->line_len + 1) & ~1; + + unpack_line( pic, img_info->line_buffer); + + if ( img_info->line_len & 1) + { + uint8 *odd, *even; + int16 i; + + odd = img_info->line_buffer + ( img_info->line_len * head->planes); + even = odd + head->planes; + + for ( i = 0; i < head->planes; i++) + { + *( --even) = 0; + odd -= img_info->line_len; + even -= img_info->line_len; + memcpy( even, odd, img_info->line_len); + } + } + + if( !plane2packed24( even_len >> 1, even_len, head->planes, img_info->line_buffer, buffer, info->palette)) + return FALSE; + + return TRUE; +} + + +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata) +{ + return; +} + + +void CDECL reader_quit( IMGINFO info) +{ + IMG_REF *pic = ( IMG_REF *)info->_priv_ptr; + + if ( pic) + { + Fclose( pic->file_handle ); + + free( pic->info.img_buf); + free( pic->info.line_buffer); + free( pic); + } +} + + +void CDECL init( void) +{ + return; +} + + +int main( void) +{ + ldg_init( &img_plugin); + return( 0); +} diff --git a/sources/z-tools/trunk/zview/plugins/img/xp32.S b/sources/z-tools/trunk/zview/plugins/img/xp32.S new file mode 100644 index 0000000..c8d9970 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/img/xp32.S @@ -0,0 +1,166 @@ + .text + + .globl _plane2packed24 + +| int32 plane2packed24( int32 no_words, int32 plane_length, int16 no_planes, void *src, void *dst, CTAB_REF src_ctab ); +| d0 d1 d2 a0 a1 4(sp) + +| 11x4 + 4 + 5x4 + +_plane2packed24: + movem.l d2-d7/a2-a6,-(sp) + + move.l 11*4+4(sp),d0 + move.l 11*4+8(sp),d1 + move.l 11*4+12(sp),d2 + movea.l 11*4+16(sp),a0 + movea.l 11*4+20(sp),a1 + + movea.l 11*4+24(sp),a6 |source of the color table + + move.l d0,d4 + subq.l #1,d4 + move.l d1,d6 + add.l d6,d6 + add.l d6,d6 + + movea.l a1,a4 |destination's adress to A4 + lea (a0,d1.l),a1 + lea (a1,d1.l),a2 + lea (a2,d1.l),a3 + + lea not_supported(pc),a5 + + cmpi.w #8,d2 + bhi.s plane2packed24_transform + + lea plane2packed24_table(pc),a5 + add.w d2,d2 + adda.w 0(a5,d2.w),a5 + +plane2packed24_transform: + jsr (a5) + + movem.l (sp)+,d2-d7/a2-a6 + rts + +plane2packed24_table: + DC.w not_supported-plane2packed24_table + DC.w pp_1_to_8-plane2packed24_table |1 Bit + DC.w not_supported-plane2packed24_table + DC.w not_supported-plane2packed24_table + DC.w pp_4_to_24-plane2packed24_table |4 Bit + DC.w not_supported-plane2packed24_table + DC.w not_supported-plane2packed24_table + DC.w not_supported-plane2packed24_table + DC.w pp_8_to_24-plane2packed24_table |8 Bit + + +not_supported: + moveq #0,d0 + rts + +pp_1_to_8: + move.w (a0)+,d0 + moveq #15,d5 + +pp_1_to_8_exp: + moveq #0,d6 + + add.w d0,d0 + addx.l d6,d6 + + move.b d6,(a4)+ + + dbra d5,pp_1_to_8_exp + + subq.l #1,d4 + bpl.b pp_1_to_8 + moveq #1,d0 + rts + + +pp_4_to_24: move.w (a0)+,d0 + move.w (a1)+,d1 + move.w (a2)+,d2 + move.w (a3)+,d3 + + moveq #15,d5 +pp_4_to_24_exp: moveq #0,d6 + add.w d3,d3 + addx.w d6,d6 + add.w d2,d2 + addx.w d6,d6 + add.w d1,d1 + addx.w d6,d6 + add.w d0,d0 + addx.w d6,d6 + + + lsl.w #2,d6 + + lea (a6,d6.w),a5 + move.b (a5),(a4)+ |R + move.b 1(a5),(a4)+ |G + move.b 2(a5),(a4)+ |B + +pp_4_to_24_next: dbra d5,pp_4_to_24_exp + + subq.l #1,d4 + bpl.b pp_4_to_24 + moveq #1,d0 + rts + + +pp_8_to_24: move.l d4,-(sp) + move.l d6,-(sp) + + move.w (a0)+,d0 + move.w (a1)+,d1 + move.w (a2)+,d2 + move.w (a3)+,d3 + move.w -2(a0,d6.l),d4 + move.w -2(a1,d6.l),d5 + move.w -2(a3,d6.l),d7 + move.w -2(a2,d6.l),d6 + + swap d0 + swap d5 + move.w #15,d5 +pp_8_to_24_exp: swap d5 + clr.w d0 + add.w d7,d7 + addx.w d0,d0 + add.w d6,d6 + addx.w d0,d0 + add.w d5,d5 + addx.w d0,d0 + add.w d4,d4 + addx.w d0,d0 + add.w d3,d3 + addx.w d0,d0 + add.w d2,d2 + addx.w d0,d0 + add.w d1,d1 + addx.w d0,d0 + swap d0 + add.w d0,d0 + swap d0 + addx.w d0,d0 + + lsl.w #2,d0 + + lea (a6,d0.w),a5 + move.b (a5),(a4)+ |R + move.b 1(a5),(a4)+ |G + move.b 2(a5),(a4)+ |B + + swap d5 + dbra d5,pp_8_to_24_exp + + move.l (sp)+,d6 + move.l (sp)+,d4 + subq.l #1,d4 + bpl.b pp_8_to_24 + moveq #1,d0 + rts diff --git a/sources/z-tools/trunk/zview/plugins/jpg/Makefile b/sources/z-tools/trunk/zview/plugins/jpg/Makefile new file mode 100644 index 0000000..c0143b4 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/jpg/Makefile @@ -0,0 +1,15 @@ +STACKSIZE = 64k +OPTIMISATION = -O2 -fomit-frame-pointer +CPU = -m68020-60 +LIB = -ljpeg -lexif -lldgserver + +CFLAGS = $(CPU) $(OPTIMISATION) -Wall -I../common +LDFLAGS = -nostdlib + +DSP_OBJ = jpgdsp.o + +OBJ = $(LDG_STARTUP_OBJ) $(DSP_OBJ) jpgldg.o + +PROGRAM = jpg.ldg + +include ../../../common.mak diff --git a/sources/z-tools/trunk/zview/plugins/jpg/copyright b/sources/z-tools/trunk/zview/plugins/jpg/copyright new file mode 100644 index 0000000..a1ef488 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/jpg/copyright @@ -0,0 +1,503 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/sources/z-tools/trunk/zview/plugins/jpg/jpgdh.h b/sources/z-tools/trunk/zview/plugins/jpg/jpgdh.h new file mode 100644 index 0000000..c36a310 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/jpg/jpgdh.h @@ -0,0 +1,93 @@ +/* JPEGD header file + ½1992-93 Brainstorm & Atari Corporation. + to be included after vdi.h + Last modification on 8-apr-1993. +*/ + +typedef struct _JPGD_STRUCT { + void *InPointer; /* JPEG Image Pointer */ + void *OutPointer; /* Output Buffer/Filename Pointer (see OutFlag) */ + long InSize; /* JPEG Image Size (Bytes) */ + long OutSize; /* Output Image Size (Bytes) */ + short InComponents; /* JPEG Image Components Number (1->4) */ + short OutComponents; /* Output Components Number (1->4) */ + short OutPixelSize; /* Output Pixel Size (1->4) */ + short OutFlag; /* 0 (RAM Output) / -1 (Disk Output) */ + short XLoopCounter; /* Number of MCUs per Row */ + short YLoopCounter; /* Number of MCUs per Column */ + short (*Create)(struct _JPGD_STRUCT *); /* Pointer to User Routine / NULL */ + short (*Write)(struct _JPGD_STRUCT *); /* Pointer to User Routine / NULL */ + short (*Close)(struct _JPGD_STRUCT *); /* Pointer to User Routine / NULL */ + short (*SigTerm)(struct _JPGD_STRUCT *); /* Pointer to User Routine / NULL */ + uint8 *Comp1GammaPtr; /* Component 1 Gamma Table / NULL */ + uint8 *Comp2GammaPtr; /* Component 2 Gamma Table / NULL */ + uint8 *Comp3GammaPtr; /* Component 3 Gamma Table / NULL */ + uint8 *Comp4GammaPtr; /* Component 4 Gamma Table / NULL */ + short (*UserRoutine)(struct _JPGD_STRUCT *); /* Pointer to User Routine (Called during Decompression) / NULL */ + void *OutTmpPointer; /* Current OutPointer / Temporary Disk Buffer Pointer (see OutFlag) */ + short MCUsCounter; /* Number of MCUs not Decoded */ + short OutTmpHeight; /* Number of Lines in OutTmpPointer */ + long User[2]; /* Free, Available for User */ + short OutHandle; /* 0 / Output File Handle (see OutFlag) */ + MFDB MFDBStruct; /* Output Image MFDB */ +} JPGD_STRUCT; +typedef JPGD_STRUCT *JPGD_PTR; + +#define JPGD_MAGIC '_JPD' +#define JPGD_VERSION 1 + +enum JPGD_ENUM { + NOERROR=0, /* File correctly uncompressed */ + UNKNOWNFORMAT, /* File is not JFIF (Error) */ + INVALIDMARKER, /* Reserved CCITT Marker Found (Error) */ + SOF1MARKER, /* Mode not handled by the decoder (Error) */ + SOF2MARKER, /* Mode not handled by the decoder (Error) */ + SOF3MARKER, /* Mode not handled by the decoder (Error) */ + SOF5MARKER, /* Mode not handled by the decoder (Error) */ + SOF6MARKER, /* Mode not handled by the decoder (Error) */ + SOF7MARKER, /* Mode not handled by the decoder (Error) */ + SOF9MARKER, /* Mode not handled by the decoder (Error) */ + SOF10MARKER, /* Mode not handled by the decoder (Error) */ + SOF11MARKER, /* Mode not handled by the decoder (Error) */ + SOF13MARKER, /* Mode not handled by the decoder (Error) */ + SOF14MARKER, /* Mode not handled by the decoder (Error) */ + SOF15MARKER, /* Mode not handled by the decoder (Error) */ + RSTmMARKER, /* Unexpected RSTm found (Error) */ + BADDHTMARKER, /* Buggy DHT Marker (Error) */ + DACMARKER, /* Marker not handled by the decoder (Error) */ + BADDQTMARKER, /* Buggy DQT Marker (Error) */ + BADDNLMARKER, /* Invalid/Unexpected DNL Marker (Error) */ + BADDRIMARKER, /* Invalid DRI Header Size (Error) */ + DHPMARKER, /* Marker not handled by the decoder (Error) */ + EXPMARKER, /* Marker not handled by the decoder (Error) */ + BADSUBSAMPLING, /* Invalid components subsampling (Error) */ + NOTENOUGHMEMORY, /* Not enough memory... (Error) */ + DECODERBUSY, /* Decoder is busy (Error) */ + DSPBUSY, /* Can't lock the DSP (Error) */ + BADSOFnMARKER, /* Buggy SOFn marker (Error) */ + BADSOSMARKER, /* Buggy SOS marker (Error) */ + HUFFMANERROR, /* Buggy Huffman Stream (Error) */ + BADPIXELFORMAT, /* Invalid Output Pixel Format (Error) */ + DISKFULL, /* Hard/Floppy Disk Full (Error) */ + MISSINGMARKER, /* Marker expected but not found (Error) */ + IMAGETRUNCATED, /* More bytes Needed (Error) */ + EXTRABYTES, /* Dummy Bytes after EOI Marker (Warning) */ + USERABORT, /* User Routine signaled 'Abort' */ + DSPMEMORYERROR, /* Not Enough DSP RAM (Error) */ + NORSTmMARKER, /* RSTm Marker expected but not found */ + BADRSTmMARKER, /* Invalid RSTm Marker Number */ + DRIVERCLOSED, /* Driver is Already Closed. */ + ENDOFIMAGE /* Stop Decoding (Internal Message, Should Never Appear) */ +}; +typedef long JPGD_ENUM; + +typedef struct { + long JPGDVersion; + JPGD_ENUM (*JPGDOpenDriver)(JPGD_PTR); + JPGD_ENUM (*JPGDCloseDriver)(JPGD_PTR); + long (*JPGDGetStructSize)(void); + JPGD_ENUM (*JPGDGetImageInfo)(JPGD_PTR); + JPGD_ENUM (*JPGDGetImageSize)(JPGD_PTR); + JPGD_ENUM (*JPGDDecodeImage)(JPGD_PTR); +} JPGDDRV_STRUCT; +typedef JPGDDRV_STRUCT *JPGDDRV_PTR; diff --git a/sources/z-tools/trunk/zview/plugins/jpg/jpgdsp.c b/sources/z-tools/trunk/zview/plugins/jpg/jpgdsp.c new file mode 100644 index 0000000..f3c6bfd --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/jpg/jpgdsp.c @@ -0,0 +1,233 @@ +#include "zview.h" +#include "jpgdh.h" + +int16 dsp_ram = 0; + +int16 reader_dsp_init( const char *name, IMGINFO info); + +JPGDDRV_PTR jpgdrv = NULL; + +#define JPGDOpenDriver( jpgd, jpgdrv) \ +__extension__ \ +({ register int32 retv __asm__("d0"); \ + __asm__ volatile \ + (" movl %1,a0; \ + movl (%2,4),a1; \ + jsr a1@; \ + " /* end of code */ \ + : "=r" (retv) /* out */ \ + : "a" (jpgd) /* in */ \ + , "a" (jpgdrv) /* in */ \ + : "a0", "a1" \ + ); \ + retv; \ +}) + +#define JPGDCloseDriver( jpgd, jpgdrv) \ +__extension__ \ +({ register int32 retv __asm__("d0"); \ + __asm__ volatile \ + (" movl %1,a0; \ + movl (%2,8),a1; \ + jsr a1@; \ + " /* end of code */ \ + : "=r" (retv) /* out */ \ + : "a" (jpgd) /* in */ \ + , "a" (jpgdrv) /* in */ \ + : "a0", "a1" \ + ); \ + retv; \ +}) + +#define JPGDGetImageInfo( jpgd, jpgdrv) \ +__extension__ \ +({ register int32 retv __asm__("d0"); \ + __asm__ volatile \ + (" movl %1,a0; \ + movl (%2,16),a1; \ + jsr a1@; \ + " /* end of code */ \ + : "=r" (retv) /* out */ \ + : "a" (jpgd) /* in */ \ + , "a" (jpgdrv) /* in */ \ + : "a0", "a1" \ + ); \ + retv; \ +}) + +#define JPGDGetImageSize( jpgd, jpgdrv) \ +__extension__ \ +({ register int32 retv __asm__("d0"); \ + __asm__ volatile \ + (" movl %1,a0; \ + movl (%2,20),a1; \ + jsr a1@; \ + " /* end of code */ \ + : "=r" (retv) /* out */ \ + : "a" (jpgd) /* in */ \ + , "a" (jpgdrv) /* in */ \ + : "a0", "a1" \ + ); \ + retv; \ +}) + +#define JPGDDecodeImage( jpgd, jpgdrv) \ +__extension__ \ +({ register int32 retv __asm__("d0"); \ + __asm__ volatile \ + (" movl %1,a0; \ + movl (%2,24),a1; \ + jsr a1@; \ + " /* end of code */ \ + : "=r" (retv) /* out */ \ + : "a" (jpgd) /* in */ \ + , "a" (jpgdrv) /* in */ \ + : "a0", "a1" \ + ); \ + retv; \ +}) + +/*==================================================================================* + * boolean CDECL reader_init: * + * Open the file "name", fit the "info" struct. ( see zview.h) and make others * + * things needed by the decoder. * + *----------------------------------------------------------------------------------* + * input: * + * name -> The file to open. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +int16 reader_dsp_init( const char *name, IMGINFO info) +{ + char pad[] = { -1, -1, -1, -1, -1, -1, -1, -1, 0, 0}; + void *src, *dst; + int16 jpeg_file; + int32 jpgdsize, jpeg_file_size; + JPGD_PTR jpgd; + + if ( ( jpeg_file = ( int16)Fopen( name, 0)) < 0) + return GOLBAL_ERROR; + + jpeg_file_size = Fseek( 0L, jpeg_file, 2); + + Fseek( 0L, jpeg_file, 0); + + if (( src = ( void*)Mxalloc( jpeg_file_size + sizeof( pad), dsp_ram)) == NULL) + { + Fclose( jpeg_file); + return GOLBAL_ERROR; + } + + if ( Fread( jpeg_file, jpeg_file_size, src) != jpeg_file_size) + { + Mfree( src); + Fclose( jpeg_file); + return GOLBAL_ERROR; + } + + Fclose( jpeg_file); + + memcpy( ( uint8 *)src + jpeg_file_size, pad, sizeof( pad)); + + jpgdsize = jpgdrv->JPGDGetStructSize(); + + if( jpgdsize < 1) + { + Mfree( src); + return DSP_ERROR; + } + + jpgd = ( JPGD_PTR)Mxalloc( jpgdsize, dsp_ram); + + if( jpgd == NULL) + { + Mfree( src); + return GOLBAL_ERROR; + } + + memset( ( void *)jpgd, 0, jpgdsize); + + if( JPGDOpenDriver( jpgd, jpgdrv) != 0) + { + Dsp_Unlock(); + Mfree( jpgd); + Mfree( src); + return DSP_ERROR; + } + + jpgd->InPointer = src; + jpgd->InSize = jpeg_file_size; + + if( JPGDGetImageInfo( jpgd, jpgdrv) != 0) + { + JPGDCloseDriver( jpgd, jpgdrv); + Dsp_Unlock(); + Mfree( jpgd); + Mfree( src); + return DSP_ERROR; + } + + jpgd->OutComponents = 3; + jpgd->OutPixelSize = 3; + + if( JPGDGetImageSize( jpgd, jpgdrv) != 0) + { + JPGDCloseDriver( jpgd, jpgdrv); + Mfree( jpgd); + Mfree( src); + return DSP_ERROR; + } + + if(( dst = ( void*)Mxalloc( jpgd->OutSize, dsp_ram)) == NULL) + { + JPGDCloseDriver( jpgd, jpgdrv); + Mfree( jpgd); + Mfree( src); + return GOLBAL_ERROR; + } + + jpgd->OutPointer = dst; + jpgd->OutFlag = 0; + jpgd->UserRoutine = NULL; + + if( JPGDDecodeImage( jpgd, jpgdrv) != 0) + { + JPGDCloseDriver( jpgd, jpgdrv); + Mfree( jpgd); + Mfree( src); + Mfree( dst); + return DSP_ERROR; + } + + info->components = 3; + info->width = jpgd->MFDBStruct.fd_w; + info->height = jpgd->MFDBStruct.fd_h; + info->real_width = info->width; + info->real_height = info->height; + info->memory_alloc = TT_RAM; + info->planes = 24; + info->orientation = UP_TO_DOWN; + info->colors = 1uL << ( uint32)info->planes; + info->indexed_color = FALSE; + info->page = 1; + info->delay = 0; + info->num_comments = 0; + info->max_comments_length = 0; + + info->_priv_ptr = dst; + info->_priv_var = jpgd->MFDBStruct.fd_wdwidth << 1; + info->_priv_var_more = info->_priv_var; + + strcpy( info->info, "JPEG"); + strcpy( info->compression, "JPG"); + + JPGDCloseDriver( jpgd, jpgdrv); + + Mfree( jpgd); + Mfree( src); + + return ALL_OK; +} + diff --git a/sources/z-tools/trunk/zview/plugins/jpg/jpgldg.c b/sources/z-tools/trunk/zview/plugins/jpg/jpgldg.c new file mode 100644 index 0000000..db7b274 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/jpg/jpgldg.c @@ -0,0 +1,813 @@ +#include +#include +#include +#include "zview.h" +#include "jpgdh.h" +#include +#include + +void CDECL init( void); +boolean CDECL reader_init( const char *name, IMGINFO info); +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata); +boolean CDECL reader_read( IMGINFO info, uint8 *buffer); +void CDECL reader_quit( IMGINFO info); +boolean CDECL encoder_init( const char *name, IMGINFO info); +boolean CDECL encoder_write( IMGINFO info, uint8 *buffer); +void CDECL encoder_quit( IMGINFO info); +void CDECL set_jpg_option( int16 set_quality, J_COLOR_SPACE set_color_space, boolean set_progressive); + + +extern int16 reader_dsp_init( const char *name, IMGINFO info); + +PROC LibFunc[] = +{ + { "plugin_init", "", init}, + { "reader_init", "", reader_init}, + { "reader_get_txt", "", reader_get_txt}, + { "reader_read", "", reader_read}, + { "reader_quit", "", reader_quit}, + { "encoder_init", "", encoder_init}, + { "encoder_write", "", encoder_write}, + { "encoder_quit", "", encoder_quit}, + { "set_jpg_option", "", set_jpg_option} +}; + + +LDGLIB plugin = +{ + 0x0200, /* Plugin version */ + 9, /* Number of plugin's functions */ + LibFunc, /* List of functions */ + "JPGJPEPEG", /* File's type Handled */ + LDG_NOT_SHARED, /* The flags NOT_SHARED is used here.. */ + NULL, + 3L /* Howmany file type are supported by this plugin */ +}; + +typedef struct +{ + struct jpeg_source_mgr pub; /* public fields */ + uint8 *buffer; + int size; + JOCTET terminal[2]; +}my_source_mgr; + +/* Options*/ +static int quality = 90; /* quality 0 -> 100 % */ +static J_COLOR_SPACE color_space = JCS_RGB; +static boolean progressive = FALSE; + + +/* Brainstorm DSP driver cookie pointer */ +extern JPGDDRV_PTR jpgdrv; +boolean dsp_decoding = FALSE; +extern int16 dsp_ram; + +typedef struct jpeg_decompress_struct *JPEG_DEC; +typedef struct jpeg_error_mgr *JPEG_ERR; +typedef struct jpeg_compress_struct *JPEG_ENC; +typedef my_source_mgr *my_src_ptr; + + + + +static void _jpeg_shutup( j_common_ptr cinfo, int msg_level) +{ + ( void)cinfo; + ( void)msg_level; +} + + +static void _jpeg_errjmp( j_common_ptr cinfo) +{ + jmp_buf *escape = cinfo->client_data; + + if ( escape) + longjmp( *escape, TRUE); +} + +static void init_source (j_decompress_ptr cinfo) +{ +} + + +static boolean fill_input_buffer (j_decompress_ptr cinfo) +{ + my_src_ptr src = (my_src_ptr) cinfo->src; + + src->pub.next_input_byte = src->terminal; + src->pub.bytes_in_buffer = 2; + src->terminal[0] = (JOCTET) 0xFF; + src->terminal[1] = (JOCTET) JPEG_EOI; + + return TRUE; +} + +static void skip_input_data( j_decompress_ptr cinfo, long num_bytes) +{ + my_src_ptr src = (my_src_ptr) cinfo->src; + src->pub.next_input_byte = src->pub.next_input_byte + num_bytes; +} + +static void term_source (j_decompress_ptr cinfo) +{ +} + + +boolean decompress_thumbnail_image( void *source, uint32 size, IMGINFO info) +{ + int header = 0; + jmp_buf escape; + JPEG_ERR jerr; + JPEG_DEC jpeg; + my_src_ptr src; + + jpeg = ( JPEG_DEC) malloc( sizeof( struct jpeg_decompress_struct)); + jerr = ( JPEG_ERR) malloc( sizeof( struct jpeg_error_mgr)); + + if ( jpeg == NULL || jerr == NULL) + { + if ( jerr) free( jerr); + if ( jpeg) free( jpeg); + return FALSE; + } + + + if( setjmp( escape)) + { + if ( header == 2) + jpeg_abort_decompress( jpeg); + + jpeg_destroy_decompress( jpeg); + if ( jerr) free( jerr); + if ( jpeg) free( jpeg); + return FALSE; + } + + jpeg->err = jpeg_std_error( jerr); + jpeg->err->emit_message = _jpeg_shutup; + jpeg->err->error_exit = _jpeg_errjmp; + jpeg->client_data = &escape; + + jpeg_create_decompress( jpeg); + + if (jpeg->src == NULL) + jpeg->src = (struct jpeg_source_mgr *)(*jpeg->mem->alloc_small)((j_common_ptr)jpeg, JPOOL_PERMANENT, sizeof (my_source_mgr)); + + src = (my_src_ptr)jpeg->src; + + src->pub.init_source = init_source; + src->pub.fill_input_buffer = fill_input_buffer; + src->pub.skip_input_data = skip_input_data; + src->pub.resync_to_restart = jpeg_resync_to_restart; + src->pub.term_source = term_source; + src->pub.bytes_in_buffer = size; + src->pub.next_input_byte = source; + src->buffer = source; + src->size = size; + + jpeg_read_header( jpeg, TRUE); + + jpeg->dct_method = JDCT_IFAST; + jpeg->do_fancy_upsampling = FALSE; + + header = 1; + jpeg_start_decompress( jpeg); + header = 2; + + switch( jpeg->out_color_space) + { + case JCS_RGB: + info->components = 3; + break; + case JCS_GRAYSCALE: + info->components = 1; + break; + default: + jpeg->out_color_space = JCS_RGB; + info->components = jpeg->out_color_components = 3; + break; + } + + info->width = jpeg->image_width; + info->height = jpeg->image_height; + info->planes = ( ( jpeg->out_color_space == JCS_RGB) ? 24 : 8); + info->colors = 1 << info->planes; + + info->_priv_ptr = ( void*)jpeg; + info->_priv_var_more = 1; + info->_priv_var = -1; + + jpeg->client_data = NULL; + + return TRUE; +} + + +/*==================================================================================* + * boolean CDECL reader_init: * + * Open the file "name", fit the "info" struct. ( see zview.h) and make others * + * things needed by the decoder. * + *----------------------------------------------------------------------------------* + * input: * + * name -> The file to open. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL reader_init( const char *name, IMGINFO info) +{ + JPEG_ERR jerr; + JPEG_DEC jpeg; + jpeg_saved_marker_ptr mark; + txt_data *comment; + jmp_buf escape; + FILE* jpeg_file; + int16 header = 0; + + /* If Brainstorm cookie is used, we try to decode with it*/ + if( jpgdrv) + { + int16 dsp_result = reader_dsp_init( name, info); + + switch( dsp_result) + { + case GOLBAL_ERROR: + dsp_decoding = FALSE; + return FALSE; + + case DSP_ERROR: + case PROGRESSIVE_JPG: + dsp_decoding = FALSE; + break; + + case ALL_OK: + dsp_decoding = TRUE; + return TRUE; + } + } + + if ( ( jpeg_file = fopen( name, "rb")) == NULL) + return FALSE; + + jpeg = ( JPEG_DEC) malloc( sizeof( struct jpeg_decompress_struct)); + jerr = ( JPEG_ERR) malloc( sizeof( struct jpeg_error_mgr)); + comment = ( txt_data*)malloc( sizeof( txt_data)); + + if ( jpeg == NULL || jerr == NULL || comment == NULL) + { + if ( comment) free( comment); + if ( jerr) free( jerr); + if ( jpeg) free( jpeg); + fclose( jpeg_file); + return FALSE; + } + + comment->lines = 0; + comment->max_lines_length = 0; + comment->txt[0] = NULL; + + jpeg->err = jpeg_std_error( jerr); + jpeg->err->emit_message = _jpeg_shutup; + jpeg->err->error_exit = _jpeg_errjmp; + jpeg->client_data = &escape; + + if ( setjmp( escape)) + { + if ( header >= 2) + jpeg_abort_decompress( jpeg); + + jpeg_destroy_decompress( jpeg); + + if ( comment) + { + register int16 i; + + for ( i = 0; i < comment->lines; i++) + { + if( comment->txt[i]) + free( comment->txt[i]); + } + + free( comment); + comment = NULL; + } + + if ( jerr) free( jerr); + if ( jpeg) free( jpeg); + fclose( jpeg_file); + return FALSE; + } + + jpeg_create_decompress( jpeg); + jpeg_stdio_src( jpeg, jpeg_file); + jpeg_save_markers( jpeg, JPEG_COM, 0xffff); /* comment */ + jpeg_save_markers( jpeg, M_EXIF, 0xFFFF); /* EXIF */ + jpeg_read_header( jpeg, TRUE); + + + // faster that the default method ( 10%) for a very little output quality lost + jpeg->dct_method = JDCT_IFAST; + jpeg->do_fancy_upsampling = FALSE; + + header = 1; + jpeg_start_decompress( jpeg); + header = 2; + + jpeg->client_data = NULL; + + switch( jpeg->out_color_space) + { + case JCS_RGB: + info->components = 3; + break; + case JCS_GRAYSCALE: + info->components = 1; + break; + default: + jpeg->out_color_space = JCS_RGB; + info->components = jpeg->out_color_components = 3; + break; + } + + info->real_width = jpeg->image_width; + info->real_height = jpeg->image_height; + info->width = info->real_width; + info->height = info->real_height; + info->planes = ( ( jpeg->out_color_space == JCS_RGB) ? 24 : 8); + info->orientation = UP_TO_DOWN; + info->colors = 1 << info->planes; + info->memory_alloc = TT_RAM; + info->indexed_color = FALSE; + info->page = 1; + info->delay = 0; + + strcpy( info->info, "JPEG"); + + if( info->planes == 8) + strcat( info->info, " Greyscale"); + + strcpy( info->compression, "JPG"); + + for ( mark = jpeg->marker_list; mark; mark = mark->next) + { + if( mark->marker == JPEG_COM) + { + if (!mark->data || !mark->data_length) + continue; + + comment->txt[comment->lines] = ( int8*)malloc( mark->data_length + 1); + + if( comment->txt[comment->lines] == NULL) + continue; + + memcpy( comment->txt[comment->lines], mark->data, mark->data_length); + comment->max_lines_length = MAX( comment->max_lines_length, ( int16)mark->data_length + 1); + comment->lines++; + } + else if( mark->marker == M_EXIF) + { + int i, l, lenght; + char value[1024+256]; + ExifData *exifData = exif_data_new_from_data(( char*)mark->data, mark->data_length); + + if( !exifData) + continue; + + for( i = 0; i < EXIF_IFD_COUNT; i++) + { + ExifContent* content = exifData->ifd[i]; + + for ( l = 0; l < content->count; l++) + { + if( comment->lines > 253) + break; + + ExifEntry *e = content->entries[l]; + + sprintf( value, "%s", exif_tag_get_name (e->tag)); + + strcat( value, ": "); + + lenght = strlen( value); + + exif_entry_get_value( e, &value[lenght], sizeof(value) - lenght); + + lenght = strlen( value); + + comment->txt[comment->lines] = ( int8*)malloc( lenght + 1); + + if( comment->txt[comment->lines] == NULL) + break; + + strcpy( comment->txt[comment->lines], value); + + comment->max_lines_length = MAX( comment->max_lines_length, ( int16)lenght); + comment->lines++; + } + } + + if(( exifData->data) && ( exifData->size > 0) && info->thumbnail) + { + int32 size = exifData->size; + + info->__priv_ptr_more = malloc( size + 1); + memcpy( info->__priv_ptr_more, exifData->data, size); + + exif_data_unref( exifData); + + jpeg_finish_decompress( jpeg); + jpeg_destroy_decompress( jpeg); + free( jpeg->err); + free( jpeg); + fclose( jpeg_file); + + if( decompress_thumbnail_image( info->__priv_ptr_more, size, info)) + { + info->num_comments = comment->lines; + info->max_comments_length = comment->max_lines_length; + info->_priv_ptr_more = ( void*)comment; + + return TRUE; + } + else // We can't extract the thumbnail :/ + { + free( info->__priv_ptr_more); + exif_data_unref( exifData); + + if ( comment) + { + register int16 i; + + for ( i = 0; i < comment->lines; i++) + { + if( comment->txt[i]) + free( comment->txt[i]); + } + + free( comment); + comment = NULL; + } + + return FALSE; + } + } + + exif_data_unref( exifData); + } + } + + info->num_comments = comment->lines; + info->max_comments_length = comment->max_lines_length; + + + info->_priv_ptr = ( void*)jpeg; + info->_priv_ptr_more = ( void*)comment; + info->__priv_ptr_more = NULL; + info->_priv_var = jpeg_file; + info->_priv_var_more = 0; /* 1 for exif thumbnail */ + + jpeg->client_data = NULL; + + return TRUE; +} + + +/*==================================================================================* + * boolean CDECL reader_get_txt * + * This function , like other CDECL function mus be always present. * + * It fills txtdata struct. with the text present in the picture ( if any). * + *----------------------------------------------------------------------------------* + * input: * + * txtdata -> The destination text buffer. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata) +{ + register int16 i; + txt_data *comment; + + if( dsp_decoding) + return; + + comment = ( txt_data *)info->_priv_ptr_more; + + for ( i = 0; i < txtdata->lines; i++) + strcpy( txtdata->txt[i] , comment->txt[i]); +} + + +/*==================================================================================* + * boolean CDECL reader_read: * + * This function fits the buffer with image data * + *----------------------------------------------------------------------------------* + * input: * + * buffer -> The destination buffer. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL reader_read( IMGINFO info, uint8 *buffer) +{ + if( dsp_decoding) + { + const void *source = ( uint8*)info->_priv_ptr + info->_priv_var_more; + + memcpy( ( void*)buffer, source, info->_priv_var); + info->_priv_var_more += info->_priv_var; + + return TRUE; + } + + if( jpeg_read_scanlines(( JPEG_DEC)info->_priv_ptr, ( JSAMPROW*)&buffer, 1)) + return TRUE; + + return FALSE; +} + + +/*==================================================================================* + * boolean CDECL reader_quit: * + * This function makes the last job like close the file handler and free the * + * allocated memory. * + *----------------------------------------------------------------------------------* + * input: * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_quit( IMGINFO info) +{ + JPEG_DEC jpeg; + txt_data *comment; + + if( dsp_decoding) + { + if( info->_priv_ptr) + { + // DSP decoder uses Mxalloc() + Mfree( info->_priv_ptr); + } + return; + } + + jpeg = ( JPEG_DEC)info->_priv_ptr; + comment = ( txt_data *)info->_priv_ptr_more; + + if( !jpeg) + return; + + if( comment) + { + register int16 i; + + for ( i = 0; i < comment->lines; i++) + { + if( comment->txt[i]) + free( comment->txt[i]); + } + free( comment); + } + + jpeg_finish_decompress( jpeg); + jpeg_destroy_decompress( jpeg); + + free( jpeg->err); + free( jpeg); + + /* thumbnail mode? */ + if( info->__priv_ptr_more) + { + free( info->__priv_ptr_more); + return; + } + + fclose( info->_priv_var); +} + + + + +/*==================================================================================* + * boolean set_jpg_option: * + * This function set some encoder's options * + *----------------------------------------------------------------------------------* + * input: * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL set_jpg_option( int16 set_quality, J_COLOR_SPACE set_color_space, boolean set_progressive) +{ + quality = set_quality; + color_space = set_color_space; + progressive = set_progressive; +} + + +/*==================================================================================* + * boolean CDECL encoder_init: * + * Open the file "name", fit the "info" struct. ( see zview.h) and make others * + * things needed by the encoder. * + *----------------------------------------------------------------------------------* + * input: * + * name -> The file to open. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL encoder_init( const char *name, IMGINFO info) +{ + JPEG_ERR jerr = NULL; + JPEG_ENC jpeg = NULL; + FILE* jpeg_file; + jmp_buf escape; + int16 header = 0; + + if ( ( jpeg_file = fopen( name, "wb")) == NULL) + return FALSE; + + jpeg = ( JPEG_ENC) malloc( sizeof( struct jpeg_decompress_struct)); + jerr = ( JPEG_ERR) malloc( sizeof( struct jpeg_error_mgr)); + + if ( jpeg == NULL || jerr == NULL) + { + if ( jerr) free( jerr); + if ( jpeg) free( jpeg); + fclose( jpeg_file); + return FALSE; + } + + if ( setjmp( escape)) + { + if ( header > 1) + jpeg_abort_compress( jpeg); + + jpeg_destroy_compress( jpeg); + + if ( jerr) free( jerr); + if ( jpeg) free( jpeg); + jerr = NULL; + jpeg = NULL; + fclose( jpeg_file); + return FALSE; + } + + jpeg->err = jpeg_std_error( jerr); + jpeg->err->emit_message = _jpeg_shutup; + jpeg->err->error_exit = _jpeg_errjmp; + jpeg->client_data = &escape; + + jpeg_create_compress( jpeg); + jpeg_stdio_dest( jpeg, jpeg_file); + + jpeg->image_width = info->width; + jpeg->image_height = info->height; + jpeg->input_components = info->components = 3; + jpeg->in_color_space = JCS_RGB; + + jpeg_set_defaults( jpeg); + jpeg_set_colorspace ( jpeg, color_space); + +/* jpeg->num_components = ( color_space == JCS_RGB ? 3 : 1); + jpeg->jpeg_color_space = color_space; +*/ jpeg->progressive_mode = progressive; + + jpeg_set_quality( jpeg, quality, TRUE); + + header = 1; + jpeg_start_compress( jpeg, TRUE); + header = 2; + + info->planes = 24; + info->colors = 16777215L; + info->orientation = UP_TO_DOWN; + info->real_width = info->width; + info->real_height = info->height; + info->memory_alloc = TT_RAM; + info->indexed_color = FALSE; + info->page = 1; + info->delay = 0; + info->_priv_ptr = ( void*)jpeg; + info->_priv_ptr_more = NULL; + info->__priv_ptr_more = NULL; + info->_priv_var = jpeg_file; + info->_priv_var_more = 0; + + jpeg->client_data = NULL; + + return TRUE; +} + + +/*==================================================================================* + * boolean CDECLencoder_write: * + * This function write data from buffer to file * + *----------------------------------------------------------------------------------* + * input: * + * buffer -> The source buffer. * + * info -> The IMGINFO struct . * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL encoder_write( IMGINFO info, uint8 *buffer) +{ + ( void)jpeg_write_scanlines( ( JPEG_ENC)info->_priv_ptr, ( JSAMPROW*)&buffer, 1); + return TRUE; +} + + + +/*==================================================================================* + * boolean CDECL encoder_quit: * + * This function makes the last job like close the file handler and free the * + * allocated memory. * + *----------------------------------------------------------------------------------* + * input: * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL encoder_quit( IMGINFO info) +{ + JPEG_ENC jpeg = ( JPEG_ENC)info->_priv_ptr; + if( jpeg) + { + jpeg_finish_compress( jpeg); + jpeg_destroy_compress( jpeg); + free( jpeg->err); + free( jpeg); + fclose( info->_priv_var); + } +} + + + +/*==================================================================================* + * boolean CDECL init: * + * First function called from zview, in this one, you can make some internal * + * initialisation. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL init( void) +{ + int32 mach, cpu = 0; + + /* DSP decoder present */ + if( Getcookie( C__JPD, ( long*)&jpgdrv) != 0) + jpgdrv = NULL; + else + { + // Cconws("JPG Cookie found \n\r"); + + Getcookie( C__MCH, ( long*)&mach); + + /* If Aranym is detected, we decode with the DSP routine */ + /* and we can use TT ram for DSP allocation */ + if( mach == 0x50000L) + { + dsp_ram = 3; + // Cconws("JPG Cookie used \n\r"); + return; + } + + Getcookie( C__CPU, ( long*)&cpu); + cpu &= 0xFFFF; + + /* if we have a CPU > 68030, we decode with this one, it's faster */ + if( cpu != 30) + jpgdrv = NULL; + } +} + + +/*==================================================================================* + * int main: * + * Main function, his job is to call ldg_init function. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * 0 * + *==================================================================================*/ +int main( void) +{ + ldg_init( &plugin); + return( 0); +} + diff --git a/sources/z-tools/trunk/zview/plugins/libs.txt b/sources/z-tools/trunk/zview/plugins/libs.txt new file mode 100644 index 0000000..5ab64d3 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/libs.txt @@ -0,0 +1,9 @@ +Download required libs from: + +https://sourceforge.net/projects/giflib/ +http://www.libpng.org/pub/png/libpng.html +http://www.ijg.org/ +http://libtiff.maptools.org/ +http://easybmp.sourceforge.net/ +http://libexif.sourceforge.net/ +http://www.cs.wisc.edu/graphics/Gallery/LibTarga/ diff --git a/sources/z-tools/trunk/zview/plugins/neochrome/Makefile b/sources/z-tools/trunk/zview/plugins/neochrome/Makefile new file mode 100644 index 0000000..135a10b --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/neochrome/Makefile @@ -0,0 +1,13 @@ +STACKSIZE = 64k +OPTIMISATION = -O2 -fomit-frame-pointer -finline-functions +CPU = -m68020-60 +LIB = -lldgserver + +CFLAGS = $(CPU) $(OPTIMISATION) -Wall -I../common +LDFLAGS = -nostdlib + +OBJ = $(LDG_STARTUP_OBJ) neoldg.o + +PROGRAM = neo.ldg + +include ../../../common.mak diff --git a/sources/z-tools/trunk/zview/plugins/neochrome/copyright b/sources/z-tools/trunk/zview/plugins/neochrome/copyright new file mode 100644 index 0000000..a1ef488 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/neochrome/copyright @@ -0,0 +1,503 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/sources/z-tools/trunk/zview/plugins/neochrome/neoldg.c b/sources/z-tools/trunk/zview/plugins/neochrome/neoldg.c new file mode 100644 index 0000000..5ca4eab --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/neochrome/neoldg.c @@ -0,0 +1,302 @@ +#include "zview.h" + +boolean CDECL reader_init( const char *name, IMGINFO info); +boolean CDECL reader_read( IMGINFO info, uint8 *buffer); +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata); +void CDECL reader_quit( IMGINFO info); +void CDECL init( void); + + +PROC NEOFunc[] = +{ + { "plugin_init", "", init}, + { "reader_init", "", reader_init}, + { "reader_get_txt", "", reader_get_txt}, + { "reader_read", "", reader_read}, + { "reader_quit", "", reader_quit} +}; + + +LDGLIB neo_plugin = +{ + 0x0200, /* Plugin version */ + 5, /* Number of plugin's functions */ + NEOFunc, /* List of functions */ + "NEO", /* File's type Handled */ + LDG_NOT_SHARED, /* The flags NOT_SHARED is used here.. even if zview plugins are reentrant + and are shareable, we must use this flags because we don't know if the + user has ldg.prg deamon installed on his computer */ + NULL, /* Function called when the plugin is unloaded */ + 1L /* Howmany file type are supported by this plugin */ +}; + +typedef struct +{ + int16 flags; /* Always 0 */ + int16 resolution; /* 0 = low, 1 = medium, 3 = high */ + uint16 palette[16]; /* Picture palette in Atari ST hardware format */ + int8 filename[12]; /* The original file name */ + int16 color_anim_limit; /* color animation limit */ + int16 color_anim_speed; /* color animation speed and direction */ + int16 color_steps; /* numbre of color step */ + int16 x_offset; /* image offset */ + int16 y_offset; /* " */ + int16 width; + int16 height; + int16 reserverd[33]; +} NEOHDR; + + +/*==================================================================================* + * boolean CDECL reader_init: * + * Open the file "name", fit the "info" struct. ( see zview.h) and make others * + * things needed by the decoder. * + *----------------------------------------------------------------------------------* + * input: * + * name -> The file to open. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL reader_init( const char *name, IMGINFO info) +{ + int32 position; + int16 handle; + NEOHDR *neo; + + if ( ( handle = ( int16)Fopen( name, 0)) < 0) + return FALSE; + + if( Fseek( 0L, handle, 2) != 32128L) + { + Fclose( handle); + return FALSE; + } + + Fseek( 0L, handle, 0); + + neo = ( NEOHDR *)malloc( 32128L); + + if ( neo == NULL) + { + Fclose( handle); + return FALSE; + } + + if ( Fread( handle, 32128L, neo) != 32128L) + { + free( neo); + Fclose( handle); + return FALSE; + } + + Fclose( handle); + + switch( neo->resolution) + { + case 0: + info->width = 320; + info->height = 200; + info->planes = 4; + info->components = 3; + info->indexed_color = TRUE; + info->colors = 16; + break; + + case 1: + info->width = 640; + info->height = 200; + info->planes = 2; + info->components = 3; + info->indexed_color = TRUE; + info->colors = 4; + break; + + case 2: + info->width = 640; + info->height = 400; + info->planes = 1; + info->components = 1; + info->indexed_color = FALSE; + info->colors = 2; + break; + + default: + free( neo); + return FALSE; + } + + position = sizeof( NEOHDR); + + info->real_width = info->width; + info->real_height = info->height; + info->memory_alloc = TT_RAM; + info->page = 1; + info->delay = 0; + info->orientation = UP_TO_DOWN; + info->num_comments = 0; + info->max_comments_length = 0; + info->_priv_ptr = ( void*)neo; + info->_priv_var_more = position; + + strcpy( info->info, "Neochrome"); + strcpy( info->compression, "None"); + + if( info->indexed_color) + { + register int16 i; + + for ( i = 0; i < info->colors; i++) + { + info->palette[i].red = ((( neo->palette[i] >> 7) & 0xE) + (( neo->palette[i] >> 11) & 0x1)) * 0x11; + info->palette[i].green = ((( neo->palette[i] >> 3) & 0xE) + (( neo->palette[i] >> 7) & 0x1)) * 0x11; + info->palette[i].blue = ((( neo->palette[i] << 1) & 0xE) + (( neo->palette[i] >> 3) & 0x1)) * 0x11; + } + } + + return TRUE; +} + + +/*==================================================================================* + * boolean CDECL reader_read: * + * This function fits the buffer with image data * + *----------------------------------------------------------------------------------* + * input: * + * buffer -> The destination buffer. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL reader_read( IMGINFO info, uint8 *buffer) +{ + NEOHDR *neo = ( NEOHDR*)info->_priv_ptr; + uint8 *l, *s = ( uint8*)neo + info->_priv_var_more; + uint16 x, c, p0, p1, p2, p3; + + switch( info->planes) + { + case 4: + for( x = 0, l = s; x < info->width; l += 8) + { + p0 = ( l[0] << 8) | l[1]; + p1 = ( l[2] << 8) | l[3]; + p2 = ( l[4] << 8) | l[5]; + p3 = ( l[6] << 8) | l[7]; + + for ( c = 0; c < 16; c++) + { + buffer[x++] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2) | ((p2 >> 13) & 4) | ((p3 >> 12) & 8); + p0 <<= 1; + p1 <<= 1; + p2 <<= 1; + p3 <<= 1; + } + } + info->_priv_var_more += 160; + break; + + case 2: + for ( x = 0, l = s; x < info->width; l += 4) + { + p0 = (l[0] << 8) | l[1]; + p1 = (l[2] << 8) | l[3]; + + for (c = 0; c < 16; c++) + { + buffer[x++] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2); + p0 <<= 1; + p1 <<= 1; + } + } + info->_priv_var_more += 160; + break; + + case 1: + for (x = 0, l = s; x < info->width; l += 2) + { + p0 = ( l[0] << 8) | l[1]; + + for ( c = 0; c < 16; c++) + { + buffer[x++] = ((p0 >> 15) & 1); + p0 <<= 1; + } + } + info->_priv_var_more += 80; + break; + } + + return TRUE; +} + + +/*==================================================================================* + * boolean CDECL reader_get_txt * + * This function , like other CDECL function mus be always present. * + * It fills txtdata struct. with the text present in the picture ( if any). * + *----------------------------------------------------------------------------------* + * input: * + * txtdata -> The destination text buffer. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata) +{ + return; +} + + +/*==================================================================================* + * boolean CDECL reader_quit: * + * This function makes the last job like close the file handler and free the * + * allocated memory. * + *----------------------------------------------------------------------------------* + * input: * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_quit( IMGINFO info) +{ + NEOHDR *neo = ( NEOHDR*)info->_priv_ptr; + + free( neo); +} + + +/*==================================================================================* + * boolean CDECL init: * + * First function called from zview, in this one, you can make some internal * + * initialisation. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL init( void) +{ +} + +/*==================================================================================* + * int main: * + * Main function, his job is to call ldg_init function. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * 0 * + *==================================================================================*/ +int main( void) +{ + ldg_init( &neo_plugin); + return( 0); +} diff --git a/sources/z-tools/trunk/zview/plugins/png/Makefile b/sources/z-tools/trunk/zview/plugins/png/Makefile new file mode 100644 index 0000000..6da0f63 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/png/Makefile @@ -0,0 +1,13 @@ +STACKSIZE = 64k +OPTIMISATION = -O2 -fomit-frame-pointer +CPU = -m68020-60 +LIB = -lpng -lz -lldgserver + +CFLAGS = $(CPU) $(OPTIMISATION) -Wall -I../common +LDFLAGS = -nostdlib + +OBJ = $(LDG_STARTUP_OBJ) pngldg.o + +PROGRAM = png.ldg + +include ../../../common.mak diff --git a/sources/z-tools/trunk/zview/plugins/png/copyright b/sources/z-tools/trunk/zview/plugins/png/copyright new file mode 100644 index 0000000..bee4c19 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/png/copyright @@ -0,0 +1,503 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/sources/z-tools/trunk/zview/plugins/png/pngldg.c b/sources/z-tools/trunk/zview/plugins/png/pngldg.c new file mode 100644 index 0000000..d865908 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/png/pngldg.c @@ -0,0 +1,364 @@ +#include "zview.h" +#include + +boolean CDECL reader_init( const char *name, IMGINFO info); +boolean CDECL reader_read( IMGINFO info, uint8 *buffer); +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata); +void CDECL reader_quit( IMGINFO info); +void CDECL init( void); + +#define alpha_composite( composite, fg, alpha, bg) { \ + uint16 register temp = (( uint16)( fg) * ( uint16)( alpha) + \ + ( uint16)( bg) * ( uint16)(255 - ( uint16)( alpha)) + ( uint16)128); \ + ( composite) = ( uint8)(( temp + ( temp >> 8)) >> 8); \ +} + +PROC PNGFunc[] = +{ + { "plugin_init", "", init}, + { "reader_init", "", reader_init}, + { "reader_get_txt", "", reader_get_txt}, + { "reader_read", "", reader_read}, + { "reader_quit", "", reader_quit} +}; + + +LDGLIB png_plugin = +{ + 0x0200, /* Plugin version */ + 5, /* Number of plugin's functions */ + PNGFunc, /* List of functions */ + "PNG", /* File's type Handled */ + LDG_NOT_SHARED, /* The flags NOT_SHARED is used here.. even if zview plugins are reentrant + and are shareable, we must use this flags because we don't know if the + user has ldg.prg deamon installed on his computer */ + NULL, /* Function called when the plugin is unloaded */ + 1L /* Howmany file type are supported by this plugin */ +}; + +boolean first_pass; +uint8 *line_buffer, *png_image, *png_image_ptr; +int16 number_passes; + + +/*==================================================================================* + * void tga_write_pixel_to_mem: * + * Write the pixel to the data regarding how the header says the data * + * is ordered. * + *----------------------------------------------------------------------------------* + * input: * + * dst -> the pixel is wrote here. * + * orientation -> the pixel orientation ( from TGA header). * + * pixel_position -> the pixel position in the x axis. * + * width -> the image's width. * + * pixel -> the 24 bits pixel to write. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +boolean CDECL reader_init( const char *name, IMGINFO info) +{ + png_structp png_ptr = NULL; + png_infop info_ptr = NULL; + FILE* png_file; + char header[8]; + int header_size = sizeof( header); +/* png_color_16 my_background = {0,0xFFFF,0xFFFF,0xFFFF,0xFFFF}; + png_color_16p image_background; +*/ + png_textp png_text_ptr; + int num_text; + + first_pass = TRUE; + png_image = NULL; + line_buffer = NULL; + number_passes = 0; + + + if ( ( png_file = fopen( name, "rb")) == NULL) + return FALSE; + + if ( fread( header, 1, header_size, png_file) != header_size || png_sig_cmp( header, 0, header_size)) + { + fclose ( png_file); + return FALSE; + } + + png_ptr = png_create_read_struct( PNG_LIBPNG_VER_STRING, NULL, 0, 0); + + if ( !png_ptr || ( info_ptr = png_create_info_struct ( png_ptr)) == NULL) + { + png_destroy_read_struct ( &png_ptr, &info_ptr, NULL); + fclose ( png_file); + return FALSE; + } + + if( setjmp( png_jmpbuf( png_ptr))) + { + png_destroy_read_struct( &png_ptr, &info_ptr, NULL); + fclose ( png_file); + return FALSE; + } + + png_init_io ( png_ptr, png_file); + png_set_sig_bytes ( png_ptr, ( int)header_size); + png_read_info ( png_ptr, info_ptr); + + if( png_get_color_type( png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) + png_set_expand( png_ptr); + if( png_get_color_type( png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY && png_get_bit_depth( png_ptr, info_ptr) < 8) + png_set_expand( png_ptr); + if( png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) + png_set_tRNS_to_alpha( png_ptr); + if( png_get_bit_depth( png_ptr, info_ptr) == 16) + png_set_strip_16( png_ptr); + if( png_get_color_type( png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY || png_get_color_type( png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_gray_to_rgb( png_ptr); + + strcpy( info->info, "Portable Network Format "); + strcpy( info->compression, "ZIP"); + + if ( png_get_interlace_type( png_ptr, info_ptr) == PNG_INTERLACE_ADAM7) + { + strcat( info->info, "( Interlaced)"); + number_passes = png_set_interlace_handling( png_ptr); + } + + png_read_update_info( png_ptr, info_ptr); + + png_get_text( png_ptr, info_ptr, &png_text_ptr, &num_text); + + info->width = png_get_image_width( png_ptr, info_ptr); + info->height = png_get_image_height( png_ptr, info_ptr); + info->real_width = info->width; + info->real_height = info->height; + info->memory_alloc = TT_RAM; + info->components = ( png_get_channels( png_ptr, info_ptr) > 3) ? 3 : png_get_channels( png_ptr, info_ptr); + info->planes = png_get_bit_depth( png_ptr, info_ptr); + info->colors = 1 << info->planes; + info->delay = 0; + info->orientation = UP_TO_DOWN; + info->page = 1; + info->num_comments = num_text; + info->max_comments_length = 0; + info->indexed_color = FALSE; + info->_priv_ptr = ( void*)png_ptr; + info->_priv_ptr_more = ( void*)info_ptr; + info->__priv_ptr_more = png_file; + + if( png_get_channels( png_ptr, info_ptr) == 4) + { + line_buffer = ( uint8*)malloc( png_get_rowbytes( png_ptr, info_ptr) + 64); + + if( line_buffer == NULL) + { + reader_quit( info); + return FALSE; + } + } + + if( num_text) + { + register int16 i; + + for ( i = 0; i < num_text; i++) + info->max_comments_length = MAX( info->max_comments_length, ( strlen(png_text_ptr[i].key) + png_text_ptr[i].text_length)); + + info->max_comments_length += 4; + } + + return TRUE; +} + + +/*==================================================================================* + * boolean CDECL reader_get_txt * + * This function , like other CDECL function mus be always present. * + * It fills txtdata struct. with the text present in the picture ( if any). * + *----------------------------------------------------------------------------------* + * input: * + * txtdata -> The destination text buffer. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata) +{ + register int16 i; + png_infop info_ptr = ( png_infop)info->_priv_ptr_more; + png_structp png_ptr = ( png_structp)info->_priv_ptr; + png_textp png_text_ptr; + int num_text; + + png_get_text( png_ptr, info_ptr, &png_text_ptr, &num_text); + + for ( i = 0; i < txtdata->lines; i++) + sprintf( txtdata->txt[i] , "%s: %s", png_text_ptr[i].key, png_text_ptr[i].text); +} + +/*==================================================================================* + * boolean CDECL reader_read: * + * This function fits the buffer with image data * + *----------------------------------------------------------------------------------* + * input: * + * buffer -> The destination buffer. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL reader_read( IMGINFO info, uint8 *buffer) +{ + png_structp png_ptr = ( png_structp)info->_priv_ptr; + png_infop info_ptr = ( png_infop)info->_priv_ptr_more; + uint8 *buf; + int16 i; + + if( png_get_channels( png_ptr, info_ptr) == 4) + buf = line_buffer; + else + buf = buffer; + + if( setjmp( png_jmpbuf( png_ptr))) + return FALSE; + + if( png_get_interlace_type( png_ptr, info_ptr) == PNG_INTERLACE_ADAM7) + { + /* We make the first pass here and not before to avoid memory fragmentation */ + if( first_pass == TRUE) + { + int16 pass; + + png_image = ( uint8*)malloc( png_get_rowbytes( png_ptr, info_ptr) * ( info->height + 1)); + + png_image_ptr = png_image; + + for ( pass = 1; pass < number_passes; pass++) + { + for( i = 0; i < info->height; i++) + { + png_bytep row = png_image + i * png_get_rowbytes( png_ptr, info_ptr); + png_read_row( png_ptr, row, NULL); + } + } + first_pass = FALSE; + } + + png_read_row( png_ptr, png_image_ptr, NULL); + memcpy( buf, png_image_ptr, png_get_rowbytes( png_ptr, info_ptr)); + png_image_ptr += png_get_rowbytes( png_ptr, info_ptr); + } + else + png_read_row( png_ptr, buf, NULL); + + + if( png_get_channels( png_ptr, info_ptr) == 4) + { + uint8 red, green, blue, r, g, b, a; + uint8 *dest = buffer, *buf_ptr = buf; + + for ( i = info->width; i > 0; --i) + { + r = *buf_ptr++; + g = *buf_ptr++; + b = *buf_ptr++; + a = *buf_ptr++; + + if( a == 255) + { + red = r; + green = g; + blue = b; + } + else if ( a == 0) + { + red = 0xFF; + green = 0xFF; + blue = 0xFF; + } + else + { + register uint32 transparent_color = info->background_color; + + alpha_composite( red, r, a, ( transparent_color >> 16) & 0xFF); + alpha_composite( green, g, a, ( transparent_color >> 8) & 0xFF); + alpha_composite( blue, b, a, ( transparent_color) & 0xFF); + } + + *dest++ = red; + *dest++ = green; + *dest++ = blue; + } + } + + return TRUE; +} + +/*==================================================================================* + * boolean CDECL reader_quit: * + * This function makes the last job like close the file handler and free the * + * allocated memory. * + *----------------------------------------------------------------------------------* + * input: * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_quit( IMGINFO info) +{ + png_structp png_ptr = ( png_structp)info->_priv_ptr; + png_infop info_ptr = ( png_infop)info->_priv_ptr_more; + + if ( png_ptr) + { + if( png_image) + free ( png_image); + + if( line_buffer) + free( line_buffer); + + if ( !setjmp( png_jmpbuf( png_ptr))) + png_read_end( png_ptr, info_ptr); + + png_destroy_read_struct ( &png_ptr, &info_ptr, NULL); + fclose( info->__priv_ptr_more); + info->_priv_ptr = NULL; + info->_priv_ptr_more = NULL; + info->__priv_ptr_more = NULL; + } +} + + +/*==================================================================================* + * boolean CDECL init: * + * First function called from zview, in this one, you can make some internal * + * initialisation. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL init( void) +{ + return; +} + +/*==================================================================================* + * int main: * + * Main function, his job is to call ldg_init function. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * 0 * + *==================================================================================*/ +int main( void) +{ + ldg_init( &png_plugin); + return( 0); +} diff --git a/sources/z-tools/trunk/zview/plugins/tga/Makefile b/sources/z-tools/trunk/zview/plugins/tga/Makefile new file mode 100644 index 0000000..1ca770c --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/tga/Makefile @@ -0,0 +1,13 @@ +STACKSIZE = 64k +OPTIMISATION = -O2 -fomit-frame-pointer -finline-functions +CPU = -m68020-60 +LIB = -lldgserver + +CFLAGS = $(CPU) $(OPTIMISATION) -Wall -I../common +LDFLAGS = -nostdlib + +OBJ = $(LDG_STARTUP_OBJ) tgaldg.o + +PROGRAM = tga.ldg + +include ../../../common.mak diff --git a/sources/z-tools/trunk/zview/plugins/tga/copyright b/sources/z-tools/trunk/zview/plugins/tga/copyright new file mode 100644 index 0000000..a1ef488 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/tga/copyright @@ -0,0 +1,503 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/sources/z-tools/trunk/zview/plugins/tga/libtarga.h b/sources/z-tools/trunk/zview/plugins/tga/libtarga.h new file mode 100644 index 0000000..27a5372 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/tga/libtarga.h @@ -0,0 +1,67 @@ +#ifndef _libtarga_h_ +#define _libtarga_h_ + +#define TGA_IMG_NODATA (0) +#define TGA_IMG_UNC_PALETTED (1) +#define TGA_IMG_UNC_TRUECOLOR (2) +#define TGA_IMG_UNC_GRAYSCALE (3) +#define TGA_IMG_RLE_PALETTED (9) +#define TGA_IMG_RLE_TRUECOLOR (10) +#define TGA_IMG_RLE_GRAYSCALE (11) + + +#define TGA_LOWER_LEFT (0) +#define TGA_LOWER_RIGHT (1) +#define TGA_UPPER_LEFT (2) +#define TGA_UPPER_RIGHT (3) + + +#define HDR_LENGTH (18) +#define HDR_IDLEN (0) +#define HDR_CMAP_TYPE (1) +#define HDR_IMAGE_TYPE (2) +#define HDR_CMAP_FIRST (3) +#define HDR_CMAP_LENGTH (5) +#define HDR_CMAP_ENTRY_SIZE (7) +#define HDR_IMG_SPEC_XORIGIN (8) +#define HDR_IMG_SPEC_YORIGIN (10) +#define HDR_IMG_SPEC_WIDTH (12) +#define HDR_IMG_SPEC_HEIGHT (14) +#define HDR_IMG_SPEC_PIX_DEPTH (16) +#define HDR_IMG_SPEC_IMG_DESC (17) + +typedef struct +{ + uint8 idlen; /* length of the image_id string below. */ + uint8 cmap_type; /* paletted image <=> cmap_type */ + uint8 image_type; /* can be any of the IMG_TYPE constants above. */ + uint16 cmap_first; + uint16 cmap_length; /* how long the colormap is */ + uint8 cmap_entry_size; /* how big a palette entry is. */ + uint16 img_spec_xorig; /* the x origin of the image in the image data.*/ + uint16 img_spec_yorig; /* the y origin of the image in the image data.*/ + uint16 img_spec_width; /* the width of the image. */ + uint16 img_spec_height; /* the height of the image. */ + uint8 img_spec_pix_depth; /* the depth of a pixel in the image. */ + uint8 img_spec_img_desc; /* the image descriptor. */ +} targa_hdr; + +#define TGA_TRUECOLOR_32 (4) +#define TGA_TRUECOLOR_24 (3) + +typedef struct +{ + int16 handle; + uint8 *img_buf; /* buffer for 1 line of packet TGA Data */ + uint8 alphabits; + uint8 bytes_per_pix; + uint8 orientation; + int32 line_size; + int32 img_buf_len; /* L„nge des IMG-Buffers */ + int32 img_buf_offset; /* Abstand zum Anfang des IMG-Buffers */ + int32 img_buf_used; /* Anzahl der benutzten Bytes des IMG-Buffers */ + int32 rest_length; /* noch einzulesende Dateil„nge */ + targa_hdr tga; +} tga_pic; + +#endif /* _libtarga_h_ */ diff --git a/sources/z-tools/trunk/zview/plugins/tga/tgaldg.c b/sources/z-tools/trunk/zview/plugins/tga/tgaldg.c new file mode 100644 index 0000000..5835986 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/tga/tgaldg.c @@ -0,0 +1,526 @@ +#include "zview.h" +#include "libtarga.h" + +#define alpha_composite( composite, fg, alpha) { \ + uint16 temp = (( uint16)( fg) * ( uint16)( alpha) + ( uint16)128); \ + ( composite) = ( uint8)(( temp + ( temp >> 8)) >> 8); \ +} + +static uint8 *unpack_line1( tga_pic *tga_struct, uint8 *src, uint8 *dst, uint16 line_width); +static int16 fill_img_buf( tga_pic *tga_struct, int32 read); +static int16 unpack_line( tga_pic *tga_struct, uint8 *dst); + +boolean CDECL reader_init( const char *name, IMGINFO info); +boolean CDECL reader_read( IMGINFO info, uint8 *buffer); +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata); +void CDECL reader_quit( IMGINFO info); +void CDECL init( void); + + +PROC TGAFunc[] = +{ + { "plugin_init", "", init}, + { "reader_init", "", reader_init}, + { "reader_get_txt", "", reader_get_txt}, + { "reader_read", "", reader_read}, + { "reader_quit", "", reader_quit} +}; + + +LDGLIB tga_plugin = +{ + 0x0200, /* Plugin version */ + 5, /* Number of plugin's functions */ + TGAFunc, /* List of functions */ + "TGA", /* File's type Handled */ + LDG_NOT_SHARED, /* The flags NOT_SHARED is used here.. even if zview plugins are reentrant + and are shareable, we must use this flags because we don't know if the + user has ldg.prg deamon installed on his computer */ + NULL, /* Function called when the plugin is unloaded */ + 1L /* Howmany file type are supported by this plugin */ +}; + + +/*==================================================================================* + * void tga_write_pixel_to_mem: * + * Write the pixel to the data regarding how the header says the data * + * is ordered. * + *----------------------------------------------------------------------------------* + * input: * + * dst -> the pixel is wrote here. * + * orientation -> the pixel orientation ( from TGA header). * + * pixel_position -> the pixel position in the x axis. * + * width -> the image's width. * + * pixel -> the 24 bits pixel to write. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +static inline void tga_write_pixel_to_mem( uint8 *dst, uint8 orientation, uint16 pixel_position, uint16 width, uint8 *rgb) +{ + register uint16 x, addy; + + switch( orientation) + { + case TGA_UPPER_LEFT: + case TGA_LOWER_LEFT: + default: + x = pixel_position % width; + break; + + case TGA_LOWER_RIGHT: + case TGA_UPPER_RIGHT: + x = width - 1 - ( pixel_position % width); + break; + } + + addy = x * 3; + + dst[addy++] = rgb[0]; + dst[addy++] = rgb[1]; + dst[addy] = rgb[2]; +} + + +/*==================================================================================* + * uint32 tga_convert_color: * + * Write the pixel to the data regarding how the header says the data * + * is ordered. * + *----------------------------------------------------------------------------------* + * input: * + * rgb -> bgra value. * + * bpp_in -> original image bitplanes. * + * alphabits -> Alpha bit... 1 if present else 0. * + *----------------------------------------------------------------------------------* + * return: * + * the converted pixel. * + *==================================================================================*/ +static inline void tga_convert_color( uint8 *bgra, uint8 *rgb, uint8 bpp_in, uint8 alphabits) +{ + uint8 r = 0, g = 0, b = 0, a = 0; + + switch( bpp_in) + { + case 32: + case 24: + if( alphabits) + { + /* not premultiplied alpha -- multiply. */ + a = bgra[3]; + alpha_composite( r, bgra[2], a); + alpha_composite( g, bgra[1], a); + alpha_composite( b, bgra[0], a); + } + else + { + r = bgra[2]; + g = bgra[1]; + b = bgra[0]; + } + break; + + case 16: + case 15: + { + /* 16-bit to 32-bit; (force alpha to full) */ + register uint16 src16 = (( ( uint16)bgra[1] << 8) | bgra[0]); + b = (( src16) & 0x001F) << 3; + g = (( src16 >> 5) & 0x001F) << 3; + r = (( src16 >> 10) & 0x001F) << 3; + break; + } + } + + rgb[0] = r; + rgb[1] = g; + rgb[2] = b; +} + + +/*==================================================================================* + * boolean CDECL reader_init: * + * Open the file "name", fit the "info" struct. ( see zview.h) and make others * + * things needed by the decoder. * + *----------------------------------------------------------------------------------* + * input: * + * name -> The file to open. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL reader_init( const char *name, IMGINFO info) +{ + uint32 num_pixels, file_length; + int16 handle, format = TGA_TRUECOLOR_24; + uint8 header_buf[HDR_LENGTH]; + tga_pic *tga_struct; + + if ( ( handle = ( int16)Fopen( name, 0)) < 0) + return FALSE; + + if( Fread( handle, HDR_LENGTH, &header_buf) != HDR_LENGTH) + { + Fclose( handle); + return FALSE; + } + + tga_struct = ( tga_pic*)malloc( sizeof( tga_pic)); + + if( tga_struct == NULL) + { + Fclose( handle); + return FALSE; + } + + /* byte order is important here. */ + tga_struct->tga.idlen = header_buf[0]; + tga_struct->tga.cmap_type = header_buf[1]; + tga_struct->tga.image_type = header_buf[2]; + tga_struct->tga.cmap_first = (uint16)header_buf[3] + ((uint16)header_buf[4] << 8); + tga_struct->tga.cmap_length = (uint16)header_buf[5] + ((uint16)header_buf[6] << 8); + tga_struct->tga.cmap_entry_size = header_buf[7]; + tga_struct->tga.img_spec_xorig = (uint16)header_buf[8] + ((uint16)header_buf[9] << 8); + tga_struct->tga.img_spec_yorig = (uint16)header_buf[10] + ((uint16)header_buf[11] << 8); + tga_struct->tga.img_spec_width = (uint16)header_buf[12] + ((uint16)header_buf[13] << 8); + tga_struct->tga.img_spec_height = (uint16)header_buf[14] + ((uint16)header_buf[15] << 8); + tga_struct->tga.img_spec_pix_depth = header_buf[16]; + tga_struct->tga.img_spec_img_desc = header_buf[17]; + + num_pixels = tga_struct->tga.img_spec_width * tga_struct->tga.img_spec_height; + + if( num_pixels == 0) + { + free( ( void*)tga_struct); + Fclose( handle); + return FALSE; + } + + file_length = Fseek( 0L, handle, 2); + + tga_struct->alphabits = tga_struct->tga.img_spec_img_desc & 0x0F; + tga_struct->handle = handle; + + /* seek past the image id, if there is one */ + if( Fseek( tga_struct->tga.idlen + HDR_LENGTH, handle, 0) < 0 ) + { + free( ( void*)tga_struct); + Fclose( handle); + return FALSE; + } + + /* if the image type is not supported, just jump out. */ + if( tga_struct->tga.image_type != TGA_IMG_UNC_TRUECOLOR && tga_struct->tga.image_type != TGA_IMG_RLE_TRUECOLOR) + { + free( ( void*)tga_struct); + Fclose( handle); + return FALSE; + } + + /* compute number of bytes in an image data unit (either index or BGR triple) */ + if( tga_struct->tga.img_spec_pix_depth & 0x07 ) + tga_struct->bytes_per_pix = ((( 8 - ( tga_struct->tga.img_spec_pix_depth & 0x07)) + tga_struct->tga.img_spec_pix_depth) >> 3); + else + tga_struct->bytes_per_pix = ( tga_struct->tga.img_spec_pix_depth >> 3); + + /* assume that there's one byte per pixel */ + if( tga_struct->bytes_per_pix == 0 ) + tga_struct->bytes_per_pix = 1; + + tga_struct->line_size = tga_struct->tga.img_spec_width * tga_struct->bytes_per_pix; + tga_struct->img_buf_len = tga_struct->line_size << 1; + + tga_struct->img_buf = ( uint8 *)malloc( tga_struct->img_buf_len + 256L); + + if( tga_struct->img_buf == NULL) + { + free( ( void*)tga_struct); + Fclose( handle); + return FALSE; + } + + tga_struct->orientation = ( tga_struct->tga.img_spec_img_desc & 0x30) >> 4; + tga_struct->rest_length = file_length - ( tga_struct->tga.idlen + HDR_LENGTH); + + if ( tga_struct->img_buf_len > tga_struct->rest_length) + tga_struct->img_buf_len = tga_struct->rest_length; + + tga_struct->img_buf_offset = 0; + tga_struct->img_buf_used = Fread( handle, tga_struct->img_buf_len, tga_struct->img_buf); + tga_struct->rest_length -= tga_struct->img_buf_used; + + info->width = tga_struct->tga.img_spec_width; + info->height = tga_struct->tga.img_spec_height; + info->real_width = info->width; + info->real_height = info->height; + info->memory_alloc = TT_RAM; + info->components = format; + info->planes = tga_struct->tga.img_spec_pix_depth; + info->colors = 1L << ( uint32)info->planes; + info->page = 1; + info->delay = 0; + info->num_comments = 0; + info->max_comments_length = 0; + info->indexed_color = FALSE; + info->_priv_ptr = ( void *)tga_struct; + + if( tga_struct->orientation == TGA_UPPER_LEFT || tga_struct->orientation == TGA_UPPER_RIGHT) + { + info->orientation = UP_TO_DOWN; + } + else + { + info->orientation = DOWN_TO_UP; + } + + strcpy( info->info, "Truevision Graphics Adapter"); + + if( tga_struct->tga.image_type == TGA_IMG_UNC_TRUECOLOR) + { + strcpy( info->compression, "None"); + } + else + { + strcpy( info->compression, "RLE"); + } + + return TRUE; +} + + +/*==================================================================================* + * int16 fill_img_buf: * + * fill the buffer "tga_struct->img_buf" with a line from file. * + * the buffer can contain 2 lines, this function search also where write the * + * new line from the file. * + *----------------------------------------------------------------------------------* + * input: * + * tga_struct -> tga_pic struct. with all the wanted information. * + * read -> internal counter. * + *----------------------------------------------------------------------------------* + * return: * + * Always 1 ( need to code something more secure) * + *==================================================================================*/ +static int16 fill_img_buf( tga_pic *tga_struct, int32 read) +{ + tga_struct->img_buf_used -= read; + tga_struct->img_buf_offset += read; + + if ( tga_struct->img_buf_offset >= ( tga_struct->img_buf_len >> 1)) + { + if ( tga_struct->img_buf_used > 0) + memcpy( tga_struct->img_buf, tga_struct->img_buf + tga_struct->img_buf_offset, tga_struct->img_buf_used); + + read = tga_struct->img_buf_offset; + + if ( read > tga_struct->rest_length ) + read = tga_struct->rest_length; + + read = Fread( tga_struct->handle, read, tga_struct->img_buf + tga_struct->img_buf_used); + + tga_struct->img_buf_used += read; + tga_struct->img_buf_offset = 0; + tga_struct->rest_length -= read; + } + + return( 1); +} + + +/*==================================================================================* + * uint8 *unpack_line1: * + * depack ( for RLE image) and copy data from source to destination. * + *----------------------------------------------------------------------------------* + * input: * + * tga_struct -> tga_pic struct. with all the wanted information. * + * src -> the source buffer. * + * dst -> the destination buffer. * + * line_width -> the image width. * + *----------------------------------------------------------------------------------* + * return: * + * Howmany source buffer position after that the job is done. * + *==================================================================================*/ +static uint8 *unpack_line1( tga_pic *tga_struct, uint8 *src, uint8 *dst, uint16 line_width) +{ + register uint16 i, j, bytes_per_pix = ( int16)tga_struct->bytes_per_pix; + uint8 bgra[4], rgb[3], packet_header, repcount; + + if( tga_struct->tga.image_type == TGA_IMG_UNC_TRUECOLOR) + { + for ( i = 0; i < line_width; i++) + { + for ( j = 0; j < bytes_per_pix; j++) + bgra[j] = *src++; + + tga_convert_color( &bgra[0], &rgb[0], tga_struct->tga.img_spec_pix_depth, tga_struct->alphabits); + tga_write_pixel_to_mem( dst, tga_struct->orientation, i, line_width, &rgb[0]); + } + } + else + { + register uint16 l; + + for( i = 0; i < line_width; ) + { + packet_header = *src++; + + if( packet_header & 0x80 ) + { + + for ( j = 0; j < bytes_per_pix; j++) + bgra[j] = *src++; + + tga_convert_color( &bgra[0], &rgb[0], tga_struct->tga.img_spec_pix_depth, tga_struct->alphabits); + + repcount = (packet_header & 0x7F) + 1; + + /* write all the data out */ + for( j = 0; j < repcount; j++ ) + tga_write_pixel_to_mem( dst, tga_struct->orientation, i + j, line_width, &rgb[0]); + + i += repcount; + } + else + { + repcount = ( packet_header & 0x7F) + 1; + + for( l = 0; l < repcount; l++) + { + for ( j = 0; j < bytes_per_pix; j++) + bgra[j] = *src++; + + tga_convert_color( &bgra[0], &rgb[0], tga_struct->tga.img_spec_pix_depth, tga_struct->alphabits); + + tga_write_pixel_to_mem( dst, tga_struct->orientation, i + l, line_width, &rgb[0]); + } + + i += repcount; + } + } + } + + return( src); +} + + +/*==================================================================================* + * int16 unpack_line: * + * Call the "source's buffer to destination's buffer" and * + * "image to source's buffer" functions. * + *----------------------------------------------------------------------------------* + * input: * + * tga_struct -> tga_pic struct. with all the wanted information. * + * dst -> the destination buffer. * + *----------------------------------------------------------------------------------* + * return: * + * 1 if ok else 0. * + *==================================================================================*/ +static int16 unpack_line( tga_pic *tga_struct, uint8 *dst) +{ + uint8 *line_begin; + int32 read; + + line_begin = tga_struct->img_buf + tga_struct->img_buf_offset; + + read = ( int32)( unpack_line1( tga_struct, line_begin, dst, ( uint16)tga_struct->tga.img_spec_width) - line_begin); + + if( fill_img_buf( tga_struct, read)) + return ( 1); + else + return ( 0); +} + + +/*==================================================================================* + * boolean CDECL reader_read: * + * This function fits the buffer with image data * + *----------------------------------------------------------------------------------* + * input: * + * buffer -> The destination buffer. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL reader_read( IMGINFO info, uint8 *buffer) +{ + tga_pic *tga_struct = ( tga_pic*)info->_priv_ptr; + + if( unpack_line( tga_struct, buffer)) + return TRUE; + else + return FALSE; +} + + +/*==================================================================================* + * boolean CDECL reader_get_txt * + * This function , like other CDECL function mus be always present. * + * It fills txtdata struct. with the text present in the picture ( if any). * + *----------------------------------------------------------------------------------* + * input: * + * txtdata -> The destination text buffer. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata) +{ + return; +} + + +/*==================================================================================* + * boolean CDECL reader_quit: * + * This function makes the last job like close the file handler and free the * + * allocated memory. * + *----------------------------------------------------------------------------------* + * input: * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_quit( IMGINFO info) +{ + tga_pic *tga_struct = ( tga_pic*)info->_priv_ptr; + + Fclose( tga_struct->handle); + free( tga_struct->img_buf); + free( ( void*)tga_struct); +} + + +/*==================================================================================* + * boolean CDECL init: * + * First function called from zview, in this one, you can make some internal * + * initialisation. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL init( void) +{ +} + + + +/*==================================================================================* + * int main: * + * Main function, his job is to call ldg_init function. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * 0 * + *==================================================================================*/ +int main( void) +{ + ldg_init( &tga_plugin); + return( 0); +} diff --git a/sources/z-tools/trunk/zview/plugins/tiff/Makefile b/sources/z-tools/trunk/zview/plugins/tiff/Makefile new file mode 100644 index 0000000..fe349b1 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/tiff/Makefile @@ -0,0 +1,13 @@ +STACKSIZE = 64k +OPTIMISATION = -O2 -fomit-frame-pointer -finline-functions +CPU = -m68020-60 +LIB = -ltiff -ljpeg -lz -lldgserver -lgcc + +CFLAGS = $(CPU) $(OPTIMISATION) -Wall -I. -I../common +LDFLAGS = -nostdlib + +OBJ = $(LDG_STARTUP_OBJ) tiffldg.o + +PROGRAM = tiff.ldg + +include ../../../common.mak diff --git a/sources/z-tools/trunk/zview/plugins/tiff/copyright b/sources/z-tools/trunk/zview/plugins/tiff/copyright new file mode 100644 index 0000000..a1ef488 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/tiff/copyright @@ -0,0 +1,503 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/sources/z-tools/trunk/zview/plugins/tiff/tiffldg.c b/sources/z-tools/trunk/zview/plugins/tiff/tiffldg.c new file mode 100644 index 0000000..2c85ac0 --- /dev/null +++ b/sources/z-tools/trunk/zview/plugins/tiff/tiffldg.c @@ -0,0 +1,422 @@ +#include +#define HAVE_INTS_DEFINED +#include "zview.h" + +#define alpha_composite( composite, fg, alpha) { \ + uint16 temp = (( uint16)( fg) * ( uint16)( alpha) + ( uint16)128); \ + ( composite) = ( uint8)(( temp + ( temp >> 8)) >> 8); \ +} + +void CDECL init( void); +boolean CDECL reader_init( const char *name, IMGINFO info); +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata); +boolean CDECL reader_read( IMGINFO info, uint8 *buffer); +void CDECL reader_quit( IMGINFO info); +boolean CDECL encoder_init( const char *name, IMGINFO info); +boolean CDECL encoder_write( IMGINFO info, uint8 *buffer); +void CDECL encoder_quit( IMGINFO info); +void CDECL set_tiff_option( int16 set_quality, uint16 set_encode_compression); + + +PROC TIFFFunc[] = +{ + { "plugin_init", "", init}, + { "reader_init", "", reader_init}, + { "reader_get_txt", "", reader_get_txt}, + { "reader_read", "", reader_read}, + { "reader_quit", "", reader_quit}, + { "encoder_init", "", encoder_init}, + { "encoder_write", "", encoder_write}, + { "encoder_quit", "", encoder_quit}, + { "set_tiff_option","", set_tiff_option} +}; + + +LDGLIB tiff_plugin = +{ + 0x0200, /* Plugin version */ + 9, /* Number of plugin's functions */ + TIFFFunc, /* List of functions */ + "TIFIFF", /* File's type Handled */ + LDG_NOT_SHARED, /* The flags NOT_SHARED is used here.. even if zview plugins are reentrant + and are shareable, we must use this flags because we don't know if the + user has ldg.prg deamon installed on his computer */ + NULL, /* Function called when the plugin is unloaded */ + 2L /* Howmany file type are supported by this plugin */ +}; + +uint16 encode_compression = COMPRESSION_LZW; +int quality = 75; + +/*==================================================================================* + * boolean CDECL reader_init: * + * Open the file "name", fit the "info" struct. ( see zview.h) and make others * + * things needed by the decoder. * + *----------------------------------------------------------------------------------* + * input: * + * name -> The file to open. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL reader_init( const char *name, IMGINFO info) +{ + TIFF *tif; + uint32 w, h, *raster; + uint16 compression, bitpersample, samplesperpixel, planes; + + if(( tif = TIFFOpen( name, "r")) == NULL) + { + return FALSE; + } + +/* + do + { + info->page++; + }while( TIFFReadDirectory( tif)); +*/ + + TIFFGetField( tif, TIFFTAG_IMAGEWIDTH, &w); + TIFFGetField( tif, TIFFTAG_IMAGELENGTH, &h); + TIFFGetField( tif, TIFFTAG_COMPRESSION, &compression); + TIFFGetField( tif, TIFFTAG_BITSPERSAMPLE, &bitpersample); + TIFFGetField( tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); + + planes = bitpersample * samplesperpixel; + + info->width = ( uint16)w; + info->height = ( uint16)h; + info->components = 3; + info->planes = planes; + info->indexed_color = FALSE; + info->page = 1; + + planes = MIN( 24, planes); + + info->colors = ( uint32)( 1uL << planes); + info->real_width = info->width; + info->real_height = info->height; + info->memory_alloc = TT_RAM; + info->delay = 0; + info->orientation = UP_TO_DOWN; + info->num_comments = 0; + info->max_comments_length = 0; + + + strcpy( info->info, "Tag Image File Format - TIFF"); + + switch( compression) + { + case 1: + strcpy( info->compression, "None"); + break; + case 2: /* CCITT modified Huffman RLE */ + strcpy( info->compression, "HRLE"); + break; + case 3: /* CCITT Group 3 fax encoding */ + strcpy( info->compression, "FAX3"); + break; + case 4: /* CCITT Group 4 fax encoding */ + strcpy( info->compression, "FAX4"); + break; + case 5: /* Lempel-Ziv & Welch */ + strcpy( info->compression, "LZW"); + break; + case 6: /* Old JPG, no supported ! */ + TIFFClose( tif); + return FALSE; + case 7: /* JPEG DCT compression */ + strcpy( info->compression, "JPEG"); + break; + case 32766: /* NeXT 2-bit RLE */ + strcpy( info->compression, "NeXT"); + break; + case 32771: /* #1 w/ word alignment RLE*/ + strcpy( info->compression, "RLEw"); + break; + case 32773: /* Macintosh RLE */ + strcpy( info->compression, "MAC"); + break; + case 32809: /* ThunderScan RLE */ + strcpy( info->compression, "Thun"); + break; + case 32895: /* IT8 CT w/padding */ + strcpy( info->compression, "IT8"); + break; + case 32896: /* IT8 Linework RLE */ + strcpy( info->compression, "IT8R"); + break; + case 32897: /* IT8 Monochrome picture */ + strcpy( info->compression, "IT8M"); + break; + case 32898: /* IT8 Binary line art */ + strcpy( info->compression, "IT8B"); + break; + case 32908: /* Pixar companded 10/11bit LZW */ + case 32909: + strcpy( info->compression, "Pixa"); + break; + case 8: + case 32946: /* Deflate compression */ + strcpy( info->compression, "Defl"); + break; + case 32947: /* Kodak DCS encoding */ + strcpy( info->compression, "DCS"); + break; + case 34661: /* ISO JBIG */ + strcpy( info->compression, "JBIG"); + break; + case 34676: /* SGI Log Luminance RLE / 24bits*/ + case 34677: + strcpy( info->compression, "SGI"); + break; + case 34712: /* Leadtools JPEG2000 */ + strcpy( info->compression, "JP20"); + break; + default: + strcpy( info->compression, "???"); + break; + } + + raster = ( uint32*)malloc( ( w * h) << 2); + + if( raster == NULL) + { + TIFFClose( tif); + return FALSE; + } + + info->_priv_ptr = ( void*)raster; + info->_priv_ptr_more = ( void*)raster; + info->__priv_ptr_more = ( void*)tif; + + if( TIFFReadRGBAImageOriented( tif, w, h, raster, ORIENTATION_TOPLEFT, 0)) + return TRUE; + + free( raster); + TIFFClose( tif); + return FALSE; +} + + +/*==================================================================================* + * boolean CDECL reader_read: * + * This function fits the buffer with image data * + *----------------------------------------------------------------------------------* + * input: * + * buffer -> The destination buffer. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL reader_read( IMGINFO info, uint8 *buffer) +{ + uint8 r = 0, g = 0, b = 0, a = 0; + uint16 i, j = 0; + uint32 *img = ( uint32*)info->_priv_ptr_more; + + for( i = 0; i < info->width; i++) + { + a = TIFFGetA(img[i]); + r = TIFFGetR(img[i]); + g = TIFFGetG(img[i]); + b = TIFFGetB(img[i]); + + alpha_composite( buffer[j++], r, a); + alpha_composite( buffer[j++], g, a); + alpha_composite( buffer[j++], b, a); + } + + info->_priv_ptr_more = ( uint32*)info->_priv_ptr_more + info->width; + + return TRUE; +} + + +/*==================================================================================* + * boolean CDECL reader_get_txt * + * This function , like other CDECL function must be always present. * + * It fills txtdata struct. with the text present in the picture ( if any). * + *----------------------------------------------------------------------------------* + * input: * + * txtdata -> The destination text buffer. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_get_txt( IMGINFO info, txt_data *txtdata) +{ + return; +} + + +/*==================================================================================* + * boolean CDECL reader_quit: * + * This function makes the last job like close the file handler and free the * + * allocated memory. * + *----------------------------------------------------------------------------------* + * input: * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL reader_quit( IMGINFO info) +{ + TIFF *tif = ( TIFF*)info->__priv_ptr_more; + + free( ( uint32*)info->_priv_ptr); + TIFFClose( tif); +} + + + +/*==================================================================================* + * boolean CDECL encoder_init: * + * Open the file "name", fit the "info" struct. ( see zview.h) and make others * + * things needed by the encoder. * + *----------------------------------------------------------------------------------* + * input: * + * name -> The file to open. * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL encoder_init( const char *name, IMGINFO info) +{ + TIFF *tif; + + if(( tif = TIFFOpen( name, "w")) == NULL) + { + return FALSE; + } + + TIFFSetField( tif, TIFFTAG_IMAGEWIDTH, ( uint32)info->width); + TIFFSetField( tif, TIFFTAG_IMAGELENGTH, ( uint32)info->height); + TIFFSetField( tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); + TIFFSetField( tif, TIFFTAG_SAMPLESPERPIXEL, 3); + TIFFSetField( tif, TIFFTAG_BITSPERSAMPLE, 8); + TIFFSetField( tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField( tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); + TIFFSetField( tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); + TIFFSetField( tif, TIFFTAG_COMPRESSION, encode_compression); + + if( encode_compression == COMPRESSION_JPEG) + { + TIFFSetField( tif, TIFFTAG_JPEGQUALITY, quality); + TIFFSetField( tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + } + + TIFFSetField( tif, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize( tif, 0)); + + info->planes = 24; + info->colors = 16777215L; + info->orientation = UP_TO_DOWN; + info->memory_alloc = TT_RAM; + info->indexed_color = FALSE; + info->page = 1; + info->delay = 0; + info->_priv_ptr = ( void*)tif; + info->_priv_ptr_more = NULL; + info->__priv_ptr_more = NULL; + info->_priv_var = 0uL; + info->_priv_var_more = 0uL; + + + return TRUE; +} + + +/*==================================================================================* + * boolean CDECLencoder_write: * + * This function write data from buffer to file * + *----------------------------------------------------------------------------------* + * input: * + * buffer -> The source buffer. * + * info -> The IMGINFO struct . * + *----------------------------------------------------------------------------------* + * return: * + * TRUE if all ok else FALSE. * + *==================================================================================*/ +boolean CDECL encoder_write( IMGINFO info, uint8 *buffer) +{ + if ( TIFFWriteScanline( ( TIFF *)info->_priv_ptr, buffer, info->_priv_var++, 0) < 0) + return FALSE; + + return TRUE; +} + + + +/*==================================================================================* + * boolean CDECL encoder_quit: * + * This function makes the last job like close the file handler and free the * + * allocated memory. * + *----------------------------------------------------------------------------------* + * input: * + * info -> The IMGINFO struct. to fit. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL encoder_quit( IMGINFO info) +{ + TIFF *tif = ( TIFF*)info->_priv_ptr; + + TIFFClose( tif); +} + + + +/*==================================================================================* + * boolean set_tiff_option: * + * This function set some encoder's options * + *----------------------------------------------------------------------------------* + * input: * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL set_tiff_option( int16 set_quality, uint16 set_encode_compression) +{ + encode_compression = set_encode_compression; + quality = set_quality; +} + + +/*==================================================================================* + * boolean CDECL init: * + * First function called from zview, in this one, you can make some internal * + * initialisation. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ +void CDECL init( void) +{ +} + + +/*==================================================================================* + * int main: * + * Main function, his job is to call ldg_init function. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * return: * + * 0 * + *==================================================================================*/ +int main( void) +{ + ldg_init( &tiff_plugin); + return( 0); +} diff --git a/sources/z-tools/trunk/zview/pref_dialog.c b/sources/z-tools/trunk/zview/pref_dialog.c new file mode 100644 index 0000000..a931290 --- /dev/null +++ b/sources/z-tools/trunk/zview/pref_dialog.c @@ -0,0 +1,223 @@ +#include "general.h" +#include "catalog/catalog.h" +#include "catalog/catalog_mini_entry.h" +#include "prefs.h" +#include "ztext.h" +#include "file/file.h" +#include "close_modal.h" + +static OBJECT *pref_dialog ; + +static int old_show_size = 0; +static int old_show_hidden = 0; +static int old_show_non_image = 0; +static int old_show_read_progress_bar = 0; +static int old_show_write_progress_bar = 0; +static int old_pdf_fit_to_win = 0; +static int old_pdf_aa = 0; +static int old_smooth_thumbnail = 0; + +static char *items[] = { "None", "Triangle", "Blackman", "Gaussian", "Quadratic", "Cubic", "Lanczos"}; +static int drive[] = { PREFS_A ,PREFS_B, PREFS_C, PREFS_D, PREFS_E, PREFS_F, PREFS_G, PREFS_H, PREFS_I, PREFS_J, +PREFS_K, PREFS_L, PREFS_M, PREFS_N, PREFS_O, PREFS_P, PREFS_Q, PREFS_R, PREFS_S, PREFS_T, PREFS_U, PREFS_V, PREFS_W, +PREFS_X, PREFS_Y, PREFS_Z}; +static int i, drv; + +static void format_popup( WINDOW *win, int obj_index) +{ + int16 x, y; + int choice; + + objc_offset( FORM(win), obj_index, &x, &y); + + choice = MenuPopUp ( items, x, y, 7, -1, smooth_thumbnail + 1, P_LIST + P_WNDW + P_CHCK); + + if( choice < 0) + return; + + smooth_thumbnail = choice - 1; + + strcpy( pref_dialog[PREFS_SMOOTH_METHOD].ob_spec.free_string, items[smooth_thumbnail]); + ObjcDraw( OC_FORM, win, PREFS_SMOOTH_METHOD, 1); +} + + +/*==================================================================================* + * void handle_preference: * + * Handle OK and CANCEL buttons in the preference dialog. * + *----------------------------------------------------------------------------------* + * input: * + * win -> Pointer to the preference window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +static void handle_preference( WINDOW *win) +{ + switch( evnt.buff[4]) + { + case PREFS_PDF_FIT_TO_WINDOW: + pdf_fit_to_win = ( ( pref_dialog[PREFS_PDF_FIT_TO_WINDOW].ob_state & SELECTED) ? 1 : 0); + break; + + case PREFS_PDF_ANTIALIAS: + pdf_aa = ( ( pref_dialog[PREFS_PDF_ANTIALIAS].ob_state & SELECTED) ? 1 : 0); + break; + + case PREFS_SHOW_SIZE: + show_size = ( ( pref_dialog[PREFS_SHOW_SIZE].ob_state & SELECTED) ? 1 : 0); + break; + + case PREFS_SHOW_HIDDEN: + show_hidden = ( ( pref_dialog[PREFS_SHOW_HIDDEN].ob_state & SELECTED) ? 1 : 0); + break; + + case PREFS_SHOW_NON_IMAGE: + show_non_image = ( ( pref_dialog[PREFS_SHOW_NON_IMAGE].ob_state & SELECTED) ? 1 : 0); + break; + + case PREFS_SHOW_READ_PROGRESS: + show_read_progress_bar = ( ( pref_dialog[PREFS_SHOW_READ_PROGRESS].ob_state & SELECTED) ? 1 : 0); + break; + + case PREFS_SHOW_WRITE_PROGRESS: + show_write_progress_bar = ( ( pref_dialog[PREFS_SHOW_WRITE_PROGRESS].ob_state & SELECTED) ? 1 : 0); + break; + + case PREFS_SMOOTH_METHOD: + format_popup( win, evnt.buff[4]); + ObjcChange( OC_FORM, win, evnt.buff[4], NORMAL, TRUE); + break; + + case PREFS_CANCEL: + smooth_thumbnail = old_smooth_thumbnail; + show_size = old_show_size; + show_hidden = old_show_hidden; + show_non_image = old_show_non_image; + show_read_progress_bar = old_show_read_progress_bar; + show_write_progress_bar = old_show_write_progress_bar; + pdf_fit_to_win = old_pdf_fit_to_win; + pdf_aa = old_pdf_aa; + + ObjcChange( OC_FORM, win, evnt.buff[4], ~SELECTED, TRUE) ; + ApplWrite( app.id, WM_CLOSED, win->handle, 0, 0, 0, 0); + break; + + case PREFS_OK: + ObjcChange( OC_FORM, win, evnt.buff[4], ~SELECTED, TRUE); + ApplWrite( app.id, WM_CLOSED, win->handle, 0, 0, 0, 0); + + skip_drive[0] = '\0'; + + for( i = 0; i < 26; i++) + { + drv = 'A' + i; + + if( pref_dialog[drive[i]].ob_state & SELECTED) + { + char t[2]; + sprintf( t, "%c", drv); + strcat( skip_drive, t); + } + } + + if( ( old_show_size != show_size) || + ( old_show_hidden != show_hidden) || + ( old_show_non_image != show_non_image)) + { + int16 dum, w, h; + + if( win_catalog) + { + WINDICON *wicones = ( WINDICON *)DataSearch( win_catalog, WD_ICON); + + wicones -> case_h = thumbnail[thumbnail_size][1] + hcell + y_space + y_space + y_space; + + if ( show_size) + wicones -> case_h += hcell + y_space; + + win_catalog -> h_u = wicones -> case_h; + + WindCalc( WC_BORDER, win_catalog, 0, 0, wicones->case_w + border_size + browser_frame_width, wicones->case_h, &dum, &dum, &w, &h); + + win_catalog -> h_min = h; + win_catalog -> w_min = w; + + + if( old_show_hidden != show_hidden) + { + ( void)scan_dir( win_catalog, wicones->directory); + win_catalog->ypos = 0; + snd_rdw( win_catalog); + WindMakePreview( win_catalog); + } + else + snd_rdw( win_catalog); + } + } + break; + + default: + break; + } + + /* a wait loop while the mouse button is pressed */ + while(( evnt.mbut == 1) || ( evnt.mbut == 2)) + graf_mkstate( &evnt.mx, &evnt.my, &evnt.mbut, &evnt.mkstate); +} + + +/*==================================================================================* + * void preference_dialog: * + * Show the preference dialog. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void preference_dialog( void) +{ + WINDOW *win; + int frms[] = { PREFS_PANEL1, PREFS_PANEL2, PREFS_PANEL3}; + int buts[] = { PREFS_GENERAL, PREFS_BROWSER, PREFS_PDF}; + + old_show_size = show_size; + old_show_hidden = show_hidden; + old_show_non_image = show_non_image; + old_show_read_progress_bar = show_read_progress_bar; + old_show_write_progress_bar = show_write_progress_bar; + old_pdf_fit_to_win = pdf_fit_to_win; + old_pdf_aa = pdf_aa; + old_smooth_thumbnail = smooth_thumbnail; + + pref_dialog = get_tree( PREFS); + + pref_dialog[PREFS_SHOW_SIZE].ob_state |= ( show_size ? SELECTED : NORMAL); + pref_dialog[PREFS_SHOW_HIDDEN].ob_state |= ( show_hidden ? SELECTED : NORMAL); + pref_dialog[PREFS_SHOW_NON_IMAGE].ob_state |= ( show_non_image ? SELECTED : NORMAL); + pref_dialog[PREFS_SHOW_READ_PROGRESS].ob_state |= ( show_read_progress_bar ? SELECTED : NORMAL); + pref_dialog[PREFS_SHOW_WRITE_PROGRESS].ob_state |= ( show_write_progress_bar ? SELECTED : NORMAL); + pref_dialog[PREFS_PDF_ANTIALIAS].ob_state |= ( pdf_aa ? SELECTED : NORMAL); + pref_dialog[PREFS_PDF_FIT_TO_WINDOW].ob_state |= ( pdf_fit_to_win ? SELECTED : NORMAL); + strcpy( pref_dialog[PREFS_SMOOTH_METHOD].ob_spec.free_string, items[smooth_thumbnail]); + + for( i = 0; i < 26; i++) + { + drv = 'A' + i; + + pref_dialog[drive[i]].ob_state |= ( strchr( skip_drive, drv) ? SELECTED : NORMAL); + } + + win = FormCreate( pref_dialog, NAME|MOVER, handle_preference, "Options", NULL, TRUE, FALSE); + + FormThumb( win, frms, buts, 3); + + WindSet( win, WF_BEVENT, BEVENT_MODAL, 0, 0, 0); + + EvntAttach( win, WM_CLOSED, close_modal); + + MenuDisable(); +} + diff --git a/sources/z-tools/trunk/zview/pref_dialog.h b/sources/z-tools/trunk/zview/pref_dialog.h new file mode 100644 index 0000000..f573c32 --- /dev/null +++ b/sources/z-tools/trunk/zview/pref_dialog.h @@ -0,0 +1,2 @@ +extern void preference_dialog( void); + diff --git a/sources/z-tools/trunk/zview/prefs.c b/sources/z-tools/trunk/zview/prefs.c new file mode 100644 index 0000000..147757f --- /dev/null +++ b/sources/z-tools/trunk/zview/prefs.c @@ -0,0 +1,286 @@ +#include "general.h" + +/* thumbnail size in a 3D integer*/ +int thumbnail[8][2] = { /* 4:3 size */ { 64, 48}, { 96, 72}, { 120, 90}, { 180, 135}, + /* 3:4 size */ { 48, 64}, { 72, 96}, { 90, 120}, { 135, 180}}; + +/* File's Browser Preferences */ +int show_size = 1; /* show file size */ +int show_hidden = 0; /* show hidden file */ +int show_non_image = 1; /* show non-image file */ +int browser_x = 0; /* Win catalog x, y, w, h position/size */ +int browser_y = 0; /* " */ +int browser_w = 0; /* " */ +int browser_h = 0; /* " */ +int sortingmode = 0; /* File's sorting mode: 0) by name, 1) by size, 2) by date */ +int thumbnail_size = 1; /* thumbnail size */ +int browser_frame_width = 200; /* folder's browser frame width */ +int preview_frame_height = 200; /* as the integer's name say :) */ +int show_read_progress_bar = 1; /* show the read progress bar */ +int show_write_progress_bar = 1; /* show the write progress bar */ +char skip_drive[27] = "ABU"; /* Skip this drives in the browser */ +int smooth_thumbnail = 0; /* 0 = None, 1 = Triangle, 2 = Blackman, 3 = Gaussian, 4 = Quadratic, 5 = Cubic, 6 = Lanczos */ +int pdf_fit_to_win = 1; /* Fit the PDF to the Window */ +int pdf_aa = 1; /* Font Antialiasing */ + +/* Prototype */ +int prefs_read( void); +int prefs_write( void); + + +/*==================================================================================* + * prefs_read: * + * Reads the content of the INF file an put it in the preference global variables. * + *----------------------------------------------------------------------------------* + * returns: 0 if error * + *==================================================================================*/ +int prefs_read( void) +{ + char filename[256] = ""; + char unknown_s[256] = ""; + FILE *inffile; + int32 filepos; + char *env_home; + int16 len; + boolean valid_entry_found; + + + shel_envrn( &env_home, "HOME="); + + /* Home directory exist? */ + if ( env_home != NULL) + { + strcpy( filename, env_home); + len = ( int16)strlen( filename); + + if ((filename[len - 1] != '\\') && (filename[len - 1] != '/')) + { + strcat( filename, "\\"); + } + + strcat( filename, "zview.inf"); + + if (( inffile = fopen( filename, "rb+")) != NULL) + goto loop; + + } + + /* With ftell, we MUST open the file in binary mode and not in text mode !!! */ + if (( inffile = fopen( "zview.inf", "rb+")) == NULL) + return( 0); + +loop: + + do + { + valid_entry_found = FALSE; + + filepos = ftell( inffile); + + if ( fscanf( inffile, "show_size=%d ", &show_size) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "show_hidden=%d ", &show_hidden) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "show_non_image=%d ", &show_non_image) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "browser_x=%d ", &browser_x) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "browser_y=%d ", &browser_y) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + + if ( fscanf( inffile, "browser_w=%d ", &browser_w) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "browser_h=%d ", &browser_h) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "sortingmode=%d ", (int *)&sortingmode) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "thumbnail_size=%d ", &thumbnail_size) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "browser_frame_width=%d ", &browser_frame_width) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "preview_frame_height=%d ", &preview_frame_height) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "show_read_progress_bar=%d ", &show_read_progress_bar) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "show_write_progress_bar=%d ", &show_write_progress_bar) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "skip_drive=%s ", skip_drive) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "smooth_thumbnail=%d ", &smooth_thumbnail) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "pdf_fit_to_win=%d ", &pdf_fit_to_win) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "pdf_aa=%d ", &pdf_aa) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "%s ", unknown_s) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + } while ( valid_entry_found); + + fclose( inffile); + + return( 1); +} + + + +/*==================================================================================* + * prefs_write: * + * Writes the preference variables in the preference file. * + *----------------------------------------------------------------------------------* + * returns: 0 if error * + *==================================================================================*/ +int prefs_write( void) +{ + char filename[256] = ""; + FILE *inffile; + char *env_home; + int16 len; + + shel_envrn( &env_home, "HOME="); + + /* Home directory exist? */ + if ( env_home != NULL) + strcpy( filename, env_home); + else + strcpy( filename, zview_path); + + len = ( int16)strlen( filename); + + if ((filename[len - 1] != '\\') && (filename[len - 1] != '/')) + strcat( filename, "\\"); + + strcat( filename, "zview.inf"); + + /* With ftell, we MUST open the file in binary mode and not in text mode !!! */ + if (( inffile = fopen( filename, "wb+")) == NULL) + return( 0); + + fprintf( inffile, "show_size=%d\r\n", show_size); + fprintf( inffile, "show_hidden=%d\r\n", show_hidden); + fprintf( inffile, "show_non_image=%d\r\n", show_non_image); + fprintf( inffile, "browser_x=%d\r\n", browser_x); + fprintf( inffile, "browser_y=%d\r\n", browser_y); + fprintf( inffile, "browser_w=%d\r\n", browser_w); + fprintf( inffile, "browser_h=%d\r\n", browser_h); + fprintf( inffile, "sortingmode=%d\r\n", (int )sortingmode); + fprintf( inffile, "thumbnail_size=%d\r\n", thumbnail_size); + fprintf( inffile, "browser_frame_width=%d\r\n", browser_frame_width); + fprintf( inffile, "preview_frame_height=%d\r\n", preview_frame_height); + fprintf( inffile, "show_read_progress_bar=%d\r\n", show_read_progress_bar); + fprintf( inffile, "show_write_progress_bar=%d\r\n", show_write_progress_bar); + fprintf( inffile, "skip_drive=%s\r\n", skip_drive); + fprintf( inffile, "smooth_thumbnail=%d\r\n", smooth_thumbnail); + fprintf( inffile, "pdf_fit_to_win=%d\r\n", pdf_fit_to_win); + fprintf( inffile, "pdf_aa=%d\r\n", pdf_aa); + + fclose( inffile); + return( 1); +} diff --git a/sources/z-tools/trunk/zview/prefs.h b/sources/z-tools/trunk/zview/prefs.h new file mode 100644 index 0000000..209be2f --- /dev/null +++ b/sources/z-tools/trunk/zview/prefs.h @@ -0,0 +1,27 @@ +/* Global variable */ +extern int thumbnail[8][2]; +extern int show_size; +extern int show_hidden; +extern int show_non_image; +extern int browser_x; +extern int browser_y; +extern int browser_w; +extern int browser_h; +extern int sortingmode; +extern int thumbnail_size; +extern int browser_frame_width; +extern int preview_frame_height; +extern int show_read_progress_bar; +extern int show_write_progress_bar; +extern int empty_trash_confirmation; +extern int pdf_fit_to_win; +extern int pdf_aa; +extern int smooth_thumbnail; +extern char skip_drive[32]; + + +/* Function */ +extern int prefs_read( void); +extern int prefs_write( void); + + diff --git a/sources/z-tools/trunk/zview/progress.c b/sources/z-tools/trunk/zview/progress.c new file mode 100644 index 0000000..325bb22 --- /dev/null +++ b/sources/z-tools/trunk/zview/progress.c @@ -0,0 +1,118 @@ +#include "general.h" +#include "ztext.h" + +/* Prototype */ +void win_progress_begin( char *string); +void win_progress( int16 new_bar_width); +void win_progress_end( void); + +/* Local variable */ +WINDOW *win_read = NULL; + + +/*==================================================================================* + * int16 win_read_progress_begin: * + * Open the read's progress bar dialog ( if needed). * + *----------------------------------------------------------------------------------* + * input: * + * string -> The text to show in the progress bar. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void win_progress_begin( char *string) +{ + W_FORM *form; + OBJECT *progress_bar = get_tree( SINGLE_PROGRESS); + +// wind_update( BEG_MCTRL); + + zstrncpy( progress_bar[SINGLE_PROGRESS_TXT].ob_spec.tedinfo->te_ptext, string, 25); + + win_read = FormCreate( progress_bar, MOVER|NAME, NULL, "", NULL, 0, 0); + + form = ( W_FORM *)DataSearch( win_read, WD_WFRM); + + vsf_color( win_read->graf.handle, BLUE); + + EvntRedraw( win_read); +} + + +/*==================================================================================* + * void win_read_progress: * + * redraw the bar with the news coordinates computed. * + *----------------------------------------------------------------------------------* + * input: * + * new_bar_width -> the size of the progress bar. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void win_progress( int16 new_bar_width) +{ + static int16 bar_width = 1; + int16 pxy[4]; + GRECT rwin, raes; + W_FORM *form = ( W_FORM *)DataSearch( win_read, WD_WFRM); + + if ( bar_width == new_bar_width) + return; + + WindGet( win_read, WF_WORKXYWH, &rwin.g_x, &rwin.g_y, &rwin.g_w, &rwin.g_h); + + bar_width = new_bar_width; + + pxy[0] = rwin.g_x + form->root[SINGLE_PROGRESS_CONTAINER].ob_x; + pxy[1] = rwin.g_y + form->root[SINGLE_PROGRESS_CONTAINER].ob_y; + pxy[2] = pxy[0] + bar_width; + pxy[3] = pxy[1] + form->root[SINGLE_PROGRESS_CONTAINER].ob_height - 1; + + while( !wind_update( BEG_UPDATE)); + graf_mouse( M_OFF, 0L); + wind_get( win_read->handle, WF_FIRSTXYWH, &raes.g_x, &raes.g_y, &raes.g_w, &raes.g_h); + + while ( raes.g_w && raes.g_h) + { + if( rc_intersect( &rwin, &raes)) + { + rc_clip_on( win_read->graf.handle, &raes); + + v_bar( win_read->graf.handle, pxy); + + rc_clip_off( win_read->graf.handle); + } + + wind_get( win_read->handle, WF_NEXTXYWH, &raes.g_x, &raes.g_y, &raes.g_w, &raes.g_h); + } + + graf_mouse( M_ON, 0L); + + wind_update( END_UPDATE); +} + + +/*==================================================================================* + * void win_read_progress_end: * + * Destroy the read's progress formular. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void win_progress_end( void) +{ + if ( win_read == NULL) + return; + + snd_msg( win_read, WM_DESTROY, 0, 0, 0, 0); + +// wind_update( END_MCTRL); + + win_read = NULL; +} diff --git a/sources/z-tools/trunk/zview/progress.h b/sources/z-tools/trunk/zview/progress.h new file mode 100644 index 0000000..e37248e --- /dev/null +++ b/sources/z-tools/trunk/zview/progress.h @@ -0,0 +1,3 @@ +extern void win_progress_begin( char *string); +extern void win_progress( int16 new_bar_width); +extern void win_progress_end( void); diff --git a/sources/z-tools/trunk/zview/resample.c b/sources/z-tools/trunk/zview/resample.c new file mode 100644 index 0000000..9124c33 --- /dev/null +++ b/sources/z-tools/trunk/zview/resample.c @@ -0,0 +1,313 @@ +#include "general.h" +#include "mfdb.h" +#include "pic_load.h" +#include "zvdi/pixel.h" +#include + +#define MagickEpsilon 1.0e-6 + +typedef struct +{ + double weight; + long pixel; +}ContributionInfo; + +typedef struct +{ + double (*function)( double); + double support; +} FilterInfo; + + +static double ( *algo)( double x) = NULL; +double algo_support = 3.0f; + + +static inline uint8 RoundToQuantum( double value) +{ + if( value < 0.0) + return( 0); + + if ( value >= 255.0) + return(( uint8) 255); + + return(( uint8)( value + 0.5)); +} + + +static double Sinc( double x) +{ + if( x == 0.0) + return( 1.0); + + return( sin( x) / x); +} + + +static double Lanczos( double x) +{ + x = fabs(x); + + return( x < 3.0) ? Sinc( M_PI * x) * Sinc( 1.0471975511965977461533333333333 * x) : 0.0; +} + + + +static double Gaussian( double x) +{ + return( exp((double)( -2.0 * x * x)) * sqrt( 2.0 / M_PI)); +} + + +static double Cubic( double x) +{ + if( x < -2.0) + return( 0.0); + if( x < -1.0) + return( ( 2.0 + x) * ( 2.0 + x) * ( 2.0 + x) / 6.0); + if( x < 0.0) + return( ( 4.0 + x * x * ( -6.0 - 3.0 * x)) / 6.0); + if( x < 1.0) + return( ( 4.0 + x * x * ( -6.0 + 3.0 * x)) / 6.0); + if( x < 2.0) + return( ( 2.0 - x) * ( 2.0 - x) * ( 2.0 - x) / 6.0); + + return(0.0); +} + + +static double Blackman( double x) +{ + return( 0.42 + 0.5 * cos( M_PI * ( double)x) + 0.08 * cos( 2 * M_PI * (double) x)); +} + +static double Triangle( double x) +{ + if( x < -1.0) + return( 0.0); + if( x < 0.0) + return( 1.0 + x); + if( x < 1.0) + return( 1.0 - x); + + return( 0.0); +} + + +static double Quadratic( double x) +{ + if( x < -1.5) + return( 0.0); + if( x < -0.5) + return( 0.5 * ( x + 1.5) * ( x + 1.5)); + if( x < 0.5) + return( 0.75 - x * x); + if( x < 1.5) + return( 0.5 * ( x - 1.5) * ( x - 1.5)); + + return( 0.0); +} + + +static void HorizontalFilter( MFDB *source, MFDB *destination, double x_factor, ContributionInfo *contribution) +{ + long start, stop; + double center, density, scale, support; + register long i, x, y, n; + uint8 source_red, source_green, source_blue; + uint32 source_line_size, dst_line_size; + + source_line_size = (( uint32)source->fd_wdwidth << 1 ) * ( uint32)source->fd_nplanes; + dst_line_size = (( uint32)destination->fd_wdwidth << 1 ) * ( uint32)destination->fd_nplanes; + scale = MAX( 1.0 / x_factor, 1.0); + support = scale * algo_support; + + if( support <= 0.5) + { + /* Reduce to point sampling. */ + support = ( double)( 0.5 + MagickEpsilon); + scale = 1.0; + } + + scale = 1.0 / scale; + + for( x = 0; x < destination->fd_w; x++) + { + center = ( double)( x + 0.5) / x_factor; + start = ( long)MAX( center - support + 0.5, 0); + stop = ( long)MIN( center + support + 0.5, ( double)source->fd_w); + density = 0.0; + + for( n = 0; n < (stop-start); n++) + { + contribution[n].pixel = start + n; + contribution[n].weight = algo( scale * (( double)( start + n) - center + 0.5)); + density += contribution[n].weight; + } + + if(( density != 0.0) && ( density != 1.0)) + { + density = 1.0 / density; + + for( i = 0; i < n; i++) + contribution[i].weight *= density; + } + /* source->fd_h */ + for( y = 0; y < destination->fd_h; y++) + { + register double gamma = 0.0; + register double red = 0.0; + register double green = 0.0; + register double blue = 0.0; + + for( i = 0; i < n; i++) + { + getPixel( contribution[i].pixel, y, source_line_size, &source_red, &source_green, &source_blue, source->fd_addr); + + red += contribution[i].weight * source_red; + green += contribution[i].weight * source_green; + blue += contribution[i].weight * source_blue; + gamma += contribution[i].weight; + } + + gamma = 1.0 / ( fabs( gamma) <= MagickEpsilon ? 1.0 : gamma); + + setPixel( x, y, dst_line_size, RoundToQuantum( gamma * red), RoundToQuantum( gamma * green), RoundToQuantum( gamma * blue), destination->fd_addr); + } + } +} + + + +static void VerticalFilter( MFDB *source, MFDB *destination, double y_factor, ContributionInfo *contribution) +{ + register long i, y, x, n; + long start, stop; + double center, density, scale, support; + uint8 source_red, source_green, source_blue; + uint32 source_line_size, dst_line_size; + + source_line_size = (( uint32)source->fd_wdwidth << 1 ) * ( uint32)source->fd_nplanes; + dst_line_size = (( uint32)destination->fd_wdwidth << 1 ) * ( uint32)destination->fd_nplanes; + scale = MAX( 1.0 / y_factor, 1.0); + support = scale * algo_support; + + if( support <= 0.5) + { + /* Reduce to point sampling. */ + support = ( double)( 0.5 + MagickEpsilon); + scale = 1.0; + } + + scale = 1.0 / scale; + + for( y = 0; y < destination->fd_h; y++) + { + center = ( double)( y + 0.5) / y_factor; + start = ( long)MAX( center - support + 0.5, 0); + stop = ( long)MIN( center + support + 0.5, ( double) source->fd_h); + density = 0.0; + + for( n = 0; n < ( stop - start); n++) + { + contribution[n].pixel = start + n; + contribution[n].weight = algo( scale * (( double)( start + n) - center + 0.5)); + density += contribution[n].weight; + } + + if(( density != 0.0) && ( density != 1.0)) + { + /* Normalize. */ + density = 1.0 / density; + + for( i = 0; i < n; i++) + contribution[i].weight *= density; + } + + for ( x = 0; x < destination->fd_w; x++) + { + register double gamma = 0.0; + register double red = 0.0; + register double green = 0.0; + register double blue = 0.0; + + for ( i = 0; i < n; i++) + { + getPixel( x, contribution[i].pixel, source_line_size, &source_red, &source_green, &source_blue, source->fd_addr); + + red += contribution[i].weight * source_red; + green += contribution[i].weight * source_green; + blue += contribution[i].weight * source_blue; + gamma += contribution[i].weight; + } + + gamma = 1.0 / ( fabs( gamma) <= MagickEpsilon ? 1.0 : gamma); + + setPixel( x, y, dst_line_size, RoundToQuantum( gamma * red), RoundToQuantum( gamma * green), RoundToQuantum( gamma * blue), destination->fd_addr); + } + } +} + +int16 smooth_resize( MFDB *source_image, MFDB *resized_image, int resize_algo) +{ + MFDB tmp_img; + double support, x_factor, x_support, y_factor, y_support; + ContributionInfo *contribution; + + static const FilterInfo filters[7] = + { + { NULL, 0}, + { Triangle, 1.0f}, + { Blackman, 1.0f}, + { Gaussian, 1.25f}, + { Quadratic, 1.5f}, + { Cubic, 2.0f}, + { Lanczos, 3.0f} + }; + + algo = filters[resize_algo].function; + algo_support = filters[resize_algo].support; + + x_factor = (double) resized_image->fd_w / (double) source_image->fd_w; + y_factor = (double) resized_image->fd_h / (double) source_image->fd_h; + x_support = MAX( 1.0 / x_factor, 1.0) * algo_support; + y_support = MAX( 1.0 / y_factor, 1.0) * algo_support; + support = MAX( x_support, y_support); + + if( support < algo_support) + support = algo_support; + + contribution = ( ContributionInfo *)gmalloc( ( size_t)( 2.0 * MAX( support, 0.5) + 3) * sizeof( *contribution)); + + if( contribution == NULL) + return 0; + + /* Resize image. */ + if (( resized_image->fd_w * (( uint32) source_image->fd_h + resized_image->fd_h)) > ( resized_image->fd_h * ((uint32) source_image->fd_w + resized_image->fd_w))) + { + if( !init_mfdb( &tmp_img, resized_image->fd_w, source_image->fd_h, app.nplanes)) + { + gfree(contribution); + return 0; + } + + HorizontalFilter( source_image , &tmp_img, x_factor, contribution); + VerticalFilter( &tmp_img, resized_image, y_factor, contribution); + } + else + { + if( !init_mfdb( &tmp_img, source_image->fd_w, resized_image->fd_h, app.nplanes)) + { + gfree(contribution); + return 0; + } + + VerticalFilter( source_image, &tmp_img, y_factor, contribution); + HorizontalFilter( &tmp_img, resized_image, x_factor, contribution); + } + + gfree( contribution); + gfree( tmp_img.fd_addr); + + return 1; +} diff --git a/sources/z-tools/trunk/zview/save_dialog.c b/sources/z-tools/trunk/zview/save_dialog.c new file mode 100644 index 0000000..010adbc --- /dev/null +++ b/sources/z-tools/trunk/zview/save_dialog.c @@ -0,0 +1,273 @@ +#include "general.h" +#include "prefs.h" +#include "plugins.h" +#include "close_modal.h" +#include "ztext.h" +#include "pic_load.h" +#include "catalog/catalog.h" +#include "file/file.h" + + +void CDECL ( *encoder_quit) ( IMGINFO); +boolean CDECL ( *encoder_write) ( IMGINFO, uint8 *); +boolean CDECL ( *encoder_init) ( const char *, IMGINFO); +void CDECL ( *set_jpg_option) ( int16 set_quality, J_COLOR_SPACE set_color_space, boolean set_progressive) = NULL; +void CDECL ( *set_tiff_option)( int16 set_quality, uint16 set_encode_compression) = NULL; + +/* extern function */ +extern int16 pic_save( const char *in_file, const char *out_file); +extern void jpg_option_dialog( char *source_file); +extern void tiff_option_dialog( void); + +int16 encoder_plugins_nbr = 0; +LDG *encoder[100]; + + +/* Prototype */ +void save_dialog( const char *fullfilename); + + +/* local variable */ +static int last_choice = -1; +static OBJECT *save_dialog_content = NULL; + +char source_file[MAXNAMLEN]; + + +static boolean encoder_plugin_setup( WINDOW *win, int encoder_selected) +{ + encoder_init = ldg_find( "encoder_init", encoder[encoder_selected]); + encoder_write = ldg_find( "encoder_write", encoder[encoder_selected]); + encoder_quit = ldg_find( "encoder_quit", encoder[encoder_selected]); + + if ( !encoder_init || !encoder_write || !encoder_quit) + { + errshow( encoder[encoder_selected]->infos, ldg_error()); + return FALSE; + } + + set_jpg_option = NULL; + set_tiff_option = NULL; + + if( strncmp( encoder[encoder_selected]->infos, "JPG", 3) == 0) + set_jpg_option = ldg_find( "set_jpg_option", encoder[encoder_selected]); + else if( strncmp( encoder[encoder_selected]->infos, "TIF", 3) == 0) + set_tiff_option = ldg_find( "set_tiff_option", encoder[encoder_selected]); + else + ObjcChange( OC_FORM, win, SAVE_DIAL_OPTIONS, DISABLED, 0); + + zstrncpy( save_dialog_content[SAVE_DIAL_FORMAT].ob_spec.free_string, encoder[encoder_selected]->infos, 4); + + if( set_jpg_option != NULL || set_tiff_option != NULL) + ObjcChange( OC_FORM, win, SAVE_DIAL_OPTIONS, NORMAL, 0); + + ObjcDraw( OC_FORM, win, SAVE_DIAL_FORMAT, 1); + ObjcDraw( OC_FORM, win, SAVE_DIAL_OPTIONS, 1); + + return TRUE; +} + + +static void format_popup( WINDOW *win, int obj_index) +{ + char items[100][4]; + char *items_ptr[100]; + int16 i, x, y; + int choice; + + for( i = 0; i < encoder_plugins_nbr; i++) + { + zstrncpy( items[i], encoder[i]->infos, 4); + items_ptr[i] = items[i]; + } + + objc_offset( FORM(win), obj_index, &x, &y); + + choice = MenuPopUp ( items_ptr, x, y, encoder_plugins_nbr, -1, last_choice, P_LIST + P_WNDW + P_CHCK); + + if( choice < 1) + choice = 1; + + if( last_choice != choice) + encoder_plugin_setup( win, choice - 1); + + last_choice = choice; + + if( last_choice) + ObjcChange( OC_FORM, win, SAVE_DIAL_SAVE, NORMAL, TRUE); + else + ObjcChange( OC_FORM, win, SAVE_DIAL_SAVE, DISABLED, TRUE); +} + + +static void save_dialog_event( WINDOW *win) +{ + char target_file[MAX_PATH+MAXNAMLEN]; + char target_file_path[MAX_PATH]; + char target_file_name[MAXNAMLEN]; + char extention[3]; + char file_mask[5]; + int16 object = evnt.buff[4], source_file_len, source_name_len, source_path_len, i; + + switch( object) + { + case SAVE_DIAL_FORMAT: + format_popup( win, evnt.buff[4]); + ObjcChange( OC_FORM, win, evnt.buff[4], NORMAL, TRUE); + break; + + case SAVE_DIAL_OPTIONS: + if( strncmp( encoder[last_choice-1]->infos, "JPG", 3) == 0) + { + ObjcChange( OC_FORM, win, object, NORMAL, TRUE); + jpg_option_dialog( source_file); + } + else if( strncmp( encoder[last_choice-1]->infos, "TIF", 3) == 0) + { + ObjcChange( OC_FORM, win, object, NORMAL, TRUE); + tiff_option_dialog(); + } + break; + + case SAVE_DIAL_SAVE: + source_file_len = ( int16)strlen( source_file); + + source_path_len = source_file_len; + + while(( source_file[source_path_len] != '/') && ( source_file[source_path_len] != '\\')) + source_path_len--; + + source_name_len = ( source_file_len - source_path_len); + + strncpy( target_file_path, source_file, source_path_len); + + target_file_path[source_path_len] = '\0'; + + source_path_len++; + + for ( i = 0; i < source_name_len; i++) + target_file_name[i] = source_file[source_path_len++]; + + target_file_name[i] = '\0'; + + /* copy the source's name in the target's name with the new extention for exemple ( "toto.gif" to "toto.jpg") */ + zstrncpy( extention, encoder[last_choice - 1]->infos, 4); + str2lower( extention); + strcpy ( target_file_name + strlen( target_file_name) - 3, extention); + + /* The file mask ( for exemple *.jpg) */ + strcpy( file_mask, "*."); + strcat( file_mask, extention); + + ObjcChange( OC_FORM, win, evnt.buff[4], NORMAL, FALSE); + close_modal( win); + + if( FselInput( target_file_path, target_file_name, file_mask, get_string( SAVE_TITLE), NULL, NULL)) + { + strcpy( target_file, target_file_path); + + /* workaround for a bug in tos fileselector, when we navigate through this one, the file name is deleted */ + if( strlen( target_file_name) < 5) + { + source_path_len -= i; + + for ( i = 0; i < source_name_len; i++) + target_file_name[i] = source_file[source_path_len++]; + + target_file_name[i] = '\0'; + } + + strcat( target_file, target_file_name); + + /* for be sure that the extention match with the encoder */ + strcpy ( target_file + strlen( target_file) - 4, file_mask + 1); + + /* with fat filesystem, the file selector return upper case name, some the strcmp() function doens't work */ + str2lower( source_file); + str2lower( target_file); + + /* the source can't be the same that the destination */ + if( strcmp( source_file, target_file) == 0) + { + errshow( NULL, SOURCE_TARGET_SAME); + break; + } + + if( !pic_save( source_file, target_file)) + break; + + /* if the new file is added in the same dir that win_catalog, we refresh it */ + if( win_catalog) + { + WINDICON *wicones = (WINDICON *)DataSearch( win_catalog, WD_ICON); + + //strcat( target_file_path, "\\"); + + if( strcmpi( target_file_path, wicones->directory) == 0) + { + ( void)scan_dir( win_catalog, wicones->directory); + WinCatalog_filelist_redraw(); + ObjcDraw( OC_TOOLBAR, win_catalog, TOOLBAR_DELETE, 1); + ObjcDraw( OC_TOOLBAR, win_catalog, TOOLBAR_INFO, 1); + ObjcDraw( OC_TOOLBAR, win_catalog, TOOLBAR_SAVE, 1); + menu_ienable( get_tree( MENU_BAR), MENU_BAR_DELETE, 0); + menu_ienable( get_tree( MENU_BAR), MENU_BAR_INFORMATION, 0); + menu_ienable( get_tree( MENU_BAR), MENU_BAR_SAVE, 0); + } + } + } + break; + + case SAVE_DIAL_ABORT: + ObjcChange( OC_FORM, win, evnt.buff[4], NORMAL, FALSE); + ApplWrite( app.id, WM_CLOSED, win->handle, 0, 0, 0, 0); + break; + } +} + +/*==================================================================================* + * void infobox: * + * Show the infobox for a image or a file. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void save_dialog( const char *fullfilename) +{ + WINDOW *win_save_dialog; + + if( !encoder_plugins_nbr) + { + int16 i; + + for( i = 0; i < plugins_nbr; i++) + { + if( ldg_find( "encoder_init", codecs[i])) + { + encoder[encoder_plugins_nbr] = codecs[i]; + encoder_plugins_nbr++; + } + } + + if( !encoder_plugins_nbr) + return; + } + + strcpy( source_file, fullfilename); + + save_dialog_content = get_tree( SAVE_DIAL); + + win_save_dialog = FormCreate( save_dialog_content, NAME|MOVER, save_dialog_event, get_string( SAVE_TITLE), NULL, TRUE, FALSE); + + /* Make this window modal */ + WindSet( win_save_dialog, WF_BEVENT, BEVENT_MODAL, 0, 0, 0); + + EvntAttach( win_save_dialog, WM_CLOSED, close_modal); + + MenuDisable(); + +} + diff --git a/sources/z-tools/trunk/zview/tiff_dialog.c b/sources/z-tools/trunk/zview/tiff_dialog.c new file mode 100644 index 0000000..019955b --- /dev/null +++ b/sources/z-tools/trunk/zview/tiff_dialog.c @@ -0,0 +1,117 @@ +#include "general.h" +#include "prefs.h" +#include "ztext.h" +#include "pic_load.h" +#include "catalog/catalog.h" + +#define COMPRESSION_NONE 1 /* dump mode */ +#define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ +#define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ +#define COMPRESSION_JPEG 7 /* JPEG DCT compression */ +#define COMPRESSION_DEFLATE 32946 /* Deflate compression */ + +OBJECT *tiff_option_content; +void *tiff_option_slider = NULL; + +static int16 quality = 75; +static uint16 compression = COMPRESSION_NONE; +static int compression_button = 0; + + +extern void CDECL ( *set_tiff_option)( int16 set_quality, uint16 set_encode_compression); + + +static void tiff_option_close( WINDOW *win) +{ + free( tiff_option_slider); + frm_cls( win); +} + +static void tiff_option_ok_event( WINDOW *win, int16 obj_index) +{ + switch( compression_button) + { + case TIFFPREF_DEFLATE: + compression = COMPRESSION_DEFLATE; + break; + case TIFFPREF_JPEG: + compression = COMPRESSION_JPEG; + break; + case TIFFPREF_LZW: + compression = COMPRESSION_LZW; + break; + case TIFFPREF_RLE: + compression = COMPRESSION_PACKBITS; + break; + default: + compression = COMPRESSION_NONE; + break; + } + + set_tiff_option( quality, compression); + + ObjcChange( OC_FORM, win, obj_index, NORMAL, TRUE); + ApplWrite( app.id, WM_CLOSED, win->handle, 0, 0, 0, 0); +} + + +static void tiff_option_slider_event( WINDOW *win, int mode, float value) +{ + quality = ( int16)value; + evnt_timer( 50); + sprintf( ObjcString( FORM( win), TIFFPREF_PERCENT, NULL), "%d", quality); + ObjcDraw( mode, win, TIFFPREF_PERCENT, TRUE); +} + +/*==================================================================================* + * void tiff_option_dialog: * + * Open and handle TIFF encoder option dialog. * + *----------------------------------------------------------------------------------* + * input: * + * -- * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void tiff_option_dialog( void) +{ + WINDOW *win; + + tiff_option_content = get_tree( TIFFPREF); + + sprintf( ObjcString( tiff_option_content, TIFFPREF_PERCENT, NULL), "%d", quality); + + tiff_option_content[TIFFPREF_SL].ob_x = quality; + + if( ( win = FormCreate( tiff_option_content, NAME|MOVER, NULL, get_string( TIFF_OPTION_TITLE), NULL, TRUE, FALSE)) == NULL) + { + errshow( "", ALERT_WINDOW); + return; + } + + WindSet( win, WF_BEVENT, BEVENT_MODAL, 0, 0, 0); + + if( ( tiff_option_slider = SlidCreate( 1, 100, 1, 10, quality, SLD_HORI, SLD_IMME)) == NULL) + { + WindClose( win); + errshow( "", ENOMEM); + return; + } + + + EvntAttach( win, WM_CLOSED, tiff_option_close); + SlidAttach( tiff_option_slider, OC_FORM, win, TIFFPREF_LF, TIFFPREF_PG, TIFFPREF_SL, TIFFPREF_RT); + SlidSetFunc( tiff_option_slider, tiff_option_slider_event, NULL); + + if( compression == COMPRESSION_NONE) + ObjcChange( OC_FORM, win, TIFFPREF_None, SELECTED, TRUE); + + ObjcAttach( OC_FORM, win, TIFFPREF_None, BIND_VAR, &compression_button); + ObjcAttach( OC_FORM, win, TIFFPREF_RLE, BIND_VAR, &compression_button); + ObjcAttach( OC_FORM, win, TIFFPREF_LZW, BIND_VAR, &compression_button); + ObjcAttach( OC_FORM, win, TIFFPREF_JPEG, BIND_VAR, &compression_button); + ObjcAttach( OC_FORM, win, TIFFPREF_DEFLATE, BIND_VAR, &compression_button); + + ObjcAttach( OC_FORM, win, TIFFPREF_OK, BIND_FUNC, tiff_option_ok_event); +} + diff --git a/sources/z-tools/trunk/zview/todo.txt b/sources/z-tools/trunk/zview/todo.txt new file mode 100644 index 0000000..20dc7ce --- /dev/null +++ b/sources/z-tools/trunk/zview/todo.txt @@ -0,0 +1,39 @@ +- PDF window: zView should always remember which zoom has been set when the +- next +or previous page is shown. At the moment, it displays a new page with 100% +- or +fitted to the window (last one if the option "Fit PDF to the window" is set) +regardless of the zoom set by the user beforehand via the zoom buttons. + +- Keyboard shortcuts: a) It would be great to be able to use + +- not +just for the browser and image windows but also for the options dialogues +- and +the PDF windows. b) Some more shortcuts: + +All windows: + + = changing windows + +Browser and PDF window: + + cursor up = page up + + cursor down = page down + = beginning of the page + + = end of the page + +Browser window: + + = go back button (switches to the contents of the +directory above the present one) + = update directory button +<+> = enlarge thumbnail size button +<-> = reduce thumbnail size button + +Image windows: +<+> = enlarge picture size button (zoom) +<-> = reduce picture size button (zoom) +<*> = full screen button + +PDF windows: +<+> = enlarge page size button (zoom) +<-> = reduce page size button (zoom) + + cursor right/up = next page button + + cursor left/down = previous page button diff --git a/sources/z-tools/trunk/zview/txt_data.c b/sources/z-tools/trunk/zview/txt_data.c new file mode 100644 index 0000000..f63f329 --- /dev/null +++ b/sources/z-tools/trunk/zview/txt_data.c @@ -0,0 +1,72 @@ +#include "general.h" +#include "pic_load.h" + +/*==================================================================================* + * delete_txt_data: * + * free memory reserved in txt_data struct. * + *----------------------------------------------------------------------------------* + * IMAGE *img: The IMAGE struct where is the txt_data struct. to handle. * + *----------------------------------------------------------------------------------* + * returns: -- * + *==================================================================================*/ +void delete_txt_data( IMAGE *img) +{ + int16 i; + + if( !img->comments) + return; + + for ( i = 0; i < img->comments->lines; i++) + { + if( img->comments->txt[i]) + gfree( img->comments->txt[i]); + } + + gfree( img->comments); + img->comments = NULL; +} + + +/*==================================================================================* + * init_txt_data: * + * Initialisation with various shared_malloc of the txt_data struct. * + * This struct. will contain the comment of the picture or the EXIF data. * + *----------------------------------------------------------------------------------* + * txtdata: The IMAGE struct where is the txt_dataThe IMAGE struct * + * where is the txt_data struct. to be initialized. * + * lines: The number of lines in the text. * + * max_lines_length: The line size in character. * + *----------------------------------------------------------------------------------* + * returns: 0 if error else 1 * + *==================================================================================*/ +int16 init_txt_data( IMAGE *img, int16 lines, int16 max_lines_length) +{ + int16 i; + size_t line_size = max_lines_length * sizeof( int8); + + img->comments = gmalloc( sizeof( txt_data)); + + if( !img->comments) + return( 0); + + if( lines > 255) + img->comments->lines = 255; + else + img->comments->lines = lines; + + img->comments->max_lines_length = max_lines_length; + + for ( i = 0; i < img->comments->lines; i++) + { + img->comments->txt[i] = gmalloc( line_size); + + if( !img->comments->txt[i]) + { + delete_txt_data( img); + return( 0); + } + } + + return( 1); +} + diff --git a/sources/z-tools/trunk/zview/txt_data.h b/sources/z-tools/trunk/zview/txt_data.h new file mode 100644 index 0000000..639f7db --- /dev/null +++ b/sources/z-tools/trunk/zview/txt_data.h @@ -0,0 +1,3 @@ +extern void delete_txt_data( IMAGE *img); +extern int16 init_txt_data( IMAGE *img, int16 lines, int16 max_lines_length); + diff --git a/sources/z-tools/trunk/zview/types2b.h b/sources/z-tools/trunk/zview/types2b.h new file mode 100644 index 0000000..9eade7b --- /dev/null +++ b/sources/z-tools/trunk/zview/types2b.h @@ -0,0 +1,43 @@ +#ifndef __2B_UNIVERSAL_TYPES__ +#define __2B_UNIVERSAL_TYPES__ + +typedef signed char int8; +typedef unsigned char uint8; +typedef signed long int32; +typedef unsigned long uint32; +typedef int32 fix31; + +#ifdef __GNUC__ + typedef signed short int16; + typedef unsigned short uint16; + #define __2B_HAS64_SUPPORT /* Compiler supports 64 Bit Integers */ + typedef signed long long int64; + typedef unsigned long long uint64; +#else /* Compiler doesn't support 64 Bit Integers */ + typedef signed int int16; + typedef unsigned int uint16; + + typedef struct + { + int32 hi; + uint32 lo; + } int64; + + typedef struct + { + int32 hi; + uint32 lo; + } loff_t; + + typedef struct + { + uint32 hi; + uint32 lo; + } uint64; +#endif + + +typedef int32 boolean; + + +#endif /* __2B_UNIVERSAL_TYPES__ */ diff --git a/sources/z-tools/trunk/zview/winimg.c b/sources/z-tools/trunk/zview/winimg.c new file mode 100644 index 0000000..97729eb --- /dev/null +++ b/sources/z-tools/trunk/zview/winimg.c @@ -0,0 +1,1085 @@ +#include "general.h" +#include "prefs.h" +#include "mfdb.h" +#include "txt_data.h" +#include "pic_load.h" +#include "winimg.h" +#include "winpdf.h" +#include "full_scr.h" +#include "menu.h" +#include "infobox.h" +#include "pdf_load.h" +#include "pdf/pdflib.h" +#include "pic_resize.h" +#include "wintimer.h" +#include "ztext.h" +#include "custom_font.h" +#include "catalog/catalog.h" +#include "catalog/catalog_other_event.h" +#include "catalog/catalog_icons.h" +#include "catalog/catalog_slider.h" + + +static int16 dum; + +extern void save_dialog( const char *fullfilename); + +/* Prototype */ +WINDOW *WindView( char *filename); + +/*==================================================================================* + * void WindViewIcon: * + * Function to handle iconfied windows drawing... If the icon doesn't exist, * + * It is created. * + *----------------------------------------------------------------------------------* + * input: * + * win -> the window to handle. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void WindViewIcon( WINDOW *win) +{ + int16 posx, posy, x, y, w, h, xy[8]; + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + IMAGE *wview = &windata->img; + MFDB *out = NULL, screen = {0}; + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + + if( wview->image[windata->page_to_show].fd_w > w || wview->image[windata->page_to_show].fd_h > h) + { + if( windata->icon.fd_addr == NULL) + { + windata->icon.fd_w = w; + windata->icon.fd_h = h; + + if( pic_resize( &wview->image[windata->page_to_show], &windata->icon) == 0) + { + draw_window_iconified( win); + return; + } + } + } + + xy[0] = x; + xy[1] = y; + xy[2] = xy[0] + w - 1; + xy[3] = xy[1] + h - 1; + + vsf_color( win->graf.handle, BLACK); + v_bar( win->graf.handle, xy); + + if( windata->icon.fd_addr) + out = &windata->icon; + else + out = &wview->image[windata->page_to_show]; + + posx = MAX( x + (( w - out->fd_w) >> 1), x); + posy = MAX( y + (( h - out->fd_h) >> 1), y); + + if (posx == x) + xy[2] = w - 1; + else + xy[2] = out->fd_w - 1; + + if (posy == y) + xy[3] = h - 1; + else + xy[3] = out->fd_h - 1; + + xy[0] = 0; + xy[1] = 0; + xy[4] = posx; + xy[5] = posy; + xy[6] = posx + xy[2]; + xy[7] = posy + xy[3]; + + /* draw the image */ + if ( wview->image[0].fd_nplanes == 1) + { + int16 color[2] = { BLACK, WHITE}; + + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, out, &screen, color); + } + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, out, &screen); +} + + + +static void WindViewZoom( WINDOW *win) +{ + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + MFDB *picture = &windata->zoom_picture; + IMAGE *img = &windata->img; + uint16 width = 0, height = 0; + + if( ( img->page > 1) && ( img->delay[0] > 0)) + return; + + if( windata->zoom_picture.fd_addr != NULL) + { + gfree( windata->zoom_picture.fd_addr); + windata->zoom_picture.fd_addr = NULL; + } + + switch ( windata->zoom_level) + { + case 200: + width = img->image[windata->page_to_show].fd_w << 1; + height = img->image[windata->page_to_show].fd_h << 1; + break; + + case 150: + width = (uint16)MAX(( ( double)img->image[windata->page_to_show].fd_w * 1.5 + 0.5), 1.0); + height = (uint16)MAX(( ( double)img->image[windata->page_to_show].fd_h * 1.5 + 0.5), 1.0); + break; + + case 100: + break; + + case 50: + width = (uint16)MAX(( ( double)img->image[windata->page_to_show].fd_w * 0.5 + 0.5), 1.0); + height = (uint16)MAX(( ( double)img->image[windata->page_to_show].fd_h * 0.5 + 0.5), 1.0); + break; + + case 25: + width = (uint16)MAX(( ( double)img->image[windata->page_to_show].fd_w * 0.25 + 0.5), 1.0); + height = (uint16)MAX(( ( double)img->image[windata->page_to_show].fd_h * 0.25 + 0.5), 1.0); + break; + + default: + width = (uint16)MAX(( (( double)img->image[windata->page_to_show].fd_w * ( double)windata->zoom_level) / 100.0 + 0.5), 1.0); + height = (uint16)MAX(( (( double)img->image[windata->page_to_show].fd_h * ( double)windata->zoom_level) / 100.0 + 0.5), 1.0); + break; + } + + + if(( windata->zoom_level == 100) || ( width < 16 && height < 16)) + { + EvntRedraw( win); + return; + } + + windata->zoom_picture.fd_w = width; + windata->zoom_picture.fd_h = height; + + + if( !pic_resize( &img->image[windata->page_to_show], &windata->zoom_picture)) + { + errshow( "", ENOMEM); + windata->zoom_level = 100; + } + + win -> ypos_max = ( int32)( ( picture->fd_h + 1) >> 3); + win -> xpos_max = ( int32)( ( picture->fd_w) >> 3); + win -> ypos = 0; + win -> xpos = 0; + + EvntRedraw( win); +} + + +/*==================================================================================* + * WindViewTool: * + * Toolbar binding. * + *----------------------------------------------------------------------------------* + * input: * + * win -> Pointer to the target window * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ +void WindViewTop( WINDOW *win); +static void WindViewTool( WINDOW *win) +{ + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + int16 zoom; + + switch( evnt.buff[4]) + { + case VIEWTOOLBAR_SMALL: + zoom = windata->zoom_level; + + if( windata->zoom_level <= 25) + return; + else if( windata->zoom_level > 200) + windata->zoom_level = 200; + else if( windata->zoom_level > 150) + windata->zoom_level = 150; + else if( windata->zoom_level > 100) + windata->zoom_level = 100; + else if( windata->zoom_level > 50) + windata->zoom_level = 50; + else if( windata->zoom_level > 25) + windata->zoom_level = 25; + + WindViewZoom( win); + + if( zoom >= 200 && windata->zoom_level < 200) + ObjcDraw( OC_TOOLBAR, win, VIEWTOOLBAR_BIG, 1); + break; + + case VIEWTOOLBAR_BIG: + zoom = windata->zoom_level; + + if( windata->zoom_level >= 200) + return; + else if( windata->zoom_level < 25) + windata->zoom_level = 25; + else if( windata->zoom_level < 50) + windata->zoom_level = 50; + else if( windata->zoom_level < 100) + windata->zoom_level = 100; + else if( windata->zoom_level < 150) + windata->zoom_level = 150; + else if( windata->zoom_level < 200) + windata->zoom_level = 200; + + WindViewZoom( win); + + if( zoom <= 25 && windata->zoom_level > 25) + ObjcDraw( OC_TOOLBAR, win, VIEWTOOLBAR_SMALL, 1); + break; + + case VIEWTOOLBAR_OPEN: + Menu_open_image(); + break; + + case VIEWTOOLBAR_FULLSCREEN: + show_fullscreen( windata); + break; + + case VIEWTOOLBAR_SAVE: + save_dialog( windata->name); + break; + + case VIEWTOOLBAR_INFO: + WindViewTop( win); + infobox(); + break; + + default: + break; + } + + ObjcChange( OC_TOOLBAR, win, evnt.buff[4], NORMAL, 1); +} + + + +void WindViewTop( WINDOW *win) +{ + OBJECT *menu = get_tree( MENU_BAR); + + menu_ienable( menu, MENU_BAR_SHOW_FULLSCREEN, 1); + menu_ienable( menu, MENU_BAR_INFORMATION, 1); + menu_ienable( menu, MENU_BAR_SAVE, 1); + menu_ienable( menu, MENU_BAR_DELETE, 0); + WindSet( win, WF_TOP, win->handle, 0, 0, 0); + wglb.appfront = wglb.front = win; +} + + +static void WindViewKeyb( WINDOW *win) +{ + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + int16 zoom; + + switch ( evnt.keybd >> 8) + { + case SC_UPARW: + if( !( evnt.mkstate & ( K_LSHIFT|K_RSHIFT))) + snd_arrw( win, WA_UPLINE); + else + case SC_PGUP: + snd_arrw( win, WA_UPPAGE); + break; + + case SC_DWARW: + if( !( evnt.mkstate & ( K_LSHIFT|K_RSHIFT))) + snd_arrw( win, WA_DNLINE); + else + case SC_PGDN: /* page down */ + snd_arrw( win, WA_DNPAGE); + break; + + case SC_LFARW: + if( !( evnt.mkstate & ( K_LSHIFT|K_RSHIFT))) + snd_arrw( win, WA_LFLINE); + else + snd_arrw( win, WA_LFPAGE); + break; + + case SC_RTARW: + if( !( evnt.mkstate & ( K_LSHIFT|K_RSHIFT))) + snd_arrw( win, WA_RTLINE); + else + snd_arrw( win, WA_RTPAGE); + break; + + case SC_MINUS: + zoom = windata->zoom_level; + + if( windata->zoom_level <= 25) + return; + else if( windata->zoom_level > 200) + windata->zoom_level = 200; + else if( windata->zoom_level > 150) + windata->zoom_level = 150; + else if( windata->zoom_level > 100) + windata->zoom_level = 100; + else if( windata->zoom_level > 50) + windata->zoom_level = 50; + else if( windata->zoom_level > 25) + windata->zoom_level = 25; + + WindViewZoom( win); + ObjcDraw( OC_TOOLBAR, win, VIEWTOOLBAR_SMALL, 1); + + if( zoom >= 200 && windata->zoom_level < 200) + ObjcDraw( OC_TOOLBAR, win, VIEWTOOLBAR_BIG, 1); + + break; + + case SC_PLUS: + zoom = windata->zoom_level; + + if( windata->zoom_level >= 200) + return; + else if( windata->zoom_level < 25) + windata->zoom_level = 25; + else if( windata->zoom_level < 50) + windata->zoom_level = 50; + else if( windata->zoom_level < 100) + windata->zoom_level = 100; + else if( windata->zoom_level < 150) + windata->zoom_level = 150; + else if( windata->zoom_level < 200) + windata->zoom_level = 200; + + WindViewZoom( win); + ObjcDraw( OC_TOOLBAR, win, VIEWTOOLBAR_BIG, 1); + + if( zoom <= 25 && windata->zoom_level > 25) + ObjcDraw( OC_TOOLBAR, win, VIEWTOOLBAR_SMALL, 1); + + break; + + case SC_SPACE: + if( win->status & WS_ICONIFY) + return; + + if( windata->pause == FALSE) windata->pause = TRUE; + else windata->pause = FALSE; + break; + + default: + break; + } +} + + +static void WindViewRedraw( WINDOW *win) +{ + int16 xw, yw, ww, hw, tmp, xy[8], pxy[4], page; + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + MFDB *picture, screen = {0}; + + page = windata->page_to_show; + + WindGet( win, WF_WORKXYWH, &xw, &yw, &ww, &hw); + + pxy[0] = xw; + pxy[1] = yw; + pxy[2] = pxy[0] + ww - 1; + pxy[3] = yw; + + vsl_color( win->graf.handle, BLACK); + v_pline( win->graf.handle, 2, pxy); + + yw++; + + /* if the picture or the zoomed picture don't exist, we draw a gray rectangle and we exit the function*/ + if( windata->zoom_picture.fd_addr) + picture = &windata->zoom_picture; + else if( windata->img.image[page].fd_addr) + picture = &windata->img.image[page]; + else + { + pxy[0] = xw; + pxy[1] = yw; + pxy[2] = pxy[0] + ww - 1; + pxy[3] = pxy[1] + hw - 1; + + vsf_color( win->graf.handle, LWHITE); + v_bar( win->graf.handle, pxy); + return; + } + + + xy[0] = ( int16)win->xpos * win->w_u; + xy[4] = xw; + + tmp = MIN( ww, ( picture->fd_w - xy[0])); + + xy[2] = xy[0] + tmp - 1; + xy[6] = xy[4] + tmp - 1; + + + xy[1] = ( int16)win->ypos * win->h_u; + xy[5] = yw; + + tmp = MIN( hw, ( picture->fd_h - xy[1])); + + xy[3] = xy[1] + tmp - 1; + xy[7] = xy[5] + tmp - 1; + + if(( xy[6] < ( xw + ww)) || ( xy[7] < ( yw + hw))) + { + pxy[0] = xw; + pxy[1] = yw; + pxy[2] = pxy[0] + ww - 1; + pxy[3] = pxy[1] + hw - 1; + + vsf_color( win->graf.handle, LWHITE); + v_bar( win->graf.handle, pxy); + } + + if ( picture->fd_nplanes == 1) + { + int16 color[2] = { BLACK, WHITE}; + + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, picture, &screen, color); + } + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, picture, &screen); + + + WindSlider ( win, VSLIDER|HSLIDER); +} + + +static void WindViewAnim( WINDOW *win) +{ + int16 x, y, w, h, xy[8], tmp; + GRECT r1, rect; + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + uint16 page_to_show; + clock_t current_t = clock(); + clock_t relative_t; + MFDB *picture, screen = {0}; + + if( ( windata->pause == TRUE) || ( full_screen == TRUE)) + return; + + page_to_show = windata->page_to_show + 1; + + if( page_to_show >= windata->img.page) + page_to_show = 0; + + relative_t = current_t - windata->chrono_value; + + if( relative_t < windata->img.delay[page_to_show]) + return; + + windata->chrono_value = current_t; + + windata->page_to_show = page_to_show; + + WindGet ( win, WF_WORKXYWH, &x, &y, &w, &h); + + y++; + h--; + + picture = &windata->img.image[page_to_show]; + + xy[0] = ( int16)win->xpos * win->w_u; + xy[4] = x; + + tmp = MIN( w, ( picture->fd_w - xy[0])); + + xy[2] = xy[0] + tmp - 1; + xy[6] = xy[4] + tmp - 1; + + xy[1] = ( int16)win->ypos * win->h_u; + xy[5] = y; + + tmp = MIN( h, ( picture->fd_h - xy[1])); + + xy[3] = xy[1] + tmp - 1; + xy[7] = xy[5] + tmp - 1; + + while( !wind_update(BEG_UPDATE)); + graf_mouse( M_OFF, 0L); + rc_set( &rect, x, y, w, h); + wind_get( win -> handle, WF_FIRSTXYWH, &r1.g_x, &r1.g_y, &r1.g_w, &r1.g_h); + + while (r1.g_w && r1.g_h) + { + if( rc_intersect( &rect, &r1)) + { + rc_clip_on( win->graf.handle, &r1); + + if ( picture->fd_nplanes == 1) + { + int16 color[2] = { BLACK, WHITE}; + + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, picture, &screen, color); + } + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, picture, &screen); + + rc_clip_off( win->graf.handle); + } + + wind_get( win -> handle, WF_NEXTXYWH, &r1.g_x, &r1.g_y, &r1.g_w, &r1.g_h); + } + + graf_mouse( M_ON, 0L); + wind_update(END_UPDATE); + +// zdebug("frame = %d, delay = %d ms", page_to_show, windata->img.delay[page_to_show]); +} + + +static void WindViewClose( WINDOW *win) +{ + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + IMAGE *img = &windata->img; + + if( ( img->page > 1) && ( img->delay[0] > 0)) + TimerDelete( win); + + delete_txt_data( img); + delete_mfdb( img->image, img->page); + + if( windata->icon.fd_addr != NULL) + gfree( windata->icon.fd_addr); + + if( windata->zoom_picture.fd_addr != NULL) + gfree( windata->zoom_picture.fd_addr); + + gfree( windata); + + DataDelete( win, WD_DATA); + WindDelete( win); + + if( wglb.first) + { + snd_msg( wglb.first, WM_TOPPED, 0, 0, 0, 0); + } + else + { + menu_ienable( get_tree( MENU_BAR), MENU_BAR_SHOW_FULLSCREEN, 0); + menu_ienable( get_tree( MENU_BAR), MENU_BAR_SAVE, 0); + menu_ienable( get_tree( MENU_BAR), MENU_BAR_INFORMATION, 0); + } +} + + +static void WindViewIconify( WINDOW *win) +{ + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); +// zdebug( "iconify"); + windata->pause = TRUE; +} + + +static void WindViewUniconify( WINDOW *win) +{ + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); +// zdebug( "uniconify"); + windata->pause = FALSE; +} + + +/*==================================================================================* + * void Win_VSlide: * + * this function handle the WM_VSLID event for the main frame in the * + * catalog ( the entries). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void Win_VSlide( WINDOW *win) +{ + int32 pos; + int16 x, y, w, h, dy; + int16 old_ypos = win->ypos; + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + pos = ( int32)( win->ypos_max - h / win->h_u) * ( int32)evnt.buff[4] / 1000L; + + if ( pos < 0) + pos = 0; + + dy = ( int16)(( pos - win->ypos) * win->h_u); + win->ypos = ( int16) pos; + + if( dy && ( old_ypos != win->ypos)) + { + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + move_main_work( win, x, y, w, h, 0, dy, windata->frame_width, windata->border_width); + } +} + + +/*==================================================================================* + * void Win_HSlide: * + * this function handle the WM_HSLID event for the main frame in the * + * catalog ( the entries). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void Win_HSlide( WINDOW *win) +{ + int32 pos; + int16 x, y, w, h, dx; + int16 old_xpos = win->xpos; + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + + pos = ( int32)( win->xpos_max - w / win->w_u) * ( int32)evnt.buff[4] / 1000L; + + if ( pos < 0) + pos = 0; + + dx = ( int16)(( pos - win->xpos) * win->w_u); + win->xpos = ( int16) pos; + + if( dx && ( old_xpos != win->xpos)) + { + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + move_main_work( win, x, y, w, h, dx, 0, windata->frame_width, windata->border_width); + } +} + + + +/*==================================================================================* + * void Win_DownPage: * + * this function handle the WM_DNPAGE event for the main frame in the * + * window ( the picture's frame). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void Win_DownPage( WINDOW *win) +{ + int16 page, x, y, w, h, dy; + int32 old_pos = win -> ypos; + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + + page = h / win -> h_u; + + if ( win -> ypos < win -> ypos_max - page) + { + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + win -> ypos = MIN( win->ypos_max, win->ypos) + page; + win -> ypos = MIN( win -> ypos, win -> ypos_max - page); + dy = ( int16) (( win->ypos - old_pos) * win->h_u); + move_main_work( win, x, y, w, h, 0, dy, windata->frame_width, windata->border_width); + } +} + + +/*==================================================================================* + * void Win_RightPage: * + * this function handle the WM_RTPAGE event for the main frame in the * + * window ( the picture's frame). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void Win_RightPage( WINDOW *win) +{ + int16 page, x, y, w, h, dx; + int32 old_pos = win -> xpos; + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + + page = w / win -> w_u; + + if ( win -> xpos < win -> xpos_max - page) + { + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + win -> xpos = MIN( win->xpos_max, win->xpos) + page; + win -> xpos = MIN( win -> xpos, win -> xpos_max - page); + dx = ( int16) (( win->xpos - old_pos) * win->w_u); + move_main_work( win, x, y, w, h, dx, 0, windata->frame_width, windata->border_width); + } +} + + + +/*==================================================================================* + * void Win_LeftPage: * + * this function handle the WM_LFPAGE event for the main frame in the * + * window ( the picture's frame). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void Win_LeftPage( WINDOW *win) +{ + int32 pos; + int16 x, y, w, h, dx; + + if ( win -> xpos > 0L) + { + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + pos = MAX( 0L, win->xpos - w / win->w_u); + dx = ( int16) (( pos - win->xpos) * win->w_u); + win->xpos = pos; + move_main_work( win, x, y, w, h, dx, 0, windata->frame_width, windata->border_width); + } +} + + + +/*==================================================================================* + * void Win_UpPage: * + * this function handle the WM_UPPAGE event for the main frame in the * + * window ( the picture's frame). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void Win_UpPage( WINDOW *win) +{ + int32 pos; + int16 x, y, w, h, dy; + + if ( win -> ypos > 0L) + { + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + pos = MAX( 0L, win->ypos - h / win->h_u); + dy = ( int16) (( pos - win->ypos) * win->h_u); + win->ypos = pos; + move_main_work( win, x, y, w, h, 0, dy, windata->frame_width, windata->border_width); + } +} + + +/*==================================================================================* + * void Win_UpLine: * + * this function handle the WM_UPLINE event for the main frame in the * + * window ( the picture's frame). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void Win_UpLine( WINDOW *win) +{ + int16 x, y, w, h; + + if ( win -> ypos > 0L) + { + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + win->ypos --; + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + move_main_work( win, x, y, w, h, 0, -win->h_u, windata->frame_width, windata->border_width); + } +} + +/*==================================================================================* + * void Win_LeftLine: * + * this function handle the WM_LFLINE event for the main frame in the * + * window ( the picture's frame). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void Win_LeftLine( WINDOW *win) +{ + int16 x, y, w, h; + + if ( win -> xpos > 0L) + { + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + win->xpos --; + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + move_main_work( win, x, y, w, h, -win->w_u, 0, windata->frame_width, windata->border_width); + } +} + + +/*==================================================================================* + * void Win_RightLine: * + * this function handle the WM_RTLINE event for the main frame in the * + * window ( the picture's frame). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void Win_RightLine( WINDOW *win) +{ + int16 x, y, w, h; + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + + if (( win -> xpos < win -> xpos_max - w / win -> w_u) && ( win -> xpos_max > w / win -> w_u )) + { + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + win -> xpos++; + move_main_work( win, x, y, w, h, win->w_u, 0, windata->frame_width, windata->border_width); + } +} + +/*==================================================================================* + * void Win_DownLine: * + * this function handle the WM_DNLINE event for the main frame in the * + * window ( the picture's frame). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void Win_DownLine( WINDOW *win) +{ + int16 x, y, w, h; + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + + if (( win -> ypos < win -> ypos_max - h / win -> h_u) && ( win -> ypos_max > h / win -> h_u )) + { + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + win -> ypos ++; + move_main_work( win, x, y, w, h, 0, win->h_u, windata->frame_width, windata->border_width); + } +} + + +/*==================================================================================* + * void Win_Arrow: * + * this function handle the WM_ARROWED event for the main frame in the * + * window ( the picture's frame). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void Win_Arrow( WINDOW *win) +{ + switch( evnt.buff[4]) + { + case WA_UPPAGE: + Win_UpPage( win); + break; + case WA_DNPAGE: + Win_DownPage( win); + break; + case WA_LFPAGE: + Win_LeftPage( win); + break; + case WA_RTPAGE: + Win_RightPage( win); + break; + case WA_UPLINE: + Win_UpLine( win); + break; + case WA_DNLINE: + Win_DownLine( win); + break; + case WA_LFLINE: + Win_LeftLine( win); + break; + case WA_RTLINE: + Win_RightLine( win); + break; + default: + break; + } +} + + + + +WINDOW *WindView( char *filename) +{ + WINDOW *winview = NULL; + WINDATA *windata; + IMAGE *img; + int16 w, h; + char extention[4]; + + graf_mouse( BUSYBEE, NULL); + + if ( !icons_init()) + { + graf_mouse( ARROW, NULL); + errshow( "", NO_ICON); + applexit(); + } + + /* get the file extention */ + strcpy ( extention, filename + strlen( filename) - 3); + str2upper( extention); + + if( strncmp( "PDF", extention, 3) == 0) + return WindPdf( filename); + + if ( ( windata = ( WINDATA*) gmalloc( sizeof( WINDATA))) == NULL) + { + graf_mouse( ARROW, NULL); + errshow( "", ENOMEM); + return NULL; + } + + windata->icon.fd_addr = NULL; + windata->zoom_picture.fd_addr = NULL; + windata->zoom_level = 100; + windata->page_to_show = 0; + windata->pause = FALSE; + windata->frame_width = 0; + windata->border_width = 0; + windata->root = NULL; + windata->selected = NULL; + windata->frame_slider = NULL; + windata->nbr_bookmark = 0; + img = &windata->img; + + img->_priv_ptr = NULL; + img->view_mode = full_size; + img->progress_bar = show_read_progress_bar; + + strcpy( windata->name, filename); + + if ( !pic_load( filename, extention, img)) + { + gfree( windata); + // errshow( "", IMG_NO_VALID); + graf_mouse( ARROW, NULL); + return NULL; + } + + sprintf( windata->info, " %dx%dx%d | %ld colors | %s", img->img_w, img->img_h, img->bits, img->colors, img->info); + + + if ( ( winview = WindCreate( WAT_ALL, app.x, app.y, app.w, app.h)) == NULL) + { + delete_mfdb( img->image, img->page); + gfree( windata); + errshow( "", ALERT_WINDOW); + graf_mouse( ARROW, NULL); + return NULL; + } + + DataAttach( winview, WD_DATA, windata); + EvntAttach( winview, WM_REDRAW, WindViewRedraw); + EvntAttach( winview, WM_DESTROY, WindViewClose); + EvntAttach( winview, WM_XKEYBD, WindViewKeyb); + EvntAttach( winview, WM_TOPPED, WindViewTop); + EvntAttach( winview, WM_ARROWED, Win_Arrow); + EvntAttach( winview, WM_UPPAGE, Win_UpPage); + EvntAttach( winview, WM_DNPAGE, Win_DownPage); + EvntAttach( winview, WM_LFPAGE, Win_LeftPage); + EvntAttach( winview, WM_RTPAGE, Win_RightPage); + EvntAttach( winview, WM_UPLINE, Win_UpLine); + EvntAttach( winview, WM_DNLINE, Win_DownLine); + EvntAttach( winview, WM_RTLINE, Win_RightLine); + EvntAttach( winview, WM_LFLINE, Win_LeftLine); + EvntAttach( winview, WM_VSLID , Win_VSlide); + EvntAttach( winview, WM_HSLID , Win_HSlide); + EvntAdd( winview, WM_ICONIFY, WindViewIconify, EV_TOP); + EvntAdd( winview, WM_UNICONIFY,WindViewUniconify, EV_BOT); + + WindSetStr( winview, WF_NAME, windata->name); + WindSetStr( winview, WF_ICONDRAW, WindViewIcon); + WindSetStr( winview, WF_INFO, windata->info); + + WindSetPtr( winview, WF_TOOLBAR, get_tree( VIEWTOOLBAR), WindViewTool); + + WindCalc( WC_BORDER, winview, 0, 0, img->image[0].fd_w, img->image[0].fd_h + 1, &dum, &dum, &w, &h); + + RsrcUserDraw ( OC_TOOLBAR, winview, VIEWTOOLBAR_BIG, draw_icon_greater, windata); + RsrcUserDraw ( OC_TOOLBAR, winview, VIEWTOOLBAR_SMALL, draw_icon_smaller, windata); + RsrcUserDraw ( OC_TOOLBAR, winview, VIEWTOOLBAR_OPEN, draw_icon_open, NULL); + RsrcUserDraw ( OC_TOOLBAR, winview, VIEWTOOLBAR_INFO, draw_icon_info, NULL); + RsrcUserDraw ( OC_TOOLBAR, winview, VIEWTOOLBAR_SAVE, draw_icon_save, NULL); + RsrcUserDraw ( OC_TOOLBAR, winview, VIEWTOOLBAR_FULLSCREEN, draw_icon_fullscreen, NULL); + RsrcUserDraw ( OC_TOOLBAR, winview, VIEWTOOLBAR_PRINT, draw_icon_printer, NULL); + + w = MIN( w, app.w); + h = MIN( h, app.h); + + winview -> h_min = 80; + winview -> w_min = 80; +/* winview -> h_max = MAX( h, winview -> h_min); + winview -> w_max = MAX( w, winview -> w_min); +*/ winview -> h_u = 8; + winview -> w_u = 8; + winview -> ypos_max = ( int32)( ( img->image[0].fd_h + 1) >> 3); + winview -> xpos_max = ( int32)( img->image[0].fd_w >> 3); + + if ( !( WindOpen( winview, -1, -1, w, h))) + { + WindViewClose( winview); + errshow( "", ALERT_WINDOW); + graf_mouse( ARROW, NULL); + return NULL; + } + + menu_ienable( get_tree( MENU_BAR), MENU_BAR_INFORMATION, 1); + menu_ienable( get_tree( MENU_BAR), MENU_BAR_SAVE, 1); + menu_ienable( get_tree( MENU_BAR), MENU_BAR_SHOW_FULLSCREEN, 1); + + if( ( img->page > 1) && ( img->delay[0] > 0)) + { + windata->chrono_value = clock(); + TimerAttach( winview, WindViewAnim); + } + + graf_mouse( ARROW, NULL); + + return winview; +} diff --git a/sources/z-tools/trunk/zview/winimg.h b/sources/z-tools/trunk/zview/winimg.h new file mode 100644 index 0000000..b63a735 --- /dev/null +++ b/sources/z-tools/trunk/zview/winimg.h @@ -0,0 +1,60 @@ +#define WD_DATA 0x4E414D45L + +typedef struct _bookm +{ + char name[MAXNAMLEN]; /* Folder's name shown in the window */ + + RECT16 arrow_position; /* icon position in the window */ + + struct _bookm *parent; /* the parent entry */ + struct _bookm *child; /* the child(s) entry */ + + int16 nbr_child; /* number of valid child's entries */ + int16 txt_width; /* Text width for screen output */ + int16 state; /* Deployed or not ( ON/OFF) */ + int16 linked_page; + int16 valid; +} Bookmark; + +typedef struct +{ + int8 name[MAXNAMLEN+MAX_PATH]; /* Window's name text buffer */ + int8 info[256]; /* Window's infobar text buffer */ + int8 title[256]; /* document's title text buffer */ + + int16 zoom_level; /* Allowed values: + 25, 50, 100, 150, 200, fit the window */ + int16 pause; /* make a "pause" in the animation */ + uint16 page_to_show; /* Page to show in the window */ + clock_t chrono_value; /* for animation function */ + + IMAGE img; /* the image structure */ + MFDB icon; /* the icon for the iconify mode */ + MFDB zoom_picture; /* the zoomed picture */ + + /* The following data is for the bookmark's frame.. */ + int16 frame_width; /* first frame width if any */ + int16 border_width; /* frame border's width if any */ + int32 ypos; /* relative data position in the window */ + int32 ypos_max; /* Maximal values of ypos variables */ + int16 h_u; /* vertical scroll offset */ + OBJECT *frame_slider; /* vertical slider OBJECT if any */ + Bookmark *selected; + Bookmark *root; + int16 nbr_bookmark; /* Number of valid root's bookmarks */ +}WINDATA; + +extern WINDOW *WindView( char *filename); +extern void WindViewIcon( WINDOW *win); +extern void Win_VSlide( WINDOW *win); +extern void Win_HSlide( WINDOW *win); +extern void Win_DownPage( WINDOW *win); +extern void Win_RightPage( WINDOW *win); +extern void Win_LeftPage( WINDOW *win); +extern void Win_UpPage( WINDOW *win); +extern void Win_UpLine( WINDOW *win); +extern void Win_LeftLine( WINDOW *win); +extern void Win_RightLine( WINDOW *win); +extern void Win_DownLine( WINDOW *win); +extern void Win_Arrow( WINDOW *win); + diff --git a/sources/z-tools/trunk/zview/winpdf.c b/sources/z-tools/trunk/zview/winpdf.c new file mode 100644 index 0000000..da55649 --- /dev/null +++ b/sources/z-tools/trunk/zview/winpdf.c @@ -0,0 +1,1484 @@ +#include "general.h" +#include "prefs.h" +#include "mfdb.h" +#include "txt_data.h" +#include "pic_load.h" +#include "winimg.h" +#include "full_scr.h" +#include "pdf_load.h" +#include "menu.h" +#include "infobox.h" +#include "pdf/pdflib.h" +#include "pic_resize.h" +#include "wintimer.h" +#include "ztext.h" +#include "custom_font.h" +#include "catalog/catalog.h" +#include "catalog/catalog_other_event.h" +#include "catalog/catalog_icons.h" +#include "catalog/catalog_slider.h" + + +static int16 dum; +static OBJECT *menu; + +/* Prototype */ +void calc_slider( WINDATA *windata, OBJECT *slider_root); + + +/*==================================================================================* + * void WindPdfSize: * + * this function handle the WM_SIZED event for the WINDOW win * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +static void WindPdfSize( WINDOW *win) +{ + int16 x, y, w, h, old_h, rdw_frame = 0; + uint32 old_frame_ypos; + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + + x = MAX( evnt.buff[6], win -> w_min); + y = MAX( evnt.buff[7], win -> h_min); + + w = MIN( x, win -> w_max); + h = MIN( y, win -> h_max); + + WindGet( win, WF_WORKXYWH, &dum, &dum, &dum, &old_h); + + wind_set( evnt.buff[3], WF_CURRXYWH, evnt.buff[4], evnt.buff[5], w, h); + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + + old_frame_ypos = windata -> ypos; + + if( ( uint16)h > windata -> ypos_max * windata -> h_u) + windata -> ypos = 0; + else + windata -> ypos = MIN( windata -> ypos, windata -> ypos_max - h / windata -> h_u); + + if( ( uint16)h > win -> ypos_max * win -> h_u) + win -> ypos = 0; + else + win -> ypos = MIN( win -> ypos, win -> ypos_max - h / win -> h_u); + + if( ( uint16)w > win -> xpos_max * win -> w_u) + win -> xpos = 0; + else + win -> xpos = MIN( win -> xpos, win -> xpos_max - w / win -> w_u); + + + if( old_frame_ypos != windata -> ypos) + rdw_frame = 1; + + win->status &= ~WS_FULLSIZE; + + draw_page( win, x + windata->frame_width + windata->border_width , y, w - ( windata->frame_width + windata->border_width), h); + + if( ( old_h != h) && windata->frame_width) + { + if( rdw_frame) + draw_page( win, x, y, windata->frame_width, h); + else + draw_page( win, x + windata->frame_width - 16, y, 16, h); + } + + WindSlider( win, VSLIDER|HSLIDER); +} + + + +/*==================================================================================* + * void move_bookmark_work: * + * this function moves the 'bookmark' frame work area of the window. * + *----------------------------------------------------------------------------------* + * input: * + * win -> The target window. * + * dy -> The step fo the move. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +static void move_bookmark_work( WINDOW *win, int16 dy, WINDATA *windata) +{ + int16 x, y, w, h, absolute_dy; + GRECT rect, r1, r2, screen; + + absolute_dy = abs( dy); + + if ( dy) + { + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + y++; + h--; + w = windata->frame_width - 16; + + while( !wind_update(BEG_UPDATE)); + graf_mouse( M_OFF, 0L); + rc_set( &rect, x + 1, y, w, h); + wind_get_grect( 0, WF_CURRXYWH, &screen); + wind_get( win -> handle, WF_FIRSTXYWH, &r1.g_x, &r1.g_y, &r1.g_w, &r1.g_h); + + while ( r1.g_w && r1.g_h) + { + if( rc_intersect( &rect, &r1) && rc_intersect( &screen, &r1)) + { + if ( ( absolute_dy < r1.g_h) ) + { + r2 = r1; /* save */ + + if ( dy > 0) + { + r1.g_y += dy; + r1.g_h -= dy; + } + else + r1.g_h += dy; + + move_area( win->graf.handle, &r1, 0, -dy); + + if ( dy) + { + r1 = r2 ; /* restore */ + + if (dy > 0) + { + r1.g_y += r1.g_h - dy; + r1.g_h = dy; + } + else + r1.g_h = -dy; + + rc_clip_on( win->graf.handle, &r1); + EvntExec( win, WM_REDRAW); + rc_clip_off( win->graf.handle); + } + } + else + { + rc_clip_on( win->graf.handle, &r1); + EvntExec( win, WM_REDRAW); + rc_clip_off( win->graf.handle); + } + } + wind_get( win->handle, WF_NEXTXYWH, &r1.g_x, &r1.g_y, &r1.g_w, &r1.g_h); + } + wind_update(END_UPDATE); + graf_mouse( M_ON, 0L); + + if ( dy) + { + calc_slider( windata, windata->frame_slider); + + /* check it in the windom source, I'm not sure if the clipping area must be clip.g_x, clip.g_y, clip.g_w, clip.g_h or not */ + ObjcWindDraw( win, windata->frame_slider, SLIDERS_BACK, 2, x + windata->frame_width - 15, y, 16, h - 31); + } + } +} + + + + +/*==================================================================================* + * redraw_mini_entry: * + * Send a redraw event for a mini_entry in the WINDOW *win. * + *----------------------------------------------------------------------------------* + * input: * + * win = the target window * + * entry = the icon to be redraw * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ + +static void redraw_bookmark( WINDOW *win, int16 frame_width, Bookmark *entry, int16 xw, int16 yw, int16 hw) +{ + int16 x, y, w, h; + + x = entry->arrow_position.x1; + y = entry->arrow_position.y1 - 5; + w = entry->arrow_position.x2 + x_space + entry->txt_width + 20; + h = entry->arrow_position.y2 - y + 10; + + x += xw; + y += yw; + + /* send the redraw event only if the bookmark is visible */ + if (( y + entry->arrow_position.y2 > yw) && ( y < yw + hw)) + draw_page( win, x, y, MIN( w, frame_width), h); +} + + +static int16 find_bookmark_child_on_mouse( WINDOW *win, WINDATA *windata, Bookmark *entry, int16 mouse_x, int16 mouse_y, int16 x, int16 y, int16 w, int16 h) +{ + int16 i, zoom; + char temp[20]; + double scale = 1.0; + + if( entry->child == NULL) + return( 0); + + for ( i = 0; i < entry->nbr_child ; i++) + { + if ( entry->child[i].valid == FALSE) + continue; + + if ( entry->child[i].state == ON) + if ( find_bookmark_child_on_mouse( win, windata, &entry->child[i], mouse_x, mouse_y, x, y, w, h)) + return ( 1); + + if (( mouse_x >= entry->child[i].arrow_position.x2 + x_space && mouse_x <= entry->child[i].arrow_position.x2 + x_space + entry->child[i].txt_width && mouse_y >= entry->child[i].arrow_position.y1 && mouse_y <= entry->child[i].arrow_position.y2)) + { + if ( windata->selected != &entry->child[i]) + { + Bookmark *old_selected = windata->selected; + windata->selected = &entry->child[i]; + + if ( old_selected) + redraw_bookmark( win, windata->frame_width, old_selected, x, y, h); + + redraw_bookmark( win, windata->frame_width, windata->selected, x, y, h); + } + + if( entry->child[i].linked_page == windata->page_to_show || entry->child[i].linked_page > windata->img.page || entry->child[i].linked_page < 0) + return( 1); + + graf_mouse( BUSYBEE, NULL); + + if( windata->img.image[windata->page_to_show].fd_addr != NULL) + { + gfree( windata->img.image[windata->page_to_show].fd_addr); + windata->img.image[windata->page_to_show].fd_addr = NULL; + } + + if( pdf_fit_to_win) + scale = get_scale_value( &windata->img, entry->child[i].linked_page + 1, w - ( windata->frame_width + windata->border_width + 20), h - 20); + + zoom = windata->zoom_level; + + if( read_pdf( &windata->img, entry->child[i].linked_page + 1, scale)) + { + scale = scale * 100.0; + sprintf( temp, "%.0f%%", scale); + windata->zoom_level = ( int16)scale; + + ObjcStrCpy( win->tool.root, PDFTOOLBAR_PERCENT, temp); + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_PERCENT, 1); + + sprintf( temp, "%d of %d", entry->child[i].linked_page + 1, windata->img.page); + ObjcStrCpy( win->tool.root, PDFTOOLBAR_PAGE, temp); + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_PAGE, 1); + + windata->page_to_show = entry->child[i].linked_page; + + win -> ypos_max = ( int32)( ( windata->img.image[windata->page_to_show].fd_h) >> 3); + win -> xpos_max = ( int32)( ( windata->img.image[windata->page_to_show].fd_w + windata->frame_width + windata->border_width) >> 3); + + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_PREVIOUS, 1); + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_NEXT, 1); + + if( zoom >= 200 && windata->zoom_level < 200) + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_BIG, 1); + + if( zoom <= 25 && windata->zoom_level > 25) + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_SMALL, 1); + } + + win -> ypos = 0; + win -> xpos = 0; + + draw_page( win, x + windata->frame_width + windata->border_width, y, w - ( windata->frame_width + windata->border_width) , h); + + graf_mouse( ARROW, NULL); + return( 1); + } + else if ( entry->child[i].state != UNKNOWN) + { + if (( mouse_x >= entry->child[i].arrow_position.x1 && mouse_x <= entry->child[i].arrow_position.x2 && mouse_y >= entry->child[i].arrow_position.y1 && mouse_y <= entry->child[i].arrow_position.y2)) + { + entry->child[i].state = ( entry->child[i].state == ON) ? OFF : ON; + + draw_page( win, x, y, windata->frame_width, h); + + return( 1); + } + } + } + return( 0); +} + + + + +/*==================================================================================* + * void WindPdfMouse: * + * this function handle the mouse event for the winview WINDOW * + * catalog ( the entries). * + *----------------------------------------------------------------------------------* + * input: * + * win -> The window to handle. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +static void WindPdfMouse( WINDOW *win) +{ + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + GRECT mouse; + int16 zoom, x, y, w, h, old_x, old_y, i = 0, nb_click, in_frame_border = 0, in_bookmark_frame = 0; + char temp[20]; + double scale = 1.0; +// Entry *entry_ptr = NULL, *old_selected = wicones->first_selected; + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + + mouse.g_x = evnt.mx - x; + mouse.g_y = evnt.my - y; + old_x = evnt.mx; + old_y = evnt.my; + nb_click = evnt.nb_click; + + if ( windata->frame_width && ( mouse.g_x >= windata->frame_width && mouse.g_x <= windata->frame_width + windata->border_width)) + { /* mouse on frame border */ + in_frame_border = 1; + } + else if ( windata->frame_width && ( mouse.g_x < windata->frame_width + windata->border_width)) + { /* mouse on browser */ + in_bookmark_frame = 1; + } + + if ( in_frame_border && evnt.mbut == 1) + { + int16 last_mouse_x; + + graf_mouse( FLAT_HAND, NULL); + + while( !wind_update( BEG_MCTRL)); + + graf_dragbox( windata->border_width, h, x + windata->frame_width, y, x + 100, y, w - ( 180), h, &last_mouse_x, &dum ); + + /* Set the new toolbar position */ + if ( last_mouse_x != x + windata->frame_width) + { + windata->frame_width = last_mouse_x - x; + + win -> w_min = windata->frame_width + windata->border_width + 80; + win -> xpos_max = ( int32)( ( windata->img.image[windata->page_to_show].fd_w + windata->frame_width + windata->border_width - 1) >> 3); + + EvntRedraw( win); + WindSlider ( win, HSLIDER); + } + + wind_update( END_MCTRL); + + graf_mouse( ARROW, NULL); + } + else if ( in_bookmark_frame) + { + if( ( ( windata -> ypos_max * windata -> h_u) >= h) && ( mouse.g_x > windata->frame_width - 15) && ( mouse.g_x < windata->frame_width)) + { + int16 res; + + windata->frame_slider->ob_x = x + windata->frame_width - 15; + windata->frame_slider->ob_y = y + 2; + + res = objc_find( windata->frame_slider, SLIDERS_BOX, 2, evnt.mx, evnt.my); + + if( res != -1) + { + int32 pos, old_ypos = windata->ypos; + int16 dy, selected_object, page, redraw_arrow_slider = 0; + + switch ( res) + { + case SLIDERS_UP: + do + { + if ( windata -> ypos > 0L) + { + if( redraw_arrow_slider == 0) + ObjcWindChange( win, windata->frame_slider, SLIDERS_UP, windata->frame_slider->ob_x, windata->frame_slider[SLIDERS_UP].ob_y + y, windata->frame_slider[SLIDERS_UP].ob_width + 1, windata->frame_slider[SLIDERS_UP].ob_height + 1, SELECTED); + + windata -> ypos--; + move_bookmark_work( win, -windata->h_u, windata); + redraw_arrow_slider = 1; + } + + graf_mkstate( &dum, &dum, &res, &dum); + + }while( res); + + if( redraw_arrow_slider) + { + windata->frame_slider[SLIDERS_UP].ob_state &= ~SELECTED; + ObjcWindDraw( win, windata->frame_slider, SLIDERS_UP, 1, windata->frame_slider->ob_x, windata->frame_slider[SLIDERS_UP].ob_y + y, windata->frame_slider[SLIDERS_UP].ob_width + 1, windata->frame_slider[SLIDERS_UP].ob_height + 1); + } + break; + + case SLIDERS_DOWN: + do + { + if (( windata -> ypos < windata -> ypos_max - h / windata -> h_u) && ( windata -> ypos_max > h / windata -> h_u )) + { + if( redraw_arrow_slider == 0) + ObjcWindChange( win, windata->frame_slider, SLIDERS_DOWN, windata->frame_slider->ob_x, windata->frame_slider[SLIDERS_DOWN].ob_y + y, windata->frame_slider[SLIDERS_DOWN].ob_width + 1, windata->frame_slider[SLIDERS_DOWN].ob_height + 1, SELECTED); + + windata -> ypos++; + move_bookmark_work( win, windata->h_u, windata); + redraw_arrow_slider = 1; + } + + graf_mkstate( &dum, &dum, &res, &dum); + + } while( res); + + if( redraw_arrow_slider) + { + windata->frame_slider[SLIDERS_DOWN].ob_state &= ~SELECTED; + ObjcWindDraw( win, windata->frame_slider, SLIDERS_DOWN, 1, windata->frame_slider->ob_x, windata->frame_slider[SLIDERS_DOWN].ob_y + y, windata->frame_slider[SLIDERS_DOWN].ob_width + 1, windata->frame_slider[SLIDERS_DOWN].ob_height + 1); + } + break; + + case SLIDERS_MOVER: + if( app.aes4 & AES4_XGMOUSE) + graf_mouse( M_SAVE, 0L); + + graf_mouse( FLAT_HAND, NULL); + + while( !wind_update( BEG_MCTRL)); + + res = graf_slidebox( windata->frame_slider, SLIDERS_BACK, SLIDERS_MOVER, 1); + + wind_update( END_MCTRL); + + pos = ( int32)( windata->ypos_max - h / windata->h_u) * res / 1000L; + + if ( pos < 0) + pos = 0; + + dy = ( int16)(( pos - windata->ypos) * windata->h_u); + + windata->ypos = pos; + + if( dy && ( old_ypos != windata->ypos)) + move_bookmark_work( win, dy, windata); + + if( app.aes4 & AES4_XGMOUSE) + graf_mouse( M_RESTORE, 0L); + + graf_mouse( ARROW,NULL); + + break; + + case SLIDERS_BACK: + objc_offset( windata->frame_slider, SLIDERS_MOVER, &dum, &dy); + + dum = ( evnt.my < dy) ? WA_UPPAGE : WA_DNPAGE; + selected_object = ( evnt.my < dy) ? SLIDERS_UP : SLIDERS_DOWN; + + while( !wind_update( BEG_MCTRL)); + + windata->frame_slider[selected_object].ob_state |= SELECTED; + + if( dum == WA_DNPAGE) + { + do + { + page = h / windata -> h_u; + + if ( windata -> ypos < windata -> ypos_max - page) + { + windata -> ypos = MIN( windata->ypos_max, windata->ypos) + page; + windata -> ypos = MIN( windata -> ypos, windata -> ypos_max - page); + dy = ( int16) (( windata->ypos - old_ypos) * windata->h_u); + move_bookmark_work( win, dy, windata); + } + + graf_mkstate( &dum, &dum, &res, &dum); + } while( res); + } + else + { + do + { + if ( windata -> ypos > 0L) + { + pos = MAX( 0L, windata->ypos - h / windata->h_u); + dy = ( int16) (( pos - windata->ypos) * windata->h_u); + windata->ypos = pos; + move_bookmark_work( win, dy, windata); + } + + graf_mkstate( &dum, &dum, &res, &dum); + } while( res); + } + + windata->frame_slider[selected_object].ob_state &= ~SELECTED; + + ObjcWindDraw( win, windata->frame_slider, selected_object, 1, x, y, w, h); + + wind_update( END_MCTRL); + + break; + + default: + break; + } + } + } + else + { + for ( i = 0; i < windata->nbr_bookmark; i++) + { + if( windata->root[i].valid == FALSE) + continue; + + if ( windata->root[i].state == ON) + if ( find_bookmark_child_on_mouse( win, windata, &windata->root[i], mouse.g_x, mouse.g_y, x, y, w, h)) + break; + + if (( mouse.g_x >= windata->root[i].arrow_position.x2 + x_space && mouse.g_x <= windata->root[i].arrow_position.x2 + x_space + windata->root[i].txt_width && mouse.g_y >= windata->root[i].arrow_position.y1 && mouse.g_y <= windata->root[i].arrow_position.y2)) + { + if ( windata->selected != &windata->root[i]) + { + Bookmark *old_selected = windata->selected; + windata->selected = &windata->root[i]; + + if ( old_selected) + redraw_bookmark( win, windata->frame_width, old_selected, x, y, h); + + redraw_bookmark( win, windata->frame_width, windata->selected, x, y, h); + } + + if( windata->root[i].linked_page == windata->page_to_show || windata->root[i].linked_page > windata->img.page || windata->root[i].linked_page < 0) + break; + + graf_mouse( BUSYBEE, NULL); + + if( windata->img.image[windata->page_to_show].fd_addr != NULL) + { + gfree( windata->img.image[windata->page_to_show].fd_addr); + windata->img.image[windata->page_to_show].fd_addr = NULL; + } + + if( pdf_fit_to_win) + scale = get_scale_value( &windata->img, windata->root[i].linked_page + 1, w - ( windata->frame_width + windata->border_width + 20) , h - 20); + + zoom = windata->zoom_level; + + if( read_pdf( &windata->img, windata->root[i].linked_page + 1, scale)) + { + scale = scale * 100.0; + sprintf( temp, "%.0f%%", scale); + windata->zoom_level = ( int16)scale; + + ObjcStrCpy( win->tool.root, PDFTOOLBAR_PERCENT, temp); + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_PERCENT, 1); + + sprintf( temp, "%d of %d", windata->root[i].linked_page + 1, windata->img.page); + ObjcStrCpy( win->tool.root, PDFTOOLBAR_PAGE, temp); + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_PAGE, 1); + + windata->page_to_show = windata->root[i].linked_page; + + win -> ypos_max = ( int32)( ( windata->img.image[windata->page_to_show].fd_h) >> 3); + win -> xpos_max = ( int32)( ( windata->img.image[windata->page_to_show].fd_w + windata->frame_width + windata->border_width) >> 3); + + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_PREVIOUS, 1); + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_NEXT, 1); + + if( zoom >= 200 && windata->zoom_level < 200) + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_BIG, 1); + + if( zoom <= 25 && windata->zoom_level > 25) + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_SMALL, 1); + } + + win -> ypos = 0; + win -> xpos = 0; + + draw_page( win, x + windata->frame_width + windata->border_width, y, w - ( windata->frame_width + windata->border_width) , h); + + graf_mouse( ARROW, NULL); + + break; + } + else if( windata->root[i].state != UNKNOWN) + { + if (( mouse.g_x >= windata->root[i].arrow_position.x1 && mouse.g_x <= windata->root[i].arrow_position.x2 && mouse.g_y >= windata->root[i].arrow_position.y1 && mouse.g_y <= windata->root[i].arrow_position.y2)) + { + windata->root[i].state = ( windata->root[i].state == ON) ? OFF : ON; + + draw_page( win, x, y, windata->frame_width, h); + + break; + } + } + } + } + } + + /* a wait loop while the mouse button is pressed */ + while(( evnt.mbut == 1) || ( evnt.mbut == 2)) + graf_mkstate( &evnt.mx, &evnt.my, &evnt.mbut, &evnt.mkstate); +} + +/* +static void size_popup( WINDOW *win, int obj_index) +{ + int16 x, y; + int choice; + char *items[] = { "200%", "150%", "100%", "50%", "25%", "-------------", "Fit to window"}; + + objc_offset( win->tool.root, obj_index, &x, &y); + + choice = MenuPopUp ( items, x, y, 7, -1, smooth_thumbnail + 1 , P_LIST + P_WNDW + P_CHCK); + + if( choice < 0) + return; + + smooth_thumbnail = choice - 1; + + strcpy( pref_dialog[PREFS_SMOOTH_METHOD].ob_spec.free_string, items[smooth_thumbnail]); + ObjcDraw( OC_FORM, win, PREFS_SMOOTH_METHOD, 1); +} +*/ + +/*==================================================================================* + * WindPdfTool: * + * Toolbar binding. * + *----------------------------------------------------------------------------------* + * input: * + * win -> Pointer to the target window * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void WindViewTop( WINDOW *win); +static void WindPdfTool( WINDOW *win) +{ + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + IMAGE *img = &windata->img; + int16 x, y, w, h, zoom, object = evnt.buff[4]; + double scale = 1.0; + char temp[20]; + + switch( object) + { + case PDFTOOLBAR_OPEN: + Menu_open_image(); + break; + + case PDFTOOLBAR_INFO: + WindViewTop( win); + infobox(); + break; + + case PDFTOOLBAR_SMALL: + zoom = windata->zoom_level; + + if( windata->zoom_level <= 25) + return; + else if( windata->zoom_level > 200) + windata->zoom_level = 200; + else if( windata->zoom_level > 150) + windata->zoom_level = 150; + else if( windata->zoom_level > 100) + windata->zoom_level = 100; + else if( windata->zoom_level > 50) + windata->zoom_level = 50; + else if( windata->zoom_level > 25) + windata->zoom_level = 25; + + graf_mouse( BUSYBEE, NULL); + + if( img->image[windata->page_to_show].fd_addr != NULL) + { + gfree( img->image[windata->page_to_show].fd_addr); + img->image[windata->page_to_show].fd_addr = NULL; + } + + scale = ( scale / 100.0) * ( double)windata->zoom_level; + + if( read_pdf( img, windata->page_to_show + 1, scale)) + { + sprintf( temp, "%d%%", windata->zoom_level); + ObjcStrCpy( win->tool.root, PDFTOOLBAR_PERCENT, temp); + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_PERCENT, 1); + + win -> ypos_max = ( int32)( windata->img.image[windata->page_to_show].fd_h >> 3); + win -> xpos_max = ( int32)(( windata->img.image[windata->page_to_show].fd_w + windata->frame_width + windata->border_width) >> 3); + } + + win -> ypos = 0; + win -> xpos = 0; + + graf_mouse( ARROW, NULL); + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + draw_page( win, x + windata->frame_width + windata->border_width, y, w - ( windata->frame_width + windata->border_width) , h); + + + if( zoom >= 200 && windata->zoom_level < 200) + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_BIG, 1); + break; + + case PDFTOOLBAR_BIG: + zoom = windata->zoom_level; + + if( windata->zoom_level >= 200) + return; + else if( windata->zoom_level < 25) + windata->zoom_level = 25; + else if( windata->zoom_level < 50) + windata->zoom_level = 50; + else if( windata->zoom_level < 100) + windata->zoom_level = 100; + else if( windata->zoom_level < 150) + windata->zoom_level = 150; + else if( windata->zoom_level < 200) + windata->zoom_level = 200; + + graf_mouse( BUSYBEE, NULL); + + if( img->image[windata->page_to_show].fd_addr != NULL) + { + gfree( img->image[windata->page_to_show].fd_addr); + img->image[windata->page_to_show].fd_addr = NULL; + } + + scale = ( scale / 100.0) * ( double)windata->zoom_level; + + if( read_pdf( img, windata->page_to_show + 1, scale)) + { + sprintf( temp, "%d%%", windata->zoom_level); + ObjcStrCpy( win->tool.root, PDFTOOLBAR_PERCENT, temp); + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_PERCENT, 1); + + win -> ypos_max = ( int32)( windata->img.image[windata->page_to_show].fd_h >> 3); + win -> xpos_max = ( int32)(( windata->img.image[windata->page_to_show].fd_w + windata->frame_width + windata->border_width) >> 3); + } + + win -> ypos = 0; + win -> xpos = 0; + + graf_mouse( ARROW, NULL); + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + draw_page( win, x + windata->frame_width + windata->border_width, y, w - ( windata->frame_width + windata->border_width) , h); + + if( zoom <= 25 && windata->zoom_level > 25) + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_SMALL, 1); + break; + + case PDFTOOLBAR_NEXT: + if( windata->page_to_show == windata->img.page - 1) + return; + + graf_mouse( BUSYBEE, NULL); + + if( img->image[windata->page_to_show].fd_addr != NULL) + { + gfree( img->image[windata->page_to_show].fd_addr); + img->image[windata->page_to_show].fd_addr = NULL; + } + + windata->page_to_show++; + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + + if( pdf_fit_to_win) + scale = get_scale_value( img, windata->page_to_show + 1, w - ( windata->frame_width + windata->border_width + 20) , h - 20); + + zoom = windata->zoom_level; + + if( read_pdf( img, windata->page_to_show + 1, scale)) + { + scale = scale * 100.0; + sprintf( temp, "%.0f%%", scale); + windata->zoom_level = ( int16)scale; + ObjcStrCpy( win->tool.root, PDFTOOLBAR_PERCENT, temp); + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_PERCENT, 1); + + sprintf( temp, "%d of %d", windata->page_to_show + 1, img->page); + ObjcStrCpy( win->tool.root, PDFTOOLBAR_PAGE, temp); + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_PAGE, 1); + + win -> ypos_max = ( int32)( windata->img.image[windata->page_to_show].fd_h >> 3); + win -> xpos_max = ( int32)(( windata->img.image[windata->page_to_show].fd_w + windata->frame_width + windata->border_width) >> 3); + + if( zoom >= 200 && windata->zoom_level < 200) + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_BIG, 1); + + if( zoom <= 25 && windata->zoom_level > 25) + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_SMALL, 1); + } + + win -> ypos = 0; + win -> xpos = 0; + + graf_mouse( ARROW, NULL); + + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_PREVIOUS, 1); + draw_page( win, x + windata->frame_width + windata->border_width, y, w - ( windata->frame_width + windata->border_width) , h); + + break; + + case PDFTOOLBAR_PREVIOUS: + if( windata->page_to_show == 0) + return; + + graf_mouse( BUSYBEE, NULL); + + if( img->image[windata->page_to_show].fd_addr != NULL) + { + gfree( img->image[windata->page_to_show].fd_addr); + img->image[windata->page_to_show].fd_addr = NULL; + } + + windata->page_to_show--; + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + + if( pdf_fit_to_win) + scale = get_scale_value( img, windata->page_to_show + 1, w - ( windata->frame_width + windata->border_width + 20) , h - 20); + + zoom = windata->zoom_level; + + if( read_pdf( img, windata->page_to_show + 1, scale)) + { + sprintf( temp, "%d of %d", windata->page_to_show + 1, img->page); + ObjcStrCpy( win->tool.root, PDFTOOLBAR_PAGE, temp); + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_PAGE, 1); + + scale = scale * 100.0; + sprintf( temp, "%.0f%%", scale); + windata->zoom_level = ( int16)scale; + ObjcStrCpy( win->tool.root, PDFTOOLBAR_PERCENT, temp); + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_PERCENT, 1); + + win -> ypos_max = ( int32)( windata->img.image[windata->page_to_show].fd_h >> 3); + win -> xpos_max = ( int32)(( windata->img.image[windata->page_to_show].fd_w + windata->frame_width + windata->border_width) >> 3); + + if( zoom >= 200 && windata->zoom_level < 200) + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_BIG, 1); + + if( zoom <= 25 && windata->zoom_level > 25) + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_SMALL, 1); + + } + + win -> ypos = 0; + win -> xpos = 0; + + graf_mouse( ARROW, NULL); + + ObjcDraw( OC_TOOLBAR, win, PDFTOOLBAR_NEXT, 1); + draw_page( win, x + windata->frame_width + windata->border_width, y, w - ( windata->frame_width + windata->border_width) , h); + + break; + + + case PDFTOOLBAR_PERCENT: + // size_popup( win, object); + break; + + default: + break; + } + + ObjcChange( OC_TOOLBAR, win, object, NORMAL, 1); +} + + +static void WindPdfTop( WINDOW *win) +{ + menu = get_tree( MENU_BAR); + + menu_ienable( menu, MENU_BAR_SHOW_FULLSCREEN, 1); + menu_ienable( menu, MENU_BAR_INFORMATION, 1); + menu_ienable( menu, MENU_BAR_SAVE, 0); + menu_ienable( menu, MENU_BAR_DELETE, 0); + WindSet( win, WF_TOP, win->handle, 0, 0, 0); + wglb.appfront = wglb.front = win; +} + + +static void WindPdfKeyb( WINDOW *win) +{ + switch ( evnt.keybd >> 8) + { + case SC_UPARW: + if( !( evnt.mkstate & ( K_LSHIFT|K_RSHIFT))) + snd_arrw( win, WA_UPLINE); + else + case SC_PGUP: + snd_arrw( win, WA_UPPAGE); + break; + + case SC_DWARW: + if( !( evnt.mkstate & ( K_LSHIFT|K_RSHIFT))) + snd_arrw( win, WA_DNLINE); + else + case SC_PGDN: /* page down */ + snd_arrw( win, WA_DNPAGE); + break; + + case SC_LFARW: + if( !( evnt.mkstate & ( K_LSHIFT|K_RSHIFT))) + snd_arrw( win, WA_LFLINE); + else + snd_arrw( win, WA_LFPAGE); + break; + + case SC_RTARW: + if( !( evnt.mkstate & ( K_LSHIFT|K_RSHIFT))) + snd_arrw( win, WA_RTLINE); + else + snd_arrw( win, WA_RTPAGE); + break; + + case SC_MINUS: +// WindViewZoom( win, 2); +// ObjcDraw( OC_TOOLBAR, win, VIEWTOOLBAR_SMALL, 1); + break; + + case SC_PLUS: +// WindViewZoom( win, 1); +// ObjcDraw( OC_TOOLBAR, win, VIEWTOOLBAR_BIG, 1); + break; + + default: + break; + } +} + + +/*==================================================================================* + * draw_bookmark: * + * draw one bookmark in the WINDOW *win. * + *----------------------------------------------------------------------------------* + * return: * + * -- * + *==================================================================================*/ + +static void draw_bookmark( WINDOW *win, Bookmark *selected, Bookmark *entry, int16 x, int16 y, int16 h) +{ + int16 xy[8], xtext, ytext; + + if( ( entry->arrow_position.y1 + y) < y || ( entry->arrow_position.y1 + y) >= y + h) + return; + + /* DRAW ARROW IS NEEDED */ + if ( entry->state != UNKNOWN) + { + if ( entry->state == ON) + { + xy[0] = entry->arrow_position.x1 + x; + xy[1] = entry->arrow_position.y1 + 3 + y; + xy[2] = xy[0] + 10; + xy[3] = xy[1]; + xy[4] = xy[0] + 5; + xy[5] = xy[1] + 5; + } + else + { + xy[0] = entry->arrow_position.x1 + x + 4; + xy[1] = entry->arrow_position.y1 + y; + xy[2] = xy[0]; + xy[3] = xy[1] + 10; + xy[4] = xy[0] + 5; + xy[5] = xy[1] + 5; + } + + vsf_color( win->graf.handle, LBLACK); + v_fillarea( win->graf.handle, 3, xy); + } + + /* DRAW TEXT */ + xtext = entry->arrow_position.x2 + x + x_space; + ytext = entry->arrow_position.y1 + y + 2; + + if ( entry == selected) + { + xy[0] = xtext - 2; + xy[2] = xy[0] + entry->txt_width + 4; + xy[1] = ytext - 1; + xy[3] = xy[1] + hcell + 2; + + vsf_color( win->graf.handle, BLACK); + v_bar( win->graf.handle, xy); + + draw_text( win->graf.handle, xtext, ytext, WHITE, entry->name); + } + else + draw_text( win->graf.handle, xtext, ytext, BLACK, entry->name); +} + + + +/*==================================================================================* + * draw_bookmark_child: * + * draw every bookmark's childs in the WINDOW *win. * + *----------------------------------------------------------------------------------* + * return: * + * number of lines drawn * + *==================================================================================*/ + +static int16 draw_bookmark_child( WINDOW *win, Bookmark *selected, Bookmark *entry, int16 x, int16 y, int16 xw, int16 yw, int16 hw) +{ + int16 i, lines = 0; + + if( entry->child == NULL) + return lines; + + for ( i = 0; i < entry->nbr_child ; i++) + { + if( entry->child[i].valid == FALSE) + continue; + + entry->child[i].arrow_position.x1 = x + 3; + entry->child[i].arrow_position.y1 = y + 3; + entry->child[i].arrow_position.x2 = x + 14; + entry->child[i].arrow_position.y2 = y + 14; + + draw_bookmark( win, selected, &entry->child[i], xw, yw, hw); + lines++; + y += 18; + + if( entry->child[i].state != ON) + continue; + + dum = draw_bookmark_child( win, selected, &entry->child[i], x + 15, y, xw, yw, hw); + + y += ( dum * 18); + + lines += dum; + } + + return lines; +} + + +void calc_slider( WINDATA *windata, OBJECT *slider_root) +{ + int16 max_mover_size = slider_root[SLIDERS_BACK].ob_height; + int16 full_win_size = windata->ypos_max * windata->h_u; + int16 win_h = slider_root->ob_height + 3; + + if ( win_h >= full_win_size) + { + windata -> ypos = 0; + + slider_root[SLIDERS_MOVER].ob_y = 0; + slider_root[SLIDERS_MOVER].ob_height = max_mover_size; + + } + else + { + int16 ligne_reste; + float mover_position = 0L; + float position_step = 0L; + float mover_size = MAX( ( float)max_mover_size * ( ( float)win_h / ( float)full_win_size), 10L); + + if( windata->ypos) + { + ligne_reste = windata->ypos_max - ( win_h / windata->h_u); + position_step = (( float)max_mover_size - mover_size) / ( float)ligne_reste; + mover_position = position_step * ( float)windata->ypos; + + while( (( int16)mover_size + ( int16)mover_position > max_mover_size) && windata->ypos > 0) + { + windata->ypos--; + mover_position -= position_step; + } + } + + slider_root[SLIDERS_MOVER].ob_height = ( int16)mover_size; + slider_root[SLIDERS_MOVER].ob_y = ( int16)mover_position; + } +} + + +static void WindPdfRedraw( WINDOW *win) +{ + int16 lines = 0, y, i, xw, yw, ww, hw, tmp, xy[8], pxy[4], page; + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + MFDB *picture, screen = {0}; + + page = windata->page_to_show; + + WindGet( win, WF_WORKXYWH, &xw, &yw, &ww, &hw); + + /* Multipages ? */ + if( windata->frame_width) /* browser active */ + { + pxy[0] = xw; + pxy[1] = yw; + pxy[2] = pxy[0] + windata->frame_width; + pxy[3] = pxy[1] + hw - 1; + + /* clean the first frame */ + vsf_color( win->graf.handle, WHITE); + v_bar( win->graf.handle, pxy); + + + /* Draw the 1st frame ( navigation folder) */ + y = 0 - ( ( int16)windata -> ypos * windata -> h_u); + + for ( i = 0 ; i < windata->nbr_bookmark; i++) + { + if( windata->root[i].valid == FALSE) + continue; + + windata->root[i].arrow_position.x1 = 3; + windata->root[i].arrow_position.y1 = y + 3; + windata->root[i].arrow_position.x2 = 14; + windata->root[i].arrow_position.y2 = y + 14; + + draw_bookmark( win, windata->selected, &windata->root[i], xw, yw, hw); + + lines++; + + y += windata -> h_u; + + if( windata->root[i].state != ON) + continue; + + dum = draw_bookmark_child( win, windata->selected, &windata->root[i], 15, y, xw, yw, hw); + + y += ( dum * windata -> h_u); + + lines += dum; + } + + windata -> ypos_max = lines; + + /* Draw the frame border */ + pxy[0] = pxy[2]; + vsl_color( win->graf.handle, BLACK); + v_pline( win->graf.handle, 2, pxy); + + pxy[0]++; + pxy[2] = pxy[0]; + vsl_color( win->graf.handle, WHITE); + v_pline( win->graf.handle, 2, pxy); + + pxy[0]++; + pxy[2] = pxy[0]; + vsl_color( win->graf.handle, LWHITE); + v_pline( win->graf.handle, 2, pxy); + + pxy[0]++; + pxy[2] = pxy[0]; + v_pline( win->graf.handle, 2, pxy); + + pxy[0]++; + pxy[2] = pxy[0]; + vsl_color( win->graf.handle, BLACK); + v_pline( win->graf.handle, 2, pxy); + + pxy[0] = xw; + pxy[1] = yw; + pxy[2] = pxy[0] + windata->frame_width - 1; + pxy[3] = yw; + v_pline( win->graf.handle, 2, pxy); + + if( ( windata -> ypos_max * windata -> h_u) >= hw) + { + windata->frame_slider->ob_x = xw + windata->frame_width - 15; + windata->frame_slider->ob_y = yw + 2; + windata->frame_slider->ob_height = hw - 3; + windata->frame_slider[SLIDERS_BACK].ob_height = hw - 31; + windata->frame_slider[SLIDERS_UP].ob_y = windata->frame_slider->ob_height - 31; + windata->frame_slider[SLIDERS_DOWN].ob_y = windata->frame_slider->ob_height - 15; + + calc_slider( windata, windata->frame_slider); + objc_draw( windata->frame_slider, SLIDERS_BOX, 2, clip.g_x, clip.g_y, clip.g_w, clip.g_h); + } + + xw += ( windata->frame_width + border_size); + ww -= ( windata->frame_width + border_size); + } + + pxy[0] = xw; + pxy[1] = yw; + pxy[2] = pxy[0] + ww - 1; + pxy[3] = yw; + + vsl_color( win->graf.handle, BLACK); + v_pline( win->graf.handle, 2, pxy); + + yw++; + + /* if the picture or the zoomed picture don't exist, we draw a gray rectangle and we exit the function */ + if( windata->zoom_picture.fd_addr) + picture = &windata->zoom_picture; + else if( windata->img.image[page].fd_addr) + picture = &windata->img.image[page]; + else + { + pxy[0] = xw; + pxy[1] = yw; + pxy[2] = pxy[0] + ww - 1; + pxy[3] = pxy[1] + hw - 1; + + vsf_color( win->graf.handle, LWHITE); + v_bar( win->graf.handle, pxy); + return; + } + + xy[0] = ( int16)win->xpos * win->w_u; + xy[4] = xw; + + if( picture->fd_w < ww) + xy[4] += ( ( ww - picture->fd_w) >> 1); + + tmp = MIN( ww, ( ( picture->fd_w) - xy[0])); + + xy[2] = xy[0] + tmp - 1; + xy[6] = xy[4] + tmp - 1; + + + xy[1] = ( int16)win->ypos * win->h_u; + xy[5] = yw; + + if( picture->fd_h < hw) + xy[5] += ( ( hw - picture->fd_h) >> 1); + + tmp = MIN( hw, ( ( picture->fd_h) - xy[1])); + + xy[3] = xy[1] + tmp - 1; + xy[7] = xy[5] + tmp - 1; + + if(( xy[6] <= ( xw + ww)) || ( xy[7] <= ( yw + hw))) + { + pxy[0] = xw; + pxy[1] = yw; + pxy[2] = pxy[0] + ww - 1; + pxy[3] = pxy[1] + hw - 1; + + vsf_color( win->graf.handle, LWHITE); + v_bar( win->graf.handle, pxy); + } + + if ( picture->fd_nplanes == 1) + { + int16 color[2] = { BLACK, WHITE}; + + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, picture, &screen, color); + } + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, picture, &screen); + + WindSlider ( win, VSLIDER|HSLIDER); +} + + + +static void WindPdfClose( WINDOW *win) +{ + WINDATA *windata = ( WINDATA *)DataSearch( win, WD_DATA); + IMAGE *img = &windata->img; + + delete_txt_data( img); + delete_mfdb( img->image, img->page); + + if( windata->icon.fd_addr != NULL) + gfree( windata->icon.fd_addr); + +// if( windata->zoom_picture.fd_addr != NULL) +// gfree( windata->zoom_picture.fd_addr); + + pdf_quit( img); + + if( windata->root) + { + int i; + + for ( i = 0; i < windata->nbr_bookmark; i++) + { + if ( windata->root[i].nbr_child) + delete_bookmark_child( &windata->root[i]); + } + + gfree( windata->root); + } + + if( windata->frame_slider) + ObjcFree( windata->frame_slider); + + gfree( windata); + + DataDelete( win, WD_DATA); + WindDelete( win); + + if( wglb.first) + { + snd_msg( wglb.first, WM_TOPPED, 0, 0, 0, 0); + } + else + { + menu_ienable( menu, MENU_BAR_SHOW_FULLSCREEN, 0); + menu_ienable( menu, MENU_BAR_SAVE, 0); + menu_ienable( menu, MENU_BAR_INFORMATION, 0); + } +} + + + + +WINDOW *WindPdf( char *filename) +{ + WINDOW *winview = NULL; + WINDATA *windata; + IMAGE *img; + double scale = 1.0; + int16 w, h; + char temp[10]; + + if ( ( windata = ( WINDATA*) gmalloc( sizeof( WINDATA))) == NULL) + { + graf_mouse( ARROW, NULL); + errshow( "", ENOMEM); + return NULL; + } + + windata->icon.fd_addr = NULL; + windata->zoom_picture.fd_addr = NULL; + windata->zoom_level = 100; + windata->page_to_show = 0; + windata->pause = FALSE; + windata->frame_width = 0; + windata->border_width = 0; + windata->root = NULL; + windata->selected = NULL; + windata->frame_slider = NULL; + windata->nbr_bookmark = 0; + + img = &windata->img; + + img->_priv_ptr = NULL; + img->view_mode = full_size; + img->progress_bar = show_read_progress_bar; + + strcpy( windata->name, filename); + + if ( ( winview = WindCreate( WAT_NOINFO, app.x, app.y, app.w, app.h)) == NULL) + { + gfree( windata); + errshow( "", ALERT_WINDOW); + graf_mouse( ARROW, NULL); + return NULL; + } + + WindSetPtr( winview, WF_TOOLBAR, get_tree( PDFTOOLBAR), WindPdfTool); + + WindCalc( WC_WORK, winview, 0, 0, app.w, app.h, &dum, &dum, &w, &h); + + if( !pdf_load( filename, img, w - 225, h - 20)) + { + WindDelete( winview); + gfree( windata); + // errshow( "", IMG_NO_VALID); + graf_mouse( ARROW, NULL); + return NULL; + } + + strcpy( windata->title, get_pdf_title()); + sprintf( windata->info, "zView - [%s]", fullpathname_to_filename( windata->name)); + + if( img->page > 1) + { + pdf_build_bookmark( windata, winview); + + if( windata->nbr_bookmark) + { + OBJECT *frame; + rsrc_gaddr( 0, SLIDERS, &frame); + windata->frame_slider = ObjcDup( frame, NULL); + EvntAttach( winview, WM_XBUTTON, WindPdfMouse); + EvntAttach( winview, WM_SIZED, WindPdfSize); + windata -> frame_width = 200; + windata -> border_width = 5; + } + } + + winview -> h_min = 80; + winview -> w_min = MAX( 80, windata->frame_width + windata->border_width + 80); + winview -> h_u = 8; + winview -> w_u = 8; + winview -> ypos_max = ( int32)( ( img->image[0].fd_h) >> 3); + winview -> xpos_max = ( int32)( ( img->image[0].fd_w + windata->frame_width + windata->border_width) >> 3); + windata -> h_u = 18; + windata -> ypos = 0; + windata -> ypos_max = 1; + + DataAttach( winview, WD_DATA, windata); + EvntAttach( winview, WM_REDRAW, WindPdfRedraw); + EvntAttach( winview, WM_DESTROY, WindPdfClose); + EvntAttach( winview, WM_XKEYBD, WindPdfKeyb); + EvntAttach( winview, WM_TOPPED, WindPdfTop); + EvntAttach( winview, WM_ARROWED, Win_Arrow); + EvntAttach( winview, WM_UPPAGE, Win_UpPage); + EvntAttach( winview, WM_DNPAGE, Win_DownPage); + EvntAttach( winview, WM_LFPAGE, Win_LeftPage); + EvntAttach( winview, WM_RTPAGE, Win_RightPage); + EvntAttach( winview, WM_UPLINE, Win_UpLine); + EvntAttach( winview, WM_DNLINE, Win_DownLine); + EvntAttach( winview, WM_RTLINE, Win_RightLine); + EvntAttach( winview, WM_LFLINE, Win_LeftLine); + EvntAttach( winview, WM_VSLID , Win_VSlide); + EvntAttach( winview, WM_HSLID , Win_HSlide); + + + WindSetStr( winview, WF_ICONDRAW, WindViewIcon); + WindSetStr( winview, WF_NAME, windata->info); + + RsrcUserDraw ( OC_TOOLBAR, winview, PDFTOOLBAR_BIG, draw_icon_greater, windata); + RsrcUserDraw ( OC_TOOLBAR, winview, PDFTOOLBAR_SMALL, draw_icon_smaller, windata); + RsrcUserDraw ( OC_TOOLBAR, winview, PDFTOOLBAR_NEXT, draw_icon_forward, windata); + RsrcUserDraw ( OC_TOOLBAR, winview, PDFTOOLBAR_PREVIOUS, draw_icon_back, windata); + RsrcUserDraw ( OC_TOOLBAR, winview, PDFTOOLBAR_OPEN, draw_icon_open, NULL); + RsrcUserDraw ( OC_TOOLBAR, winview, PDFTOOLBAR_INFO, draw_icon_info, NULL); +// RsrcUserDraw ( OC_TOOLBAR, winview, PDFTOOLBAR_SAVE, draw_icon_save, NULL); + RsrcUserDraw ( OC_TOOLBAR, winview, PDFTOOLBAR_PRINT, draw_icon_printer, NULL); + RsrcUserDraw ( OC_TOOLBAR, winview, PDFTOOLBAR_FIND, draw_icon_find, NULL); + + sprintf( temp, "1 of %d", img->page); + ObjcStrCpy( winview->tool.root, PDFTOOLBAR_PAGE, temp); + + if( pdf_fit_to_win) + scale = get_scale_value( img, windata->page_to_show + 1, w - ( windata->frame_width + windata->border_width + 20) , h - 20); + + sprintf( temp, "%.0f%%", scale * 100); + + ObjcStrCpy( winview->tool.root, PDFTOOLBAR_PERCENT, temp); + + + if ( !( WindOpen( winview, app.x, app.y, app.w, app.h))) + { + WindPdfClose( winview); + errshow( "", ALERT_WINDOW); + graf_mouse( ARROW, NULL); + return NULL; + } + + menu = get_tree( MENU_BAR); + + menu_ienable( menu, MENU_BAR_INFORMATION, 1); + menu_ienable( menu, MENU_BAR_SAVE, 0); + menu_ienable( menu, MENU_BAR_SHOW_FULLSCREEN, 1); + + graf_mouse( ARROW, NULL); + + return winview; +} diff --git a/sources/z-tools/trunk/zview/winpdf.h b/sources/z-tools/trunk/zview/winpdf.h new file mode 100644 index 0000000..c01971a --- /dev/null +++ b/sources/z-tools/trunk/zview/winpdf.h @@ -0,0 +1 @@ +extern WINDOW *WindPdf( char *filename); diff --git a/sources/z-tools/trunk/zview/wintimer.c b/sources/z-tools/trunk/zview/wintimer.c new file mode 100644 index 0000000..9d995d6 --- /dev/null +++ b/sources/z-tools/trunk/zview/wintimer.c @@ -0,0 +1,67 @@ +#include "general.h" +typedef struct xtimer +{ + void (*func)( WINDOW *); + WINDOW *win; + struct xtimer *next; +} XTIMER; +static XTIMER *root = NULL; +static void std_xtimer( void) +{ + XTIMER *scan; + for( scan = root; scan; scan = scan->next) + (*scan->func)( scan->win); +} +void TimerInit( int32 slice_timer) +{ + evnt.timer = slice_timer; + EvntAttach( NULL, WM_XTIMER, std_xtimer); +} +int16 TimerAttach( WINDOW *win, void *func) +{ + XTIMER *new = ( XTIMER *)gmalloc( sizeof(XTIMER)); + if( !new) + return FALSE; + new -> win = win; + new -> func = func; + new -> next = root; + root = new; + return TRUE; +} +static XTIMER *find_parent_timer( XTIMER *child) +{ + XTIMER *scan = root; + + while( scan) + { + if( scan->next != child) + { + scan = scan->next; + continue; + } + break; + } + + return( scan); +} +void TimerDelete( WINDOW *win) +{ + XTIMER *scan = root, *parent; + + while( scan) + { + if( scan->win != win) + { + scan = scan->next; + continue; + } + parent = find_parent_timer( scan); + + if( parent == NULL) + root = scan->next; + else + parent->next = scan->next; + gfree( scan); + break; + } +} diff --git a/sources/z-tools/trunk/zview/wintimer.h b/sources/z-tools/trunk/zview/wintimer.h new file mode 100644 index 0000000..0a4d9a4 --- /dev/null +++ b/sources/z-tools/trunk/zview/wintimer.h @@ -0,0 +1,4 @@ +extern void TimerInit( int32 slice_timer); +extern int16 TimerAttach( WINDOW *win, void *func); +extern void TimerDelete( WINDOW *win); + diff --git a/sources/z-tools/trunk/zview/zaes.c b/sources/z-tools/trunk/zview/zaes.c new file mode 100644 index 0000000..1bfdf2b --- /dev/null +++ b/sources/z-tools/trunk/zview/zaes.c @@ -0,0 +1,673 @@ +#include "general.h" +#include "prefs.h" +#include "infobox.h" +#include "pic_load.h" +#include "winimg.h" +#include "custom_font.h" +#include "catalog/catalog_icons.h" +#include "catalog/catalog.h" + +/* the variable need to be global because this function is done by */ +/* the AES in supervisor mode.. it's safe. */ +static int16 posx, posy, xy[10]; +static MFDB screen = {0}; +static int16 wanted_color[2] = { BLACK, WHITE}; +static MFDB *source = NULL; +static WINDATA *windata; +static WINDICON *wicones; + + +/* *** workaround for TOS and its small supervisor stack **** + * + * gemlib function that are stack hungry are replaced by the following + * function. These replacement are not safe thread but we don't care + * because this is for the non-shareable version of the LDG (for monoTOS) + */ + +static short vdi_intin[VDI_INTINMAX]; +static short vdi_intout[VDI_INTOUTMAX]; +static short vdi_ptsin[VDI_PTSINMAX]; +static short vdi_ptsout[VDI_PTSOUTMAX]; +static short vdi_control[VDI_CNTRLMAX]; + +static VDIPB vdi_params = { + &vdi_control[0], + &vdi_intin[0], + &vdi_ptsin[0], + &vdi_intout[0], + &vdi_ptsout[0] +}; + + + +static int my_vsl_color (short handle, short idx) { + vdi_intin[0] = idx; + + vdi_control[0] = 17; + vdi_control[1] = vdi_control[5] = 0; + vdi_control[3] = 1; + vdi_control[6] = handle; + + vdi (&vdi_params); + + return ((int)vdi_intout[0]); +} + +#define vsl_color my_vsl_color + +/* *** end of the workaround for TOS *** */ + +void generic_form_event( WINDOW *win) +{ + ObjcChange( OC_FORM, win, evnt.buff[4], NORMAL, FALSE); + ApplWrite( app.id, WM_CLOSED, win->handle, 0, 0, 0, 0); +} + + +OBJECT *get_tree( int16 obj_index) +{ + OBJECT *tree; + RsrcGaddr( NULL, 0, obj_index, &tree); + return tree; +} + + +/* Return a string from resource file */ + +char *get_string( int16 str_index) +{ + char *txt; + rsrc_gaddr( 5, str_index, &txt); + return txt; +} + + +void CDECL draw_object_image( WINDOW *win, PARMBLK *pblk, void *data) +{ + source = ( MFDB*)data; + + if( source == NULL) + { + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y; + xy[2] = xy[0] + 127; + xy[3] = xy[1] + 127; + + vsf_color( win->graf.handle, WHITE); + v_bar( win->graf.handle, xy); + + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y; + xy[2] = pblk->pb_x; + xy[3] = pblk->pb_y + 127; + xy[4] = pblk->pb_x + 127; + xy[5] = xy[3]; + xy[6] = xy[4]; + xy[7] = pblk->pb_y; + xy[8] = pblk->pb_x; + xy[9] = pblk->pb_y; + + vsl_color( win->graf.handle, BLACK); + v_pline( win->graf.handle, 5, xy); + + return; + } + else if(( source->fd_w < 128) || ( source->fd_h < 128)) + { + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y; + xy[2] = xy[0] + 127; + xy[3] = xy[1] + 127; + + vsf_color( win->graf.handle, WHITE); + v_bar( win->graf.handle, xy); + } + + posx = MAX( ( 128 - source->fd_w) >> 1, 0); + posy = MAX( ( 128 - source->fd_h) >> 1, 0); + + if (posx == 0) + xy[2] = 127; + else + xy[2] = source->fd_w - 1; + + if (posy == 0) + xy[3] = 127; + else + xy[3] = source->fd_h - 1; + + xy[0] = 0; + xy[1] = 0; + xy[4] = pblk->pb_x + posx; + xy[5] = pblk->pb_y + posy; + xy[6] = xy[4] + xy[2]; + xy[7] = xy[5] + xy[3]; + + if ( source->fd_nplanes == 1) + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, source, &screen, wanted_color); + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, source, &screen); + + xy[0] = pblk->pb_x; + xy[1] = pblk->pb_y; + xy[2] = pblk->pb_x; + xy[3] = pblk->pb_y + 127; + xy[4] = pblk->pb_x + 127; + xy[5] = xy[3]; + xy[6] = xy[4]; + xy[7] = pblk->pb_y; + xy[8] = pblk->pb_x; + xy[9] = pblk->pb_y; + + vsl_color( win->graf.handle, BLACK); + v_pline( win->graf.handle, 5, xy); +} + + +void CDECL draw_icon_up( WINDOW *win, PARMBLK *pblk, void *data) +{ + if( pblk->pb_currstate & SELECTED) + source = &mini_up_on; + else + source = &mini_up; + + xy[0] = xy[1] = 0; + xy[2] = 15; + xy[3] = 15; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 15; + xy[7] = xy[5] + 15; + + if ( source->fd_nplanes == 1) + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, source, &screen, wanted_color); + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, source, &screen); +} + +void CDECL draw_icon_find( WINDOW *win, PARMBLK *pblk, void *data) +{ +// if( pblk->pb_currstate & SELECTED) + source = &mini_find_on; +// else +// source = &mini_find; + + xy[0] = xy[1] = 0; + xy[2] = 15; + xy[3] = 15; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 15; + xy[7] = xy[5] + 15; + + if ( source->fd_nplanes == 1) + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, source, &screen, wanted_color); + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, source, &screen); +} + + +void CDECL draw_icon_reload( WINDOW *win, PARMBLK *pblk, void *data) +{ + if( pblk->pb_currstate & SELECTED) + source = &mini_reload_on; + else + source = &mini_reload; + + xy[0] = xy[1] = 0; + xy[2] = 15; + xy[3] = 15; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 15; + xy[7] = xy[5] + 15; + + if ( source->fd_nplanes == 1) + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, source, &screen, wanted_color); + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, source, &screen); +} + +void CDECL draw_icon_greater( WINDOW *win, PARMBLK *pblk, void *data) +{ + windata = ( WINDATA *)data; + + if( windata && (( windata->zoom_level >= 200) || ( windata->img.delay[0] != 0))) + { + source = &mini_big_on; + } + else if( !windata && ( thumbnail_size >= 7 || thumbnail_size == 3)) + { + source = &mini_big_on; + } + else + { + if( pblk->pb_currstate & SELECTED) + source = &mini_big_on; + else + source = &mini_big; + } + + xy[0] = xy[1] = 0; + xy[2] = 15; + xy[3] = 15; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 15; + xy[7] = xy[5] + 15; + + if ( source->fd_nplanes == 1) + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, source, &screen, wanted_color); + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, source, &screen); +} + +void CDECL draw_icon_smaller( WINDOW *win, PARMBLK *pblk, void *data) +{ + windata = ( WINDATA *)data; + + if( windata && (( windata->zoom_level <= 25) || ( windata->img.delay[0] != 0))) + { + source = &mini_small_on; + } + else if( !windata && ( !thumbnail_size || thumbnail_size == 4)) + { + source = &mini_small_on; + } + else + { + if( pblk->pb_currstate & SELECTED) + source = &mini_small_on; + else + source = &mini_small; + } + + + xy[0] = xy[1] = 0; + xy[2] = 15; + xy[3] = 15; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 15; + xy[7] = xy[5] + 15; + + if ( source->fd_nplanes == 1) + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, source, &screen, wanted_color); + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, source, &screen); +} + +void CDECL draw_icon_back( WINDOW *win, PARMBLK *pblk, void *data) +{ + windata = ( WINDATA *)data; + + if( windata->page_to_show == 0) + { + source = &mini_back_on; + } + else + { + if( pblk->pb_currstate & SELECTED) + source = &mini_back_on; + else + source = &mini_back; + } + + xy[0] = xy[1] = 0; + xy[2] = 15; + xy[3] = 15; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 15; + xy[7] = xy[5] + 15; + + if ( source->fd_nplanes == 1) + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, source, &screen, wanted_color); + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, source, &screen); +} + +void CDECL draw_icon_forward( WINDOW *win, PARMBLK *pblk, void *data) +{ + windata = ( WINDATA *)data; + + if( windata->page_to_show == windata->img.page - 1) + { + source = &mini_forward_on; + } + else + { + if( pblk->pb_currstate & SELECTED) + source = &mini_forward_on; + else + source = &mini_forward; + } + + xy[0] = xy[1] = 0; + xy[2] = 15; + xy[3] = 15; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 15; + xy[7] = xy[5] + 15; + + if ( source->fd_nplanes == 1) + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, source, &screen, wanted_color); + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, source, &screen); +} + +void CDECL draw_icon_printer( WINDOW *win, PARMBLK *pblk, void *data) +{ + source = &mini_printer_on; + + xy[0] = xy[1] = 0; + xy[2] = 15; + xy[3] = 15; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 15; + xy[7] = xy[5] + 15; + + if ( source->fd_nplanes == 1) + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, source, &screen, wanted_color); + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, source, &screen); +} + + +void CDECL draw_icon_open( WINDOW *win, PARMBLK *pblk, void *data) +{ + if( pblk->pb_currstate & SELECTED) + source = &mini_open_on; + else + source = &mini_open; + + xy[0] = xy[1] = 0; + xy[2] = 15; + xy[3] = 15; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 15; + xy[7] = xy[5] + 15; + + if ( source->fd_nplanes == 1) + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, source, &screen, wanted_color); + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, source, &screen); +} + +void CDECL draw_icon_fullscreen( WINDOW *win, PARMBLK *pblk, void *data) +{ + if( pblk->pb_currstate & SELECTED) + source = &mini_fullscreen_on; + else + source = &mini_fullscreen; + + xy[0] = xy[1] = 0; + xy[2] = 15; + xy[3] = 15; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 15; + xy[7] = xy[5] + 15; + + if ( source->fd_nplanes == 1) + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, source, &screen, wanted_color); + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, source, &screen); +} + + +void CDECL draw_icon_info( WINDOW *win, PARMBLK *pblk, void *data) +{ + if( win_catalog == win) + { + wicones = ( WINDICON *)DataSearch( win, WD_ICON); + + if( wicones->first_selected) + { + if( pblk->pb_currstate & SELECTED) + source = &mini_info_on; + else + source = &mini_info; + } + else source = &mini_info_on; + } + else + { + if( pblk->pb_currstate & SELECTED) + source = &mini_info_on; + else + source = &mini_info; + } + + xy[0] = xy[1] = 0; + xy[2] = 15; + xy[3] = 15; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 15; + xy[7] = xy[5] + 15; + + if ( source->fd_nplanes == 1) + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, source, &screen, wanted_color); + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, source, &screen); +} + + +void CDECL draw_icon_save( WINDOW *win, PARMBLK *pblk, void *data) +{ + if( win_catalog == win) + { + wicones = ( WINDICON *)DataSearch( win, WD_ICON); + + if( wicones->first_selected && wicones->first_selected->type == ET_IMAGE) + { + if( pblk->pb_currstate & SELECTED) + source = &mini_save_on; + else + source = &mini_save; + } + else source = &mini_save_on; + } + else + { + if( pblk->pb_currstate & SELECTED) + source = &mini_save_on; + else + source = &mini_save; + } + + xy[0] = xy[1] = 0; + xy[2] = 15; + xy[3] = 15; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 15; + xy[7] = xy[5] + 15; + + if ( source->fd_nplanes == 1) + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, source, &screen, wanted_color); + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, source, &screen); +} + +void CDECL draw_icon_delete( WINDOW *win, PARMBLK *pblk, void *data) +{ + wicones = ( WINDICON *)DataSearch( win, WD_ICON); + + if( wicones->first_selected) + { + if( pblk->pb_currstate & SELECTED) + source = &mini_delete_on; + else + source = &mini_delete; + } + else source = &mini_delete_on; + + xy[0] = xy[1] = 0; + xy[2] = 15; + xy[3] = 15; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 15; + xy[7] = xy[5] + 15; + + if ( source->fd_nplanes == 1) + vrt_cpyfm( win->graf.handle, MD_REPLACE, xy, source, &screen, wanted_color); + else + vro_cpyfm( win->graf.handle, S_ONLY, xy, source, &screen); +} + +/*==================================================================================* + * void draw_window_iconified: * + * Function to handle iconfied windows drawing. * + *----------------------------------------------------------------------------------* + * input: * + * win -> the window to handle. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void draw_window_iconified( WINDOW *win) +{ + int16 x, y, w, h, pxy[4]; + OBJECT *tree; + + rsrc_gaddr( 0, MINI_ICON, &tree); + + WindGet( win, WF_WORKXYWH, &x, &y, &w, &h); + + pxy[0] = x; + pxy[1] = y; + pxy[2] = pxy[0] + w - 1; + pxy[3] = pxy[1] + h - 1; + + vsf_color( win->graf.handle, LWHITE); + v_bar( win->graf.handle, pxy); + + tree->ob_x = x + (( w - 32) >> 1); + tree->ob_y = y + (( h - 32) >> 1); + + objc_draw( tree, MINI_ICON_SNIPE, 0, clip.g_x, clip.g_y, clip.g_w, clip.g_h); +} + + + +void errshow( const char *name, int16 error) +{ + switch( error) + { + case ALERT_WINDOW: + ( void)FormAlert( 1 , get_string( ALERT_WINDOW)); + break; + case ENAMETOOLONG: + ( void)FormAlert( 1 , get_string( NAMETOOLONG)); + break; + case ENOENT: + ( void)FormAlert( 1 , get_string( NOENT), name); + break; + case EACCES: + ( void)FormAlert( 1 , get_string( ACCES)); + break; + case ELOOP: + ( void)FormAlert( 1 , get_string( LOOP)); + break; + case ENOTDIR: + ( void)FormAlert( 1 , get_string( NOTDIR)); + break; + case E_NAMEEXIST: + ( void)FormAlert( 1 , get_string( NAMEALREADYUSED)); + break; + case EXDEV: + ( void)FormAlert( 1 , get_string( XDEV)); + break; + case ENOSPC: + ( void)FormAlert( 1 , get_string( NOSPC)); + break; + case EIO: + ( void)FormAlert( 1 , get_string( IO)); + break; + case EROFS: + ( void)FormAlert( 1 , get_string( ROFS)); + break; + case EFAULT: + ( void)FormAlert( 1 , get_string( FAULT)); + break; + case EINVAL: + ( void)FormAlert( 1 , get_string( INVAL)); + break; + case EBADF: + ( void)FormAlert( 1 , get_string( BADF)); + break; + case ENOMEM: + ( void)FormAlert( 1 , get_string( NOMEM)); + break; + case E_RSC: + ( void)FormAlert( 1 , "[1][zview.rsc not found!][Abort]"); + break; + case NO_EDDI: + ( void)FormAlert( 1 , get_string( NOEDDI)); + break; + case LDG_LIB_FULLED: + ( void)FormAlert( 1 , get_string( LDG_LIB_FULLED), name); + break; + case LDG_APP_FULLED: + ( void)FormAlert( 1 , get_string( APP_FULLED), name); + break; + case LDG_ERR_EXEC: + ( void)FormAlert( 1 , get_string( ERR_EXEC), name); + break; + case LDG_BAD_FORMAT: + ( void)FormAlert( 1 , get_string( BAD_LFORMAT), name); + break; + case LDG_LIB_LOCKED: + ( void)FormAlert( 1 , get_string( LIB_LOCKED), name); + break; + case LDG_NOT_FOUND: + ( void)FormAlert( 1 , get_string( NOT_FOUND), name); + break; + case LDG_NO_MEMORY: + ( void)FormAlert( 1 , get_string( NO_MEMORY), name); + break; + case LDG_NO_FUNC: + ( void)FormAlert( 1 , get_string( NOFUNC), name); + break; + case PLUGIN_DECODER_ABSENT: + ( void)FormAlert( 1 , get_string( PLUGIN_DECODER_ABSENT)); + break; + case PLUGIN_ENCODER_ABSENT: + ( void)FormAlert( 1 , get_string( PLUGIN_ENCODER_ABSENT)); + break; + case CANT_LOAD_IMG: + ( void)FormAlert( 1 , get_string( CANT_LOAD_IMG), name); + break; + case CANT_SAVE_IMG: + ( void)FormAlert( 1 , get_string( CANT_SAVE_IMG)); + break; + case IMG_NO_VALID: + ( void)FormAlert( 1 , get_string( IMG_NO_VALID)); + break; + case SOURCE_TARGET_SAME: + ( void)FormAlert( 1 , get_string( SOURCE_TARGET_SAME)); + break; + case NOZCODECS: + ( void)FormAlert( 1 , get_string( NOZCODECS)); + break; + case NO_ICON: + ( void)FormAlert( 1 , get_string( NOICONS)); + break; + default: + ( void)FormAlert( 1 , get_string( GENERIC)); + break; + } +} + + + + + + diff --git a/sources/z-tools/trunk/zview/zaes.h b/sources/z-tools/trunk/zview/zaes.h new file mode 100644 index 0000000..218bc5f --- /dev/null +++ b/sources/z-tools/trunk/zview/zaes.h @@ -0,0 +1,21 @@ +extern OBJECT *get_tree( int16 obj_index); +extern char *get_string( int16 str_index); +extern void errshow( const char *name, int16 error); +extern void generic_form_event( WINDOW *win); + +extern void CDECL draw_icon_up( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_icon_reload( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_icon_greater( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_icon_smaller( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_object_image( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_icon_back( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_icon_forward( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_icon_printer( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_icon_open( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_icon_info( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_icon_delete( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_icon_save( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_icon_fullscreen( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_icon_find( WINDOW *win, PARMBLK *pblk, void *data); + +extern void draw_window_iconified( WINDOW *win); diff --git a/sources/z-tools/trunk/zview/zedit/char.c b/sources/z-tools/trunk/zview/zedit/char.c new file mode 100644 index 0000000..03375f1 --- /dev/null +++ b/sources/z-tools/trunk/zview/zedit/char.c @@ -0,0 +1,227 @@ +/* + * Routines d'‚dition de texte + * D.B‚r‚ziat 1998 + * Insertion/Suppressions de caractŠres + */ + +#include +#include +#include +#include +#include "../types2b.h" +#include "../pdf/goo/gmem.h" +#include "libtedit.h" + +/* extern function */ +extern EDLINE *line_new( char *buf); +extern void line_add( EDIT *edit, EDLINE *line, int16 mode); +extern void line_rem( EDIT *edit); + + +/* prototype */ +void char_shift_right( char *buf); +void char_shift_left( char *buf); + + + +/* d‚calage vers la droite du buffer */ + +void char_shift_right( char *buf) +{ + int16 l = ( int16)strlen(buf); + + buf += l; + *(buf+1) = '\0'; + + while( l) + { + *buf = *(buf-1); + buf --; + l --; + } +} + +/* d‚calage vers la gauche du buffer */ + +void char_shift_left( char *buf) +{ + do + { + *buf = *(buf+1); + } while (*buf++); +} + + +/* Insertion … la position courante + * et incr‚mentation de la position */ + +void char_put( EDIT *edit, int16 c) +{ + EDLINE *line; + int16 pos; + + if( edit -> top == NULL) + { + edit -> top = line_new( NULL); + edit -> bot = edit -> cur.line = edit -> top; + } + + pos = edit->cur.row; + + if( c == NEWLINE) + { + line = line_new( edit->cur.line->buf+pos); + edit->cur.line->buf[pos] = ENDLINE; + edit->cur.line->len = (int)strlen( edit->cur.line->buf); + line_add( edit, line, ED_CUR); + edit->cur.row = 0; + edit->cur.line = line; + edit->cur.index ++; + } + else + { + line = edit->cur.line; + + if( ++line->len >= line->size) + { + line->size += SIZE_REALLOC; + line->buf = ( char*)grealloc(line->buf,line->size); + } + + char_shift_right( line->buf + pos); + line->buf[pos] = c; + edit->cur.row ++; + } +} + +/* int char_get(void); */ + +/* + * Efface le caractŠre derriŠre le curseur + * retourne 1 si OK 0 si on a effacer une ligne + */ + +int16 char_del( EDIT *edit) +{ + if( edit -> top == NULL) + return 0; + + if( edit -> cur.row) + { + edit -> cur.row --; + edit -> cur.line -> len --; + char_shift_left( edit -> cur.line->buf + edit -> cur.row); + } + else + { + EDLINE *line = edit -> cur.line; + int16 pos, tindex; + + if( line -> prev) + { + /* Concat‚ner la ligne pr‚c‚dente avec la ligne courante */ + pos = line -> prev -> len; + + /* Adapter la taille */ + if( line -> prev -> size < line -> prev -> len + line -> len) + { + line -> prev -> size = line -> prev -> len + line -> len + 1; + line -> prev -> buf = (char *) grealloc( line -> prev -> buf, line -> size); + } + + strcat( line -> prev -> buf, line -> buf); + line -> prev -> len = (int) strlen( line -> prev -> buf); + /* Effacer la ligne courante */ + line = line -> prev; + tindex = edit -> cur.index; + line_rem( edit); + /* Pointer la ligne pr‚c‚dente … la bonne position */ + edit -> cur.row = pos; + edit -> cur.line = line; + edit -> cur.index = tindex-1; + return 0; + } + } + return 1; +} + +/* Mouvement du curseur */ + +int16 curs_left( EDIT *edit) +{ + if( edit->cur.row ) + { + edit->cur.row --; + edit->maxcur --; + } + else if( edit->cur.line->prev) + { + edit->cur.index --; + edit->cur.line = edit->cur.line->prev; + edit->maxcur = edit->cur.row = edit->cur.line->len; + } + else + return 0; + + return 1; +} + +int16 curs_right( EDIT *edit) +{ + int16 c = edit->cur.line->buf[edit->cur.row]; + + if( c == '\0') + { + if( edit->cur.line->next) + { + edit->cur.index ++; + edit->cur.line = edit->cur.line->next; + edit->cur.row = 0; + edit->maxcur = 0; + } + else + return 0; /* fin du buffer */ + } + else + { + edit->cur.row ++; + edit->maxcur ++; + } + return 1; +} + +int16 curs_up( EDIT *edit) +{ + if( edit -> cur.line -> prev) + { + edit -> cur.index --; + edit -> cur.line = edit -> cur.line -> prev; + edit -> cur.row = MAX( edit -> cur.row, edit -> maxcur); + edit -> cur.row = MIN( edit -> cur.row, edit -> cur.line -> len); + return 1; + } + return 0; +} + +int16 curs_down( EDIT *edit) +{ + if( edit -> cur.line -> next) + { + edit -> cur.index ++; + edit -> cur.line = edit -> cur.line -> next; + edit -> cur.row = MAX( edit -> cur.row, edit -> maxcur); + edit -> cur.row = MIN( edit -> cur.row, edit -> cur.line -> len); + return 1; + } + return 0; +} + +/* Insertion d'une chaine dans une ligne */ + +void string_put( EDIT *edit, char *str) +{ + for( ;*str;str++) + { + char_put( edit, *str); + } +} diff --git a/sources/z-tools/trunk/zview/zedit/edit.c b/sources/z-tools/trunk/zview/zedit/edit.c new file mode 100644 index 0000000..74078f5 --- /dev/null +++ b/sources/z-tools/trunk/zview/zedit/edit.c @@ -0,0 +1,196 @@ +/* + * Routines d'‚dition de texte + * Dominique B‚r‚ziat, tous droits r‚serv‚s + * module : edit.c + * descr. : + */ +#include +#include +#include +#include "../types2b.h" +#include "../pdf/goo/gmem.h" +#include "libtedit.h" + +/* NewLine: cr‚‚ une nouvelle ligne */ + +EDLINE *line_new( char *buf) +{ + EDLINE *line = (EDLINE*)gmalloc(sizeof(EDLINE)); + + if( line == NULL) return NULL; + + if( buf) + { + line -> buf = copyString( buf); + + if( line -> buf) + { + line -> len = (int)strlen( buf); + line -> size = line -> len + 1; + line -> next = line ->prev = NULL; + return line; + } + + } + else + { + line -> buf = gmalloc( sizeof(char)*SIZE_REALLOC); + + if( line -> buf) + { + *line -> buf = '\0'; + line -> len = 0; + line -> size = SIZE_REALLOC; + line -> next = line ->prev = NULL; + return line; + } + } + gfree( line); + + return NULL; +} + +/* Addline : ajoute une ligne dans le buffer */ + +void line_add( EDIT *edit, EDLINE *line, int16 mode) +{ + EDLINE *tmp; + + edit -> maxline ++; + + if( edit->top == NULL) + edit->top = edit->bot = edit->cur.line = line; + else + switch( mode) + { + case ED_TOP: + tmp = edit -> top; + edit -> top = line; + line -> next = tmp; + tmp -> prev = line; + break; + + case ED_BOT: + tmp = edit -> bot; + edit -> bot = line; + line -> prev = tmp; + tmp -> next = line; + break; + + /* Insertion … la position du curseur */ + case ED_CUR: + tmp = edit -> cur.line; + /* la ligne ajout‚e devient la ligne courante */ + edit -> cur.line = line; + /* lien avec la ligne suivante (si elle existe ) */ + line -> next = tmp->next; + + if( tmp -> next) + tmp -> next -> prev = line; + /* lien avec la ligne pr‚c‚dente */ + line -> prev = tmp; + tmp -> next = line; + break; + } +} + +/* RemLine : retire la ligne courante */ + +void line_rem( EDIT *edit) +{ + EDLINE *line = edit -> cur.line; + + if( edit -> top == NULL) + return; + + edit -> maxline --; + + if( line -> prev) + { + /* connecter les lignes pr‚c‚dente et suivante */ + if( line -> prev) + line -> prev -> next = line -> next; + else + edit -> top = line -> next; + + if( line -> next) + line -> next -> prev = line -> prev; + else + edit -> bot = line -> prev; + + /* nouvelle ligne courante */ + if( line->next) + edit -> cur.line = line->next; + else + { + edit -> cur.line = line->prev?line->prev:NULL; + + if( line->prev) + edit -> cur.index --; + } + edit -> cur.row = 0; + } + else + { + /* Connecter … la ligne suiante */ + edit -> top = edit->cur.line = line->next; + + if( edit->cur.line) + edit->cur.line->prev = NULL; + + edit -> cur.row = 0; + } + + gfree( line -> buf); + gfree( line); +} + + +/* + * D‚clare un nouveau texte + */ + +EDIT* edit_new( void) +{ + EDIT *edit = ( EDIT *)gmalloc( sizeof( EDIT)); + + if( edit == NULL) + return NULL; + + edit -> top = edit -> bot = edit -> cur.line = NULL; + edit -> cur.row = 0; + edit -> cur.index = 1; + edit -> maxline = 0L; + edit -> maxcur = 0; + edit -> type = T_DOS; + *edit -> name = '\0'; + return edit; +} + +void edit_free( EDIT *edit) { + EDLINE *scan = edit -> top; + EDLINE *next; + + while( scan) + { + next = scan -> next; + gfree( scan->buf); + gfree( scan); + scan = next; + } + + gfree( edit); +} + +int16 diff_line( EDLINE *up, EDLINE *dn) +{ + EDLINE *scan; + int16 diff; + + for( diff = 0, scan = up; scan!=dn && scan!=NULL; diff ++, scan = scan->next); + + if( scan == NULL) + for( diff = 0, scan = up; scan!=dn && scan!=NULL; diff --, scan = scan->prev); + + return diff; +} diff --git a/sources/z-tools/trunk/zview/zedit/libtedit.h b/sources/z-tools/trunk/zview/zedit/libtedit.h new file mode 100644 index 0000000..5ad1e4e --- /dev/null +++ b/sources/z-tools/trunk/zview/zedit/libtedit.h @@ -0,0 +1,94 @@ +/* + * Routines d'‚dition de texte + * D.B‚r‚ziat 1998/1999/200 + * D‚finition g‚n‚rales + * + * version 1.02 bug fix‚ dans line_rem() + * version 1.01 bug fix‚ dans la r‚allocation des lignes + * version 1.00 premiŠre version fonctionnelle + */ + +#ifndef pos_t +typedef size_t pos_t; +#endif + +#define MAXBUF 256 +#define SIZE_REALLOC 128 +#define NEWLINE '\n' +#define ENDLINE '\0' +#define TABULATOR '\t' + +/* type */ +#define T_AUTO -1 +#define T_DOS 0 +#define T_NULL 1 +#define T_BIN 2 +#define T_UNIX 3 +#define T_MAC 4 +#define T_USER 5 + +/* typedef unsigned int uint; */ + +typedef struct edline +{ + char *buf; /* adresse buffer ligne */ + int16 len; /* longueur de la ligne */ + int16 size; /* taille en octet de la ligne, octet en surplus y compris */ + struct edline *prev, *next; +} EDLINE; + + +typedef struct cursor +{ + EDLINE *line; /* ligne */ + int16 row; /* colonne */ + int16 index; /* index de la ligne */ +} CURSOR; + + +typedef struct edit +{ + EDLINE *top; /* premiere ligne */ + EDLINE *bot; /* derniere ligne */ + CURSOR cur; /* position curseur */ + int16 maxcur; /* col max curseur */ + pos_t maxline; /* nombre de lignes */ + int16 type; /* Type du buffer */ + char name[255]; /* Nom du buffer */ + void *gr; /* Interface utilisateur */ +} EDIT; + +/* mode de line_add */ +#define ED_TOP 1 +#define ED_BOT 2 +#define ED_CUR 3 + +/* qqs macros */ +#define IS_TOP( edit) ((!(edit)->cur.row && !(edit)->cur.line->prev)?1:0) +#define IS_BOT( edit) (((edit)->cur.line->buf[(edit)->cur.row] == ENDLINE && !edit->cur.line->next) ? 1:0) +#define IS_UP( edit) (((edit)->cur.line->prev)?0:1) +#define IS_DN( edit) (((edit)->cur.line->next)?0:1) + +#define GET_CHAR( edit) ((edit)->cur.line->buf[(edit)->cur.row]) +#define GET_ROW( edit) ((edit)->cur.row) + +#ifndef NOPROTO + +int16 curs_left ( EDIT *edit); +int16 curs_right ( EDIT *edit); +int16 curs_up ( EDIT *edit); +int16 curs_down ( EDIT *edit); +int16 char_del ( EDIT *edit); +void char_put ( EDIT *edit, int16 c); +void string_put ( EDIT *edit, char *str); +EDIT * edit_new ( void); +void edit_free ( EDIT *edit); +EDLINE *line_new ( char *buf); +void line_add ( EDIT *edit, EDLINE *line, int16 mode); +void line_rem ( EDIT *edit); + +char * tab2spc ( int16 tab, char *dest, char *src, int16 ); +size_t edit_size ( EDIT *edit); +int16 diff_line ( EDLINE *up, EDLINE *dn); + +#endif diff --git a/sources/z-tools/trunk/zview/zedit/zedit.c b/sources/z-tools/trunk/zview/zedit/zedit.c new file mode 100644 index 0000000..544838a --- /dev/null +++ b/sources/z-tools/trunk/zview/zedit/zedit.c @@ -0,0 +1,141 @@ +#include "../general.h" +#include "../catalog/catalog.h" +#include "../zaes.h" +#include "../custom_font.h" + +/* prototype */ +void cursor_position( WINDOW *win, int16 *x, int16 *y, int16 *w, int16 *h); +void edit_icon_txt( WINDOW *win, Entry *entry); +void init_edit_mode( WINDOW *win, Entry *entry); +void exit_edit_mode( WINDOW *win, Entry *entry); + + +/*==================================================================================* + * cursor_position: * + * compute the cursor position in edition_mode. * + *----------------------------------------------------------------------------------* + * returns: - * + *----------------------------------------------------------------------------------* + * win: The Target Window. * + * x, y, w, h: Returned Cursor Positions. * + *==================================================================================*/ + +void cursor_position( WINDOW *win, int16 *x, int16 *y, int16 *w, int16 *h) +{ + WINDICON *wicones = (WINDICON *)DataSearch( win, WD_ICON); + CURSOR *cur = &wicones->edit->cur; + + WindGet( win, WF_WORKXYWH, x, y, w, h); + + *h = 8; + + if( cur->line) + { + char txt[] = " "; + char *p; + + *txt = cur -> line -> buf [ cur -> row]; + cur -> line -> buf [ cur -> row] = '\0'; + + p = cur -> line -> buf; + + *x += get_text_width( p); + cur -> line -> buf [ cur -> row] = *txt; + + *w = MAX( get_text_width( p), 8); + } + else + { + *w = 8; + *x += cur -> row * 8; /* Must be 0 ? */ + } +} + + + + + +/*==================================================================================* + * edit_icon_txt: * + * edit the selected icon 's text in real time in the WINDOW *win. * + *----------------------------------------------------------------------------------* + * wind = the target window * + * entry = the selected entry to be edited * + *----------------------------------------------------------------------------------* + * returns: - * + *==================================================================================*/ + +void edit_icon_txt( WINDOW *win, Entry *entry) +{ + int16 xw, yw, x, y, w, h; + + WindGet ( win, WF_WORKXYWH, &xw, &yw, &w, &h); + + x = entry->txt_pos.x1 - 5; + y = entry->txt_pos.y1 - 1; + w = entry->txt_pos.x2 + 10 - x; + h = entry->txt_pos.y2 + 2 - y; + + x += xw; + y += yw; + + draw_page( win, x, y, w, h); +} + +/*==================================================================================* + * init_edit_mode: * + * initialize the edition mode. * + *----------------------------------------------------------------------------------* + * win = the target window * + * entry = the icon to be edited * + *----------------------------------------------------------------------------------* + * returns: - * + *==================================================================================*/ + +void init_edit_mode( WINDOW *win, Entry *entry) +{ + WINDICON *wicones = (WINDICON *)DataSearch( win, WD_ICON); + + if ( wicones->edit == NULL) + wicones->edit = edit_new(); + + string_put( wicones->edit, entry->name); + + WinCatalog_Refresh( win); + + edit_icon_txt( win, entry); +} + + + +/*==================================================================================* + * exit_edit_mode: * + * Exit edition mode and refresh the edited icon. * + *----------------------------------------------------------------------------------* + * wind = the target window * + * entry = the last edited icon * + *----------------------------------------------------------------------------------* + * returns: - * + *==================================================================================*/ + +void exit_edit_mode( WINDOW *win, Entry *entry) +{ + WINDICON *wicones = (WINDICON *)DataSearch( win, WD_ICON); + int16 xw, yw, x, y, w, h; + + WindGet( win, WF_WORKXYWH, &xw, &yw, &w, &h); + + x = entry->txt_pos.x1 - 5; + y = entry->txt_pos.y1 - 1; + w = entry->txt_pos.x2 + 10 - x; + h = entry->txt_pos.y2 + 2 - y; + + x += xw; + y += yw; + + edit_free( wicones->edit); + wicones->edit = NULL; + + draw_page( win, x, y, w, h); +} + diff --git a/sources/z-tools/trunk/zview/zedit/zedit.h b/sources/z-tools/trunk/zview/zedit/zedit.h new file mode 100644 index 0000000..3068fc1 --- /dev/null +++ b/sources/z-tools/trunk/zview/zedit/zedit.h @@ -0,0 +1,4 @@ +extern void edit_icon_txt( WINDOW *win, Entry *entry); +extern void init_edit_mode( WINDOW *win, Entry *entry); +extern void exit_edit_mode( WINDOW *win, Entry *entry); +extern void cursor_position( WINDOW *win, int16 *x, int16 *y, int16 *w, int16 *h); diff --git a/sources/z-tools/trunk/zview/ztext.c b/sources/z-tools/trunk/zview/ztext.c new file mode 100644 index 0000000..848147d --- /dev/null +++ b/sources/z-tools/trunk/zview/ztext.c @@ -0,0 +1,173 @@ +#include "general.h" + + +/* Local variable */ +typedef struct +{ + char upper; + char lower; +} CUL; + + +static CUL c[] = { {'A', 'a'}, {'B', 'b'}, {'C', 'c'}, {'D', 'd'}, {'E', 'e'}, {'F', 'f'}, {'G', 'g'}, {'H', 'h'}, + {'I', 'i'}, {'J', 'j'}, {'K', 'k'}, {'L', 'l'}, {'M', 'm'}, {'N', 'n'}, {'O', 'o'}, {'P', 'p'}, + {'Q', 'q'}, {'R', 'r'}, {'S', 's'}, {'T', 't'}, {'U', 'u'}, {'V', 'v'}, {'W', 'w'}, {'X', 'x'}, + {'Y', 'y'}, {'Z', 'z'}, {'š', ''}, {'', '‚'}, {'Ž', '„'}, {0xb6, '…'}, {'', '†'}, {'€', '‡'}, + {'’', '‘'}, {'™', '”'}, {'¥', '¤'}, {0xb7, 0xb0}, {0xb8, 0xb1}, {0xb2, 0xb3}, {0xb5, 0xb4} }; + + +/* Prototype */ +void size_to_text( char *txt, float size); +void str2lower(char *str); +void str2upper(char *str); +int16 name_shorter( int16 handle, int16 max_size, char *str); +char *zstrncpy( char *dst, const char *src, size_t n); + + +/*==================================================================================* + * zstrncpy: * + * Copy bytes from to , including the terminating \0'-byte. * * + * If is longer than , it will be truncated with a '\0'-byte at * + * position n-1. * + * Example: zstrncpy(b, "string", 1) would put a '\0'-byte at b[0] and * + * return. * + * Basically, think of the as a limiter on the number of bytes at * + * we're allowed to touch, and then fit a string-copying idea on top of that. * + * Works for me, and a lot better than the standard strncpy(), too. * + *----------------------------------------------------------------------------------* + * returns: * + *----------------------------------------------------------------------------------* + * dst: Pointer to destination text. * + * src: Pointer to source text. * + * n: Limiter on the number of bytes at * + *==================================================================================*/ + +char *zstrncpy( char *dst, const char *src, size_t n) +{ + register const char *source = src; + register char *dest = dst; + register size_t count = n; + + if( dest && !source && count) + *dest = '\0'; + else if( dest && source && (count >= 1)) + { + for( count--; count > 0 && *source != '\0'; count--) + *dest++ = *source++; + *dest = '\0'; + } + return dst; +} + +/*==================================================================================* + * fullpathname_to_filename: * + * return a file name from a full path name. * + *----------------------------------------------------------------------------------* + * returns: the filename * + *----------------------------------------------------------------------------------* + * fullpathname: the full path name. * + *==================================================================================*/ + +char *fullpathname_to_filename( char *fullpathname) +{ + int16 path_len, file_len; + int8 *fullname = fullpathname; + + file_len = ( int16)strlen( fullname); + path_len = file_len; + + while(( fullname[path_len] != '/') && ( fullname[path_len] != '\\')) + path_len--; + + path_len++; + + return &fullname[path_len]; +} + +/*==================================================================================* + * size_to_text: * + * convert to a Human readable string. * + *----------------------------------------------------------------------------------* + * returns: - * + *----------------------------------------------------------------------------------* + * txt: Pointer to a text for the convertion. * + * size: File size in byte. * + *==================================================================================*/ + +void size_to_text( char *txt, float size) +{ + char format[10]; + + if ( size > 1023.0) + { + size = size / 1024.0; + + if ( size > 1023.0) + { + size = size / 1024.0; + sprintf( format, "MB"); + } + else + sprintf( format, "KB"); + + sprintf( txt, "%.1f %s", size, format); + } + else + sprintf( txt, "%.0f bytes", size); +} + +/*==================================================================================* + * str2lower: * + * Transforms all letters in the string to lower case. * + *----------------------------------------------------------------------------------* + * returns: - * + *----------------------------------------------------------------------------------* + * str: Pointer to null terminated string. * + *==================================================================================*/ +void str2lower(char *str) +{ + int16 i, k; + + i = 0; + while (str[i] != '\0') + { + for (k = 0; k < (sizeof(c) / sizeof(CUL)); k++) + { + if (c[k].upper == str[i]) + { + str[i] = c[k].lower; + break; + } + } + i++; + } +} + + +/*==================================================================================* + * str2upper: * + * Transforms all letters in the string to uper case. * + *----------------------------------------------------------------------------------* + * returns: - * + *----------------------------------------------------------------------------------* + * str: Pointer to null terminated string. * + *==================================================================================*/ +void str2upper(char *str) +{ + int16 i, k; + + i = 0; + while (str[i] != '\0') + { + for (k = 0; k < (sizeof(c) / sizeof(CUL)); k++) + { + if (c[k].lower == str[i]) + { + str[i] = c[k].upper; + break; + } + } + i++; + } +} + diff --git a/sources/z-tools/trunk/zview/ztext.h b/sources/z-tools/trunk/zview/ztext.h new file mode 100644 index 0000000..4a65ab9 --- /dev/null +++ b/sources/z-tools/trunk/zview/ztext.h @@ -0,0 +1,6 @@ +extern void size_to_text( char *txt, float size); +extern void str2lower(char *str); +extern void str2upper(char *str); +extern char *zstrncpy( char *dst, const char *src, size_t n); +extern char *fullpathname_to_filename( char *fullpathname); + diff --git a/sources/z-tools/trunk/zview/zvdi/color.c b/sources/z-tools/trunk/zview/zvdi/color.c new file mode 100644 index 0000000..b2448f0 --- /dev/null +++ b/sources/z-tools/trunk/zview/zvdi/color.c @@ -0,0 +1,190 @@ +#include "..//general.h" +#include "..//pic_load.h" +#include "vdi.h" + +typedef struct +{ + uint8 satur; + uint8 red, green, blue; +} SRGB; + +static SRGB screen_colortab[256]; + + +/* prototype */ +void save_colors(void); +int16 remap_color (int32 value); +uint32 color_lookup ( uint32 rgb, int16 *trans); +void cnvpal_mono ( IMGINFO info, DECDATA data); +void cnvpal_1_2 (IMGINFO info, DECDATA data); +void cnvpal_4_8( IMGINFO info, DECDATA data); +void cnvpal_15( IMGINFO info, DECDATA data); +void cnvpal_high( IMGINFO info, DECDATA data); +void cnvpal_true( IMGINFO info, DECDATA data); + + +static uint8 saturation (uint8 * rgb) +{ + uint8 satr; + + if (rgb[0] >= rgb[1]) + { + if (rgb[1] >= rgb[2]) + satr = rgb[0] - rgb[2]; + else if (rgb[0] > rgb[2]) + satr = rgb[0] - rgb[1]; + else + satr = rgb[2] - rgb[1]; + } + else if (rgb[1] >= rgb[2]) + { + if (rgb[0] >= rgb[2]) + satr = rgb[1] - rgb[2]; + else + satr = rgb[1] - rgb[0]; + } + else + satr = rgb[2] - rgb[0]; + + return satr; +} + + +void save_colors(void) +{ + register int16 i; + + for( i = 0; i < app.color; i++) + { + screen_colortab[i].red = ((((int32)app.palette[i][0] << 8 ) - app.palette[i][0]) + 500) / 1000; + screen_colortab[i].green = ((((int32)app.palette[i][1] << 8 ) - app.palette[i][1]) + 500) / 1000; + screen_colortab[i].blue = ((((int32)app.palette[i][2] << 8 ) - app.palette[i][2]) + 500) / 1000; + screen_colortab[i].satur = saturation ( &screen_colortab[i].red); + } +} + +int16 remap_color (int32 value) +{ + int16 red = ((uint8*)&value)[1]; + int16 green = ((uint8*)&value)[2]; + int16 blue = ((uint8*)&value)[3]; + int16 satur = saturation (((uint8*)&value) +1); + + int16 best_fit = 0; + uint16 best_err = 0xFFFFu; + int16 max_color = 1 << app.nplanes; + + int16 i = 0; + + value = ( value & 0x00FFFFFFl) | (( int32)satur << 24); + + do + { + if ( *( int32*)&screen_colortab[i] == value) + { + /* gotcha! */ + best_fit = i; + break; + } + else + { + uint16 err = + ( red > screen_colortab[i].red ? red - screen_colortab[i].red : screen_colortab[i].red - red) + + (green > screen_colortab[i].green ? green - screen_colortab[i].green : screen_colortab[i].green - green) + + (blue > screen_colortab[i].blue ? blue - screen_colortab[i].blue : screen_colortab[i].blue - blue) + + (satur > screen_colortab[i].satur ? satur - screen_colortab[i].satur : screen_colortab[i].satur - satur); + + if (err <= best_err) + { + best_err = err; + best_fit = i; + } + } + } while (++i < max_color); + + return best_fit; +} + + +uint32 color_lookup ( uint32 rgb, int16 *trans) +{ + uint8 idx = ((rgb & ~0xFFuL) == ~0xFFuL ? rgb : remap_color (rgb)); + return ( (( int32)(trans ? trans[idx] : idx) << 24) | (*(int32*)&screen_colortab[idx] & 0x00FFFFFFuL)); +} + + +void cnvpal_mono ( IMGINFO info, DECDATA data) +{ +/* if ( info->indexed_color) + { + uint32 bgnd, fgnd; + + bgnd = (((( int32)info->palette[0].red <<8) | info->palette[0].green) <<8) | info->palette[0].blue; + fgnd = (((( int32)info->palette[1].red <<8) | info->palette[1].green) <<8) | info->palette[1].blue; + + data->Pixel[0] = remap_color ( bgnd); + data->Pixel[1] = remap_color ( fgnd); + + } + else +*/ { + data->Pixel[0] = G_WHITE; + data->Pixel[1] = G_BLACK; + } +} + + +void cnvpal_1_2 (IMGINFO info, DECDATA data) +{ + register int32 i; + + for( i = 0; i < info->colors; i++) + { + data->Pixel[i] = ( int16)info->palette[i].red * 5 + ( int16)info->palette[i].green * 9 + (( int16)info->palette[i].blue << 1); + } +} + + +void cnvpal_4_8( IMGINFO info, DECDATA data) +{ + register int32 i; + + for( i = 0; i < info->colors; i++) + { + uint32 rgb = (((( int32)info->palette[i].red << 8) | info->palette[i].green) << 8) | info->palette[i].blue; + data->Pixel[i] = rgb | (( int32)pixel_val[remap_color ( rgb)] << 24); + } +} + + +void cnvpal_15( IMGINFO info, DECDATA data) +{ + register int32 i; + + for( i = 0; i < info->colors; i++) + { + data->Pixel[i] = (( int16)( info->palette[i].red & 0xF8) << 7) | (( int16)( info->palette[i].green & 0xF8) << 2) | ( info->palette[i].blue >> 3); + } +} + + +void cnvpal_high( IMGINFO info, DECDATA data) +{ + register int32 i; + + for( i = 0; i < info->colors; i++) + { + data->Pixel[i] = (( int16)( info->palette[i].red & 0xF8) << 8) | (( int16)( info->palette[i].green & 0xFC) << 3) | ( info->palette[i].blue >> 3); + } +} + + +void cnvpal_true ( IMGINFO info, DECDATA data) +{ + register int32 i; + + for( i = 0; i < info->colors; i++) + { + data->Pixel[i] = (((( int32)info->palette[i].red << 8) | info->palette[i].green) << 8) | info->palette[i].blue; + } +} diff --git a/sources/z-tools/trunk/zview/zvdi/color.h b/sources/z-tools/trunk/zview/zvdi/color.h new file mode 100644 index 0000000..56a7aa9 --- /dev/null +++ b/sources/z-tools/trunk/zview/zvdi/color.h @@ -0,0 +1,14 @@ +extern void save_colors( void); +extern int16 remap_color( int32 value); + +extern uint32 color_lookup( uint32 rgb, int16 *trans); + +extern void cnvpal_mono( IMGINFO info, DECDATA data); +extern void cnvpal_1_2( IMGINFO info, DECDATA data); +extern void cnvpal_4_8( IMGINFO info, DECDATA data); +extern void cnvpal_15( IMGINFO info, DECDATA data); +extern void cnvpal_high( IMGINFO info, DECDATA data); +extern void cnvpal_true( IMGINFO info, DECDATA data); + +extern void ( *cnvpal_color)( IMGINFO, DECDATA); + diff --git a/sources/z-tools/trunk/zview/zvdi/dither.c b/sources/z-tools/trunk/zview/zvdi/dither.c new file mode 100644 index 0000000..ba4c5f0 --- /dev/null +++ b/sources/z-tools/trunk/zview/zvdi/dither.c @@ -0,0 +1,61 @@ +#include "../general.h" + +extern uint32 cube216[216]; +extern uint32 graymap[32]; + +/* prototype */ +inline uint8 dither_true ( uint8 * rgb, int16 * err, int8 ** buf); +inline uint8 dither_gray( uint8 *gray, int16 *err, int8 **buf); + +inline uint8 ditherize_32 ( uint8 * rgb, int16 * err, int8 ** buf) +{ + int8 *dth = *buf; + unsigned short r = (( err[0] += ( int16)dth[0] + rgb[1]) <= 42 ? 0 : err[0] >= 213 ? 5 : ( err[0] * 3) >> 7); + unsigned short g = (( err[1] += ( int16)dth[1] + rgb[2]) <= 42 ? 0 : err[1] >= 213 ? 5 : ( err[1] * 3) >> 7); + unsigned short b = (( err[2] += ( int16)dth[2] + rgb[3]) <= 42 ? 0 : err[2] >= 213 ? 5 : ( err[2] * 3) >> 7); + uint8 * irgb = ( uint8*)&cube216[( r * 6 + g) * 6 + b]; + + err[0] -= irgb[1]; + dth[0] = ( err[0] <= -254 ? ( err[0] =- 127) : err[0] >= +254 ? ( err[0] =+ 127) : ( err[0] >>= 1)); + err[1] -= irgb[2]; + dth[1] = ( err[1] <= -254 ? ( err[1] =- 127) : err[1] >= +254 ? ( err[1] =+ 127) : ( err[1] >>= 1)); + err[2] -= irgb[3]; + dth[2] = ( err[2] <= -254 ? ( err[2] = -127) : err[2] >= +254 ? ( err[2] = +127) : ( err[2] >>= 1)); + ( *buf) += 3; + + return irgb[0]; +} + + +inline uint8 dither_true ( uint8 * rgb, int16 * err, int8 ** buf) +{ + int8 *dth = *buf; + unsigned short r = (( err[0] += ( int16)dth[0] + rgb[0]) <= 42 ? 0 : err[0] >= 213 ? 5 : ( err[0] * 3) >> 7); + unsigned short g = (( err[1] += ( int16)dth[1] + rgb[1]) <= 42 ? 0 : err[1] >= 213 ? 5 : ( err[1] * 3) >> 7); + unsigned short b = (( err[2] += ( int16)dth[2] + rgb[2]) <= 42 ? 0 : err[2] >= 213 ? 5 : ( err[2] * 3) >> 7); + uint8 * irgb = ( uint8*)&cube216[( r * 6 + g) * 6 + b]; + + err[0] -= irgb[1]; + dth[0] = ( err[0] <= -254 ? ( err[0] =- 127) : err[0] >= +254 ? ( err[0] =+ 127) : ( err[0] >>= 1)); + err[1] -= irgb[2]; + dth[1] = ( err[1] <= -254 ? ( err[1] =- 127) : err[1] >= +254 ? ( err[1] =+ 127) : ( err[1] >>= 1)); + err[2] -= irgb[3]; + dth[2] = ( err[2] <= -254 ? ( err[2] = -127) : err[2] >= +254 ? ( err[2] = +127) : ( err[2] >>= 1)); + ( *buf) += 3; + + return irgb[0]; +} + + +inline uint8 dither_gray( uint8 *gray, int16 *err, int8 **buf) +{ + int8 *dth = *buf; + unsigned short idx = (( err[0] += ( int16)dth[0] + gray[0]) <= 0x07 ? 0 : err[0] >= 0xF8 ? 0x1F : err[0] >> 3); + uint8 *irgb = ( uint8*)&graymap[idx]; + + err[0] -= irgb[1]; + dth[0] = ( err[0] <= -254 ? ( err[0] = -127) : err[0] >= +254 ? ( err[0] =+ 127) : ( err[0] >>= 1)); + (*buf) += 1; + + return irgb[0]; +} diff --git a/sources/z-tools/trunk/zview/zvdi/dither.h b/sources/z-tools/trunk/zview/zvdi/dither.h new file mode 100644 index 0000000..fefdeb4 --- /dev/null +++ b/sources/z-tools/trunk/zview/zvdi/dither.h @@ -0,0 +1,3 @@ +extern inline uint8 ditherize_32 ( uint8 * rgb, int16 * err, int8 ** buf); +extern inline uint8 dither_true ( uint8 * rgb, int16 * err, int8 ** buf); +extern inline uint8 dither_gray( uint8 *gray, int16 *err, int8 **buf); diff --git a/sources/z-tools/trunk/zview/zvdi/p2c.c b/sources/z-tools/trunk/zview/zvdi/p2c.c new file mode 100644 index 0000000..addd878 --- /dev/null +++ b/sources/z-tools/trunk/zview/zvdi/p2c.c @@ -0,0 +1,82 @@ +#include "../general.h" + +void ( *planar_to_chunky)( uint8 *in, uint8 *out, int16 width); + + +inline void planar8_to_chunky8( uint8 *in, uint8 *out, int16 width) +{ + uint8 *l; + uint16 x, c, p0, p1, p2, p3, p4, p5, p6, p7; + + for( x = 0, l = in; x < width; l += 16) + { + p0 = ( l[0] << 8) | l[1]; + p1 = ( l[2] << 8) | l[3]; + p2 = ( l[4] << 8) | l[5]; + p3 = ( l[6] << 8) | l[7]; + p4 = ( l[8] << 8) | l[9]; + p5 = ( l[10] << 8) | l[11]; + p6 = ( l[12] << 8) | l[13]; + p7 = ( l[14] << 8) | l[15]; + + for ( c = 0; c < 16; c++) + { + out[x++] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2) | ((p2 >> 13) & 4) | ((p3 >> 12) & 8) | + ((p4 >> 11) & 16) | ((p5 >> 10) & 32)| ((p6 >> 9) & 64) | ((p7 >> 8) & 128); + p0 <<= 1; + p1 <<= 1; + p2 <<= 1; + p3 <<= 1; + p4 <<= 1; + p5 <<= 1; + p6 <<= 1; + p7 <<= 1; + } + } +} + + +inline void planar4_to_chunky8( uint8 *in, uint8 *out, int16 width) +{ + uint8 *l; + uint16 x, c, p0, p1, p2, p3; + + for( x = 0, l = in; x < width; l += 8) + { + p0 = ( l[0] << 8) | l[1]; + p1 = ( l[2] << 8) | l[3]; + p2 = ( l[4] << 8) | l[5]; + p3 = ( l[6] << 8) | l[7]; + + for ( c = 0; c < 16; c++) + { + out[x++] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2) | ((p2 >> 13) & 4) | ((p3 >> 12) & 8); + + p0 <<= 1; + p1 <<= 1; + p2 <<= 1; + p3 <<= 1; + } + } +} + + +inline void planar2_to_chunky8( uint8 *in, uint8 *out, int16 width) +{ + uint8 *l; + uint16 x, c, p0, p1; + + for ( x = 0, l = in; x < width; l += 4) + { + p0 = (l[0] << 8) | l[1]; + p1 = (l[2] << 8) | l[3]; + + for (c = 0; c < 16; c++) + { + out[x++] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2); + p0 <<= 1; + p1 <<= 1; + } + } +} + diff --git a/sources/z-tools/trunk/zview/zvdi/p2c.h b/sources/z-tools/trunk/zview/zvdi/p2c.h new file mode 100644 index 0000000..f0f9bba --- /dev/null +++ b/sources/z-tools/trunk/zview/zvdi/p2c.h @@ -0,0 +1,5 @@ +extern void ( *planar_to_chunky)( uint8 *in, uint8 *out, int16 width); +extern void planar8_to_chunky8( uint8 *in, uint8 *out, int16 width); +extern void planar4_to_chunky8( uint8 *in, uint8 *out, int16 width); +extern void planar2_to_chunky8( uint8 *in, uint8 *out, int16 width); + diff --git a/sources/z-tools/trunk/zview/zvdi/pixel.c b/sources/z-tools/trunk/zview/zvdi/pixel.c new file mode 100644 index 0000000..d332c41 --- /dev/null +++ b/sources/z-tools/trunk/zview/zvdi/pixel.c @@ -0,0 +1,137 @@ +#include "../general.h" + +void ( *getPixel)( int, int, uint32, uint8*, uint8*, uint8*, uint8*); +void ( *setPixel)( int, int, uint32, uint8, uint8, uint8, uint8*); + + +void getPixel_32( int x, int y, uint32 line_size, uint8 *red, uint8 *green, uint8 *blue, uint8 *src) +{ + register uint8 *line_source = src + ( y * line_size) + ( x << 2); + + *red = line_source[1]; + *green = line_source[2]; + *blue = line_source[3]; +} + + +void setPixel_32( int x, int y, uint32 line_size, uint8 red, uint8 green, uint8 blue, uint8 *dst) +{ + register uint32 *line_dst = ( uint32*)( dst + ( y * line_size)); + + line_dst[x] = ((((uint32)red << 8) | green) << 8) | blue; +} + + +void getPixel_32r( int x, int y, uint32 line_size, uint8 *red, uint8 *green, uint8 *blue, uint8 *src) +{ + register uint8 *line_source = src + ( y * line_size) + ( x << 2); + + *red = line_source[2]; + *green = line_source[1]; + *blue = line_source[0]; +} + + +void setPixel_32r( int x, int y, uint32 line_size, uint8 red, uint8 green, uint8 blue, uint8 *dst) +{ + register uint32 *line_dst = ( uint32*)( dst + ( y * line_size)); + + line_dst[x] = (((((uint32)blue << 8) | green) << 8) | red) << 8; +} + + +void getPixel_32z( int x, int y, uint32 line_size, uint8 *red, uint8 *green, uint8 *blue, uint8 *src) +{ + register uint8 *line_source = src + ( y * line_size) + ( x << 2); + + *red = line_source[0]; + *green = line_source[1]; + *blue = line_source[2]; +} + + +void setPixel_32z( int x, int y, uint32 line_size, uint8 red, uint8 green, uint8 blue, uint8 *dst) +{ + register uint32 *line_dst = ( uint32*)( dst + ( y * line_size)); + + line_dst[x] = (((((uint32)red << 8) | green) << 8) | blue) << 8; +} + + +void getPixel_24( int x, int y, uint32 line_size, uint8 *red, uint8 *green, uint8 *blue, uint8 *src) +{ + register uint8 *line_source = src + ( y * line_size) + ( x * 3); + + *red = line_source[0]; + *green = line_source[1]; + *blue = line_source[2]; +} + + +void setPixel_24( int x, int y, uint32 line_size, uint8 red, uint8 green, uint8 blue, uint8 *dst) +{ + register uint8 *line_dst = dst + ( y * line_size) + ( x * 3); + + line_dst[0] = red; + line_dst[1] = green; + line_dst[2] = blue; +} + + +void getPixel_24r( int x, int y, uint32 line_size, uint8 *red, uint8 *green, uint8 *blue, uint8 *src) +{ + register uint8 *line_source = src + ( y * line_size) + ( x * 3); + + *red = line_source[2]; + *green = line_source[1]; + *blue = line_source[0]; +} + + +void setPixel_24r( int x, int y, uint32 line_size, uint8 red, uint8 green, uint8 blue, uint8 *dst) +{ + register uint8 *line_dst = dst + ( y * line_size) + ( x * 3); + + line_dst[2] = red; + line_dst[1] = green; + line_dst[0] = blue; +} + + +void getPixel_16( int x, int y, uint32 line_size, uint8 *red, uint8 *green, uint8 *blue, uint8 *src) +{ + register uint16 *line_source = ( uint16*)( src + ( y * line_size) + ( x << 1)); + register uint16 src16 = line_source[0]; + + *red = (( src16 >> 11) & 0x001F) << 3; + *green = (( src16 >> 5) & 0x003F) << 2; + *blue = (( src16) & 0x001F) << 3; +} + + +void setPixel_16( int x, int y, uint32 line_size, uint8 red, uint8 green, uint8 blue, uint8 *dst) +{ + register uint16 *line_dst = ( uint16*)( dst + ( y * line_size)); + + line_dst[x] = (((uint16)red & 0xF8) << 8) | (((uint16)green & 0xFC) << 3) | ( blue >> 3); +} + + +void getPixel_16r( int x, int y, uint32 line_size, uint8 *red, uint8 *green, uint8 *blue, uint8 *src) +{ + register uint16 *line_source = ( uint16*)( src + ( y * line_size) + ( x << 1)); + register uint16 src16 = (line_source[0] >> 8) | (line_source[0] << 8); + + *red = (( src16 >> 11) & 0x001F) << 3; + *green = (( src16 >> 5) & 0x003F) << 2; + *blue = (( src16) & 0x001F) << 3; +} + + +void setPixel_16r( int x, int y, uint32 line_size, uint8 red, uint8 green, uint8 blue, uint8 *dst) +{ + register uint16 *line_dst = ( uint16*)( dst + ( y * line_size)); + register uint16 pix = (((uint16)red & 0xF8) << 8) | (((uint16)green & 0xFC) << 3) | ( blue >> 3); + + line_dst[x] = (pix >> 8) | (pix << 8); +} diff --git a/sources/z-tools/trunk/zview/zvdi/pixel.h b/sources/z-tools/trunk/zview/zvdi/pixel.h new file mode 100644 index 0000000..563ee07 --- /dev/null +++ b/sources/z-tools/trunk/zview/zvdi/pixel.h @@ -0,0 +1,19 @@ +extern void ( *getPixel)( int, int, uint32, uint8*, uint8*, uint8*, uint8*); +extern void ( *setPixel)( int, int, uint32, uint8, uint8, uint8, uint8*); + +extern void getPixel_32( int x, int y, uint32 line_size, uint8 *red, uint8 *green, uint8 *blue, uint8 *src); +extern void setPixel_32( int x, int y, uint32 line_size, uint8 red, uint8 green, uint8 blue, uint8 *dst); +extern void getPixel_32r( int x, int y, uint32 line_size, uint8 *red, uint8 *green, uint8 *blue, uint8 *src); +extern void setPixel_32r( int x, int y, uint32 line_size, uint8 red, uint8 green, uint8 blue, uint8 *dst); +extern void getPixel_32z( int x, int y, uint32 line_size, uint8 *red, uint8 *green, uint8 *blue, uint8 *src); +extern void setPixel_32z( int x, int y, uint32 line_size, uint8 red, uint8 green, uint8 blue, uint8 *dst); +extern void getPixel_24( int x, int y, uint32 line_size, uint8 *red, uint8 *green, uint8 *blue, uint8 *src); +extern void setPixel_24( int x, int y, uint32 line_size, uint8 red, uint8 green, uint8 blue, uint8 *dst); +extern void getPixel_24r( int x, int y, uint32 line_size, uint8 *red, uint8 *green, uint8 *blue, uint8 *src); +extern void setPixel_24r( int x, int y, uint32 line_size, uint8 red, uint8 green, uint8 blue, uint8 *dst); +extern void getPixel_16( int x, int y, uint32 line_size, uint8 *red, uint8 *green, uint8 *blue, uint8 *src); +extern void setPixel_16( int x, int y, uint32 line_size, uint8 red, uint8 green, uint8 blue, uint8 *dst); +extern void getPixel_16r( int x, int y, uint32 line_size, uint8 *red, uint8 *green, uint8 *blue, uint8 *src); +extern void setPixel_16r( int x, int y, uint32 line_size, uint8 red, uint8 green, uint8 blue, uint8 *dst); + + diff --git a/sources/z-tools/trunk/zview/zvdi/raster.c b/sources/z-tools/trunk/zview/zvdi/raster.c new file mode 100644 index 0000000..1807862 --- /dev/null +++ b/sources/z-tools/trunk/zview/zvdi/raster.c @@ -0,0 +1,1195 @@ +#include "..//general.h" +#include "..//pic_load.h" +#include "dither.h" +#include "raster.h" + +inline void raster_mono ( DECDATA info, void * _dst) +{ +#ifdef USE_ASM + __asm__ volatile ( + " subq.w #1, %2 | width\n" + " move.l %3, d0 | scale -> index\n" + " addq.l #1, d0\n" + " lsr.l #1, d0\n" + "0:\n" + " clr.w d1 | chunk\n" + " move.w #0x8000, d2 | pixel\n" + "1:\n" + " swap d0\n" + " btst #0, (d0.w,%1) | (src[index>>16] & 1)\n" + " beq.b 2f\n" + " or.w d2, d1 | chunk |= pixel\n" + "2:\n" + " swap d0\n" + " add.l %3, d0 | index += info->IncXfx\n" + " lsr.w #1, d2\n" + " dbeq %2, 1b\n" + " move.w d1, (%0)+\n" + " subq.w #1, %2\n" + " bpl.b 0b" + : /* output */ + : "a"(_dst), "a"(info->RowBuf), + /* %0 %1 */ + "d"(info->DthWidth),"d"(info->IncXfx) /* input */ + /* %2 %3 */ + : "d0","d1","d2" /* clobbered */ + ); +#else + uint16 *dst = _dst; + uint32 *map = info->Pixel; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + if ( map[(int16)info->RowBuf[x >>16] & 1]) + chunk |= pixel; + + if ( !--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while ( width); +#endif +} + +inline void raster_D1 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + int16 *buf = info->DthBuf; + int16 ins = 0; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + ins += *buf + map[(int16)info->RowBuf[x >>16] & mask]; + + if ( ins < 2040) + chunk |= pixel; + else + ins -= 4080; + + *(buf++) = (ins >>= 2); + + if ( !--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while ( width); +} + +inline void gscale_D1( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = ( info->IncXfx + 1) >> 1; + int16 *buf = info->DthBuf; + int16 ins = 0; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + ins += *buf + ( int16)info->RowBuf[x >>16]; + + if ( ins < 0x80) + chunk |= pixel; + else + ins -= 0xFF; + + *(buf++) = (ins >>= 2); + + if ( !--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while (width); +} + +inline void dither_D1 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = ( info->IncXfx + 1) >> 1; + int16 *buf = info->DthBuf; + int16 ins = 0; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + uint8 *rgb = &info->RowBuf[(x >>16) *3]; + ins += *buf + ( int16)rgb[0] * 5 + ( int16)rgb[1] * 9 + (( int16)rgb[2] << 1); + + if (ins < 2040) + chunk |= pixel; + else + ins -= 4080; + + *(buf++) = (ins >>= 2); + + if (!--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while( width); +} + + +inline void raster_D2 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = ( info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + int16 *buf = info->DthBuf; + int16 ins = 0; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + ins += *buf + map[( int16)info->RowBuf[x >>16] & mask]; + + if ( ins < 2040) + chunk |= pixel; + else + ins -= 4080; + + *(buf++) = (ins >>= 2); + + if (!--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while ( width); +} + +inline void gscale_D2( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = ( info->IncXfx + 1) >> 1; + int16 *buf = info->DthBuf; + int16 ins = 0; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + ins += *buf + (short)info->RowBuf[x >>16]; + + if (ins < 0x80) + chunk |= pixel; + else + ins -= 0xFF; + + *(buf++) = (ins >>= 2); + + if (!--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while (width); +} + +inline void dither_D2 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = ( info->IncXfx + 1) >> 1; + int16 *buf = info->DthBuf; + int16 ins = 0; + uint16 pixel = 0x8000; + uint16 chunk = 0; + + do + { + uint8 *rgb = &info->RowBuf[( x >>16) * 3]; + ins += *buf + (int16)rgb[0] * 5 + (int16)rgb[1] * 9 + (int16)rgb[2] * 2; + + if (ins < 2040) + chunk |= pixel; + else + ins -= 4080; + + *(buf++) = (ins >>= 2); + + if (!--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + *(dst++) = chunk; + chunk = 0; + pixel = 0x8000; + } + x += info->IncXfx; + + } while ( width); +} + + +#ifdef USE_ASM +inline void raster_chunk4 (uint8 *src, uint16* dst, size_t num) +{ + __asm__ volatile ( + " clr.l d4\n" + " move.b (%0)+, d4\n" + " move.l d4, d5\n" + " andi.b #0x03, d4 |chunks 0/1\n" + " ror.l #1, d4\n" + " ror.w #1, d4\n" + " andi.b #0x0C, d5 |chunks 2/3\n" + " ror.l #3, d5\n" + " ror.w #1, d5\n" + + " subq.l #2, %2\n" + " bmi 9f\n" + + " moveq.l #1, d1\n" + + "1: | chunk loop\n" + " move.b (%0)+, d2\n" + + " moveq.l #0x03, d3 |chunks 0/1\n" + " and.b d2, d3\n" + " ror.l #1, d3\n" + " ror.w #1, d3\n" + " lsr.l d1, d3\n" + " or.l d3, d4\n" + " moveq.l #0x0C, d3 |chunks 2/3\n" + " and.b d2, d3\n" + " ror.l #3, d3\n" + " ror.w #1, d3\n" + " lsr.l d1, d3\n" + " or.l d3, d5\n" + + " addq.w #1, d1\n" + " dbra %2, 1b | chunk loop\n" + "9:\n" + " movem.l d4-d5, (%1)" + : /* no return value */ + : "a"(src),"a"(dst), "d"(num) + /* %0 %1 %2 */ + : "d1","d2","d3","d4","d5" + ); +} + +inline void raster_chunk8 ( uint8 *src, uint16* dst, size_t num) +{ + __asm__ volatile + ( + " clr.l d4\n" + " move.b (%0)+, d4\n" + " move.l d4, d5\n" + " move.l d4, d6\n" + " move.l d4, d7\n" + " andi.b #0x03, d4 |chunks 0/1\n" + " ror.l #1, d4\n" + " ror.w #1, d4\n" + " andi.b #0x0C, d5 |chunks 2/3\n" + " ror.l #3, d5\n" + " ror.w #1, d5\n" + " andi.b #0x30, d6 |chunks 4/5\n" + " ror.l #5, d6\n" + " ror.w #1, d6\n" + " andi.b #0xC0, d7 |chunks 6/7\n" + " ror.l #7, d7\n" + " ror.w #1, d7\n" + " subq.l #2, %2\n" + " bmi 9f\n" + " moveq.l #1, d1\n" + "1: | chunk loop\n" + " move.b (%0)+, d2\n" + " moveq.l #0x03, d3 |chunks 0/1\n" + " and.b d2, d3\n" + " ror.l #1, d3\n" + " ror.w #1, d3\n" + " lsr.l d1, d3\n" + " or.l d3, d4\n" + " moveq.l #0x0C, d3 |chunks 2/3\n" + " and.b d2, d3\n" + " ror.l #3, d3\n" + " ror.w #1, d3\n" + " lsr.l d1, d3\n" + " or.l d3, d5\n" + " moveq.l #0x30, d3 |chunks 4/5\n" + " and.b d2, d3\n" + " ror.l #5, d3\n" + " ror.w #1, d3\n" + " lsr.l d1, d3\n" + " or.l d3, d6\n" + " move.l #0xC0, d3 |chunks 6/7\n" + " and.b d2, d3\n" + " ror.l #7, d3\n" + " ror.w #1, d3\n" + " lsr.l d1, d3\n" + " or.l d3, d7\n" + + " addq.w #1, d1\n" + " dbra %2, 1b | chunk loop\n" + "9:\n" + " movem.l d4-d7, (%1)" + : /* no return value */ + : "a"(src),"a"(dst), "d"(num) + /* %0 %1 %2 */ + : "d1","d2","d3","d4","d5","d6","d7" + ); +} + +#else + +inline void raster_chunks ( uint8 *src, uint16 *dst, uint16 num, uint16 depth) +{ + uint16 mask = 0x8000; + uint16 *chunk = dst; + uint8 pixel = *src; + int16 i = depth; + + do + { + *( chunk++) = ( pixel & 1 ? mask : 0); + pixel >>= 1; + } while (--i); + + while (--num) + { + mask >>= 1; + chunk = dst; + pixel = *( ++src); + i = depth; + + do + { + if ( pixel & 1) *chunk |= mask; + else *chunk &= ~mask; + chunk++; + pixel >>= 1; + } while (--i); + } +} + +#endif + +inline void raster_I4 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + uint16 idx = info->RowBuf[x >>16]; + *(tmp++) = *( uint8*)&info->Pixel[idx]; + + if (!--width || !--n) + { + raster_chunk4( buf, dst, tmp - buf); + dst += 4; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while ( width); +} + +inline void gscale_I4( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + int8 *dth = info->DthBuf; + int16 err = 0; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + *(tmp++) = dither_gray (&info->RowBuf[x >>16], &err, &dth); + + if (!--width || !--n) + { + raster_chunk4 (buf, dst, tmp - buf); + dst += 4; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while (width); +} + +inline void dither_I4 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + int8 *dth = info->DthBuf; + int16 err[3] = { 0, 0, 0 }; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + *(tmp++) = dither_true (&info->RowBuf[(x >>16) *3], err, &dth); + + if (!--width || !--n) + { + raster_chunk4 (buf, dst, tmp - buf); + dst += 4; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while (width); +} + + +inline void raster_I8 ( DECDATA info, void * _dst) +{ +#ifdef USE_ASM + size_t x = (info->IncXfx + 1) >> 1; + __asm__ volatile ( + " subq.w #1, %4\n" + " swap %6 | -> chunk counter\n" + + " 1: | line loop\n" + " clr.w %6\n" + " clr.l d4\n" + " clr.l d5\n" + " clr.l d6\n" + " clr.l d7\n" + + " 5: | chunk loop\n" + " swap %4 | -> value\n" + " swap %6 | -> mask\n" + " move.w (%3), d3\n" + " add.l %5, (%3)\n" + " move.b (d3.w,%1), d3 | palette index\n" + " and.w %6, d3\n" + " lsl.w #2, d3\n" + " move.b (d3.w,%2), %4 | pixel value\n" + " swap %6 | -> chunk counter\n" + + " moveq.l #0x03, d3 |chunks 0/1\n" + " and.b %4, d3\n" + " ror.l #1, d3\n" + " ror.w #1, d3\n" + " lsr.l %6, d3\n" + " or.l d3, d4\n" + " moveq.l #0x0C, d3 |chunks 2/3\n" + " and.b %4, d3\n" + " ror.l #3, d3\n" + " ror.w #1, d3\n" + " lsr.l %6, d3\n" + " or.l d3, d5\n" + " moveq.l #0x30, d3 |chunks 4/5\n" + " and.b %4, d3\n" + " ror.l #5, d3\n" + " ror.w #1, d3\n" + " lsr.l %6, d3\n" + " or.l d3, d6\n" + " move.l #0xC0, d3 |chunks 6/7\n" + " and.b %4, d3\n" + " ror.l #7, d3\n" + " ror.w #1, d3\n" + " lsr.l %6, d3\n" + " or.l d3, d7\n" + + " swap %4 | -> width\n" + " addq.b #1, %6\n" + " btst.b #4, %6\n" + " dbne %4, 5b | chunk loop\n" + + " movem.l d4-d7, (%0)\n" + " adda.w #16, %0\n" + " subq.w #1, %4\n" + " bpl.b 1b" + : + : "a"(_dst),"a"(info->RowBuf),"a"(info->Pixel),"a"(&x), + /* %0 %1 %2 %3 */ + "d"(info->DthWidth),"d"(info->IncXfx),"d"(info->PixMask) + /* %4 %5 %6 */ + : "d3","d4","d5","d6","d7" + ); +#else + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + uint16 idx = info->RowBuf[x >>16]; + *(tmp++) = *(uint8*)&info->Pixel[idx]; + + if (!--width || !--n) + { + raster_chunk8 (buf, dst, tmp - buf); + dst += 8; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while (width); +#endif +} + +inline void gscale_I8( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + int8 *dth = info->DthBuf; + int16 err = 0; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + *(tmp++) = dither_gray (&info->RowBuf[x >>16], &err, &dth); + + if (!--width || !--n) { + raster_chunk8 (buf, dst, tmp - buf); + dst += 8; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while (width); +} + +inline void dither_I8 (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + int8 *dth = info->DthBuf; + int16 err[3] = { 0, 0, 0 }; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + *(tmp++) = dither_true (&info->RowBuf[(x >>16) *3], err, &dth); + + if (!--width || !--n) + { + raster_chunk8 (buf, dst, tmp - buf); + dst += 8; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while ( width); +} + + +inline void raster_P8 (DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + *(dst++) = *( uint8*)&map[( int16)info->RowBuf[x >>16] & mask]; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_P8( DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + int8 *dth = info->DthBuf; + int16 err = 0; + + do + { + *(dst++) = dither_gray (&info->RowBuf[x >>16], &err, &dth); + x += info->IncXfx; + } while (--width); +} + +inline void dither_P8 (DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + int8 *dth = info->DthBuf; + int16 err[3] = { 0, 0, 0 }; + + do + { + *(dst++) = dither_true (&info->RowBuf[(x >>16) *3], err, &dth); + x += info->IncXfx; + } while (--width); +} + + +inline void dither32_P8 (DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + int8 *dth = info->DthBuf; + int16 err[3] = { 0, 0, 0 }; + + do + { + *(dst++) = ditherize_32 (&info->RowBuf[(x >>16) << 2], err, &dth); + x += info->IncXfx; + } while (--width); +} + +inline void raster_15 (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + *(dst++) = map[(short)info->RowBuf[x >>16] & mask]; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_15( DECDATA info, void * _dst) +{ + uint16 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint16 rgb = info->RowBuf[(x >>16)]; + rgb = ((rgb & 0xF8) <<7) | ((rgb & 0xF8) <<2) | (rgb >>3); + *(dst++) = (rgb >> 8) | (rgb << 8); + x += info->IncXfx; + } while (--width); +} + +inline void dither_15 (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do { + uint8 * rgb = &info->RowBuf[(x >>16) * 3]; + *(dst++) = (((uint16)rgb[0] & 0xF8) << 7) | (((uint16)rgb[1] & 0xF8) << 2) | ( rgb[2] >> 3); + x += info->IncXfx; + } while (--width); +} + +inline void raster_15r (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + uint16 rgb = map[(short)info->RowBuf[x >>16] & mask]; + *(dst++) = (rgb >> 8) | (rgb << 8); + x += info->IncXfx; + } while (--width); +} + +inline void gscale_15r( DECDATA info, void * _dst) +{ + uint16 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint16 rgb = info->RowBuf[(x >>16)]; + rgb = ((rgb & 0xF8) <<7) | ((rgb & 0xF8) <<2) | (rgb >>3); + *(dst++) = (rgb >> 8) | (rgb << 8); + x += info->IncXfx; + } while (--width); +} + +inline void dither_15r (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >>16) * 3]; + uint16 pix = (((uint16)rgb[0] & 0xF8) << 7) | (((uint16)rgb[1] & 0xF8) << 2) | (rgb[2] >> 3); + *(dst++) = (pix >> 8) | (pix << 8); + x += info->IncXfx; + } while (--width); +} + + +inline void raster_16 (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + *(dst++) = map[(int16)info->RowBuf[x >>16] & mask]; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_16( DECDATA info, void * _dst) +{ +#ifdef USE_ASM + if (info->IncXfx == 0x00010000uL) { + __asm__ volatile ( + "subq.l #1, %2\n" + " lsr.l #1, %2\n" + " 1:\n" + " clr.l d0\n" + " move.w (%0)+, d0 |........:........|12345678:12345678|\n" + " lsl.l #8, d0 |........:12345678|12345678:........|\n" + " lsr.w #8, d0 |........:12345678|........:12345678|\n" + " move.l d0, d1\n" + " lsr.l #2, d0 |........:..123456|78......:..123456|\n" + " andi.w #0x3F, d0 |........:..123456|........:..123456|\n" + " lsl.l #5, d0 |.....123:456.....|.....123:456.....|\n" + " lsr.l #3, d1 |........:...12345|678.....:...12345|\n" + " andi.w #0x1F, d1 |........:...12345|........:...12345|\n" + " or.l d1, d0\n" + " lsl.l #8, d1 |...12345:........|...12345:........|\n" + " lsl.l #3, d1 |12345...:........|12345...:........|\n" + " or.l d1, d0\n" + " move.l d0, (%1)+\n" + " dbra %2, 1b" + : /* no return */ + : "a"(info->RowBuf),"a"(_dst), "d"((long)info->DthWidth) + /* %0 %1 %2 */ + : "d0","d1","d2" + ); + } else +#endif +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { +#ifdef USE_ASM + __asm__ volatile ( + " move.b (%0), d0\n" + " move.b d0, d1\n" + " lsl.w #5, d0\n" + " move.b d1, d0\n" + " lsl.l #6, d0\n" + " move.b d1, d0\n" + " lsr.l #3, d0\n" + " move.w d0, (%1)" + : /* no return */ + : "a"(&info->RowBuf[x >>16]),"a"(dst++) + : "d0","d1" + ); +#else + + uint16 rgb = info->RowBuf[(x >>16)]; + *(dst++) = ((rgb & 0xF8) <<8) | ((rgb & 0xFC) <<3) | (rgb >>3); +#endif + x += info->IncXfx; + } while (--width); +}} + +inline void dither_16 (DECDATA info, void * _dst) +{ +#ifdef USE_ASM + if (info->IncXfx == 0x00010000uL) { + __asm__ volatile ( + " subq.l #1, %2\n" + " lsr.l #1, %2\n" + "1:\n" + " movem.w (%0), d0/d1/d2 |R8:G8| / |B8:r8| / |g8:b8|\n" + " addq.l #6, %0\n" + " lsl.l #5, d0 |........:...RRRRR|RRRGGGGG:GGG00000|\n" + " lsl.w #3, d0 |........:...RRRRR|GGGGGGGG:00000000|\n" + " lsl.l #6, d0 |.....RRR:RRGGGGGG|GG000000:00000000|\n" + " move.w d1, d0 |.....RRR:RRGGGGGG|BBBBBBBB:rrrrrrrr|\n" + " lsl.l #5, d0 |RRRRRGGG:GGGBBBBB|BBBrrrrr:rrr00000|\n" + " move.w d0, d1 |........:........|BBBrrrrr:rrr00000|\n" + " lsl.l #8, d1 |........:BBBrrrrr|rrr00000:00000000|\n" + " move.w d2, d1 |........:BBBrrrrr|gggggggg:bbbbbbbb|\n" + " lsl.l #6, d1 |..BBBrrr:rrgggggg|ggbbbbbb:bb000000|\n" + " lsl.w #2, d1 |..BBBrrr:rrgggggg|bbbbbbbb:00000000|\n" + " lsl.l #5, d1 |rrrrrggg:gggbbbbb|bbb00000:00000000|\n" + " swap d1\n" + " move.w d1, d0\n" + " move.l d0, (%1)+\n" + " dbra %2, 1b" + : /* no return */ + : "a"(info->RowBuf),"a"(_dst), "d"(info->DthWidth) + /* %0 %1 %2 */ + : "d0","d1","d2" + ); + } else +#endif +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { +#ifdef USE_ASM + __asm__ volatile ( + "move.b (%0)+, d0\n" + " lsl.w #5, d0\n" + " move.b (%0)+, d0\n" + " lsl.l #6, d0\n" + " move.b (%0)+, d0\n" + " lsr.l #3, d0\n" + " move.w d0, (%1)" + : /* no return */ + : "a"(&info->RowBuf[(x >>16) *3]),"a"(dst++) + : "d0" + ); +#else + register uint8 *rgb = &info->RowBuf[(x >> 16) * 3]; + + *(dst++) = (((uint16)rgb[0] & 0xF8) << 8) | (((uint16)rgb[1] & 0xFC) << 3) | ( rgb[2] >> 3); +#endif + x += info->IncXfx; + } while (--width); +}} + + +inline void raster_16r (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + uint16 rgb = map[(int16)info->RowBuf[x >>16] & mask]; + *(dst++) = (rgb >> 8) | (rgb << 8); + x += info->IncXfx; + } while (--width); +} + +inline void gscale_16r( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint16 rgb = info->RowBuf[(x >>16)]; + rgb = ((rgb & 0xF8) <<8) | ((rgb & 0xFC) <<3) | (rgb >>3); + *(dst++) = (rgb >> 8) | (rgb << 8); + x += info->IncXfx; + } while (--width); +} + +inline void dither_16r (DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >>16) *3]; + uint16 pix = ((( uint16)rgb[0] & 0xF8) << 8) | ((( uint16)rgb[1] & 0xFC) << 3) | ( rgb[2] >> 3); + *(dst++) = (pix >> 8) | (pix << 8); + x += info->IncXfx; + } while (--width); +} + + +inline void raster_24 (DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + uint8 * rgb = (uint8*)&map[( int16)info->RowBuf[x >>16] & mask]; + *(dst++) = *(++rgb); + *(dst++) = *(++rgb); + *(dst++) = *(++rgb); + x += info->IncXfx; + } while (--width); +} + +inline void gscale_24( DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 rgb = info->RowBuf[(x >>16)]; + *(dst++) = rgb; + *(dst++) = rgb; + *(dst++) = rgb; + x += info->IncXfx; + } while (--width); +} + +inline void dither_24 (DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >>16) *3]; + *(dst++) = *(rgb++); + *(dst++) = *(rgb++); + *(dst++) = *(rgb); + x += info->IncXfx; + } while (--width); +} + +inline void raster_24r (DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + uint8 * rgb = (uint8*)&map[(int16)info->RowBuf[x >>16] & mask]; + *(dst++) = rgb[3]; + *(dst++) = rgb[2]; + *(dst++) = rgb[1]; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_24r( DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 rgb = info->RowBuf[(x >> 16)]; + *(dst++) = rgb; + *(dst++) = rgb; + *(dst++) = rgb; + x += info->IncXfx; + } while (--width); +} + +inline void dither_24r( DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >> 16) *3]; + *(dst++) = rgb[2]; + *(dst++) = rgb[1]; + *(dst++) = rgb[0]; + x += info->IncXfx; + } while (--width); +} + + +inline void raster_32 (DECDATA info, void * _dst) +{ + uint32 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + *(dst++) = map[(int16)info->RowBuf[x >> 16] & mask]; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_32( DECDATA info, void * _dst) +{ + uint32 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint32 rgb = info->RowBuf[(x >> 16)]; + *(dst++) = ((( rgb << 8) | rgb) << 8) | rgb; + x += info->IncXfx; + } while (--width); +} + +inline void dither_32 (DECDATA info, void * _dst) +{ + uint32 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >> 16) *3]; + *(dst++) = ((((uint32)rgb[0] << 8) | rgb[1]) << 8) | rgb[2]; + x += info->IncXfx; + } while (--width); +} + +inline void raster_32r( DECDATA info, void * _dst) +{ + uint32 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + uint32 *map = info->Pixel; + uint16 mask = info->PixMask; + + do + { + uint8 * rgb = (uint8*)&map[(int16)info->RowBuf[x >>16] & mask]; + *(dst++) = (((((int32)rgb[3] << 8) | rgb[2]) << 8) | rgb[1]) << 8; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_32r( DECDATA info, void * _dst) +{ + uint32 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint32 rgb = info->RowBuf[(x >>16)]; + *(dst++) = (((( rgb << 8) | rgb) << 8) | rgb) << 8; + x += info->IncXfx; + } while (--width); +} + +inline void dither_32r (DECDATA info, void * _dst) +{ + uint32 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >>16) *3]; + *(dst++) = (((((uint32)rgb[2] <<8) | rgb[1]) << 8) | rgb[0]) << 8; + x += info->IncXfx; + } while (--width); +} + + +inline void raster_32z ( DECDATA info, void * _dst) +{ + uint32 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + uint32 * map = info->Pixel; + uint16 mask = info->PixMask; + do { + *(dst++) = map[(int16)info->RowBuf[x >>16] & mask] << 8; + x += info->IncXfx; + } while (--width); +} + +inline void gscale_32z (DECDATA info, void * _dst) +{ + uint32 * dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + do { + uint32 rgb = info->RowBuf[(x >>16)]; + *(dst++) = ((((rgb <<8) | rgb) <<8) | rgb) << 8; + x += info->IncXfx; + } while (--width); +} + +inline void dither_32z (DECDATA info, void * _dst) +{ + uint32 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + do { + uint8 * rgb = &info->RowBuf[(x >>16) *3]; + *(dst++) = (((((uint32)rgb[0] <<8) | rgb[1]) <<8) | rgb[2]) << 8; + x += info->IncXfx; + } while (--width); +} diff --git a/sources/z-tools/trunk/zview/zvdi/raster.h b/sources/z-tools/trunk/zview/zvdi/raster.h new file mode 100644 index 0000000..86b62c7 --- /dev/null +++ b/sources/z-tools/trunk/zview/zvdi/raster.h @@ -0,0 +1,67 @@ +extern void raster_chunks ( uint8 *src, uint16 *dst, uint16 num, uint16 depth); + +#ifdef USE_ASM +extern void raster_chunk4 (uint8 *src, uint16* dst, size_t num); +extern void raster_chunk8 (uint8 *src, uint16* dst, size_t num); +#else +#define raster_chunk4(s,d,n) raster_chunks ( s, d, n, 4) +#define raster_chunk8(s,d,n) raster_chunks ( s, d, n, 8) +#endif + +extern void raster_mono ( DECDATA info, void * _dst); +extern void raster_D1 ( DECDATA info, void * _dst); +extern void dither_D1 ( DECDATA info, void * _dst); +extern void gscale_D1 ( DECDATA info, void * _dst); + +extern void raster_D2 ( DECDATA info, void * _dst); +extern void dither_D2 ( DECDATA info, void * _dst); +extern void gscale_D2 ( DECDATA info, void * _dst); + +extern void raster_I4 ( DECDATA info, void * _dst); +extern void dither_I4 ( DECDATA info, void * _dst); +extern void gscale_I4 ( DECDATA info, void * _dst); + +extern void raster_I8 ( DECDATA info, void * _dst); +extern void dither_I8 ( DECDATA info, void * _dst); +extern void gscale_I8 ( DECDATA info, void * _dst); + +extern void raster_P8 ( DECDATA info, void * _dst); +extern void dither_P8 ( DECDATA info, void * _dst); +extern void gscale_P8 ( DECDATA info, void * _dst); + +extern void raster_15 ( DECDATA info, void * _dst); +extern void dither_15 ( DECDATA info, void * _dst); +extern void gscale_15 ( DECDATA info, void * _dst); + +extern void raster_15r ( DECDATA info, void * _dst); +extern void dither_15r ( DECDATA info, void * _dst); +extern void gscale_15r ( DECDATA info, void * _dst); + +extern void raster_16 ( DECDATA info, void * _dst); +extern void dither_16 ( DECDATA info, void * _dst); +extern void gscale_16 ( DECDATA info, void * _dst); + +extern void raster_16r ( DECDATA info, void * _dst); +extern void dither_16r ( DECDATA info, void * _dst); +extern void gscale_16r ( DECDATA info, void * _dst); + +extern void raster_24 ( DECDATA info, void * _dst); +extern void dither_24 ( DECDATA info, void * _dst); +extern void gscale_24 ( DECDATA info, void * _dst); + +extern void raster_24r ( DECDATA info, void * _dst); +extern void dither_24r ( DECDATA info, void * _dst); +extern void gscale_24r ( DECDATA info, void * _dst); + +extern void raster_32 ( DECDATA info, void * _dst); +extern void dither_32 ( DECDATA info, void * _dst); +extern void gscale_32 ( DECDATA info, void * _dst); + +extern void raster_32r ( DECDATA info, void * _dst); +extern void dither_32r ( DECDATA info, void * _dst); +extern void gscale_32r ( DECDATA info, void * _dst); + +extern void raster_32z ( DECDATA info, void * _dst); +extern void dither_32z ( DECDATA info, void * _dst); +extern void gscale_32z ( DECDATA info, void * _dst); + diff --git a/sources/z-tools/trunk/zview/zvdi/raster_resize.c b/sources/z-tools/trunk/zview/zvdi/raster_resize.c new file mode 100644 index 0000000..3e3b45a --- /dev/null +++ b/sources/z-tools/trunk/zview/zvdi/raster_resize.c @@ -0,0 +1,147 @@ +#include "..//general.h" +#include "..//pic_load.h" +#include "dither.h" +#include "raster.h" + +inline void resize_mono ( DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 4; + uint16 pixel = 0x80, chunk = 0; + + do + { + chunk |= ( info->RowBuf[x >> 16] & 1); + chunk <<= 1; + + if ( !--width || !(pixel >>= 1)) + { + *(dst++) = chunk; + chunk = 0; + pixel = 0x80; + } + + x += ( info->IncXfx >> 3); + + } while ( width); +} + + +inline void resize_I4 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + *(tmp++) = *( uint8*)&info->DstBuf[x >> 16]; + + if (!--width || !--n) + { + raster_chunk4( buf, dst, tmp - buf); + dst += 4; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while ( width); +} + + +inline void resize_I8 ( DECDATA info, void * _dst) +{ + uint16 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx +1) >> 1; + uint8 buf[16]; + int16 n = 16; + uint8 *tmp = buf; + + do + { + *(tmp++) = *( uint8*)&info->DstBuf[x >> 16]; + + if (!--width || !--n) + { + raster_chunk8 (buf, dst, tmp - buf); + dst += 8; + n = 16; + tmp = buf; + } + x += info->IncXfx; + + } while (width); +} + + +inline void resize_P8(DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 *rgb = &info->RowBuf[x >> 16]; + *(dst++) = *(rgb); + x += info->IncXfx; + } while (--width); +} + + +inline void resize_16(DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 *rgb = &info->RowBuf[(x >> 16) << 1]; + *(dst++) = *(rgb++); + *(dst++) = *(rgb); + x += info->IncXfx; + } while (--width); +} + + +inline void resize_24(DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >>16) * 3]; + *(dst++) = *(rgb++); + *(dst++) = *(rgb++); + *(dst++) = *(rgb); + x += info->IncXfx; + } while (--width); +} + + +inline void resize_32( DECDATA info, void * _dst) +{ + uint8 *dst = _dst; + int16 width = info->DthWidth; + uint32 x = (info->IncXfx + 1) >> 1; + + do + { + uint8 * rgb = &info->RowBuf[(x >> 16) << 2]; + *(dst++) = *(rgb++); + *(dst++) = *(rgb++); + *(dst++) = *(rgb++); + *(dst++) = *(rgb); + + x += info->IncXfx; + } while (--width); +} diff --git a/sources/z-tools/trunk/zview/zvdi/raster_resize.h b/sources/z-tools/trunk/zview/zvdi/raster_resize.h new file mode 100644 index 0000000..b2d8561 --- /dev/null +++ b/sources/z-tools/trunk/zview/zvdi/raster_resize.h @@ -0,0 +1,8 @@ +extern void resize_mono( DECDATA info, void * _dst); +extern void resize_I4( DECDATA info, void * _dst); +extern void resize_I8( DECDATA info, void * _dst); +extern void resize_P8( DECDATA info, void * _dst); +extern void resize_16( DECDATA info, void * _dst); +extern void resize_24( DECDATA info, void * _dst); +extern void resize_32( DECDATA info, void * _dst); + diff --git a/sources/z-tools/trunk/zview/zvdi/vdi.c b/sources/z-tools/trunk/zview/zvdi/vdi.c new file mode 100644 index 0000000..21f8873 --- /dev/null +++ b/sources/z-tools/trunk/zview/zvdi/vdi.c @@ -0,0 +1,222 @@ +#include "../general.h" +#include "../pic_load.h" +#include "../pic_resize.h" +#include "raster.h" +#include "raster_resize.h" +#include "color.h" +#include "p2c.h" +#include "pixel.h" +#include + +int16 pixel_val[256]; +uint32 cube216[216]; +uint32 graymap[32]; +int16 planar = 0; + +extern void save_colors( void); + +/* prototype */ +int16 vdi_init ( void); + +int16 vdi_init( void) +{ + int16 out[273] = { -1, }; + int16 depth; + boolean reverse, z_trail; + long dum; + + if( !get_cookie( C_EdDI, (long*)&dum)) + return( 0); + + vq_scrninfo ( app.handle, out); + + if ( app.nplanes <= 8) + { + save_colors(); + memcpy ( pixel_val, out + 16, 512); + } + + depth = (( uint16)out[4] == 0x8000u ? 15 : out[2]); /* bits per pixel used */ + reverse = (out[16] < out[48]); /* intel crap... */ + z_trail = (out[48] > 0); /* bits are shifted to the right side */ + + if ( depth == 1) + { /* monochrome */ + cnvpal_color = cnvpal_1_2; + raster_cmap = raster_D1; + raster_true = dither_D1; + raster_gray = gscale_D1; + resize = resize_mono; + } + else if ( out[0] == 0) /* Planar */ + { + planar = 1; + + switch ( depth) + { + case 2: + cnvpal_color = cnvpal_1_2; + raster_cmap = raster_D2; + raster_true = dither_D2; + raster_gray = gscale_D2; + planar_to_chunky = planar2_to_chunky8; + break; + case 4: + cnvpal_color = cnvpal_4_8; + raster_cmap = raster_I4; + raster_true = dither_I4; + raster_gray = gscale_I4; + resize = resize_I4; + planar_to_chunky = planar4_to_chunky8; + break; + case 8: + cnvpal_color = cnvpal_4_8; + raster_cmap = raster_I8; + raster_true = dither_I8; + raster_gray = gscale_I8; + resize = resize_I8; + planar_to_chunky = planar8_to_chunky8; + break; + } + } + else if ( out[0] == 2) /* chunky */ + switch ( depth) + { + case 8: + cnvpal_color = cnvpal_4_8; + raster_cmap = raster_P8; + raster_true = dither_P8; + raster_gray = gscale_P8; + resize = resize_P8; + break; + + case 15: + if (!(out[14] & 0x02)) + { + cnvpal_color = cnvpal_15; + + if (reverse) + { + raster_cmap = raster_15r; + raster_gray = gscale_15r; + raster_true = dither_15r; + } + else + { + raster_cmap = raster_15; + raster_gray = gscale_15; + raster_true = dither_15; + } + + resize = resize_16; + + break; + } + + case 16: + cnvpal_color = cnvpal_high; + + if (reverse) + { + raster_cmap = raster_16r; + raster_gray = gscale_16r; + raster_true = dither_16r; + getPixel = getPixel_16r; + setPixel = setPixel_16r; + } + else + { + raster_cmap = raster_16; + raster_gray = gscale_16; + raster_true = dither_16; + getPixel = getPixel_16; + setPixel = setPixel_16; + } + + resize = resize_16; + + break; + + case 24: + cnvpal_color = cnvpal_true; + + if (reverse) + { + raster_cmap = raster_24r; + raster_gray = gscale_24r; + raster_true = dither_24r; + getPixel = getPixel_24r; + setPixel = setPixel_24r; + } + else + { + raster_cmap = raster_24; + raster_gray = gscale_24; + raster_true = dither_24; + getPixel = getPixel_24; + setPixel = setPixel_24; + } + + resize = resize_24; + + break; + + case 32: + cnvpal_color = cnvpal_true; + + if (reverse) + { + raster_cmap = raster_32r; + raster_gray = gscale_32r; + raster_true = dither_32r; + getPixel = getPixel_32r; + setPixel = setPixel_32r; + } + else if( z_trail) + { + raster_cmap = raster_32z; + raster_gray = gscale_32z; + raster_true = dither_32z; + getPixel = getPixel_32z; + setPixel = setPixel_32z; + } + else + { + raster_cmap = raster_32; + raster_gray = gscale_32; + raster_true = dither_32; + getPixel = getPixel_32; + setPixel = setPixel_32; + } + + resize = resize_32; + + break; + } + + if (depth == 4 || depth == 8) + { + uint32 * dst; + uint32 r, g, b; + dst = cube216; + + for (r = 0x000000uL; r <= 0xFF0000uL; r += 0x330000uL) + { + for (g = 0x000000uL; g <= 0x00FF00uL; g += 0x003300uL) + { + for (b = 0x000000uL; b <= 0x0000FFuL; b += 0x000033uL) + { + *(dst++) = color_lookup ( r | g | b, pixel_val); + } + } + } + + dst = graymap; + + for ( g = 0x000000uL; g <= 0xF8F8F8uL; g += 0x080808uL) + *( dst++) = color_lookup ( g | (( g >> 5) & 0x030303uL), pixel_val); + } + + return( 1); +} + diff --git a/sources/z-tools/trunk/zview/zvdi/vdi.h b/sources/z-tools/trunk/zview/zvdi/vdi.h new file mode 100644 index 0000000..2d5f320 --- /dev/null +++ b/sources/z-tools/trunk/zview/zvdi/vdi.h @@ -0,0 +1,6 @@ +extern int16 pixel_val[256]; +extern uint32 cube216[216]; +extern uint32 graymap[32]; +extern int16 planar; + +extern int16 vdi_init( void); diff --git a/sources/z-tools/trunk/zview/zview.hrd b/sources/z-tools/trunk/zview/zview.hrd new file mode 100644 index 0000000..6bba288 Binary files /dev/null and b/sources/z-tools/trunk/zview/zview.hrd differ diff --git a/sources/z-tools/trunk/zview/zview.rsc b/sources/z-tools/trunk/zview/zview.rsc new file mode 100644 index 0000000..0a3813b Binary files /dev/null and b/sources/z-tools/trunk/zview/zview.rsc differ diff --git a/sources/z-tools/trunk/zview/zview.rsh b/sources/z-tools/trunk/zview/zview.rsh new file mode 100644 index 0000000..ff0aaef --- /dev/null +++ b/sources/z-tools/trunk/zview/zview.rsh @@ -0,0 +1,292 @@ + /* Resource C-Header-File v1.97 fr ResourceMaster ab v2.06 by ARDISOFT */ + +#define MENU_BAR 0 /* menu */ +#define MENU_BAR_FILE 4 /* TITLE in tree MENU_BAR */ +#define MENU_BAR_EDIT 5 /* TITLE in tree MENU_BAR */ +#define MENU_BAR_VIEW 6 /* TITLE in tree MENU_BAR */ +#define MENU_BAR_HELP 7 /* TITLE in tree MENU_BAR */ +#define MENU_BAR_ABOUT 10 /* STRING in tree MENU_BAR */ +#define MENU_BAR_BROWSER 19 /* STRING in tree MENU_BAR */ +#define MENU_BAR_OPEN 20 /* STRING in tree MENU_BAR */ +#define MENU_BAR_INFORMATION 22 /* STRING in tree MENU_BAR */ +#define MENU_BAR_SAVE 24 /* STRING in tree MENU_BAR */ +#define MENU_BAR_PRINT 26 /* STRING in tree MENU_BAR */ +#define MENU_BAR_CLOSE 28 /* STRING in tree MENU_BAR */ +#define MENU_BAR_QUIT 30 /* STRING in tree MENU_BAR */ +#define MENU_BAR_UNDO 32 /* STRING in tree MENU_BAR */ +#define MENU_BAR_COPY 34 /* STRING in tree MENU_BAR */ +#define MENU_BAR_CUT 35 /* STRING in tree MENU_BAR */ +#define MENU_BAR_PASTE 36 /* STRING in tree MENU_BAR */ +#define MENU_BAR_DELETE 38 /* STRING in tree MENU_BAR */ +#define MENU_BAR_SELECT_ALL 40 /* STRING in tree MENU_BAR */ +#define MENU_BAR_PREFERENCE 42 /* STRING in tree MENU_BAR */ +#define MENU_BAR_BY_NAME 44 /* STRING in tree MENU_BAR */ +#define MENU_BAR_BY_SIZE 45 /* STRING in tree MENU_BAR */ +#define MENU_BAR_BY_DATE 46 /* STRING in tree MENU_BAR */ +#define MENU_BAR_SHOW_BROWSER 48 /* STRING in tree MENU_BAR */ +#define MENU_BAR_SHOW 50 /* STRING in tree MENU_BAR */ +#define MENU_BAR_LARGE_THUMB 52 /* STRING in tree MENU_BAR */ +#define MENU_BAR_LONG_THUMB 53 /* STRING in tree MENU_BAR */ +#define MENU_BAR_SHOW_FULLSCREEN 55 /* STRING in tree MENU_BAR */ +#define MENU_BAR_GUIDE 57 /* STRING in tree MENU_BAR */ +#define MENU_BAR_HISTORY 58 /* STRING in tree MENU_BAR */ + +#define TOOLBAR 1 /* form/dial */ +#define TOOLBAR_BACK 0 /* BOX in tree TOOLBAR */ +#define TOOLBAR_UP 1 /* BUTTON in tree TOOLBAR */ +#define TOOLBAR_RELOAD 2 /* BUTTON in tree TOOLBAR */ +#define TOOLBAR_BIG 3 /* BUTTON in tree TOOLBAR */ +#define TOOLBAR_PRINT 4 /* BUTTON in tree TOOLBAR */ +#define TOOLBAR_INFO 5 /* BUTTON in tree TOOLBAR */ +#define TOOLBAR_SMALL 6 /* BUTTON in tree TOOLBAR */ +#define TOOLBAR_DELETE 7 /* BUTTON in tree TOOLBAR */ +#define TOOLBAR_OPEN 8 /* BUTTON in tree TOOLBAR */ +#define TOOLBAR_SAVE 9 /* BUTTON in tree TOOLBAR */ + +#define SINGLE_PROGRESS 2 /* form/dial */ +#define SINGLE_PROGRESS_CONTAINER 1 /* BOX in tree SINGLE_PROGRESS */ +#define SINGLE_PROGRESS_TXT 2 /* TEXT in tree SINGLE_PROGRESS */ + +#define MINI_ICON 3 /* form/dial */ +#define MINI_ICON_SNIPE 1 /* CICON in tree MINI_ICON */ + +#define OPERATION_DIAL 4 /* form/dial */ +#define OPERATION_DIAL_BAR 1 /* BOX in tree OPERATION_DIAL */ +#define OPERATION_DIAL_OK 2 /* BUTTON in tree OPERATION_DIAL */ +#define OPERATION_DIAL_CANCEL 3 /* BUTTON in tree OPERATION_DIAL */ +#define OPERATION_DIAL_INFO 4 /* TEXT in tree OPERATION_DIAL */ +#define OPERATION_DIAL_PROGRESS 5 /* TEXT in tree OPERATION_DIAL */ + +#define SLIDERS 5 /* form/dial */ +#define SLIDERS_BOX 0 /* BOX in tree SLIDERS */ +#define SLIDERS_UP 1 /* CICON in tree SLIDERS */ +#define SLIDERS_DOWN 2 /* CICON in tree SLIDERS */ +#define SLIDERS_BACK 4 /* BOX in tree SLIDERS */ +#define SLIDERS_MOVER 3 /* BOX in tree SLIDERS */ + +#define ABOUT 6 /* form/dial */ +#define ABOUT_S 0 /* BOX in tree ABOUT */ +#define ABOUT_VERSION 1 /* BUTTON in tree ABOUT */ +#define ABOUT_DATE 3 /* TEXT in tree ABOUT */ + +#define SAVE_DIAL 7 /* form/dial */ +#define SAVE_DIAL_SAVE 1 /* BUTTON in tree SAVE_DIAL */ +#define SAVE_DIAL_ABORT 2 /* BUTTON in tree SAVE_DIAL */ +#define SAVE_DIAL_FORMAT 6 /* BUTTON in tree SAVE_DIAL */ +#define SAVE_DIAL_OPTIONS 7 /* BUTTON in tree SAVE_DIAL */ + +#define FILE_INFO 8 /* form/dial */ +#define FILE_INFO_PANEL3 1 /* BUTTON in tree FILE_INFO */ +#define FILE_INFO_COMMENT 2 /* BOX in tree FILE_INFO */ +#define FILE_INFO_BOX 4 /* BOX in tree FILE_INFO */ +#define FILE_INFO_UP 5 /* CICON in tree FILE_INFO */ +#define FILE_INFO_DOWN 6 /* CICON in tree FILE_INFO */ +#define FILE_INFO_VBACK 7 /* BOX in tree FILE_INFO */ +#define FILE_INFO_VMOVER 8 /* BOX in tree FILE_INFO */ +#define FILE_INFO_PANEL2 9 /* BUTTON in tree FILE_INFO */ +#define FILE_INFO_INFO 20 /* TEXT in tree FILE_INFO */ +#define FILE_INFO_WIDTH 21 /* TEXT in tree FILE_INFO */ +#define FILE_INFO_HEIGHT 22 /* TEXT in tree FILE_INFO */ +#define FILE_INFO_PLANES 23 /* TEXT in tree FILE_INFO */ +#define FILE_INFO_COMPRESSION 24 /* TEXT in tree FILE_INFO */ +#define FILE_INFO_COLOR 25 /* TEXT in tree FILE_INFO */ +#define FILE_INFO_RATIO 26 /* TEXT in tree FILE_INFO */ +#define FILE_INFO_DEC_TIME 27 /* TEXT in tree FILE_INFO */ +#define FILE_INFO_MEM 28 /* TEXT in tree FILE_INFO */ +#define FILE_INFO_PAGE 29 /* TEXT in tree FILE_INFO */ +#define FILE_INFO_PANEL1 30 /* BUTTON in tree FILE_INFO */ +#define FILE_INFO_TIME 31 /* TEXT in tree FILE_INFO */ +#define FILE_INFO_DATE 32 /* TEXT in tree FILE_INFO */ +#define FILE_INFO_SIZE 33 /* TEXT in tree FILE_INFO */ +#define FILE_INFO_NAME 34 /* TEXT in tree FILE_INFO */ +#define FILE_INFO_FILE 39 /* BUTTON in tree FILE_INFO */ +#define FILE_INFO_IMAGE 40 /* BUTTON in tree FILE_INFO */ +#define FILE_INFO_EXIF 41 /* BUTTON in tree FILE_INFO */ + +#define HSLIDERS 9 /* form/dial */ +#define HSLIDERS_LEFT 2 /* CICON in tree HSLIDERS */ +#define HSLIDERS_RIGHT 3 /* CICON in tree HSLIDERS */ +#define HSLIDERS_HBACK 4 /* BOX in tree HSLIDERS */ +#define HSLIDERS_HMOVER 5 /* BOX in tree HSLIDERS */ + +#define JPGPREF 10 /* form/dial */ +#define JPGPREF_PERCENT 5 /* BOXTEXT in tree JPGPREF */ +#define JPGPREF_OK 6 /* BUTTON in tree JPGPREF */ +#define JPGPREF_BG 7 /* IBOX in tree JPGPREF */ +#define JPGPREF_LF 8 /* BOXCHAR in tree JPGPREF */ +#define JPGPREF_RT 9 /* BOXCHAR in tree JPGPREF */ +#define JPGPREF_PG 10 /* BOX in tree JPGPREF */ +#define JPGPREF_SL 11 /* BOX in tree JPGPREF */ +#define JPGPREF_GRAY 12 /* BUTTON in tree JPGPREF */ +#define JPGPREF_PROGRESSIVE 13 /* BUTTON in tree JPGPREF */ + +#define TIFFPREF 11 /* form/dial */ +#define TIFFPREF_PERCENT 5 /* BOXTEXT in tree TIFFPREF */ +#define TIFFPREF_OK 6 /* BUTTON in tree TIFFPREF */ +#define TIFFPREF_BG 7 /* IBOX in tree TIFFPREF */ +#define TIFFPREF_LF 8 /* BOXCHAR in tree TIFFPREF */ +#define TIFFPREF_RT 9 /* BOXCHAR in tree TIFFPREF */ +#define TIFFPREF_PG 10 /* BOX in tree TIFFPREF */ +#define TIFFPREF_SL 11 /* BOX in tree TIFFPREF */ +#define TIFFPREF_None 14 /* BUTTON in tree TIFFPREF */ +#define TIFFPREF_RLE 15 /* BUTTON in tree TIFFPREF */ +#define TIFFPREF_LZW 16 /* BUTTON in tree TIFFPREF */ +#define TIFFPREF_JPEG 17 /* BUTTON in tree TIFFPREF */ +#define TIFFPREF_DEFLATE 18 /* BUTTON in tree TIFFPREF */ + +#define VIEWTOOLBAR 12 /* form/dial */ +#define VIEWTOOLBAR_BACK 0 /* BOX in tree VIEWTOOLBAR */ +#define VIEWTOOLBAR_BIG 1 /* BUTTON in tree VIEWTOOLBAR */ +#define VIEWTOOLBAR_SMALL 2 /* BUTTON in tree VIEWTOOLBAR */ +#define VIEWTOOLBAR_OPEN 3 /* BUTTON in tree VIEWTOOLBAR */ +#define VIEWTOOLBAR_SAVE 4 /* BUTTON in tree VIEWTOOLBAR */ +#define VIEWTOOLBAR_INFO 5 /* BUTTON in tree VIEWTOOLBAR */ +#define VIEWTOOLBAR_FULLSCREEN 6 /* BUTTON in tree VIEWTOOLBAR */ +#define VIEWTOOLBAR_PRINT 7 /* BUTTON in tree VIEWTOOLBAR */ + +#define PDFTOOLBAR 13 /* form/dial */ +#define PDFTOOLBAR_BACK 0 /* BOX in tree PDFTOOLBAR */ +#define PDFTOOLBAR_BIG 1 /* BUTTON in tree PDFTOOLBAR */ +#define PDFTOOLBAR_SMALL 2 /* BUTTON in tree PDFTOOLBAR */ +#define PDFTOOLBAR_PREVIOUS 3 /* BUTTON in tree PDFTOOLBAR */ +#define PDFTOOLBAR_NEXT 4 /* BUTTON in tree PDFTOOLBAR */ +#define PDFTOOLBAR_OPEN 5 /* BUTTON in tree PDFTOOLBAR */ +#define PDFTOOLBAR_PRINT 6 /* BUTTON in tree PDFTOOLBAR */ +#define PDFTOOLBAR_FIND 7 /* BUTTON in tree PDFTOOLBAR */ +#define PDFTOOLBAR_PAGE 8 /* BOXTEXT in tree PDFTOOLBAR */ +#define PDFTOOLBAR_INFO 9 /* BUTTON in tree PDFTOOLBAR */ +#define PDFTOOLBAR_PERCENT 10 /* BOXTEXT in tree PDFTOOLBAR */ + +#define PREFS 14 /* form/dial */ +#define PREFS_PANEL3 1 /* BUTTON in tree PREFS */ +#define PREFS_PDF_ANTIALIAS 2 /* BUTTON in tree PREFS */ +#define PREFS_PDF_FIT_TO_WINDOW 3 /* BUTTON in tree PREFS */ +#define PREFS_PANEL2 4 /* BUTTON in tree PREFS */ +#define PREFS_SHOW_SIZE 5 /* BUTTON in tree PREFS */ +#define PREFS_SHOW_HIDDEN 6 /* BUTTON in tree PREFS */ +#define PREFS_SHOW_NON_IMAGE 7 /* BUTTON in tree PREFS */ +#define PREFS_SMOOTH_METHOD 9 /* BUTTON in tree PREFS */ +#define PREFS_A 12 /* BUTTON in tree PREFS */ +#define PREFS_B 13 /* BUTTON in tree PREFS */ +#define PREFS_C 14 /* BUTTON in tree PREFS */ +#define PREFS_D 15 /* BUTTON in tree PREFS */ +#define PREFS_E 16 /* BUTTON in tree PREFS */ +#define PREFS_F 17 /* BUTTON in tree PREFS */ +#define PREFS_G 18 /* BUTTON in tree PREFS */ +#define PREFS_H 19 /* BUTTON in tree PREFS */ +#define PREFS_I 20 /* BUTTON in tree PREFS */ +#define PREFS_J 29 /* BUTTON in tree PREFS */ +#define PREFS_K 30 /* BUTTON in tree PREFS */ +#define PREFS_L 31 /* BUTTON in tree PREFS */ +#define PREFS_M 32 /* BUTTON in tree PREFS */ +#define PREFS_N 33 /* BUTTON in tree PREFS */ +#define PREFS_O 34 /* BUTTON in tree PREFS */ +#define PREFS_P 35 /* BUTTON in tree PREFS */ +#define PREFS_Q 36 /* BUTTON in tree PREFS */ +#define PREFS_R 37 /* BUTTON in tree PREFS */ +#define PREFS_S 38 /* BUTTON in tree PREFS */ +#define PREFS_T 39 /* BUTTON in tree PREFS */ +#define PREFS_U 40 /* BUTTON in tree PREFS */ +#define PREFS_V 41 /* BUTTON in tree PREFS */ +#define PREFS_W 42 /* BUTTON in tree PREFS */ +#define PREFS_X 43 /* BUTTON in tree PREFS */ +#define PREFS_Y 44 /* BUTTON in tree PREFS */ +#define PREFS_Z 45 /* BUTTON in tree PREFS */ +#define PREFS_PANEL1 21 /* BUTTON in tree PREFS */ +#define PREFS_SHOW_READ_PROGRESS 22 /* BUTTON in tree PREFS */ +#define PREFS_SHOW_WRITE_PROGRESS 23 /* BUTTON in tree PREFS */ +#define PREFS_GENERAL 24 /* BUTTON in tree PREFS */ +#define PREFS_BROWSER 25 /* BUTTON in tree PREFS */ +#define PREFS_PDF 26 /* BUTTON in tree PREFS */ +#define PREFS_OK 27 /* BUTTON in tree PREFS */ +#define PREFS_CANCEL 28 /* BUTTON in tree PREFS */ + +#define NOMEM 0 /* Alert string */ + +#define ALERT_WINDOW 1 /* Alert string */ + +#define GENERIC 2 /* Alert string */ + +#define ASK_READONLY 3 /* Alert string */ + +#define NOENT 4 /* Alert string */ + +#define NAMETOOLONG 5 /* Alert string */ + +#define ACCES 6 /* Alert string */ + +#define LOOP 7 /* Alert string */ + +#define NOTDIR 8 /* Alert string */ + +#define ISDIR 9 /* Alert string */ + +#define XDEV 10 /* Alert string */ + +#define NOSPC 11 /* Alert string */ + +#define IO 12 /* Alert string */ + +#define ROFS 13 /* Alert string */ + +#define FAULT 14 /* Alert string */ + +#define INVAL 15 /* Alert string */ + +#define BADF 16 /* Alert string */ + +#define NAMEALREADYUSED 17 /* Alert string */ + +#define LIB_FULLED 18 /* Alert string */ + +#define APP_FULLED 19 /* Alert string */ + +#define ERR_EXEC 20 /* Alert string */ + +#define BAD_LFORMAT 21 /* Alert string */ + +#define LIB_LOCKED 22 /* Alert string */ + +#define NOT_FOUND 23 /* Alert string */ + +#define NO_MEMORY 24 /* Alert string */ + +#define NOFUNC 25 /* Alert string */ + +#define PLUGIN_DECODER_ABSENT 26 /* Alert string */ + +#define PLUGIN_ENCODER_ABSENT 27 /* Alert string */ + +#define CANT_LOAD_IMG 28 /* Alert string */ + +#define CANT_SAVE_IMG 29 /* Alert string */ + +#define IMG_NO_VALID 30 /* Alert string */ + +#define SOURCE_TARGET_SAME 31 /* Alert string */ + +#define SAVE_TITLE 32 /* Free string */ + +#define LOAD_TITLE 33 /* Free string */ + +#define DELETE_TITLE 34 /* Free string */ + +#define DELETE_INFO 35 /* Free string */ + +#define CALCUL 36 /* Free string */ + +#define PROGRESS_TXT 37 /* Free string */ + +#define ABOUT_TITLE 38 /* Free string */ + +#define DELETE_ASK 39 /* Free string */ + +#define JPG_OPTION_TITLE 40 /* Free string */ + +#define TIFF_OPTION_TITLE 41 /* Free string */ + +#define NOZCODECS 42 /* Alert string */ + +#define NOEDDI 43 /* Alert string */ + +#define NOICONS 44 /* Alert string */ diff --git a/sources/z-tools/trunk/zview/zview.rsm b/sources/z-tools/trunk/zview/zview.rsm new file mode 100644 index 0000000..f4999ae --- /dev/null +++ b/sources/z-tools/trunk/zview/zview.rsm @@ -0,0 +1,237 @@ +ResourceMaster v3.65 +#C 15@45@0@0@ +#N 99@32@AZAaza___ _@AZAaza090___ _@@_@ +#R 0@0@3@1@4@1@ +#M 01010110@0@7728@749@ +#T 0@1@MENU_BAR@@59@@ +#O 4@32@FILE@@ +#O 5@32@EDIT@@ +#O 6@32@VIEW@@ +#O 7@32@HELP@@ +#O 10@28@ABOUT@@ +#O 19@28@BROWSER@@ +#O 20@28@OPEN@@ +#O 22@28@INFORMATION@@ +#O 24@28@SAVE@@ +#O 26@28@PRINT@@ +#O 28@28@CLOSE@@ +#O 30@28@QUIT@@ +#O 32@28@UNDO@@ +#O 34@28@COPY@@ +#O 35@28@CUT@@ +#O 36@28@PASTE@@ +#O 38@28@DELETE@@ +#O 40@28@SELECT_ALL@@ +#O 42@28@PREFERENCE@@ +#O 44@28@BY_NAME@@ +#O 45@28@BY_SIZE@@ +#O 46@28@BY_DATE@@ +#O 48@28@SHOW_BROWSER@@ +#O 50@28@SHOW@@ +#O 52@28@LARGE_THUMB@@ +#O 53@28@LONG_THUMB@@ +#O 55@28@SHOW_FULLSCREEN@@ +#O 57@28@GUIDE@@ +#O 58@28@HISTORY@@ +#T 1@2@TOOLBAR@@10@@ +#O 0@20@BACK@@ +#O 1@26@UP@@ +#O 2@26@RELOAD@@ +#O 3@26@BIG@@ +#O 4@26@PRINT@@ +#O 5@26@INFO@@ +#O 6@26@SMALL@@ +#O 7@26@DELETE@@ +#O 8@26@OPEN@@ +#O 9@26@SAVE@@ +#T 2@2@SINGLE_PROGRESS@@3@@ +#O 1@20@CONTAINER@@ +#O 2@21@TXT@@ +#T 3@2@MINI_ICON@@2@@ +#O 1@33@SNIPE@@ +#T 4@2@OPERATION_DIAL@@6@@ +#O 1@20@BAR@@ +#O 2@26@OK@@ +#O 3@26@CANCEL@@ +#O 4@21@INFO@@ +#O 5@21@PROGRESS@@ +#T 5@2@SLIDERS@@5@@ +#O 0@20@BOX@@ +#O 1@33@UP@@ +#O 2@33@DOWN@@ +#O 4@20@BACK@@ +#O 3@20@MOVER@@ +#T 6@2@ABOUT@@10@@ +#O 0@20@S@@ +#O 1@26@VERSION@@ +#O 3@21@DATE@@ +#T 7@2@SAVE_DIAL@@10@@ +#O 1@26@SAVE@@ +#O 2@26@ABORT@@ +#O 6@26@FORMAT@@ +#O 7@26@OPTIONS@@ +#T 8@2@FILE_INFO@@42@@ +#O 1@26@PANEL3@@ +#O 2@20@COMMENT@@ +#O 4@20@BOX@@ +#O 5@33@UP@@ +#O 6@33@DOWN@@ +#O 7@20@VBACK@@ +#O 8@20@VMOVER@@ +#O 9@26@PANEL2@@ +#O 20@21@INFO@@ +#O 21@21@WIDTH@@ +#O 22@21@HEIGHT@@ +#O 23@21@PLANES@@ +#O 24@21@COMPRESSION@@ +#O 25@21@COLOR@@ +#O 26@21@RATIO@@ +#O 27@21@DEC_TIME@@ +#O 28@21@MEM@@ +#O 29@21@PAGE@@ +#O 30@26@PANEL1@@ +#O 31@21@TIME@@ +#O 32@21@DATE@@ +#O 33@21@SIZE@@ +#O 34@21@NAME@@ +#O 39@26@FILE@@ +#O 40@26@IMAGE@@ +#O 41@26@EXIF@@ +#T 9@2@HSLIDERS@@6@@ +#O 2@33@LEFT@@ +#O 3@33@RIGHT@@ +#O 4@20@HBACK@@ +#O 5@20@HMOVER@@ +#T 10@2@JPGPREF@@14@@ +#O 5@22@PERCENT@@ +#O 6@26@OK@@ +#O 7@25@BG@@ +#O 8@27@LF@@ +#O 9@27@RT@@ +#O 10@20@PG@@ +#O 11@20@SL@@ +#O 12@26@GRAY@@ +#O 13@26@PROGRESSIVE@@ +#T 11@2@TIFFPREF@@19@@ +#O 5@22@PERCENT@@ +#O 6@26@OK@@ +#O 7@25@BG@@ +#O 8@27@LF@@ +#O 9@27@RT@@ +#O 10@20@PG@@ +#O 11@20@SL@@ +#O 14@26@None@@ +#O 15@26@RLE@@ +#O 16@26@LZW@@ +#O 17@26@JPEG@@ +#O 18@26@DEFLATE@@ +#T 12@2@VIEWTOOLBAR@@8@@ +#O 0@20@BACK@@ +#O 1@26@BIG@@ +#O 2@26@SMALL@@ +#O 3@26@OPEN@@ +#O 4@26@SAVE@@ +#O 5@26@INFO@@ +#O 6@26@FULLSCREEN@@ +#O 7@26@PRINT@@ +#T 13@2@PDFTOOLBAR@@11@@ +#O 0@20@BACK@@ +#O 1@26@BIG@@ +#O 2@26@SMALL@@ +#O 3@26@PREVIOUS@@ +#O 4@26@NEXT@@ +#O 5@26@OPEN@@ +#O 6@26@PRINT@@ +#O 7@26@FIND@@ +#O 8@22@PAGE@@ +#O 9@26@INFO@@ +#O 10@22@PERCENT@@ +#T 14@2@PREFS@@47@@ +#O 1@26@PANEL3@@ +#O 2@26@PDF_ANTIALIAS@@ +#O 3@26@PDF_FIT_TO_WINDOW@@ +#O 4@26@PANEL2@@ +#O 5@26@SHOW_SIZE@@ +#O 6@26@SHOW_HIDDEN@@ +#O 7@26@SHOW_NON_IMAGE@@ +#O 9@26@SMOOTH_METHOD@@ +#O 12@26@A@@ +#O 13@26@B@@ +#O 14@26@C@@ +#O 15@26@D@@ +#O 16@26@E@@ +#O 17@26@F@@ +#O 18@26@G@@ +#O 19@26@H@@ +#O 20@26@I@@ +#O 29@26@J@@ +#O 30@26@K@@ +#O 31@26@L@@ +#O 32@26@M@@ +#O 33@26@N@@ +#O 34@26@O@@ +#O 35@26@P@@ +#O 36@26@Q@@ +#O 37@26@R@@ +#O 38@26@S@@ +#O 39@26@T@@ +#O 40@26@U@@ +#O 41@26@V@@ +#O 42@26@W@@ +#O 43@26@X@@ +#O 44@26@Y@@ +#O 45@26@Z@@ +#O 21@26@PANEL1@@ +#O 22@26@SHOW_READ_PROGRESS@@ +#O 23@26@SHOW_WRITE_PROGRESS@@ +#O 24@26@GENERAL@@ +#O 25@26@BROWSER@@ +#O 26@26@PDF@@ +#O 27@26@OK@@ +#O 28@26@CANCEL@@ +#S 0@4@NOMEM@@ +#S 1@4@ALERT_WINDOW@@ +#S 2@4@GENERIC@@ +#S 3@4@ASK_READONLY@@ +#S 4@4@NOENT@@ +#S 5@4@NAMETOOLONG@@ +#S 6@4@ACCES@@ +#S 7@4@LOOP@@ +#S 8@4@NOTDIR@@ +#S 9@4@ISDIR@@ +#S 10@4@XDEV@@ +#S 11@4@NOSPC@@ +#S 12@4@IO@@ +#S 13@4@ROFS@@ +#S 14@4@FAULT@@ +#S 15@4@INVAL@@ +#S 16@4@BADF@@ +#S 17@4@NAMEALREADYUSED@@ +#S 18@4@LIB_FULLED@@ +#S 19@4@APP_FULLED@@ +#S 20@4@ERR_EXEC@@ +#S 21@4@BAD_LFORMAT@@ +#S 22@4@LIB_LOCKED@@ +#S 23@4@NOT_FOUND@@ +#S 24@4@NO_MEMORY@@ +#S 25@4@NOFUNC@@ +#S 26@4@PLUGIN_DECODER_ABSENT@@ +#S 27@4@PLUGIN_ENCODER_ABSENT@@ +#S 28@4@CANT_LOAD_IMG@@ +#S 29@4@CANT_SAVE_IMG@@ +#S 30@4@IMG_NO_VALID@@ +#S 31@4@SOURCE_TARGET_SAME@@ +#S 32@5@SAVE_TITLE@@ +#S 33@5@LOAD_TITLE@@ +#S 34@5@DELETE_TITLE@@ +#S 35@5@DELETE_INFO@@ +#S 36@5@CALCUL@@ +#S 37@5@PROGRESS_TXT@@ +#S 38@5@ABOUT_TITLE@@ +#S 39@5@DELETE_ASK@@ +#S 40@5@JPG_OPTION_TITLE@@ +#S 41@5@TIFF_OPTION_TITLE@@ +#S 42@4@NOZCODECS@@ +#S 43@4@NOEDDI@@ +#S 44@4@NOICONS@@ +#c 6446@ diff --git a/sources/z-tools/trunk/zweather/Makefile b/sources/z-tools/trunk/zweather/Makefile new file mode 100644 index 0000000..348619d --- /dev/null +++ b/sources/z-tools/trunk/zweather/Makefile @@ -0,0 +1,21 @@ +ifeq ($(CROSS),yes) +LIBXML = /usr/m68k-atari-mint/include/libxml2 +else +LIBXML = /usr/include/libxml2 +endif + +STACKSIZE = 64k +OPTIMISATION = -O2 -fomit-frame-pointer -finline-functions +CPU = -m68020-60 +LIB = -lwindom -lzcodec -lldg -lgem -lxml2 -lm -lmem -lz +CFLAGS = $(CPU) $(OPTIMISATION) -Wall -Wshadow -I$(LIBXML) +ifeq ($(CROSS),no) +CFLAGS += -I/usr/local/include +LDFLAGS += -L/usr/local/lib/m68020-60 +endif +OBJ = inet.o http_client.o parsers.o get_data.o \ + debug.o zstring.o dialog.o prefs.o zaes.o icon.o main.o + +PROGRAM = zweather.app + +include ../common.mak \ No newline at end of file diff --git a/sources/z-tools/trunk/zweather/debug.c b/sources/z-tools/trunk/zweather/debug.c new file mode 100644 index 0000000..e870e2d --- /dev/null +++ b/sources/z-tools/trunk/zweather/debug.c @@ -0,0 +1,30 @@ +#include "general.h" +#ifdef DEBUG +#include +#endif + +/*==================================================================================* + * void zdebug: * + * print debug information in 'wout' window. * + *----------------------------------------------------------------------------------* + * input: * + * ... -> text and parameter are the same that sandard "printf" function. * + *----------------------------------------------------------------------------------* + * returns: * + * -- * + *==================================================================================*/ + +void zdebug( const char *format, ...) +{ +#ifdef DEBUG + va_list args; + char fo_buff[255], *p; + + va_start( args, format); + vsprintf( fo_buff, format, args); + p = fo_buff; + va_end( args); + + wout_printf("%s\n", p); +#endif +} diff --git a/sources/z-tools/trunk/zweather/dialog.c b/sources/z-tools/trunk/zweather/dialog.c new file mode 100644 index 0000000..02dbe55 --- /dev/null +++ b/sources/z-tools/trunk/zweather/dialog.c @@ -0,0 +1,115 @@ +#include "general.h" +#include "icon.h" +#include "parsers.h" + +extern struct xml_weather *zweatherdata; +extern int8 wind_direction[8]; +extern void init_stik (void); + +WINDOW *windialog = NULL; +int8 icon_temp[8] = ""; + +static void force_update( WINDOW *win, int obj, int mode, void *data) +{ + OBJECT *weather_form = get_tree( WEATHER); + int time_minute; + + graf_mouse( BUSYBEE, NULL); + + if( EvntFind( NULL, WM_XTIMER)) + EvntDelete( NULL, WM_XTIMER); + + if( zweatherdata) + xml_weather_free( zweatherdata); + + strcpy( location_code, ObjcString( weather_form, WEATHER_CODE, NULL)); + + zweatherdata = update_weatherdata( location_code); + + time_minute = atoi( ( const char*)ObjcString( weather_form, WEATHER_UPDATE_TIME, NULL)); + + update_time = ( clock_t)( ( int32)time_minute * 12000L); + + ObjcChange( OC_FORM, windialog, WEATHER_UPDATE, NORMAL, 0); + + snd_rdw( windialog); + + EvntAttach( NULL, WM_XTIMER, timer_function); + + graf_mouse( ARROW, NULL); +} + +static void weather_dialog_quit( WINDOW *win, int obj, int mode, void *data) +{ + ObjcChange( OC_FORM, win, obj, NORMAL, TRUE); + ApplWrite( _AESapid, AP_TERM, 0, 0, 0, 0, 0); +} + +static void CDECL continent_popup( WINDOW *win, int obj, int mode, void *data) +{ + OBJECT *pop; + int16 x, y; + static int last_choice = -1; + int choice; + + rsrc_gaddr( 0, CONTINENT, &pop); + objc_offset( FORM( win), obj, &x, &y); + + choice = MenuPopUp ( pop, x, y, -1, -1, last_choice, P_WNDW + P_CHCK); + last_choice = choice; + ObjcChange( OC_FORM, win, obj, NORMAL, TRUE); +} + +void weather_dialog( void) +{ + OBJECT *weather_form = get_tree( WEATHER); + int frms[] = { WEATHER_PANEL1, WEATHER_PANEL2, WEATHER_PANEL3, WEATHER_PANEL4}; + int buts[] = { WEATHER_MAIN, WEATHER_FORECAST, WEATHER_MAP, WEATHER_PREF}; + int time_minute = ( int)( update_time / 12000L); + + strcpy( ObjcString( weather_form, WEATHER_CONTINENT, NULL), "--"); + strcpy( ObjcString( weather_form, WEATHER_STATE, NULL), "--"); + strcpy( ObjcString( weather_form, WEATHER_CODE, NULL), location_code); + sprintf( ObjcString( weather_form, WEATHER_UPDATE_TIME, NULL), "%d", time_minute); + + windialog = FormCreate( weather_form, NAME|MOVER, NULL, " zWeather ", NULL, TRUE, FALSE); + +// RsrcUserDraw( OC_FORM, windialog, WEATHER_ROOT, draw_root_dial, NULL); + RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON, draw_weather_icon, NULL); + RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON1, draw_forecast1_icon, NULL); + RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON2, draw_forecast2_icon, NULL); + RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON3, draw_forecast3_icon, NULL); + RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON4, draw_forecast4_icon, NULL); + RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON5, draw_forecast5_icon, NULL); + RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON6, draw_forecast6_icon, NULL); + RsrcUserDraw( OC_FORM, windialog, WEATHER_WICON, draw_boussole_icon, NULL); + + FormThumb( windialog, frms, buts, 4); + + if( main_icon == NULL) + main_icon = &icons[25]; + + if( forecast_icon[0] == NULL) + forecast_icon[0] = &icons[25]; + + if( forecast_icon[1] == NULL) + forecast_icon[1] = &icons[25]; + + if( forecast_icon[2] == NULL) + forecast_icon[2] = &icons[25]; + + if( forecast_icon[3] == NULL) + forecast_icon[3] = &icons[25]; + + if( forecast_icon[4] == NULL) + forecast_icon[4] = &icons[25]; + + ObjcAttachVar( OC_FORM, windialog, WEATHER_METRIC, &unit, WEATHER_METRIC); + ObjcAttachVar( OC_FORM, windialog, WEATHER_IMPERIAL, &unit, WEATHER_IMPERIAL); + ObjcAttachFormFunc( windialog, WEATHER_UPDATE, force_update, NULL); + ObjcAttachFormFunc( windialog, WEATHER_QUIT, weather_dialog_quit, NULL); + ObjcAttachFormFunc( windialog, WEATHER_CONTINENT, continent_popup, NULL); + + vswr_mode( windialog->graf->handle, MD_TRANS); + vsl_color( windialog->graf->handle, RED); +} diff --git a/sources/z-tools/trunk/zweather/general.h b/sources/z-tools/trunk/zweather/general.h new file mode 100644 index 0000000..624b415 --- /dev/null +++ b/sources/z-tools/trunk/zweather/general.h @@ -0,0 +1,67 @@ +/* + * zWeather. + * Copyright (c) 2004 Zorro ( zorro270@yahoo.fr) + * + * This application is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "zstring.h" +#include "zaes.h" +#include "prefs.h" +#include "zweather.rsh" + +/* Custom message code */ +#define E_RSC 10002 +#define E_OK 0 + +/* Option */ +// #define DEBUG + + +#ifndef MAXNAMLEN + #define MAXNAMLEN 255 +#endif + +#ifndef MAX_PATH + #define MAX_PATH 1024 +#endif + +extern int use_sting; +extern WINDOW *windialog; +extern void timer_function( WINDOW *win, short buff[8]); +extern void snd_rdw( WINDOW *win); +extern struct xml_weather *update_weatherdata( int8 *location); +extern void snd_msg( WINDOW *win, int msg, int par1, int par2, int par3, int par4); +extern void zdebug( const char *format, ...); + diff --git a/sources/z-tools/trunk/zweather/get_data.c b/sources/z-tools/trunk/zweather/get_data.c new file mode 100644 index 0000000..9c1b082 --- /dev/null +++ b/sources/z-tools/trunk/zweather/get_data.c @@ -0,0 +1,206 @@ +#include "general.h" +#include "get_data.h" + +int8 dummy[2] = "0"; + + +int8 *get_data_uv(struct xml_uv *data, enum datas_uv type) +{ + int8 *str = dummy; + + if ( !data) + return str; + + switch(type) + { + case _UV_INDEX: str = data->i; break; + case _UV_TRANS: str = data->t; break; + default: break; + } + + return str; +} + + +int8 *get_data_bar(struct xml_bar *data, enum datas_bar type) +{ + int8 *str = dummy; + + if ( !data) + return str; + + switch(type) + { + case _BAR_R: str = data->r; break; + case _BAR_D: str = data->d; break; + default: break; + } + + return str; +} + +int8 *get_data_wind(struct xml_wind *data, enum datas_wind type) +{ + int8 *str = dummy; + + if ( !data) + return str; + + switch(type) + { + case _WIND_SPEED: str = data->s; break; + case _WIND_GUST: str = data->gust; break; + case _WIND_DIRECTION: str = data->t; break; + case _WIND_TRANS: str = data->d; break; + default: break; + } + + return str; +} + +int8 *get_data_cc( struct xml_cc *data, enum datas type) +{ + int8 *str = dummy; + + if ( !data) + return str; + + switch(type) + { + case LSUP: str = data->lsup; break; + case OBST: str = data->obst; break; + case FLIK: str = data->flik; break; + case TRANS: str = data->t; break; + case TEMP: str = data->tmp; break; + case HMID: str = data->hmid; break; + case VIS: str = data->vis; break; + case UV_INDEX: return get_data_uv(data->uv, _UV_INDEX); + case UV_TRANS: return get_data_uv(data->uv, _UV_TRANS); + case WIND_SPEED: return get_data_wind(data->wind, _WIND_SPEED); + case WIND_GUST: return get_data_wind(data->wind, _WIND_GUST); + case WIND_DIRECTION: return get_data_wind(data->wind, _WIND_DIRECTION); + case WIND_TRANS: return get_data_wind(data->wind, _WIND_TRANS); + case BAR_R: return get_data_bar(data->bar, _BAR_R); + case BAR_D: return get_data_bar(data->bar, _BAR_D); + case DEWP: str = data->dewp; break; + case WICON: str = data->icon; break; + default: break; + } + return str; +} + +int8 *get_data_loc(struct xml_loc *data, enum datas_loc type) +{ + int8 *str = dummy; + + if ( !data) + return str; + + switch(type) + { + case DNAM: str = data->dnam; break; + case SUNR: str = data->sunr; break; + case SUNS: str = data->suns; break; + default: break; + } + + return str; +} + +const int8 *get_data(struct xml_weather *data, enum datas type) +{ + int8 *str = dummy; + + if( data) + { + switch (type & 0xFF00) + { + case DATAS_CC: str = get_data_cc(data->cc, type); break; + case DATAS_LOC: str = get_data_loc(data->loc, type); break; + default: break; + } + } + + return str; +} + +int8 *get_data_part(struct xml_part *data, enum forecast type) +{ + int8 *str = dummy; + + if ( !data) + return str; + + switch (type & 0x000F) + { + case F_ICON: str = data->icon; break; + case F_TRANS: str = data->t; break; + case F_PPCP: str = data->ppcp; break; + case F_W_SPEED: str = get_data_wind(data->wind, _WIND_SPEED); break; + case F_W_DIRECTION: str = get_data_wind(data->wind, _WIND_DIRECTION); break; + default: break; + } + + return str; +} + +const int8 *get_data_f(struct xml_dayf *data, enum forecast type) +{ + int8 *str = dummy; + + if (data) + { + switch (type & 0x0F00) + { + case ITEMS: + switch(type) + { + case WDAY: str = data->day; break; + case TEMP_MIN: str = data->low; break; + case TEMP_MAX: str = data->hi; break; + default: break; + } + break; + case NPART: str = get_data_part(data->part[1], type); break; + case DPART: str = get_data_part(data->part[0], type); break; + } + } + + return str; +} + +const int8 *get_unit( int myunit, enum datas type) +{ + int8 *str = dummy; + + switch (type & 0x00F0) + { + case 0x0020: str = (myunit == WEATHER_METRIC ? "ø C" : "ø F"); break; + case 0x0030: str = "%"; break; + case 0x0040: str = (myunit == WEATHER_METRIC ? "km/h" : "mph"); break; + case 0x0050: str = (myunit == WEATHER_METRIC ? "mb" : "in"); break; + default: break; + } + + return str; +} + +const int8 *get_lnks(struct xml_lnks *lnks, enum link type, int num) +{ + int8* str = ""; + + if( !lnks || num >= XML_WEATHER_LINK_N) + return str; + + switch (type) + { + case LINK: + str = lnks->l[num]; + case TEXT: + str = lnks->t[num]; + default: + break; + } + + return str; +} diff --git a/sources/z-tools/trunk/zweather/get_data.h b/sources/z-tools/trunk/zweather/get_data.h new file mode 100644 index 0000000..2d4140a --- /dev/null +++ b/sources/z-tools/trunk/zweather/get_data.h @@ -0,0 +1,98 @@ +#ifndef GET_DATA_H +#define GET_DATA_H + +#include "parsers.h" + +#define DATAS_CC 0x0100 +#define DATAS_LOC 0x0200 +#define DATAS_DAYF 0x0300 + +enum datas_wind { + _WIND_SPEED, + _WIND_GUST, + _WIND_DIRECTION, + _WIND_TRANS +}; + +enum datas_bar { + _BAR_R, + _BAR_D +}; + +enum datas_uv { + _UV_INDEX, + _UV_TRANS +}; + +enum datas { + /* cc */ + LSUP = 0x0101, + OBST = 0x0102, + TRANS = 0x0103, + VIS = 0x0104, + UV_INDEX = 0x0105, + UV_TRANS = 0x0106, + WIND_DIRECTION = 0x0107, + BAR_D = 0x0108, + WIND_TRANS = 0x0109, + WICON = 0x0110, + + FLIK = 0x0120, + TEMP = 0x0121, + DEWP = 0x0122, + + HMID = 0x0130, + + WIND_SPEED = 0x0140, + WIND_GUST = 0x0141, + + + BAR_R = 0x0150 +}; + + +enum datas_loc { + DNAM = 0x0201, + SUNR = 0x0202, + SUNS = 0x0203 +}; + +enum forecast { + ITEMS = 0x0100, + WDAY = 0x0101, + TEMP_MIN = 0x0102, + TEMP_MAX = 0x0103, + + F_ICON = 0x0001, + F_PPCP = 0x0002, + F_W_DIRECTION = 0x0003, + F_W_SPEED = 0x0004, + F_TRANS = 0x0005, + + NPART = 0x0200, + ICON_N = 0x0201, + PPCP_N = 0x0202, + W_DIRECTION_N = 0x0203, + W_SPEED_N = 0x0204, + TRANS_N = 0x0205, + + DPART = 0x0300, + ICON_D = 0x0301, + PPCP_D = 0x0302, + W_DIRECTION_D = 0x0303, + W_SPEED_D = 0x0304, + TRANS_D = 0x0305 +}; + +enum link { + LINK, + TEXT +}; + + +const int8 *get_data(struct xml_weather *data, enum datas type); +const int8 *get_data_f(struct xml_dayf * , enum forecast type); +const int8 *get_unit( int myunit, enum datas type); +const int8 *get_lnks(struct xml_lnks *lnks, enum link type, int num); + +#endif diff --git a/sources/z-tools/trunk/zweather/history.txt b/sources/z-tools/trunk/zweather/history.txt new file mode 100644 index 0000000..8b53e54 --- /dev/null +++ b/sources/z-tools/trunk/zweather/history.txt @@ -0,0 +1,52 @@ +xxxxxxxxxxxxxxxxx +================= + +News: +----- + +- Automatic TCP/IP layer detection( MiNTNet or Sting/StiK). +- Launch time 2X faster. +- smaller memory requirement. +- Compiled with latest Windom 2.x + + +Bugs fixes: +----------- + +- Now, the keyboard's shortcut to the "preference" tab works. +- Look better under Xaaes. +- corrected a little memory leak. + + + +27 January 2010: 1.02 +===================== + +- Fixed issues with memory protection +- Updated for correct cooperation with zweather.com + + + +8 August 2005: 1.01 +=================== + +- Updated to use the news zview codecs. + + + +14 march 2005: FINAL 1.0 +======================== + +- STing compatibility layer added. +- Now, zweather works on old 8+3 partitions. +- A very bad bug was present in "icon" code.. it caused a memory leak. +- Minor bugs fixes about text alignment. +- Some code clean up. +- 'O.png' had an incorrect size. + + + +3 march 2005: BETA1 +=================== + +- First public release. diff --git a/sources/z-tools/trunk/zweather/http_client.c b/sources/z-tools/trunk/zweather/http_client.c new file mode 100644 index 0000000..78eab54 --- /dev/null +++ b/sources/z-tools/trunk/zweather/http_client.c @@ -0,0 +1,155 @@ +#include "general.h" +#include "inet.h" + +long http_recv( int32 fd, int8 **buffer) +{ + long n = 0L; /* 1 = good, 0 = conn terminated, -1 = error */ + int8 thisbuffer[1024]; + clock_t time_out = 0; + + for(;;) + { + n = inet_recv ( fd, thisbuffer, 1023L); + + if( n < 0L) + { + *buffer = NULL; + break; + } + else if( n == 0) + { + clock_t clk = clock(); + + if ( !time_out) + { + time_out = clk; + continue; + } + else if (( clk -= time_out) < 3000) + { + continue; + } + else break; + } + else + { + thisbuffer[n] = '\0'; + *buffer = strdup(( const int8 *)thisbuffer); + break; + } + } + return n; +} + + +boolean http_get_header( int32 fd, int8 **buffer) +{ + int8 lastchar = 0, *thisbuffer; + int32 l; + + while((l = http_recv( fd, &thisbuffer)) > 0) + { + boolean found = FALSE; + int8 *where = NULL, *p; + + if (lastchar == '\r' && ( p = strstr_len( thisbuffer, 3, "\n\r\n"))) + { + where = p + 3; + found = TRUE; + } + else if (( p = strstr(thisbuffer, "\r\n\r\n"))) + { + where = p + 4; + found = TRUE; + } + + if( found) + { + /*TODO check if at end*/ + *buffer = strdup(where); + } + else + lastchar = thisbuffer[l]; + + free(thisbuffer); + + if( found) + return TRUE; + } + + return FALSE; +} + + +int16 http_get_file( int8 *url, int8 *hostname, int8 *filename) +{ + int32 addr, fd = -1, error; + FILE *file = NULL; + int8 *buffer= NULL, *request = NULL; + + if( inet_host_addr ( hostname, &addr) != E_OK) + { + return FALSE; + } + + if( !( fd = inet_connect( addr, 80, 10))) + { + return FALSE; + } + + request = strdup_printf( "GET %s HTTP/1.0\r\n""HOST: %s\r\n\r\n", url, hostname); + + if( request == NULL) + { + inet_close(fd); + return FALSE; + } + + error = inet_send( fd, request, strlen(request)); + free( request); + + if ( error <= 0) + { + inet_close(fd); + return FALSE; + } + + file = fopen( filename, "w"); + + if ( !file) + { + inet_close(fd); + return FALSE; + } + + + if( http_get_header( fd, &buffer) == FALSE) + { + inet_close(fd); + fclose(file); + return FALSE; + } + + + if( buffer) + { + int l = strlen(buffer); + fwrite(buffer, sizeof(char), l, file); + free(buffer); + } + + while(( error = http_recv(fd, &buffer)) > 0) + { + int l = strlen( buffer); + fwrite( buffer, sizeof(char), l, file); + free(buffer); + } + + fclose(file); + inet_close(fd); + + if( error != -316) + return FALSE; + + return TRUE; +} diff --git a/sources/z-tools/trunk/zweather/http_client.h b/sources/z-tools/trunk/zweather/http_client.h new file mode 100644 index 0000000..6dde962 --- /dev/null +++ b/sources/z-tools/trunk/zweather/http_client.h @@ -0,0 +1 @@ +extern int16 http_get_file( int8 *url, int8 *hostname, int8 *filename); diff --git a/sources/z-tools/trunk/zweather/icon.c b/sources/z-tools/trunk/zweather/icon.c new file mode 100644 index 0000000..718e89e --- /dev/null +++ b/sources/z-tools/trunk/zweather/icon.c @@ -0,0 +1,593 @@ +#include "general.h" + +IMAGE *weather_icons = { NULL }; +MFDB *main_icon = NULL; +MFDB boussole; +IMAGE *logo = NULL; +MFDB *forecast_icon[5] = { NULL }; +MFDB icons[48]; + +int16 codec_load = 0; + +int16 register_icons( void) +{ + MFDB *bm; + uint8 *data; + uint32 icon_buffer_size = 288 * app.nplanes; + + if( !( codec_load = codecs_init( "png.ldg"))) + return 0; + + if( !( weather_icons = load_img( "icons\\weather.png", -1, -1, 1))) + return 0; + + if( !( logo = load_img( "icons\\logo.png", -1, -1, 1))) + return 0; + + bm = &icons[1]; // why 1 ??? + data = weather_icons->image->fd_addr; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[2]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[3]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[4]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[5]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[6]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[7]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[8]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[9]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[10]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = icons[8].fd_addr; + + bm = &icons[11]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = icons[6].fd_addr; + + bm = &icons[12]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[13]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[14]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[15]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = icons[5].fd_addr; + + bm = &icons[16]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = icons[5].fd_addr; + + bm = &icons[17]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = icons[3].fd_addr; + + bm = &icons[18]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = icons[12].fd_addr; + + bm = &icons[19]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[20]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[21]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = icons[19].fd_addr; + + bm = &icons[22]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[23]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = icons[1].fd_addr; + + bm = &icons[24]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = icons[1].fd_addr; + + bm = &icons[25]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[26]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[27]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[28]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[29]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[30]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[31]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[32]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[33]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[34]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[35]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = icons[3].fd_addr; + + bm = &icons[36]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = icons[25].fd_addr; + + bm = &icons[37]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = icons[3].fd_addr; + + bm = &icons[38]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = icons[3].fd_addr; + + bm = &icons[39]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = icons[12].fd_addr; + + bm = &icons[40]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = icons[12].fd_addr; + + bm = &icons[41]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = icons[5].fd_addr; + + bm = &icons[42]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = icons[5].fd_addr; + + bm = &icons[43]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[44]; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = icons[30].fd_addr; + + bm = &icons[45]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[46]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &icons[47]; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + bm = &boussole; + data += icon_buffer_size; + bm->fd_w = 48; + bm->fd_h = 48; + bm->fd_wdwidth = 3; + bm->fd_stand = 0; + bm->fd_nplanes = app.nplanes; + bm->fd_r1 = 0; + bm->fd_r2 = 0; + bm->fd_r3 = 0; + bm->fd_addr = data; + + return 1; +} + +void unregister_icons( void) +{ + if( codec_load == 0) + return; + + delete_img( logo); + delete_img( weather_icons); + codecs_quit(); +} diff --git a/sources/z-tools/trunk/zweather/icon.h b/sources/z-tools/trunk/zweather/icon.h new file mode 100644 index 0000000..0df40d9 --- /dev/null +++ b/sources/z-tools/trunk/zweather/icon.h @@ -0,0 +1,8 @@ +IMAGE *logo; +IMAGE *weather_icons; +MFDB boussole; +MFDB *forecast_icon[6]; +MFDB icons[48]; +MFDB *main_icon; +extern int16 register_icons( void); +extern void unregister_icons( void); diff --git a/sources/z-tools/trunk/zweather/icons/logo.png b/sources/z-tools/trunk/zweather/icons/logo.png new file mode 100644 index 0000000..baad92a Binary files /dev/null and b/sources/z-tools/trunk/zweather/icons/logo.png differ diff --git a/sources/z-tools/trunk/zweather/icons/weather.png b/sources/z-tools/trunk/zweather/icons/weather.png new file mode 100755 index 0000000..63998e0 Binary files /dev/null and b/sources/z-tools/trunk/zweather/icons/weather.png differ diff --git a/sources/z-tools/trunk/zweather/inet.c b/sources/z-tools/trunk/zweather/inet.c new file mode 100644 index 0000000..4ca0f0f --- /dev/null +++ b/sources/z-tools/trunk/zweather/inet.c @@ -0,0 +1,202 @@ +#include "general.h" +#include + +static boolean timeout = FALSE; +TPL *tpl = NULL; +DRV_LIST *drivers = NULL; + + +static void sig_alrm (long sig) +{ + (void)sig; + timeout = TRUE; +} + + +void init_stik (void) +{ + if ( !tpl) + { + struct { + long cktag; + long ckvalue; + } * jar = (void*)Setexc (0x5A0 /4, (void (*)())-1); + long tag = 'STiK'; + + while (jar->cktag) { + if (jar->cktag == tag) { + drivers = (DRV_LIST*)jar->ckvalue; + if (strcmp (MAGIC, drivers->magic) == 0) { + tpl = (TPL*)get_dftab(TRANSPORT_DRIVER); + } + break; + } + jar++; + } + } +} + + + +void inet_close (long fh) +{ + if( fh >= 0) + { + if ( tpl && use_sting) + TCP_close ((int16)fh, 0, NULL); + else + close (fh); + } +} + + +short inet_host_addr ( const char * name, long * addr) +{ + short ret = -1; + + if ( tpl && use_sting) + { + // zdebug( "STING"); + + if ( resolve ((char*)name, NULL, ( uint32*)addr, 1) > 0) + ret = E_OK; + } + else + { + // zdebug( "MintNet"); + + struct hostent *host = gethostbyname (name); + + if (host) + { + *addr = *(long*)host->h_addr; + ret = E_OK; + } + else + ret = -errno; + } + + return ret; +} + +long inet_connect (long addr, long port, long tout_sec) +{ + long fh = -1; + + if ( tpl && use_sting) + { + long alrm = Psignal (14/*SIGALRM*/, (long)sig_alrm); + if (alrm >= 0) { + timeout = FALSE; + Talarm (tout_sec); + } + if ((fh = TCP_open (addr, (int16)port, 0, 1024)) < 0) { + fh = -( fh == -1001L ? ETIMEDOUT : 1); + } + if (alrm >= 0) { + Talarm (0); + Psignal (14/*SIGALRM*/, alrm); + } + } + else + { + struct sockaddr_in s_in; + s_in.sin_family = AF_INET; + s_in.sin_port = htons ((short)port); + s_in.sin_addr = *(struct in_addr *)&addr; + if ((fh = socket( PF_INET, SOCK_STREAM, 0)) < 0) { + fh = -errno; + } else { + long alrm = Psignal (14/*SIGALRM*/, (long)sig_alrm); + if (alrm >= 0) { + timeout = FALSE; + Talarm (tout_sec); + } + if (connect (fh, (struct sockaddr *)&s_in, sizeof (s_in)) < 0) { + close (fh); + fh = -( timeout && errno == EINTR ? ETIMEDOUT : errno); + } + if (alrm >= 0) { + Talarm (0); + Psignal (14/*SIGALRM*/, alrm); + } + } + } + + return fh; +} + + +long inet_send( long fh, const char * buf, size_t len) +{ + long ret = -1; + + + if ( tpl && use_sting) + { + if ((ret = TCP_send ((int16)fh, (char*)buf, (int16)len)) == 0) + ret = len; + } + else + ret = Fwrite( fh, len, buf); + + return ret; +} + +long inet_recv (long fh, char *buf, size_t len) +{ + long ret = 0; + + if ( tpl && use_sting) + { + while (len) + { + short n = CNbyte_count ((int16)fh); + + if (n < E_NODATA) + { + if ( !ret) ret = (n == E_EOF || n == E_RRESET ? -316 : -1); + break; + } + else if (n > 0) + { + if (n > len) n = len; + if ((n = CNget_block ((int16)fh, buf, n)) < 0) + { + if (!ret) ret = -1; + break; + } + else + { + ret += n; + buf += n; + len -= n; + } + } else break; + + } + } + else + { + while (len) + { + long n = Finstat (fh); + if (n < 0) { + if (!ret) ret = n; + break; + } else if (n == 0x7FFFFFFF) { /* connection closed */ + if ( !ret) ret = -316; + break; + } else if (n && (n = Fread (fh, ( n < len ? n : len), buf)) < 0) { + if (!ret) ret = -errno; + break; + } else if (n) { + ret += n; + buf += n; + len -= n; + } else break; + } + } + return ret; +} + diff --git a/sources/z-tools/trunk/zweather/inet.h b/sources/z-tools/trunk/zweather/inet.h new file mode 100644 index 0000000..e8953d6 --- /dev/null +++ b/sources/z-tools/trunk/zweather/inet.h @@ -0,0 +1,6 @@ +extern void inet_close (long fh); +extern short inet_host_addr (const char * name, long * addr); +extern long inet_connect (long addr, long port, long tout_sec); +extern long inet_send( long fh, const char * buf, size_t len); +extern long inet_recv (long fh, char *buf, size_t len); + diff --git a/sources/z-tools/trunk/zweather/main.c b/sources/z-tools/trunk/zweather/main.c new file mode 100644 index 0000000..9938018 --- /dev/null +++ b/sources/z-tools/trunk/zweather/main.c @@ -0,0 +1,266 @@ +#include "general.h" +#include "http_client.h" +#include "parsers.h" +#include "icon.h" +#include "get_data.h" +#include + +static clock_t chrono_value; +struct xml_weather *zweatherdata = NULL; +int use_sting = 0; + +extern void init_stik (void); +extern void weather_dialog( void); +extern int8 wind_direction[8]; +extern int8 icon_temp[8]; + + +struct xml_weather *update_weatherdata( int8 *location) +{ + OBJECT *weather_form = get_tree( WEATHER); + xmlNode *cur_node = NULL; + xmlDoc *doc = NULL; + struct xml_weather *weather = NULL; + struct stat attrs; + int icon_to_draw; + int8 fullfilename[256], url[1024]; + + sprintf( fullfilename, "cache\\%s.xml", location); + sprintf( url, "/weather/local/%s?cc=*&dayf=%d&unit=%c", location, XML_WEATHER_DAYF_N, unit == WEATHER_METRIC ? 'm' : 's'); + strcat( url, "&link=xoap&prod=xoap&par=1160181056&key=1031965b2f676b1b" ); + + if( !http_get_file( url, "xoap.weather.com", fullfilename)) + return NULL; + + stat( fullfilename, &attrs); + + if( attrs.st_size < 1024) + { + errshow( "", BADDATA); + return NULL; + } + + if( !( doc = xmlParseFile( fullfilename))) + return NULL; + + cur_node = xmlDocGetRootElement( doc); + + if( cur_node) + { + const int8 *sTmp; + + weather = parse_weather( cur_node); + + sprintf( weather_form[WEATHER_REPORT].ob_spec.tedinfo->te_ptext, "%s", get_data(weather, DNAM)); + sprintf( weather_form[WEATHER_TIME].ob_spec.tedinfo->te_ptext, "Last update: %s", get_data(weather, LSUP)); + sprintf( weather_form[WEATHER_TEMP].ob_spec.tedinfo->te_ptext, "%s%s", get_data(weather, TEMP), get_unit(unit, TEMP)); + sprintf( weather_form[WEATHER_FEEL].ob_spec.tedinfo->te_ptext, "%s%s", get_data(weather, FLIK), get_unit(unit, FLIK)); + zstrncpy( weather_form[WEATHER_DESCRIPTION].ob_spec.tedinfo->te_ptext, get_data(weather, TRANS), 26L); + sprintf( weather_form[WEATHER_DEW].ob_spec.tedinfo->te_ptext, "%s%s", get_data(weather, DEWP), get_unit(unit, DEWP)); + sprintf( weather_form[WEATHER_WSPEED].ob_spec.tedinfo->te_ptext, "%s %s", get_data(weather, WIND_SPEED), get_unit(unit, WIND_SPEED)); + + sprintf( weather_form[WEATHER_SUNRISE].ob_spec.tedinfo->te_ptext, "%s", get_data(weather, SUNR)); + sprintf( weather_form[WEATHER_SUNSET].ob_spec.tedinfo->te_ptext, "%s", get_data(weather, SUNS)); + sprintf( weather_form[WEATHER_UV].ob_spec.tedinfo->te_ptext, "%s %s", get_data(weather, UV_INDEX), get_data(weather, UV_TRANS)); + sprintf( weather_form[WEATHER_HUMIDITY].ob_spec.tedinfo->te_ptext, "%s%s", get_data(weather, HMID), get_unit(unit, HMID)); + sprintf( weather_form[WEATHER_VISIBILITY].ob_spec.tedinfo->te_ptext, "%s", get_data(weather, VIS)); + sprintf( weather_form[WEATHER_PRESSURE].ob_spec.tedinfo->te_ptext, "%s %s and %s.", get_data(weather, BAR_R), get_unit(unit, BAR_R), get_data(weather, BAR_D)); + + sprintf( ObjcString( weather_form, WEATHER_FORECAST1, NULL), " %s ", get_data_f(weather->dayf[0], WDAY)); + // today data may be outdated afternoon + sTmp = get_data_f(weather->dayf[0], TEMP_MAX); + strcpy( weather_form[WEATHER_DAY1].ob_spec.tedinfo->te_ptext, sTmp); + if( strcmp( sTmp, "N/A") != 0) + { + strcat( weather_form[WEATHER_DAY1].ob_spec.tedinfo->te_ptext, get_unit(unit, TEMP)); + } + sTmp = get_data_f(weather->dayf[0], TEMP_MIN); + strcpy( weather_form[WEATHER_NIGHT1].ob_spec.tedinfo->te_ptext, sTmp); + if( strcmp( sTmp, "N/A") != 0) + { + strcat( weather_form[WEATHER_NIGHT1].ob_spec.tedinfo->te_ptext, get_unit(unit, TEMP)); + } + sTmp = get_data_f(weather->dayf[0], W_SPEED_D); + strcpy( weather_form[WEATHER_WIND1].ob_spec.tedinfo->te_ptext, sTmp); + if( strcmp( sTmp, "N/A") != 0) + { + strcat( weather_form[WEATHER_WIND1].ob_spec.tedinfo->te_ptext, " "); + strcat( weather_form[WEATHER_WIND1].ob_spec.tedinfo->te_ptext, get_unit(unit, WIND_SPEED)); + } + zstrncpy( weather_form[WEATHER_DESCRIPTION1].ob_spec.tedinfo->te_ptext, get_data_f(weather->dayf[0], TRANS_D), 18L); + + sprintf( ObjcString( weather_form, WEATHER_FORECAST2, NULL), " %s ", get_data_f(weather->dayf[1], WDAY)); + sprintf( weather_form[WEATHER_DAY2].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[1], TEMP_MAX), get_unit(unit, TEMP)); + sprintf( weather_form[WEATHER_NIGHT2].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[1], TEMP_MIN), get_unit(unit, TEMP)); + sprintf( weather_form[WEATHER_WIND2].ob_spec.tedinfo->te_ptext, "%s %s",get_data_f(weather->dayf[1], W_SPEED_D), get_unit(unit, WIND_SPEED)); + zstrncpy( weather_form[WEATHER_DESCRIPTION2].ob_spec.tedinfo->te_ptext, get_data_f(weather->dayf[1], TRANS_D), 18L); + + sprintf( ObjcString( weather_form, WEATHER_FORECAST3, NULL), " %s ", get_data_f(weather->dayf[2], WDAY)); + sprintf( weather_form[WEATHER_DAY3].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[2], TEMP_MAX), get_unit(unit, TEMP)); + sprintf( weather_form[WEATHER_NIGHT3].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[2], TEMP_MIN), get_unit(unit, TEMP)); + sprintf( weather_form[WEATHER_WIND3].ob_spec.tedinfo->te_ptext, "%s %s",get_data_f(weather->dayf[2], W_SPEED_D), get_unit(unit, WIND_SPEED)); + zstrncpy( weather_form[WEATHER_DESCRIPTION3].ob_spec.tedinfo->te_ptext, get_data_f(weather->dayf[2], TRANS_D), 18L); + + sprintf( ObjcString( weather_form, WEATHER_FORECAST4, NULL), " %s ", get_data_f(weather->dayf[3], WDAY)); + sprintf( weather_form[WEATHER_DAY4].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[3], TEMP_MAX), get_unit(unit, TEMP)); + sprintf( weather_form[WEATHER_NIGHT4].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[3], TEMP_MIN), get_unit(unit, TEMP)); + sprintf( weather_form[WEATHER_WIND4].ob_spec.tedinfo->te_ptext, "%s %s",get_data_f(weather->dayf[3], W_SPEED_D), get_unit(unit, WIND_SPEED)); + zstrncpy( weather_form[WEATHER_DESCRIPTION4].ob_spec.tedinfo->te_ptext, get_data_f(weather->dayf[3], TRANS_D), 18L); + + sprintf( ObjcString( weather_form, WEATHER_FORECAST5, NULL), " %s ", get_data_f(weather->dayf[4], WDAY)); + sprintf( weather_form[WEATHER_DAY5].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[4], TEMP_MAX), get_unit(unit, TEMP)); + sprintf( weather_form[WEATHER_NIGHT5].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[4], TEMP_MIN), get_unit(unit, TEMP)); + sprintf( weather_form[WEATHER_WIND5].ob_spec.tedinfo->te_ptext, "%s %s",get_data_f(weather->dayf[4], W_SPEED_D), get_unit(unit, WIND_SPEED)); + zstrncpy( weather_form[WEATHER_DESCRIPTION5].ob_spec.tedinfo->te_ptext, get_data_f(weather->dayf[4], TRANS_D), 18L); + + zstrncpy( weather_form[WEATHER_LINK1].ob_spec.tedinfo->te_ptext, get_lnks(weather->lnks, TEXT, 0), 20L); + zstrncpy( weather_form[WEATHER_LINK2].ob_spec.tedinfo->te_ptext, get_lnks(weather->lnks, TEXT, 1), 20L); + zstrncpy( weather_form[WEATHER_LINK3].ob_spec.tedinfo->te_ptext, get_lnks(weather->lnks, TEXT, 2), 20L); + zstrncpy( weather_form[WEATHER_LINK4].ob_spec.tedinfo->te_ptext, get_lnks(weather->lnks, TEXT, 3), 20L); + + icon_to_draw = atoi( ( const char*)get_data(weather, WICON)); + main_icon = &icons[icon_to_draw]; + + icon_to_draw = atoi( ( const char*)get_data_f(weather->dayf[0], ICON_D)); + forecast_icon[0] = &icons[icon_to_draw]; + + icon_to_draw = atoi( ( const char*)get_data_f(weather->dayf[1], ICON_D)); + forecast_icon[1] = &icons[icon_to_draw]; + + icon_to_draw = atoi( ( const char*)get_data_f(weather->dayf[2], ICON_D)); + forecast_icon[2] = &icons[icon_to_draw]; + + icon_to_draw = atoi( ( const char*)get_data_f(weather->dayf[3], ICON_D)); + forecast_icon[3] = &icons[icon_to_draw]; + + icon_to_draw = atoi( ( const char*)get_data_f(weather->dayf[4], ICON_D)); + forecast_icon[4] = &icons[icon_to_draw]; + + sprintf( icon_temp, "%sø", get_data( weather, TEMP)); + sprintf( wind_direction, "%s", get_data( weather, WIND_DIRECTION)); + } + + xmlFreeDoc( doc); + + return weather; +} + +void timer_function( WINDOW *win, short buff[8]) +{ + #ifdef DEBUG + char tmp[15]; + struct tm *tmt; + time_t tim; + #endif + + clock_t current_t = clock(); + clock_t relative_t; + + relative_t = current_t - chrono_value; + + if( relative_t < update_time) + return; + + chrono_value = current_t; + + #ifdef DEBUG + tim = time( NULL); + tmt = localtime( &tim); + strftime( tmp, 12, "%H:%M:%S", tmt); + zdebug( "update: %s", tmp); + #endif + + if( zweatherdata) + xml_weather_free( zweatherdata); + + zweatherdata = update_weatherdata( location_code); + + if( windialog) + snd_rdw( windialog); +} + +void applexit( WINDOW *w, short buff[8]) +{ + WINDOW *last_closed = NULL; + + if( EvntFind( NULL, WM_XTIMER)) + EvntDelete( NULL, WM_XTIMER); + + while( wglb.first) + { + if (last_closed != wglb.first) + { + ApplWrite( _AESapid, WM_DESTROY, wglb.first->handle, 0, 0, 0, 0); + last_closed = wglb.first; /* to prevent sending toons of WM_CLOSED messages to each window */ + } + + if( EvntWindom( MU_MESAG | MU_TIMER) & MU_TIMER) /* MU_TIMER event catched ? */ + last_closed = NULL; /* then WM_CLOSED message has been lost ! it should be resent */ + } + + if( zweatherdata) + xml_weather_free( zweatherdata); + + xmlCleanupParser(); + + prefs_write(); + unregister_icons(); + + RsrcXtype( 0, NULL, 0); + RsrcFree(); + ApplExit(); + exit( 0); +} + + +int main( int argc, char *argv[]) +{ + int32 sting = 0; + + ApplInit(); + + if( !RsrcLoad( "zweather.rsc")) + { + errshow( "", E_RSC); + ApplExit(); + return 0; + } + + RsrcXtype( RSRC_XTYPE, NULL, 0); + + if( !register_icons()) + { + errshow( "", NOZCODECS); + unregister_icons(); + RsrcXtype( 0, NULL, 0); + RsrcFree(); + ApplExit(); + return 0; + } + + if( _AESnumapps == -1) + menu_register( _AESapid, "zWeather"); + + prefs_read(); + + if( Getcookie( C_STiK, ( long*)&sting) != 0) + { + use_sting = 1; + init_stik(); + } + + zweatherdata = update_weatherdata( location_code); + + evnt.timer = 1000L; + + weather_dialog(); + + chrono_value = clock(); + EvntAttach( NULL, WM_XTIMER, timer_function); + EvntAttach( NULL, AP_TERM, applexit); + + for(;;) + EvntWindom( MU_MESAG|MU_TIMER|MU_KEYBD|MU_BUTTON); + + return 0; +} diff --git a/sources/z-tools/trunk/zweather/parsers.c b/sources/z-tools/trunk/zweather/parsers.c new file mode 100644 index 0000000..903755f --- /dev/null +++ b/sources/z-tools/trunk/zweather/parsers.c @@ -0,0 +1,391 @@ +#include "general.h" +#include "parsers.h" + +struct xml_weather *parse_weather( xmlNode *cur_node) +{ + struct xml_weather *ret; + + if( !NODE_IS_TYPE(cur_node, "weather")) + return NULL; + + if(( ret = malloc( sizeof( struct xml_weather))) == NULL) + return NULL; + + for( cur_node = cur_node->children; cur_node; cur_node = cur_node->next) + { + if(cur_node->type != XML_ELEMENT_NODE) + continue; + + if( NODE_IS_TYPE( cur_node, "cc")) + ret->cc = parse_cc(cur_node); + else if( NODE_IS_TYPE(cur_node, "loc")) + ret->loc = parse_loc(cur_node); + else if( NODE_IS_TYPE(cur_node, "lnks")) + ret->lnks = parse_lnks(cur_node); + else if( NODE_IS_TYPE(cur_node, "dayf")) + { + xmlNode *child_node; + int i = 0; + + for( child_node = cur_node->children; child_node; child_node = child_node->next) + { + if( NODE_IS_TYPE(child_node, "day")) + { + if( i >= XML_WEATHER_DAYF_N) + break; + + ret->dayf[i] = parse_dayf( child_node); + i++; + } + } + } + } + + return ret; +} + +struct xml_loc *parse_loc(xmlNode *cur_node) +{ + struct xml_loc *ret; + + if(( ret = malloc( sizeof( struct xml_loc))) == NULL) + return NULL; + + for( cur_node = cur_node->children; cur_node; cur_node = cur_node->next) + { + if( cur_node->type != XML_ELEMENT_NODE) + continue; + + if( NODE_IS_TYPE(cur_node, "dnam")) + ret->dnam = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "sunr")) + ret->sunr = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "suns")) + ret->suns = DATA(cur_node); + } + + return ret; +} + +struct xml_lnks *parse_lnks(xmlNode *cur_node) +{ + struct xml_lnks *ret; + int i = 0; + + if ((ret = malloc( sizeof(struct xml_lnks))) == NULL) + return NULL; + + for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next) + { + if (cur_node->type != XML_ELEMENT_NODE) + continue; + + if (NODE_IS_TYPE(cur_node, "link")) + { + xmlNode *child_node; + + if( i >= XML_WEATHER_LINK_N) + break; + + for( child_node = cur_node->children; child_node; child_node = child_node->next) + { + if (NODE_IS_TYPE(child_node, "l")) + { + ret->l[i] = DATA(child_node); + } + else if (NODE_IS_TYPE(child_node, "t")) + { + ret->t[i] = DATA(child_node); + } + } + + i++; + } + } + + return ret; +} + +struct xml_uv *parse_uv (xmlNode *cur_node) +{ + struct xml_uv *ret; + + if(( ret = malloc( sizeof( struct xml_uv))) == NULL) + return NULL; + + for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next) + { + if (cur_node->type != XML_ELEMENT_NODE) + continue; + + if (NODE_IS_TYPE(cur_node, "i")) + ret->i = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "t")) + ret->t = DATA(cur_node); + } + return ret; +} + +struct xml_bar *parse_bar (xmlNode *cur_node) +{ + struct xml_bar *ret; + + if ((ret = malloc(sizeof( struct xml_bar))) == NULL) + return NULL; + + for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next) + { + if (cur_node->type != XML_ELEMENT_NODE) + continue; + + if (NODE_IS_TYPE(cur_node, "r")) + ret->r = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "d")) + ret->d = DATA(cur_node); + } + return ret; +} + +struct xml_wind *parse_wind (xmlNode *cur_node) +{ + struct xml_wind *ret; + + if ((ret = malloc(sizeof( struct xml_wind))) == NULL) + return NULL; + + for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next) + { + if (cur_node->type != XML_ELEMENT_NODE) + continue; + + if (NODE_IS_TYPE(cur_node, "s")) + ret->s = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "gust")) + ret->gust = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "d")) + ret->d = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "t")) + ret->t = DATA(cur_node); + } + return ret; +} + +struct xml_cc *parse_cc(xmlNode *cur_node) +{ + struct xml_cc *ret; + + if ((ret = malloc( sizeof(struct xml_cc))) == NULL) + return NULL; + + for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next) + { + if (cur_node->type != XML_ELEMENT_NODE) + continue; + + if (NODE_IS_TYPE(cur_node, "tmp")) + ret->tmp = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "icon")) + ret->icon = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "t")) + ret->t = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "flik")) + ret->flik = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "bar")) + ret->bar = parse_bar(cur_node); + else if (NODE_IS_TYPE(cur_node, "wind")) + ret->wind = parse_wind(cur_node); + else if (NODE_IS_TYPE(cur_node, "hmid")) + ret->hmid = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "vis")) + ret->vis = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "uv")) + ret->uv = parse_uv(cur_node); + else if (NODE_IS_TYPE(cur_node, "dewp")) + ret->dewp = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "lsup")) + ret->lsup = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "obst")) + ret->obst = DATA(cur_node); + } + return ret; +} + +struct xml_part *parse_part(xmlNode *cur_node) +{ + struct xml_part *ret; + + if (( ret = malloc( sizeof( struct xml_part))) == NULL) + return NULL; + + for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next) + { + if (cur_node->type != XML_ELEMENT_NODE) + continue; + + if (NODE_IS_TYPE(cur_node, "icon")) + ret->icon = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "t")) + ret->t = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "wind")) + ret->wind = parse_wind(cur_node); + else if (NODE_IS_TYPE(cur_node, "ppcp")) + ret->ppcp = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "hmid")) + ret->hmid = DATA(cur_node); + } + + return ret; +} + + + +struct xml_dayf *parse_dayf(xmlNode *cur_node) +{ + struct xml_dayf *ret; + int8 *value; + + if ((ret = malloc(sizeof(struct xml_dayf))) == NULL) + return NULL; + + ret->day = xmlGetProp (cur_node, (const xmlChar *) "t"); + ret->date = xmlGetProp (cur_node, (const xmlChar *) "dt"); + + for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next) + { + if (cur_node->type != XML_ELEMENT_NODE) + continue; + + if (NODE_IS_TYPE(cur_node, "hi")) + ret->hi = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "low")) + ret->low = DATA(cur_node); + else if (NODE_IS_TYPE(cur_node, "part")) + { + value = xmlGetProp (cur_node, (const xmlChar *) "p"); + + if (xmlStrEqual ((const xmlChar *)value, "d")) + ret->part[0] = parse_part(cur_node); + else if (xmlStrEqual ((const xmlChar *)value, "n")) + ret->part[1] = parse_part(cur_node); + + free(value); + } + } + return ret; +} + +#define CHK_FREE(this) if (this) free(this); + +void xml_uv_free(struct xml_uv *data) +{ + CHK_FREE(data->i); + CHK_FREE(data->t); +} + +void xml_wind_free(struct xml_wind *data) +{ + CHK_FREE(data->s); + CHK_FREE(data->gust); + CHK_FREE(data->d); + CHK_FREE(data->t); +} + +void xml_bar_free(struct xml_bar *data) +{ + CHK_FREE(data->r); + CHK_FREE(data->d); +} + +void xml_cc_free(struct xml_cc *data) +{ + CHK_FREE(data->obst); + CHK_FREE(data->lsup); + CHK_FREE(data->flik); + CHK_FREE(data->t); + CHK_FREE(data->icon); + CHK_FREE(data->tmp); + CHK_FREE(data->hmid); + CHK_FREE(data->vis); + CHK_FREE(data->dewp); + + if (data->uv) + xml_uv_free(data->uv); + + if (data->wind) + xml_wind_free(data->wind); + + if (data->bar) + xml_bar_free(data->bar); +} + +void xml_loc_free(struct xml_loc *data) +{ + CHK_FREE(data->dnam); + CHK_FREE(data->sunr); + CHK_FREE(data->suns); +} + +void xml_part_free(struct xml_part *data) +{ + if( !data) + return; + + CHK_FREE(data->icon); + CHK_FREE(data->t); + CHK_FREE(data->ppcp); + CHK_FREE(data->hmid); + + if (data->wind) + xml_wind_free(data->wind); +} + +void xml_dayf_free(struct xml_dayf *data) +{ + if (!data) + return; + + CHK_FREE(data->day); + CHK_FREE(data->date); + CHK_FREE(data->hi); + CHK_FREE(data->low); + + if (data->part[0]) + xml_part_free(data->part[0]); + + if (data->part[1]) + xml_part_free(data->part[1]); +} + +void xml_weather_free(struct xml_weather *data) +{ + if (data->cc) + xml_cc_free( data->cc); + + if (data->loc) + xml_loc_free( data->loc); + + if( data->lnks) + { + int i; + for (i = 0; i < XML_WEATHER_LINK_N; i++) + { + CHK_FREE(data->lnks->l[i]); + CHK_FREE(data->lnks->t[i]); + } + + } + + if (data->dayf) + { + int i; + for (i = 0; i < XML_WEATHER_DAYF_N; i++) + { + if (!data->dayf[i]) + break; + + xml_dayf_free(data->dayf[i]); + } + } + + free(data); +} diff --git a/sources/z-tools/trunk/zweather/parsers.h b/sources/z-tools/trunk/zweather/parsers.h new file mode 100644 index 0000000..0d50688 --- /dev/null +++ b/sources/z-tools/trunk/zweather/parsers.h @@ -0,0 +1,99 @@ +#ifndef PARSERS_H +#define PARSERS_H + +#define DATA(node) xmlNodeListGetString(node->doc, node->children, 1) +#define NODE_IS_TYPE(node, type) xmlStrEqual (node->name, (const xmlChar *) type) + + +#define XML_WEATHER_DAYF_N 5 +#define XML_WEATHER_LINK_N 4 + +struct xml_weather +{ + struct xml_loc *loc; + struct xml_lnks *lnks; + struct xml_cc *cc; + struct xml_dayf *dayf[XML_WEATHER_DAYF_N]; +}; + +struct xml_loc +{ + int8 *dnam; + int8 *sunr; + int8 *suns; +}; + +struct xml_lnks +{ + int8 *l[XML_WEATHER_LINK_N]; + int8 *t[XML_WEATHER_LINK_N]; +}; + +struct xml_uv +{ + int8 *i; + int8 *t; +}; + +struct xml_wind +{ + int8 *s; + int8 *gust; + int8 *d; + int8 *t; +}; + +struct xml_bar +{ + int8 *r; + int8 *d; +}; + +struct xml_cc +{ + int8 *lsup; + int8 *obst; + int8 *flik; + int8 *t; + int8 *icon; + int8 *tmp; + + int8 *hmid; + int8 *vis; + + struct xml_uv *uv; + struct xml_wind *wind; + struct xml_bar *bar; + + int8 *dewp; +}; + +struct xml_part +{ + int8 *icon; + int8 *t; + int8 *ppcp; + int8 *hmid; + + struct xml_wind *wind; +}; + +struct xml_dayf +{ + int8 *day; + int8 *date; + + int8 *hi; + int8 *low; + + struct xml_part *part[2]; +}; + +struct xml_weather *parse_weather(xmlNode *cur_node); +struct xml_loc *parse_loc(xmlNode *cur_node); +struct xml_lnks *parse_lnks(xmlNode *cur_node); +struct xml_cc *parse_cc(xmlNode *cur_node); +struct xml_dayf *parse_dayf(xmlNode *cur_node); + +void xml_weather_free(struct xml_weather *); +#endif diff --git a/sources/z-tools/trunk/zweather/prefs.c b/sources/z-tools/trunk/zweather/prefs.c new file mode 100644 index 0000000..235167d --- /dev/null +++ b/sources/z-tools/trunk/zweather/prefs.c @@ -0,0 +1,160 @@ +#include "general.h" + +int unit = WEATHER_METRIC; +int iconify_at_start = 1; +char location_code[9] = "BEXX0006"; +clock_t update_time = 360000L; + +/* Prototype */ +int prefs_read( void); +int prefs_write( void); + + +/*==================================================================================* + * prefs_read: * + * Reads the content of the INF file an put it in the preference global variables. * + *----------------------------------------------------------------------------------* + * returns: 0 if error * + *==================================================================================*/ +int prefs_read( void) +{ + char filename[256] = ""; + char unknown_s[256] = ""; + FILE *inffile; + int time_minute; + int32 filepos; + char *env_home; + int16 len; + boolean valid_entry_found; + + + shel_envrn( &env_home, "HOME="); + + /* Home directory exist? */ + if ( env_home != NULL) + { + strcpy( filename, env_home); + len = ( int16)strlen( filename); + + if ((filename[len - 1] != '\\') && (filename[len - 1] != '/')) + { + strcat( filename, "\\"); + } + + strcat( filename, "zweather.inf"); + + if (( inffile = fopen( filename, "rb+")) != NULL) + goto loop; + + } + + /* With ftell, we MUST open the file in binary mode and not in text mode !!! */ + if (( inffile = fopen( "zweather.inf", "rb+")) == NULL) + return( 0); + +loop: + + do + { + valid_entry_found = FALSE; + + filepos = ftell( inffile); + + if ( fscanf( inffile, "unit=%d ", &unit) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if (fscanf( inffile, "iconify_at_start=%d ", &iconify_at_start) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "update_time=%d ", &time_minute) == 1) + { + update_time = ( clock_t)( ( int32)time_minute * 12000L); + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "location_code=%s ", location_code) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + if ( fscanf( inffile, "%s ", unknown_s) == 1) + { + valid_entry_found = TRUE; + continue; + } + else + fseek( inffile, filepos, SEEK_SET); + + + } while ( valid_entry_found); + + fclose( inffile); + + return( 1); +} + + + +/*==================================================================================* + * prefs_write: * + * Writes the preference variables in the preference file. * + *----------------------------------------------------------------------------------* + * returns: 0 if error * + *==================================================================================*/ +int prefs_write( void) +{ + char filename[256] = ""; + FILE *inffile; + char *env_home; + int time_minute; + int16 len; + + shel_envrn( &env_home, "HOME="); + + /* Home directory exist? */ + if ( env_home) + { + strcpy( filename, env_home); + + len = ( int16)strlen( filename); + + if ((filename[len - 1] != '\\') && (filename[len - 1] != '/')) + strcat( filename, "\\"); + + strcat( filename, "zweather.inf"); + } + else + strcpy( filename, "zweather.inf"); + + + /* With ftell, we MUST open the file in binary mode and not in text mode !!! */ + if (( inffile = fopen( filename, "wb+")) == NULL) + return( 0); + + + time_minute = ( int)( update_time / 12000L); + + fprintf( inffile, "unit=%d\r\n", unit); + fprintf( inffile, "iconify_at_start=%d\r\n", iconify_at_start); + fprintf( inffile, "update_time=%d\r\n", time_minute); + fprintf( inffile, "location_code=%s\r\n", location_code); + fclose( inffile); + + return( 1); +} diff --git a/sources/z-tools/trunk/zweather/prefs.h b/sources/z-tools/trunk/zweather/prefs.h new file mode 100644 index 0000000..be646b7 --- /dev/null +++ b/sources/z-tools/trunk/zweather/prefs.h @@ -0,0 +1,11 @@ +/* Global variable */ +extern int unit; +extern int iconify_at_start; +extern char location_code[9]; +extern clock_t update_time; + +/* Function */ +extern int prefs_read( void); +extern int prefs_write( void); + + diff --git a/sources/z-tools/trunk/zweather/zaes.c b/sources/z-tools/trunk/zweather/zaes.c new file mode 100644 index 0000000..059d73f --- /dev/null +++ b/sources/z-tools/trunk/zweather/zaes.c @@ -0,0 +1,286 @@ +#include "general.h" +#include "icon.h" +#include "get_data.h" + +/* the variable need to be global because this function is done by */ +/* the AES in supervisor mode.. it's safe. */ +static int16 xy[8]; +static MFDB screen = {0}; +int8 wind_direction[8] = ""; +extern struct xml_weather *zweatherdata; + +OBJECT *get_tree( int16 obj_index) +{ + OBJECT *tree; + RsrcGaddr( NULL, 0, obj_index, &tree); + return tree; +} + + +/* Return a string from resource file */ + +int8 *get_string( int16 str_index) +{ + int8 *txt; + rsrc_gaddr( 5, str_index, &txt); + return txt; +} + +void CDECL draw_boussole_icon( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = xy[1] = 0; + xy[2] = 47; + xy[3] = 47; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 47; + xy[7] = xy[5] + 47; + + vro_cpyfm( win->graf->handle, S_ONLY, xy, &boussole, &screen); + + xy[2] = pblk->pb_x + 23; + xy[3] = pblk->pb_y + 23; + + switch( wind_direction[0]) + { + case 'N': + if( strcmp( wind_direction, "NNE") == 0) + { + xy[0] = pblk->pb_x + 27; + xy[1] = pblk->pb_y + 9; + break; + } + + if( strcmp( wind_direction, "NNW") == 0) + { + xy[0] = pblk->pb_x + 18; + xy[1] = pblk->pb_y + 9; + break; + } + + if( strcmp( wind_direction, "NW") == 0) + { + xy[0] = pblk->pb_x + 12; + xy[1] = pblk->pb_y + 12; + break; + } + + if( strcmp( wind_direction, "NE") == 0) + { + xy[0] = pblk->pb_x + 34; + xy[1] = pblk->pb_y + 12; + break; + } + + /* default 'N'*/ + xy[0] = pblk->pb_x + 23; + xy[1] = pblk->pb_y + 8; + break; + + case 'E': + if( strcmp( wind_direction, "ENE") == 0) + { + xy[0] = pblk->pb_x + 36; + xy[1] = pblk->pb_y + 17; + break; + } + + if( strcmp( wind_direction, "ESE") == 0) + { + xy[0] = pblk->pb_x + 36; + xy[1] = pblk->pb_y + 28; + break; + } + + /* default 'E'*/ + xy[0] = pblk->pb_x + 38; + xy[1] = pblk->pb_y + 23; + break; + + case 'W': + if( strcmp( wind_direction, "WSW") == 0) + { + xy[0] = pblk->pb_x + 9; + xy[1] = pblk->pb_y + 28; + break; + } + + if( strcmp( wind_direction, "WNW") == 0) + { + xy[0] = pblk->pb_x + 9; + xy[1] = pblk->pb_y + 17; + break; + } + + /* default 'W'*/ + xy[0] = pblk->pb_x + 8; + xy[1] = pblk->pb_y + 23; + break; + + case 'S': + if( strcmp( wind_direction, "SSE") == 0) + { + xy[0] = pblk->pb_x + 28; + xy[1] = pblk->pb_y + 36; + break; + } + + if( strcmp( wind_direction, "SSW") == 0) + { + xy[0] = pblk->pb_x + 18; + xy[1] = pblk->pb_y + 36; + break; + } + + if( strcmp( wind_direction, "SW") == 0) + { + xy[0] = pblk->pb_x + 12; + xy[1] = pblk->pb_y + 33; + break; + } + + if( strcmp( wind_direction, "SE") == 0) + { + xy[0] = pblk->pb_x + 34; + xy[1] = pblk->pb_y + 33;; + break; + } + + default: + + /* default 'S'*/ + xy[0] = pblk->pb_x + 23; + xy[1] = pblk->pb_y + 38; + break; + } + + v_pline( win->graf->handle, 2, xy); +} + +void CDECL draw_weather_icon( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = xy[1] = 0; + xy[2] = 47; + xy[3] = 47; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 47; + xy[7] = xy[5] + 47; + + vro_cpyfm( win->graf->handle, S_ONLY, xy, main_icon, &screen); +} + +void CDECL draw_forecast1_icon( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = xy[1] = 0; + xy[2] = 47; + xy[3] = 47; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 47; + xy[7] = xy[5] + 47; + + vro_cpyfm( win->graf->handle, S_ONLY, xy, forecast_icon[0], &screen); +} + + +void CDECL draw_forecast2_icon( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = xy[1] = 0; + xy[2] = 47; + xy[3] = 47; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 47; + xy[7] = xy[5] + 47; + + vro_cpyfm( win->graf->handle, S_ONLY, xy, forecast_icon[1], &screen); +} + +void CDECL draw_forecast3_icon( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = xy[1] = 0; + xy[2] = 47; + xy[3] = 47; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 47; + xy[7] = xy[5] + 47; + + vro_cpyfm( win->graf->handle, S_ONLY, xy, forecast_icon[2], &screen); +} + +void CDECL draw_forecast4_icon( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = xy[1] = 0; + xy[2] = 47; + xy[3] = 47; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 47; + xy[7] = xy[5] + 47; + + vro_cpyfm( win->graf->handle, S_ONLY, xy, forecast_icon[3], &screen); +} + +void CDECL draw_forecast5_icon( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = xy[1] = 0; + xy[2] = 47; + xy[3] = 47; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 47; + xy[7] = xy[5] + 47; + + vro_cpyfm( win->graf->handle, S_ONLY, xy, forecast_icon[4], &screen); +} + +void CDECL draw_forecast6_icon( WINDOW *win, PARMBLK *pblk, void *data) +{ + xy[0] = xy[1] = 0; + xy[2] = 60; + xy[3] = 60; + xy[4] = pblk->pb_x; + xy[5] = pblk->pb_y; + xy[6] = xy[4] + 60; + xy[7] = xy[5] + 60; + + vro_cpyfm( win->graf->handle, S_ONLY, xy, &logo->image[0], &screen); +} + + + +void errshow( const char *name, int16 error) +{ + switch( error) + { + case ALERT_WINDOW: + ( void)FormAlert( 1 , get_string( ALERT_WINDOW)); + break; + case ENOMEM: + ( void)FormAlert( 1 , get_string( NOMEM)); + break; + case E_RSC: + ( void)FormAlert( 1 , "[1][zweather.rsc not found!][Abort]"); + break; + case CANT_LOAD_IMG: + ( void)FormAlert( 1 , get_string( CANT_LOAD_IMG), name); + break; + case NOZCODECS: + ( void)FormAlert( 1 , get_string( NOZCODECS)); + break; + case BADDATA: + ( void)FormAlert( 1 , get_string( BADDATA)); + break; + default: + ( void)FormAlert( 1 , get_string( GENERIC)); + break; + } +} + + + + + + diff --git a/sources/z-tools/trunk/zweather/zaes.h b/sources/z-tools/trunk/zweather/zaes.h new file mode 100644 index 0000000..0de9c12 --- /dev/null +++ b/sources/z-tools/trunk/zweather/zaes.h @@ -0,0 +1,13 @@ +extern OBJECT *get_tree( int16 obj_index); +extern int8 *get_string( int16 str_index); +extern void errshow( const char *name, int16 error); +extern void generic_form_event( WINDOW *win); + +extern void CDECL draw_weather_icon( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_forecast1_icon( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_forecast2_icon( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_forecast3_icon( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_forecast4_icon( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_forecast5_icon( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_forecast6_icon( WINDOW *win, PARMBLK *pblk, void *data); +extern void CDECL draw_boussole_icon( WINDOW *win, PARMBLK *pblk, void *data); diff --git a/sources/z-tools/trunk/zweather/zstring.c b/sources/z-tools/trunk/zweather/zstring.c new file mode 100644 index 0000000..67445d6 --- /dev/null +++ b/sources/z-tools/trunk/zweather/zstring.c @@ -0,0 +1,131 @@ +#include "general.h" + +extern int vasprintf( int8 **strp, const int8 *fmt, va_list ap); + + +char *zstrncpy( char *dst, const char *src, size_t n) +{ + register const char *source = src; + register char *dest = dst; + register size_t count = n; + + if( dest && !source && count) + *dest = '\0'; + else if( dest && source && (count >= 1)) + { + for( count--; count > 0 && *source != '\0'; count--) + *dest++ = *source++; + *dest = '\0'; + } + return dst; +} + +int8 *stpcpy( int8 *dest, const int8 *src) +{ + register int8 *d = dest; + register const int8 *s = src; + + if( dest == NULL || src == NULL) + return NULL; + + do + *d++ = *s; + while (*s++ != '\0'); + + return d - 1; +} + +int8 *strstr_len( const int8 *haystack, int32 haystack_len, const int8 *needle) +{ + if( haystack == NULL || needle == NULL) + return NULL; + + if (haystack_len < 0) + return strstr (haystack, needle); + else + { + const int8 *end, *p = haystack; + int32 i, needle_len = strlen ( needle); + + if (needle_len == 0) + return (int8 *)haystack; + + if (haystack_len < needle_len) + return NULL; + + end = haystack + haystack_len - needle_len; + + while (*p && p <= end) + { + for (i = 0; i < needle_len; i++) + + if (p[i] != needle[i]) + goto next; + + return (int8 *)p; + + next: + p++; + } + + return NULL; + } +} + + +int8 *strdup_printf( const int8 *format, ...) +{ + int8 *buffer; + int len; + va_list args; + + va_start( args, format); + + len = vasprintf( &buffer, format, args); + + if( len < 0) + buffer = NULL; + + va_end( args); + + return buffer; +} + + +int8* strconcat( const int8 *string1, ...) +{ + int32 l; + int8 *s, *concat, *ptr; + va_list args; + + if( !string1) + return NULL; + + l = 1 + strlen( string1); + va_start( args, string1); + s = va_arg( args, int8*); + + while( s) + { + l += strlen (s); + s = va_arg ( args, int8*); + } + va_end (args); + + concat = malloc( sizeof( int8) * l); + ptr = concat; + + ptr = stpcpy ( ptr, string1); + va_start (args, string1); + s = va_arg (args, int8*); + + while (s) + { + ptr = stpcpy( ptr, s); + s = va_arg (args, int8*); + } + va_end (args); + + return concat; +} + diff --git a/sources/z-tools/trunk/zweather/zstring.h b/sources/z-tools/trunk/zweather/zstring.h new file mode 100644 index 0000000..4535f57 --- /dev/null +++ b/sources/z-tools/trunk/zweather/zstring.h @@ -0,0 +1,6 @@ +extern int8 *stpcpy( int8 *dest, const int8 *src); +extern int8 *strstr_len( const int8 *haystack, int32 haystack_len, const int8 *needle); +extern int8 *strdup_printf( const int8 *format, ...); +extern int8 *strconcat( const int8 *string1, ...); +extern char *zstrncpy( char *dst, const char *src, size_t n); + diff --git a/sources/z-tools/trunk/zweather/zweather.hrd b/sources/z-tools/trunk/zweather/zweather.hrd new file mode 100644 index 0000000..d46ee44 Binary files /dev/null and b/sources/z-tools/trunk/zweather/zweather.hrd differ diff --git a/sources/z-tools/trunk/zweather/zweather.rsc b/sources/z-tools/trunk/zweather/zweather.rsc new file mode 100644 index 0000000..c449a5d Binary files /dev/null and b/sources/z-tools/trunk/zweather/zweather.rsc differ diff --git a/sources/z-tools/trunk/zweather/zweather.rsh b/sources/z-tools/trunk/zweather/zweather.rsh new file mode 100644 index 0000000..ca1844a --- /dev/null +++ b/sources/z-tools/trunk/zweather/zweather.rsh @@ -0,0 +1,93 @@ + /* Resource C-Header-file v1.95 for ResourceMaster v2.06&up by ARDISOFT */ + +#define WEATHER 0 /* form/dial */ +#define WEATHER_PANEL4 1 /* BUTTON in tree WEATHER */ +#define WEATHER_CODE 2 /* FBOXTEXT in tree WEATHER */ +#define WEATHER_UPDATE_TIME 10 /* FBOXTEXT in tree WEATHER */ +#define WEATHER_METRIC 13 /* BUTTON in tree WEATHER */ +#define WEATHER_IMPERIAL 14 /* BUTTON in tree WEATHER */ +#define WEATHER_DATE 16 /* TEXT in tree WEATHER */ +#define WEATHER_UPDATE 107 /* BUTTON in tree WEATHER */ +#define WEATHER_PANEL2 22 /* BUTTON in tree WEATHER */ +#define WEATHER_FORECAST1 23 /* BUTTON in tree WEATHER */ +#define WEATHER_DESCRIPTION1 24 /* TEXT in tree WEATHER */ +#define WEATHER_DAY1 25 /* TEXT in tree WEATHER */ +#define WEATHER_ICON1 26 /* BOX in tree WEATHER */ +#define WEATHER_NIGHT1 29 /* TEXT in tree WEATHER */ +#define WEATHER_WIND1 31 /* TEXT in tree WEATHER */ +#define WEATHER_FORECAST3 32 /* BUTTON in tree WEATHER */ +#define WEATHER_DESCRIPTION3 33 /* TEXT in tree WEATHER */ +#define WEATHER_DAY3 34 /* TEXT in tree WEATHER */ +#define WEATHER_ICON3 35 /* BOX in tree WEATHER */ +#define WEATHER_NIGHT3 38 /* TEXT in tree WEATHER */ +#define WEATHER_WIND3 40 /* TEXT in tree WEATHER */ +#define WEATHER_FORECAST5 41 /* BUTTON in tree WEATHER */ +#define WEATHER_DESCRIPTION5 42 /* TEXT in tree WEATHER */ +#define WEATHER_DAY5 43 /* TEXT in tree WEATHER */ +#define WEATHER_ICON5 44 /* BOX in tree WEATHER */ +#define WEATHER_NIGHT5 47 /* TEXT in tree WEATHER */ +#define WEATHER_WIND5 49 /* TEXT in tree WEATHER */ +#define WEATHER_FORECAST2 50 /* BUTTON in tree WEATHER */ +#define WEATHER_DESCRIPTION2 51 /* TEXT in tree WEATHER */ +#define WEATHER_DAY2 52 /* TEXT in tree WEATHER */ +#define WEATHER_ICON2 53 /* BOX in tree WEATHER */ +#define WEATHER_NIGHT2 56 /* TEXT in tree WEATHER */ +#define WEATHER_WIND2 58 /* TEXT in tree WEATHER */ +#define WEATHER_FORECAST4 59 /* BUTTON in tree WEATHER */ +#define WEATHER_DESCRIPTION4 60 /* TEXT in tree WEATHER */ +#define WEATHER_DAY4 61 /* TEXT in tree WEATHER */ +#define WEATHER_ICON4 62 /* BOX in tree WEATHER */ +#define WEATHER_NIGHT4 65 /* TEXT in tree WEATHER */ +#define WEATHER_WIND4 67 /* TEXT in tree WEATHER */ +#define WEATHER_ICON6 68 /* BOX in tree WEATHER */ +#define WEATHER_LINK1 69 /* TEXT in tree WEATHER */ +#define WEATHER_LINK2 70 /* TEXT in tree WEATHER */ +#define WEATHER_LINK3 71 /* TEXT in tree WEATHER */ +#define WEATHER_LINK4 72 /* TEXT in tree WEATHER */ +#define WEATHER_FORECAST 73 /* BUTTON in tree WEATHER */ +#define WEATHER_PREF 74 /* BUTTON in tree WEATHER */ +#define WEATHER_QUIT 75 /* BUTTON in tree WEATHER */ +#define WEATHER_PANEL1 76 /* BUTTON in tree WEATHER */ +#define WEATHER_DESCRIPTION 78 /* TEXT in tree WEATHER */ +#define WEATHER_TEMP 80 /* TEXT in tree WEATHER */ +#define WEATHER_FEEL 82 /* TEXT in tree WEATHER */ +#define WEATHER_DEW 84 /* TEXT in tree WEATHER */ +#define WEATHER_ICON 85 /* BOX in tree WEATHER */ +#define WEATHER_SUNSET 88 /* TEXT in tree WEATHER */ +#define WEATHER_SUNRISE 90 /* TEXT in tree WEATHER */ +#define WEATHER_UV 92 /* TEXT in tree WEATHER */ +#define WEATHER_PRESSURE 95 /* TEXT in tree WEATHER */ +#define WEATHER_WSPEED 97 /* TEXT in tree WEATHER */ +#define WEATHER_WICON 98 /* BOX in tree WEATHER */ +#define WEATHER_HUMIDITY 101 /* TEXT in tree WEATHER */ +#define WEATHER_VISIBILITY 103 /* TEXT in tree WEATHER */ +#define WEATHER_TIME 104 /* TEXT in tree WEATHER */ +#define WEATHER_REPORT 105 /* TEXT in tree WEATHER */ +#define WEATHER_MAIN 106 /* BUTTON in tree WEATHER */ +#define WEATHER_MAP 108 /* BUTTON in tree WEATHER */ +#define WEATHER_PANEL3 109 /* BUTTON in tree WEATHER */ +#define WEATHER_MAP_BOX 111 /* BOX in tree WEATHER */ +#define WEATHER_CONTINENT 112 /* BUTTON in tree WEATHER */ +#define WEATHER_STATE 113 /* BUTTON in tree WEATHER */ + +#define CONTINENT 1 /* form/dial */ +#define CONTINENT_EUROPE 1 /* STRING in tree CONTINENT */ +#define CONTINENT_OCEANIA 2 /* STRING in tree CONTINENT */ +#define CONTINENT_ASIA 3 /* STRING in tree CONTINENT */ +#define CONTINENT_NORTHA 4 /* STRING in tree CONTINENT */ +#define CONTINENT_CENTRALA 5 /* STRING in tree CONTINENT */ +#define CONTINENT_SOUTHA 6 /* STRING in tree CONTINENT */ +#define CONTINENT_AFRICA 7 /* STRING in tree CONTINENT */ +#define CONTINENT_OCEAN 8 /* STRING in tree CONTINENT */ + +#define NOMEM 0 /* Alert string */ + +#define ALERT_WINDOW 1 /* Alert string */ + +#define GENERIC 2 /* Alert string */ + +#define CANT_LOAD_IMG 3 /* Alert string */ + +#define NOZCODECS 4 /* Alert string */ + +#define BADDATA 5 /* Alert string */ diff --git a/sources/z-tools/trunk/zweather/zweather.rsm b/sources/z-tools/trunk/zweather/zweather.rsm new file mode 100644 index 0000000..cb6b9b9 --- /dev/null +++ b/sources/z-tools/trunk/zweather/zweather.rsm @@ -0,0 +1,92 @@ +ResourceMaster v3.65 +#C 2@6@0@0@ +#N 99@32@AZAaza___ _@AZAaza090___ _@@_@ +#FoHRD@rsm2out@HRD@hrd@@@[HRD-File@0@ +#FoC-Header@rsm2out@C-Header@rsh@@@[C-Header@0@ +#R 0@0@3@1@4@1@ +#M 01010100@0@7728@723@ +#T 0@2@WEATHER@@114@@ +#O 1@26@PANEL4@@ +#O 2@30@CODE@@ +#O 10@30@UPDATE_TIME@@ +#O 13@26@METRIC@@ +#O 14@26@IMPERIAL@@ +#O 16@21@DATE@@ +#O 107@26@UPDATE@@ +#O 22@26@PANEL2@@ +#O 23@26@FORECAST1@@ +#O 24@21@DESCRIPTION1@@ +#O 25@21@DAY1@@ +#O 26@20@ICON1@@ +#O 29@21@NIGHT1@@ +#O 31@21@WIND1@@ +#O 32@26@FORECAST3@@ +#O 33@21@DESCRIPTION3@@ +#O 34@21@DAY3@@ +#O 35@20@ICON3@@ +#O 38@21@NIGHT3@@ +#O 40@21@WIND3@@ +#O 41@26@FORECAST5@@ +#O 42@21@DESCRIPTION5@@ +#O 43@21@DAY5@@ +#O 44@20@ICON5@@ +#O 47@21@NIGHT5@@ +#O 49@21@WIND5@@ +#O 50@26@FORECAST2@@ +#O 51@21@DESCRIPTION2@@ +#O 52@21@DAY2@@ +#O 53@20@ICON2@@ +#O 56@21@NIGHT2@@ +#O 58@21@WIND2@@ +#O 59@26@FORECAST4@@ +#O 60@21@DESCRIPTION4@@ +#O 61@21@DAY4@@ +#O 62@20@ICON4@@ +#O 65@21@NIGHT4@@ +#O 67@21@WIND4@@ +#O 68@20@ICON6@@ +#O 69@21@LINK1@@ +#O 70@21@LINK2@@ +#O 71@21@LINK3@@ +#O 72@21@LINK4@@ +#O 73@26@FORECAST@@ +#O 74@26@PREF@@ +#O 75@26@QUIT@@ +#O 76@26@PANEL1@@ +#O 78@21@DESCRIPTION@@ +#O 80@21@TEMP@@ +#O 82@21@FEEL@@ +#O 84@21@DEW@@ +#O 85@20@ICON@@ +#O 88@21@SUNSET@@ +#O 90@21@SUNRISE@@ +#O 92@21@UV@@ +#O 95@21@PRESSURE@@ +#O 97@21@WSPEED@@ +#O 98@20@WICON@@ +#O 101@21@HUMIDITY@@ +#O 103@21@VISIBILITY@@ +#O 104@21@TIME@@ +#O 105@21@REPORT@@ +#O 106@26@MAIN@@ +#O 108@26@MAP@@ +#O 109@26@PANEL3@@ +#O 111@20@MAP_BOX@@ +#O 112@26@CONTINENT@@ +#O 113@26@STATE@@ +#T 1@2@CONTINENT@@9@@ +#O 1@28@EUROPE@@ +#O 2@28@OCEANIA@@ +#O 3@28@ASIA@@ +#O 4@28@NORTHA@@ +#O 5@28@CENTRALA@@ +#O 6@28@SOUTHA@@ +#O 7@28@AFRICA@@ +#O 8@28@OCEAN@@ +#S 0@4@NOMEM@@ +#S 1@4@ALERT_WINDOW@@ +#S 2@4@GENERIC@@ +#S 3@4@CANT_LOAD_IMG@@ +#S 4@4@NOZCODECS@@ +#S 5@4@BADDATA@@ +#c 26537@