-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter.c
706 lines (556 loc) · 20.4 KB
/
filter.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
/*----------------------------------------------------------------------*/
/*
PROJECT: PPT
MODULE : EFFECT.c
$Id: filter.c,v 6.0 1999/12/15 00:16:31 jj Exp $
Code containing effects stuff.
*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* Includes */
#include "defs.h"
#include "misc.h"
#include "gui.h"
#include "rexx.h"
#include "version.h"
#ifndef INTUITION_INTUITION_H
#include <intuition/intuition.h>
#endif
#ifndef DOS_DOS_H
#include <dos/dos.h>
#endif
#ifndef DOS_DOSTAGS_H
#include <dos/dostags.h>
#endif
#include <clib/bgui_protos.h>
#include <clib/alib_protos.h>
#include <pragmas/bgui_pragmas.h>
#ifndef PROTO_INTUITION_H
#include <proto/intuition.h>
#endif
#ifndef PROTO_UTILITY_H
#include <proto/utility.h>
#endif
#ifndef PROTO_DOS_H
#include <proto/dos.h>
#endif
#include "proto/effect.h"
#include <stdlib.h>
/*----------------------------------------------------------------------*/
/* Defines */
/*----------------------------------------------------------------------*/
/* Global variables */
/*----------------------------------------------------------------------*/
/* Internal prototypes */
Local FRAME *ExecFilter(EXTBASE *, FRAME *, EFFECT *, char *args, BOOL, ULONG * );
Prototype VOID ASM Filter( REGDECL(a0,UBYTE *), REGDECL(d0,ULONG) );
Prototype PERROR ExecEasyFilter( FRAME *, FPTR, EXTBASE * );
/*----------------------------------------------------------------------*/
/* Code */
/// RunFilterCommand
/*
This routine gives a bit more control than RunFilter(). It starts
up a given effect with the given args, adding the command to
the rexx list, so that the argument string will be freed
upon completion of the job.
args may be NULL, in which case a dummy argument string is supplied.
*/
Prototype PERROR RunFilterCommand( FRAME *, STRPTR, STRPTR );
PERROR
RunFilterCommand( FRAME *frame, STRPTR filtername, STRPTR args )
{
PPTREXXARGS *ra;
char buffer[100];
PERROR res;
if( !args ) args = "";
if( ra = SimulateRexxCommand( frame, args ) ) {
sprintf( buffer, "NAME=%s ARGS=%ld", filtername, ra->process_args );
if( (res = RunFilter( frame, buffer )) != PERR_OK ) {
ReplyRexxWaitItem( ra );
}
} else {
res = PERR_OUTOFMEMORY;
}
return res;
}
///
/// RunFilter()
/*
Main routine for effect execution. This is run from within the main
task and it spawns the subtask to handle the execution. If argstr != NULL
sends it to the effect routine.
*/
Prototype PERROR RunFilter( FRAME *frame, UBYTE *argstr );
PERROR RunFilter( FRAME *frame, UBYTE *argstr )
{
char argbuf[ARGBUF_SIZE];
struct Process *p;
PERROR res = PERR_OK;
D(bug("RunFilter( %08X, %s )\n",frame,(argstr) ? argstr : (STRPTR)"NULL" ));
LOCKGLOB();
if( !IsAreaSelected(frame) ) {
SelectWholeImage( frame );
}
D(bug("\tSelBox is (%d,%d)-(%d,%d)\n",frame->selbox.MinX, frame->selbox.MinY,
frame->selbox.MaxX, frame->selbox.MaxY ));
/*
* Reserve frame and lock windows
*/
if(ObtainFrame( frame, BUSY_READONLY )) {
if(argstr)
sprintf(argbuf,"%lu %s",frame,argstr);
else
sprintf(argbuf,"%lu",frame);
#ifdef DEBUG_MODE
p = CreateNewProcTags( NP_Entry, Filter, NP_Cli, FALSE,
NP_Output, frame->debug_handle = OpenDebugFile( DFT_Effect ),
NP_CloseOutput,TRUE, NP_Name, frame->nd.ln_Name,
NP_StackSize, globals->userprefs->extstacksize,
NP_Priority, globals->userprefs->extpriority, NP_Arguments, argbuf, TAG_END );
#else
p = CreateNewProcTags( NP_Entry, Filter, NP_Cli, FALSE,
NP_Output, Open("NIL:",MODE_NEWFILE),
NP_CloseOutput, TRUE, NP_Name, frame->nd.ln_Name,
NP_StackSize, globals->userprefs->extstacksize,
NP_Priority, globals->userprefs->extpriority, NP_Arguments, argbuf, TAG_END );
#endif
if(!p) {
ReleaseFrame( frame );
D(bug("\tCouldn't create a new process.\n"));
res = PERR_GENERAL;
} else {
SetFrameStatus( frame, 1 );
LOCK(frame);
frame->currproc = p;
UNLOCK(frame);
}
}
UNLOCKGLOB();
return res;
}
///
/// ExecEasyFilter
/*
This goes through the whole select area and calls
the execute routine, which may also be the local Cut / Copy / Whatever.
BUG: Does not react too well on failed routines.
*/
PERROR ExecEasyFilter( FRAME *frame, FPTR code, EXTBASE *PPTBase )
{
WORD row,col;
ROWPTR cp,addr;
auto int (* ASM X_EasyExec)( REG(d0) FRAME *, REG(a0) UBYTE *r, REG(a1) UBYTE *g,
REG(a2) UBYTE *b, REG(d1) WORD, REG(d2) WORD,
REG(a6) EXTBASE * );
X_EasyExec = (VOID *) code;
for( row = frame->selbox.MinY; row < frame->selbox.MaxY; row++ ) {
cp = GetPixelRow( frame, row, PPTBase );
if(Progress(frame,row,PPTBase))
break;
for( col = frame->selbox.MinX; col < frame->selbox.MaxX; col++ ) {
addr = cp + MULS16(col,frame->pix->components);
switch( frame->pix->colorspace ) {
case CS_ARGB:
(*X_EasyExec)( frame, addr+1, addr+2, addr+3, row, col, PPTBase ); /* BUG: should check */
break;
case CS_RGB:
(*X_EasyExec)( frame, addr, (addr+1), (addr + 2), row, col, PPTBase ); /* BUG: should check */
break;
case CS_GRAYLEVEL:
(*X_EasyExec)( frame, addr, addr, addr, row, col, PPTBase ); /* BUG: should check */
break;
}
}
PutPixelRow( frame, row, cp,PPTBase );
}
return PERR_OK;
}
///
/// EasyFilter
/*
This is an interface for externals to ExecEasyFilter().
BUG: Not maybe necessary.
*/
Local
FRAME *EasyFilter( FRAME *frame, EFFECT *effect, EXTBASE *PPTBase )
{
FPTR X_EasyExec;
char *X_EasyTitle, buf[80];
APTR UtilityBase = PPTBase->lb_Utility;
D(bug("EasyFilter()\n"));
/* Init variables */
sprintf(buf,XGetStr(mEXECUTING_EASYEXEC),effect->info.nd.ln_Name);
X_EasyExec = (FPTR)GetTagData( PPTX_EasyExec, NULL, effect->info.tags );
X_EasyTitle = (char *)GetTagData( PPTX_EasyTitle, (ULONG)buf,effect->info.tags);
/* Execute */
InitProgress( frame, X_EasyTitle, frame->selbox.MinY, frame->selbox.MaxY, PPTBase );
ExecEasyFilter( frame, X_EasyExec, PPTBase );
FinishProgress( frame, PPTBase );
if( frame->errorcode != PERR_OK )
return NULL;
return frame;
}
///
/// HandleFilterIDCMP()
/*
Main effect IDCMP control. Returns effect selected or NULL, if nothing
happened. -1 if the user just wanted to quit...
*/
EFFECT *HandleFilterIDCMP( EXTBASE *PPTBase, struct EffectWindow *fw, ULONG rc )
{
APTR entry;
EFFECT *f = NULL;
APTR func;
struct IntuitionBase *IntuitionBase = PPTBase->lb_Intuition;
struct Library *UtilityBase = PPTBase->lb_Utility;
struct ExecBase *SysBase = PPTBase->lb_Sys;
ULONG clicked, secs, ms;
switch(rc) {
case WMHI_CLOSEWINDOW:
case GID_FW_CANCEL:
D(bug("User wanted to quit filtering\n"));
f = NEGNUL;
break;
case GID_FW_INFO:
if( entry = (APTR) FirstSelected( fw->GO_List ) ) {
SHLOCKGLOB();
f = (EFFECT *) FindName( &globals->effects, entry );
UNLOCKGLOB();
ShowExtInfo( PPTBase, &(f->info), fw->win );
f = NULL; /* We don't want to quit, however */
}
break;
case GID_FW_EXEC:
/*
* Read the current listview object. If you change, change the code
* below (doubleclick) as well.
*/
if( entry = (APTR) FirstSelected( fw->GO_List ) ) {
LOCKGLOB();
f = (EFFECT *) FindName( &globals->effects, entry );
if(f) {
f->info.usecount++;
} else {
D(bug("FATAL: FindName() failed!\n"));
}
UNLOCKGLOB();
}
break;
case GID_FW_LIST:
/*
* Update gadgets. If the corresponding function can be found
* from effect's tag array, then the gadget is activated, otherwise
* it is disabled.
*/
if( entry = (APTR) FirstSelected( fw->GO_List ) ) {
SHLOCKGLOB();
f = (EFFECT *) FindName( &globals->effects, entry );
if( !f->info.islibrary ) {
func = (APTR) GetTagData( PPTX_EasyExec, NULL, f->info.tags );
} else {
func = (APTR) TRUE;
}
XSetGadgetAttrs( PPTBase,(struct Gadget *)fw->GO_Exec, fw->win, NULL, GA_Disabled, !func, TAG_END );
XSetGadgetAttrs( PPTBase,(struct Gadget *)fw->GO_Info, fw->win, NULL, GA_Disabled, FALSE, TAG_END );
UNLOCKGLOB();
f = NULL;
}
/*
* Check for a double click
*/
GetAttr( LISTV_LastClicked, fw->GO_List, &clicked );
if(clicked == fw->lastclicked) {
CurrentTime( &secs, &ms );
if( DoubleClick( fw->lcs, fw->lcm, secs, ms )) {
LOCKGLOB();
f = (EFFECT *) FindName( &globals->effects, entry );
f->info.usecount++;
UNLOCKGLOB();
}
}
CurrentTime( &fw->lcs, &fw->lcm );
fw->lastclicked = clicked;
break;
default:
break;
}
return f;
}
///
/// Filter()
/*
This routine will open a new window, in which one can select the
effect to be applied.
This routine runs as it's own process and may be dispatched several times.
*/
SAVEDS ASM VOID Filter( REG(a0) UBYTE *argstr, REG(d0) ULONG len )
{
struct EffectWindow fw;
ULONG sigmask, sig, rc, *optarray = NULL, status = EMSTATUS_FAILED;
int quit = 0;
EXTBASE *PPTBase = NULL;
struct Library *BGUIBase;
struct IntuitionBase *IntuitionBase;
struct Library *SysBase = SYSBASE();
FRAME *f = NULL,*newframe = NULL;
struct Window *win;
EFFECT *effect = NULL;
struct EffectMessage *emsg;
UBYTE *filname=NULL,*args = NULL;
BOOL rexx=FALSE;
D(bug("Filter()\n"));
if( (PPTBase = NewExtBase(TRUE)) == NULL) {
D(bug("LIB BASE ALLOCATION FAILED!\n"));
goto errorexit;
}
/*
* Set up variables and check for REXX command
*/
if( optarray = ParseDOSArgs( argstr, "FRAME/A/N,NAME/K,ARGS/K/N,REXX/S", PPTBase ) ) {
f = (FRAME *) *( (ULONG *)optarray[0]) ;
if(optarray[1]) { /* A name was given */
filname = (UBYTE *)optarray[1];
SHLOCKGLOB();
effect = (EFFECT *)FindIName( &globals->effects, filname );
UNLOCKGLOB();
if(!effect) {
char erbuf[80];
D(bug("\tFindname(%s) failed\n",filname));
sprintf(erbuf,XGetStr(mUNKNOWN_EFFECT),filname);
SetErrorMsg( f, erbuf );
goto errorexit;
}
if( optarray[2] ) args = (UBYTE *)PEEKL(optarray[2]);
rexx = (BOOL)optarray[3];
}
} else {
InternalError( XGetStr(mFILTER_INCORRECT_ARGS) );
/*
* Attempt a last, desperate extraction of the frame address
*/
if( NULL == (f = (FRAME *)atol(argstr))) {
InternalError("Filter(): NULL frame!?!");
}
goto errorexit;
}
D(bug("\tFRAME = %08X EFFECT = '%s' ARGS = '%s'\n",
f,(filname) ? (char *)filname : "NULL",(args) ? (char *)args : "NULL"));
if(NewTaskProlog(f,PPTBase) != PERR_OK) goto errorexit;
BGUIBase = PPTBase->lb_BGUI;
IntuitionBase = PPTBase->lb_Intuition;
/*
* If there was no effect sent to us, then we will ask one from the user.
*/
if(!effect) { /* No effect yet allocated */
D(bug("\tOpening Effect window\n"));
bzero(&fw, sizeof(struct EffectWindow));
win = GimmeFilterWindow( PPTBase, f, &sigmask, &fw );
if(win) {
AddExtEntries( PPTBase, win, fw.GO_List, NT_EFFECT, AEE_ALL ); /* Update window display */
while(!quit) {
sig = Wait(sigmask | SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_F );
if (sig & SIGBREAKF_CTRL_C ) {
D(bug("***** BREAK *****\n"));
quit++;
}
if( sig & SIGBREAKF_CTRL_F ) {
if(!win) win = WindowOpen(fw.WO_Win);
if( win ) {
WindowToFront( win );
ActivateWindow( win );
}
}
if (sig & sigmask) {
while ((rc = HandleEvent(fw.WO_Win)) != WMHI_NOMORE) {
if( (effect = HandleFilterIDCMP( PPTBase, &fw , rc )) != NULL)
quit++;
} /* while (rc) */
}
} /* while */
DisposeObject(fw.WO_Win);
} else {
D(bug("\t\tCouldn't open effect window\n"));
Req(NEGNUL,NULL,XGetStr(mCOULDNT_OPEN_EFFECT_WINDOW) );
}
}
D(bug("\tEffect = %08X\n",effect));
/* Make the actual execution. */
if(effect != NEGNUL && effect != NULL) {
newframe = ExecFilter(PPTBase,f,effect,args,rexx, &status);
}
D(bug("\tFilter() done, sending message\n"));
errorexit:
if(optarray)
FreeDOSArgs( optarray, PPTBase );
/*
* Prepare to send message to main program
*/
emsg = (struct EffectMessage *)AllocPPTMsg( sizeof(struct EffectMessage), PPTBase );
emsg->em_PMsg.frame = f;
emsg->em_PMsg.code = PPTMSG_EFFECTDONE;
emsg->em_NewFrame = (APTR)newframe;
emsg->em_Status = status;
/* Send the message */
SendPPTMsg( globals->mport, emsg, PPTBase );
WaitDeathMessage( PPTBase );
EmptyMsgPort( PPTBase->mport, PPTBase );
if(PPTBase) RelExtBase(PPTBase);
/* Die. */
}
///
/// ExecFilter()
/*
This will take care of the actual effecting.
Returns a pointer to the new, rendered frame or NULL, if no change was done (for
example due to an error during rendering or maybe a break).
*/
Local
FRAME *ExecFilter( EXTBASE *PPTBase, FRAME *frame, EFFECT *effect, char *args, BOOL rexx, ULONG *statusp )
{
char *template;
ULONG colorspaces, *argitemarray = NULL;
struct TagItem tags[8];
BOOL nonewframe, nochangeframe;
FRAME *newframe = NULL, *fr, *res = NULL;
struct Library *UtilityBase = PPTBase->lb_Utility, *EffectBase = NULL;
struct ExecBase *SysBase = PPTBase->lb_Sys;
FPTR easyeffect;
D(bug("ExecFilter()\n"));
/*
* First, get info on the effect. If it is not a library,
* it must be an old-style easy effect.
*/
if( effect->info.islibrary ) {
EffectBase = OpenModule( (EXTERNAL *)effect, 0L, PPTBase );
if(!EffectBase) return NULL; // BUG: No error message
nonewframe = (BOOL)EffectInquire( PPTX_NoNewFrame, PPTBase );
nochangeframe=(BOOL)EffectInquire( PPTX_NoChangeFrame, PPTBase );
easyeffect = NULL;
colorspaces = EffectInquire( PPTX_ColorSpaces, PPTBase );
template = (STRPTR) EffectInquire( PPTX_RexxTemplate, PPTBase );
} else {
easyeffect = (FPTR)GetTagData( PPTX_EasyExec, NULL, effect->info.tags );
colorspaces = GetTagData( PPTX_ColorSpaces, CSF_RGB, effect->info.tags );
nochangeframe=(BOOL)GetTagData( PPTX_NoChangeFrame, FALSE, effect->info.tags );
nonewframe = (BOOL)GetTagData( PPTX_NoNewFrame, FALSE, effect->info.tags );
template = NULL; // These don't have them.
}
/*
* Is our current colorspace recognized?
*/
if( (colorspaces & (1 << frame->pix->colorspace)) == 0) {
XReq( NEGNUL, NULL, XGetStr(mEFFECT_DOESNT_SUPPORT_CSPACE),
effect->info.nd.ln_Name,
ColorSpaceName(frame->pix->colorspace) );
if(EffectBase) CloseModule(EffectBase,PPTBase);
return NULL;
}
/*
* Do check the command template, if it exists and this was a REXX
* command.
*/
if(template && args) {
if( (argitemarray = ParseDOSArgs( args, template, PPTBase )) == NULL ) {
char buf[256];
// XReq( NEGNUL, NULL, "\nInvalid REXX arguments!\n" );
// SetErrorCode( frame, PERR_INVALIDARGS );
sprintf(buf,XGetStr(mINVALID_ARGS_EXPECTED_X), template);
SetErrorMsg( frame, buf );
if( EffectBase ) CloseModule(EffectBase, PPTBase);
return NULL;
}
}
/*
* Initialize variables and set up tagitem array.
*/
if(template && args) {
tags[0].ti_Tag = PPTX_RexxArgs; tags[0].ti_Data = (ULONG) argitemarray;
} else {
tags[0].ti_Tag = TAG_END; tags[0].ti_Data = 0L;
}
tags[1].ti_Tag = TAG_END; tags[1].ti_Data = 0L;
/*
* Do the actual effecting.
*/
if(easyeffect || EffectBase) {
D(APTR b);
ChangeBusyStatus( frame, BUSY_CHANGING );
LOCK(frame);
frame->currext = (EXTERNAL *)effect; /* MARK: We're busy with this */
UNLOCK(frame);
/*
* fr will be either a copy (or if the module requested)
* the original frame
*/
if(!nonewframe && !nochangeframe) {
D(bug("Duplicating a new frame for the program\n"));
fr = newframe = DupFrame( frame, DFF_COPYDATA, PPTBase );
if( !newframe ) {
goto errorexit;
}
} else {
fr = frame;
}
D(bug("\tExecuting effect %s...\n",effect->info.nd.ln_Name));
D(bug("====================================\n"));
D(b = StartBench());
if( EffectBase ) {
res = EffectExec( fr, &tags[0], PPTBase );
} else {
res = EasyFilter( fr, effect, PPTBase );
}
D(StopBench(b));
D(bug("====================================\n"));
D(bug("\tExec() returns %08X\n",res));
if( fr->parent )
CloseInfoWindow( fr->parent->mywin, PPTBase );
else
CloseInfoWindow( fr->mywin, PPTBase );
if(MasterQuit) /* In case of a master quit enabled, then go down gracefully */
goto quit;
LOCK(fr);
/*
* Check for failure. If this command came directly from the user,
* we'll show up an error message, if from REXX, we'll pass it down to
* the main task to be returned to REXX.
*/
if(res == NULL) {
D(bug("\tAn error occurred during the filtering...\n"));
if( rexx ) {
CopyError( fr, frame );
} else {
if( fr->doerror &&
(fr->errorcode != PERR_BREAK) &&
(fr->errorcode != PERR_CANCELED) ) {
XReq(NEGNUL,NULL,XGetStr(mEFFECT_REPORTS_ERROR),
effect->info.nd.ln_Name, frame->nd.ln_Name, GetErrorMsg( fr, PPTBase) );
} else {
D(bug("\t\tError has already been reported or it is an irrelevant one\n"));
}
/*
* We must also make sure that no error is shown on BREAK
* and CANCELED errors when we return
*/
fr->doerror = FALSE; /* Shown */
}
} else {
/* Success ! */
*statusp = nochangeframe ? EMSTATUS_NOCHANGE : EMSTATUS_NEWFRAME;
}
UNLOCK(fr);
quit:
if(res == NULL && newframe) {
D(bug("Failed, so I am removing the new frame\n"));
RemFrame(newframe,PPTBase);
}
}
ClearProgress( frame, PPTBase );
errorexit:
if(EffectBase) CloseModule( EffectBase, PPTBase );
if(argitemarray) FreeDOSArgs( argitemarray, PPTBase );
return res;
}
///
/*----------------------------------------------------------------------*/
/* END OF CODE */
/*----------------------------------------------------------------------*/