home *** CD-ROM | disk | FTP | other *** search
- ;*---------------------------------------------------------------------------
- ; :Program. fixni.asm
- ; :Contents. fix newicons for OS3.5
- ; :Author. Bert Jahn
- ; :EMail. wepl@kagi.com
- ; :Address. Franz-Liszt-Straße 16, Rudolstadt, 07404, Germany
- ; :Version. $Id: fixni.asm 1.4 2000/10/15 18:58:10 jah Exp jah $
- ; :History. 15.12.99 initial
- ; 19.12.99 fix for selected image depth added
- ; fix for different height added
- ; 22.12.99 reworked for public release
- ; 15.10.00 fix for different width added
- ; prints also infos about the images now
- ; :Requires. OS V37+
- ; :Copyright. Public Domain
- ; :Language. 68000 Assembler
- ; :Translator. Barfly V2.9
- ;---------------------------------------------------------------------------*
- ;##########################################################################
-
- INCDIR Includes:
- INCLUDE lvo/exec.i
- INCLUDE lvo/dos.i
- INCLUDE lvo/newicon_lib.i
- INCLUDE workbench/workbench.i
-
- INCLUDE macros/ntypes.i
-
- STRUCTURE NewDiskObject,0
- APTR ndo_StdObject ;The old-style icon
- APTR ndo_NormalImage ;May be NULL, meaning no new style icon
- APTR ndo_SelectedImage ;May be NULL, meaning no secondary image
- LABEL ndo_SIZEOF
-
- ifeq 1
-
- struct ChunkyImage
- {
- UWORD Width; /* width of the image. Must be <= 93 */
- UWORD Height; /* height of the image. Must be <= 93 */
- UWORD NumColors; /* number of pens defined in the palette. Must be <= 256 */
- UWORD Flags; /* see defines below */
- UBYTE *Palette; /* array of RGB components of the pens (one byte per gun) */
- UBYTE *ChunkyData; /* Width*Height bytes storing the colors of the pixels */
- };
-
- #define CIF_COLOR_0_TRANSP (1<<0) /* color 0 is transparent, not the one */
- /* stored in palette */
-
- #define CIF_DEFAULT (1<<1) /* when this bit is set, the image was */
- /* obtained via the DEFAULTIMAGE ToolType, */
- /* therefore it is not actually part of the */
- /* icon and will not be stored in the */
- /* ToolTypes on a PutNewDiskObject(). */
- endc
-
- ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
- GL EQUR A4 ;a4 ptr to Globals
- LOC EQUR A5 ;a5 for local vars
-
- STRUCTURE ArgArray,0
- ULONG aa_input
- LABEL aa_SIZEOF
-
- NSTRUCTURE Globals,0
- NAPTR gl_execbase
- NAPTR gl_dosbase
- NAPTR gl_rdargs
- NSTRUCT gl_rdarray,aa_SIZEOF
- NALIGNLONG
- NLABEL gl_SIZEOF
-
- ;##########################################################################
-
- PURE
- OUTPUT C:FixNI
- SECTION "",CODE
-
- bra .start
- dc.b "$VER: FixNI 1.4 "
- DOSCMD "WDate >t:date"
- INCBIN "t:date"
- dc.b " by Bert Jahn <wepl@kagi.com>"
- dc.b " V37+",0
- CNOP 0,2
- .start
-
- ;##########################################################################
-
- link GL,#gl_SIZEOF
- move.l (4).w,(gl_execbase,GL)
-
- move.l #37,d0
- lea (_dosname),a1
- move.l (gl_execbase,GL),a6
- jsr _LVOOpenLibrary(a6)
- move.l d0,(gl_dosbase,GL)
- beq .nodoslib
-
- lea (_template),a0
- move.l a0,d1
- lea (gl_rdarray,GL),a0
- move.l a0,d2
- moveq #0,d3
- move.l (gl_dosbase,GL),a6
- jsr (_LVOReadArgs,a6)
- move.l d0,(gl_rdargs,GL)
- bne .argsok
- lea (_readargs),a0
- bsr _PrintErrorDOS
- bra .noargs
- .argsok
- bsr _Main
- .opend
- move.l (gl_rdargs,GL),d1
- move.l (gl_dosbase,GL),a6
- jsr (_LVOFreeArgs,a6)
- .noargs
- move.l (gl_dosbase,GL),a1
- move.l (gl_execbase,GL),a6
- jsr (_LVOCloseLibrary,a6)
- .nodoslib
- unlk GL
- moveq #0,d0
- rts
-
- ;##########################################################################
-
- _Main
- ;open newicon.library
- moveq #39,d0
- lea (_niname),a1
- move.l (gl_execbase,GL),a6
- jsr (_LVOOpenLibrary,a6)
- tst.l d0
- bne .niok
- lea (_nonilib),a0
- bsr _Print
- bra .noni
- .niok move.l d0,a6
-
- ;remove ".info"
- move.l (gl_rdarray+aa_input,GL),a0
- move.l a0,a1
- .1 tst.b (a1)+
- bne .1
- subq.l #1,a1
- cmp.b #"o",-(a1)
- bne .2
- cmp.b #"f",-(a1)
- bne .2
- cmp.b #"n",-(a1)
- bne .2
- cmp.b #"i",-(a1)
- bne .2
- cmp.b #".",-(a1)
- bne .2
- clr.b (a1)
- .2
- ;load icon
- jsr (_LVOGetNewDiskObject,a6)
- tst.l d0
- bne .iconok
- lea (_loadicon),a0
- bsr _PrintErrorDOS
- bra .noobj
- .iconok
- move.l d0,a3 ;a3 = ndo
-
- ;print info
- ; lea (_ndo),a0
- ; move.l a3,a1
- ; bsr _PrintArgs
-
- ;check & fix depth for normal image
- tst.l (ndo_NormalImage,a3)
- beq .non
- lea (_normal),a0
- bsr _Print
- lea (_image),a0
- move.l (ndo_NormalImage,a3),a1
- bsr _PrintArgs
- move.l (ndo_NormalImage,a3),a1
- cmp.w #256,(4,a1)
- bls .non
- move.w #256,(4,a1)
- .non
- ;check & fix depth for selected image
- tst.l (ndo_SelectedImage,a3)
- beq .nos
- lea (_selected),a0
- bsr _Print
- lea (_image),a0
- move.l (ndo_SelectedImage,a3),a1
- bsr _PrintArgs
- move.l (ndo_SelectedImage,a3),a2
- cmp.w #256,(4,a2)
- bls .nos
- move.w #256,(4,a2)
- .nos
- ;both images present?
- move.l (ndo_NormalImage,a3),d0
- beq .nob
- move.l (ndo_SelectedImage,a3),d1
- beq .nob
- move.l d0,a0
- move.l d1,a1
- ;check & fix different height
- move.w (2,a0),d0
- cmp.w (2,a1),d0
- beq .hok
- move.w d0,(2,a1) ;cut selected image at bottom
- .hok ;check & fix different width
- move.w (a0),d0 ;new width
- cmp.w (a1),d0
- beq .wok
- blo .w0
- exg a0,a1 ;a1 will be cut
- .w0 move.w (a0),d0 ;d0 = new width
- move.w (a1),d1 ;d1 = old width
- move.w (2,a1),d6
- move.w d0,(a1) ;set new width
- move.l (12,a1),a0 ;image data
- move.l a0,a1
- subq.w #1,d6
- .w2 move.w d0,d7
- subq.w #1,d7
- .w1 move.b (a0)+,(a1)+
- dbf d7,.w1
- add.w d1,a0
- sub.w d0,a0
- dbf d6,.w2
- .wok
- .nob
- ;write icon back
- move.l (gl_rdarray+aa_input,GL),a0
- move.l a3,a1
- jsr (_LVOPutNewDiskObject,a6)
-
- ;release icon
- .4 move.l a3,a0
- jsr (_LVOFreeNewDiskObject,a6)
-
- ;release library
- .noobj move.l a6,a1
- move.l (gl_execbase,GL),a6
- jsr (_LVOCloseLibrary,a6)
- .noni
- moveq #20,d0
- rts
-
- ;##########################################################################
-
- INCDIR Sources:
- INCLUDE dosio.i
- Print
- PrintArgs
- INCLUDE error.i
- PrintErrorDOS
-
- ;##########################################################################
-
- ; Operationen
- _readargs dc.b "read arguments",0
- _loadicon dc.b "load icon",0
-
- _nonilib dc.b "need newicon.library version 39",10,0
-
- ;subsystems
- _dosname dc.b "dos.library",0
- _niname dc.b "new"
- _iname dc.b "icon.library",0
-
- _template dc.b "INPUTFILE/A" ;name eines zu ladenden Files
- dc.b 0
-
- ;_ndo dc.b "ndo_StdObject=%lx ndo_NormalImage=%lx ndo_SelectedImage=%lx",10,0
- _image dc.b " Width=%-4dHeight=%-4dNumColor=%-4dFlags=%d Palette=%lx Data=%lx",10,0
- _normal dc.b "NormalImage ",0
- _selected dc.b "SelectedImage",0
-
- ;##########################################################################
-
- END
-
-