initial commit

This commit is contained in:
root
2023-06-12 09:14:09 +02:00
commit b4912f303e
2545 changed files with 209350 additions and 0 deletions

View File

@@ -0,0 +1,289 @@
/*
*
*
* Version PureC / Gcc
*/
#define PCGEMLIB 1 /* mettre 1 si les utilisateurs de Pure C
* utilise les librairies GEM Pure C */
/* Fichiers headers */
#include <portab.h>
#if PCGEMLIB
#include <aes.h>
#include <vdi.h>
#else
#include <aesbind.h>
#include <vdibind.h>
#endif
#include <string.h>
#include <math.h>
#include "..\..\ldg.h"
#include "..\..\vapi.h"
#include "..\..\ldv.h"
#include "..\..\mt_aes.h"
/* Prototypages */
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi) ;
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
void OnClose(void) ;
/* Variables globales */
PROC Proc[] = {
"GetLDVCapabilities", "Capacit<EFBFBD>s du LDV", (void *)GetLDVCapabilities,
"PreRun", "Init du Run", (void *)PreRun,
"Run", "Fonction du LDV", (void *)Run,
"Preview", "Pre-Visu", (void *)Preview,
} ;
char Info[] = "LDV";
LDGLIB Ldg[] = {
0x0102, /* version de la lib, recommand<6E> */
4, /* nombre de fonction dans la lib */
Proc, /* Pointeurs vers nos fonctions */
Info, /* Information sur la lib */
0x0, /* Flags de la lib, obligatoire */
OnClose, /* Fermeture, liberation de VDIHandle */
};
#define BP_CAPS (LDVF_SPECFORMAT | LDVF_OPINPLACE | LDVF_SUPPORTPREVIEW | LDVF_AFFECTPALETTE)
#define TC_CAPS (LDVF_SPECFORMAT | LDVF_OPINPLACE | LDVF_SUPPORTPREVIEW | LDVF_SUPPORTPROG | LDVF_SUPPORTCANCEL)
LDV_INFOS LdvInfos = {
(short) sizeof(LDV_INFOS), /* Taille de cette structure */
TLDV_MODIFYIMG, /* Type du LDV */
"Jean Lusetti/Olivier Landemarre", /* Auteurs */
{
{ 1, 1, BP_CAPS }, /* Capacites pour 1 plan */
{ 2, 2, BP_CAPS }, /* Capacites pour 2 plans */
{ 4, 4, BP_CAPS }, /* Capacites pour 4 plans */
{ 8, 8, BP_CAPS }, /* Capacites pour 8 plans */
{ 16, 16, TC_CAPS }, /* Capacites pour 16 plans */
{ 24, 24, TC_CAPS }, /* Capacites pour 24 plans */
{ 32, 32, TC_CAPS }, /* Capacites pour 32 plans */
{ 0, 0, 0UL } /* Fin de la liste des capacites */
},
} ;
VAPI *Vapi = NULL ;
int VDIHandle = -1 ;
/* Petites macros bien utiles ... */
#define RVB16( r, v, b ) ( (r << 11) + (v << 5) + (b) )
#define RVB32( r, v, b ) ( ((long)r << 24) + ((long)v << 16) + ((long)b << 8) )
void OnClose(void)
{
if ( VDIHandle != -1 ) v_clsvwk( VDIHandle ) ;
VDIHandle = -1 ;
}
/*
* Fonctions de la librairie
*/
int R4[256],G4[256],B4[256]; /*pr<70>calcul de luminescence 256 niveaux */
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi)
{ float valR=0,valG=0,valB=0; int i;
Vapi = vapi ;
for(i=0;i<256;i++)
{
R4[i]=(int)valR; /* methode rapide */
G4[i]=(int)valG;
B4[i]=(int)valB;
valR+=0.302;
valG+=0.589;
valB+=0.114;
}
return( &LdvInfos ) ;
}
int vdihandle(void)
{
int work_in[11], work_out[57], i ;
for ( i = 0; i < 10; work_in[i++] = 1 ) ;
work_in[10] = 2 ;
v_opnvwk( work_in, &i, work_out ) ;
return( i ) ;
}
#pragma warn -par
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
return( ELDV_NOERROR ) ;
}
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
LDV_PALETTE *vdi_palette = &in->Palette ;
VDI_ELEMENTPAL *vdi_epal ;
short vdi_index ;
short bw_value ;
short cancel = 0 ;
if ( in->Raster.fd_nplanes <= 8 )
{
if ( vdi_palette == NULL ) return( ELDV_GENERALFAILURE ) ;
vdi_epal = vdi_palette->Pal ;
if ( vdi_epal == NULL ) return( ELDV_GENERALFAILURE ) ;
for ( vdi_index = 0; vdi_index < vdi_palette->NbColors; vdi_index++, vdi_epal++ )
{
bw_value = ( vdi_epal->Red + vdi_epal->Green + vdi_epal->Blue ) / 3 ;
vdi_epal->Red = bw_value ;
vdi_epal->Green = bw_value ;
vdi_epal->Blue = bw_value ;
}
}
else
{
MFDB *img = &in->Raster ;
long nb_pts_in_line ;
short x, y, pc ;
if ( Vapi == NULL ) return( ELDV_GENERALFAILURE ) ;
/* Convertir l'image au format True Color "standard" ATARI */
/* Format specifique --> format "ATARI True Color" */
Vapi->RaTCInvConvert( img ) ;
nb_pts_in_line = img->fd_w ;
if ( nb_pts_in_line % 16 ) nb_pts_in_line = (16+nb_pts_in_line) & 0xFFF0 ; /* Toujours aligne sur 16 pixels ! */
if ( img->fd_nplanes == 16 )
{
unsigned short *ptu, red, green, blue, ugris, val, ubr ;
for ( y = params->y1; !cancel && (y <= params->y2); y++ )
{
ptu = (unsigned short *) img->fd_addr ;
ptu += nb_pts_in_line * y ;
ptu += params->x1 ;
for ( x = params->x1; x <= params->x2; x++ )
{
val = *ptu ;
red = ( val & 0x01F ) << 1 ; /* Sur 6 bits */
green = ( val & 0x07E0 ) >> 6 ; /* Sur 6 bits */
blue = ( val & 0xF800 ) >> 10 ; /* Sur 6 bits */
ugris = ( R4[red] + G4[green] + B4[blue] ) ;
ubr = ( ugris >> 1 ) ;
*ptu++ = RVB16( ubr, ugris, ubr ) ;
}
if ( ( y & 0x0F ) == 0x0F )
{
/* Appelle la routine de progression une fois sur 16 */
/* NB : en mode preview, VISION ignorera cet appel, */
/* inutile donc de s'en soucier */
pc = (short) ( ( 100L * ( y - params->y1 ) ) / ( params->y2 - params->y1 ) ) ;
if ( Vapi->PrSetProgEx )
{
cancel = Vapi->PrSetProgEx( pc ) ;
}
else
Vapi->PrSetProg( pc ) ;
}
}
}
else if ( img->fd_nplanes == 24 ) /* NON teste ! */
{
unsigned char *ptu ;
unsigned short red, green, blue, ugris ;
for ( y = params->y1; !cancel && (y <= params->y2); y++ )
{
ptu = (unsigned char *) img->fd_addr ;
ptu += 3 * nb_pts_in_line * y ;
ptu += 3 * params->x1 ;
for ( x = params->x1; x <= params->x2; x++ )
{
red = (unsigned short) (*ptu++) ;
green = (unsigned short) (*ptu++) ;
blue = (unsigned short) (*ptu++) ;
ugris = ( R4[red] + G4[green] + B4[blue] ) ;
*ptu-- = ugris ;
*ptu-- = ugris ;
*ptu-- = ugris ;
ptu += 3 ;
}
if ( ( y & 0x0F ) == 0x0F )
{
/* Appelle la routine de progression une fois sur 16 */
/* NB : en mode preview, VISION ignorera cet appel, */
/* inutile donc de s'en soucier */
pc = (short) ( ( 100L * ( y - params->y1 ) ) / ( params->y2 - params->y1 ) ) ;
if ( Vapi->PrSetProgEx )
{
cancel = Vapi->PrSetProgEx( pc ) ;
}
else
Vapi->PrSetProg( pc ) ;
}
}
}
else if ( img->fd_nplanes == 32 )
{
unsigned long *ptu, val ;
unsigned short red, green, blue, ugris ;
for ( y = params->y1; !cancel && (y <= params->y2); y++ )
{
ptu = (unsigned long *)img->fd_addr ;
ptu += nb_pts_in_line * y ;
ptu += params->x1 ;
for ( x = params->x1; x <= params->x2; x++ )
{
val = *ptu ;
val >>= 8 ;
blue = (unsigned short) (val & 0xFF) ;
val >>= 8 ;
green = (unsigned short) (val & 0xFF) ;
val >>= 8 ;
red = (unsigned short) (val & 0xFF) ;
ugris = ( R4[red] + G4[green] + B4[blue] ) ;
*ptu++ = RVB32( ugris, ugris, ugris ) ;
}
if ( ( y & 0x0F ) == 0x0F )
{
/* Appelle la routine de progression une fois sur 16 */
/* NB : en mode preview, VISION ignorera cet appel, */
/* inutile donc de s'en soucier */
pc = (short) ( ( 100L * ( y - params->y1 ) ) / ( params->y2 - params->y1 ) ) ;
if ( Vapi->PrSetProgEx )
{
cancel = Vapi->PrSetProgEx( pc ) ;
}
else
Vapi->PrSetProg( pc ) ;
}
}
}
/* Format "ATARI True Color" --> format specifique */
Vapi->RaTCConvert( img ) ;
}
return( cancel ? ELDV_CANCELLED : ELDV_NOERROR ) ;
}
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
return( Run( in, params, out ) ) ;
}
#pragma warn +par
int main(void)
{
ldg_init( Ldg ) ;
return( 0 ) ;
}

Binary file not shown.

View File

@@ -0,0 +1,12 @@
bw.ldv
;.C[-Y- -G+]
;.L[-Y-]
=
pcstart.o
bw.c
pcgemlib.lib
pcstdlib.lib
pctoslib.lib
pcfltlib.lib
..\..\ldg.lib
..\..\mt_aes.lib

View File

@@ -0,0 +1,156 @@
/*
*
*
* Version PureC / Gcc
*/
#define PCGEMLIB 1 /* mettre 1 si les utilisateurs de Pure C
* utilise les librairies GEM Pure C */
/* Fichiers headers */
#include <portab.h>
#if PCGEMLIB
#include <aes.h>
#include <vdi.h>
#else
#include <aesbind.h>
#include <vdibind.h>
#endif
#include <string.h>
#include "..\..\ldg.h"
#include "..\..\vapi.h"
#include "..\..\ldv.h"
#include "..\..\mt_aes.h"
/* Prototypages */
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi) ;
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
void OnClose(void) ;
/* Variables globales */
PROC Proc[] = {
"GetLDVCapabilities", "Capacit<EFBFBD>s du LDV", (void *)GetLDVCapabilities,
"PreRun", "Init du Run", (void *)PreRun,
"Run", "Fonction du LDV", (void *)Run,
"Preview", "Pre-Visu", (void *)Preview,
} ;
char Info[] = "LDV";
LDGLIB Ldg[] = {
0x0100, /* version de la lib, recommand<6E> */
4, /* nombre de fonction dans la lib */
Proc, /* Pointeurs vers nos fonctions */
Info, /* Information sur la lib */
0x0, /* Flags de la lib, obligatoire */
OnClose, /* Fermeture, liberation de VDIHandle */
} ;
/* Enlever le commentaire de la ligne suivante */
/* Pour que le LDV ne supporte plus la */
/* Transformation sur place (but uniquement */
/* Pedagogique ! */
/*#define NOTOPINPLACE*/
#ifndef NOTOPINPLACE
#define CAPS (LDVF_SPECFORMAT | LDVF_SUPPORTPREVIEW | LDVF_OPINPLACE)
#else
#define CAPS (LDVF_SPECFORMAT | LDVF_SUPPORTPREVIEW)
#endif
LDV_INFOS LdvInfos = {
(short) sizeof(LDV_INFOS), /* Taille de cette structure */
TLDV_MODIFYIMG, /* Type du LDV */
"Jean Lusetti", /* Auteurs */
{
{ 1, 1, CAPS }, /* Capacites pour 1 plan */
{ 2, 2, CAPS }, /* Capacites pour 2 plans */
{ 4, 4, CAPS }, /* Capacites pour 4 plans */
{ 8, 8, CAPS }, /* Capacites pour 8 plans */
{ 16, 16, CAPS }, /* Capacites pour 16 plans */
{ 32, 32, CAPS }, /* Capacites pour 24 plans */
{ 24, 24, CAPS }, /* Capacites pour 32 plans */
{ 0, 0, 0UL } /* Fin de la liste des capacites */
},
} ;
VAPI *Vapi = NULL ;
int VDIHandle = -1 ;
void OnClose(void)
{
if ( VDIHandle != -1 ) v_clsvwk( VDIHandle ) ;
}
/*
* Fonctions de la librairie
*/
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi)
{
Vapi = vapi ;
return( &LdvInfos ) ;
}
int vdihandle(void)
{
int work_in[11], work_out[57], i ;
for ( i = 0; i < 10; work_in[i++] = 1 ) ;
work_in[10] = 2 ;
v_opnvwk( work_in, &i, work_out ) ;
return( i ) ;
}
#pragma warn -par
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
out->Raster.fd_w = in->Raster.fd_w ;
out->Raster.fd_h = in->Raster.fd_h ;
return( ELDV_NOERROR ) ;
}
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
int xy[8] ;
if ( VDIHandle == -1 ) VDIHandle = vdihandle() ;
#ifndef NOTOPINPLACE
{
/* Recopie le raster source vers la destination */
xy[0] = xy[4] = 0 ;
xy[1] = xy[5] = 0 ;
xy[2] = xy[6] = in->Raster.fd_w - 1 ;
xy[3] = xy[7] = in->Raster.fd_h - 1 ;
vro_cpyfm( VDIHandle, S_ONLY, xy, &in->Raster, &out->Raster ) ;
}
#endif
xy[0] = params->x1 ;
xy[1] = params->y1 ;
xy[2] = params->x2 ;
xy[3] = params->y2 ;
memcpy( &xy[4], xy, 4*sizeof(int) ) ;
vro_cpyfm( VDIHandle, D_INVERT, xy, &out->Raster, &out->Raster ) ;
return( ELDV_NOERROR ) ;
}
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
return( Run( in, params, out ) ) ;
}
#pragma warn +par
int main(void)
{
ldg_init( Ldg ) ;
return( 0 ) ;
}

Binary file not shown.

View File

@@ -0,0 +1,11 @@
invert.ldv
;.C[-Y- -G+]
;.L[-Y-]
=
pcstart.o
invert.c
pcgemlib.lib
pcstdlib.lib
pctoslib.lib
..\..\ldg.lib
..\..\mt_aes.lib

View File

@@ -0,0 +1,346 @@
/*
*
*
* Version PureC / Gcc
*/
#define PCGEMLIB 1 /* mettre 1 si les utilisateurs de Pure C
* utilise les librairies GEM Pure C */
/* Fichiers headers */
#include <portab.h>
#if PCGEMLIB
#include <aes.h>
#include <vdi.h>
#else
#include <aesbind.h>
#include <vdibind.h>
#endif
#include <string.h>
#include "..\..\ldg.h"
#include "..\..\vapi.h"
#include "..\..\ldv.h"
#include "..\..\mt_aes.h"
/* Prototypages */
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi) ;
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl GetParams(LDV_IMAGE *in, LDV_PARAMS *params, char *path) ;
/* Variables globales */
PROC Proc[] = {
"GetLDVCapabilities", "Capacit<EFBFBD>s du LDV", (void *)GetLDVCapabilities,
"PreRun", "Init du Run", (void *)PreRun,
"Run", "Fonction du LDV", (void *)Run,
"Preview", "Pre-Visu", (void *)Preview,
} ;
char Info[] = "LDV";
LDGLIB Ldg[] = {
0x0100, /* version de la lib, recommand<6E> */
4, /* nombre de fonction dans la lib */
Proc, /* Pointeurs vers nos fonctions */
Info, /* Information sur la lib */
0x0, /* Flags de la lib, obligatoire */
NULL, /* Fermeture, liberation de VDIHandle (inutilise) */
};
#define CAPS (LDVF_ATARIFORMAT | LDVF_SUPPORTPREVIEW | LDVF_SUPPORTPROG | LDVF_REALTIMEPARAMS | LDVF_OPINPLACE | LDVF_SUPPORTCANCEL)
LDV_INFOS LdvInfos = {
(short) sizeof(LDV_INFOS), /* Taille de cette structure */
TLDV_MODIFYIMG, /* Type du LDV */
"Jean Lusetti", /* Auteurs */
{
{ 16, 16, CAPS }, /* Capacites pour 16 plans */
/* Qui le fera ? { 24, 24, CAPS }, */
{ 32, 32, CAPS }, /* Capacites pour 32 plans */
{ 0, 0, 0UL } /* Fin de la liste des capacites */
},
} ;
/* Ce LDV ne peut marcher qu'avec une versio de VAPI >= 1.02 */
/* Du <20> un bug dans la version 1.01 */
#define CHK_VAPIVERSION(vapi) if ( ( vapi == NULL ) || ( vapi->Header.Version < 0x102 ) ) return( ELDV_BADVAPIVERSION ) ;
/* Petites macros bien utiles ... */
#define RVB16( r, v, b ) ( (r << 11) + (v << 5) + (b) )
#define RVB32( r, v, b ) ( ((long)(r) << 24) + ((long)(v) << 16) + ((long)(b << 8)) )
VAPI *Vapi = NULL ;
unsigned short powerx, powery ;
unsigned long p2 ;
/*
Notez que ce LDV ne se sert pas de VDIHandle, OnClose... puisque aucune fonction VDI (vo_cpyfm par ex.) n'est utilisee
int VDIHandle = -1 ;
void OnClose(void)
{
if ( VDIHandle != -1 ) v_clsvwk( VDIHandle ) ;
VDIHandle = -1 ;
}
int vdihandle(void)
{
int work_in[11], work_out[57], i ;
for ( i = 0; i < 10; work_in[i++] = 1 ) ;
work_in[10] = 2 ;
v_opnvwk( work_in, &i, work_out ) ;
return( i ) ;
}
*/
/*
* Fonctions de la librairie
*/
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi)
{
Vapi = vapi ;
return( &LdvInfos ) ;
}
#pragma warn -par
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
CHK_VAPIVERSION( Vapi ) ;
/* La transformation se fait "sur place" */
return( ELDV_NOERROR ) ;
}
#pragma warn +par
unsigned short Pixelize16(unsigned short *pt, long nb_lpts)
{
unsigned short *last_pt = pt ;
unsigned long rsum = 0 ;
unsigned long gsum = 0 ;
unsigned long bsum = 0 ;
unsigned short pixel, *ptu ;
unsigned short red, green, blue ;
short x, y ;
for ( y = 0; y < powery; y++, last_pt += nb_lpts )
{
ptu = last_pt ;
for ( x = 0; x < powerx; x++, ptu++ )
{
pixel = *ptu ;
red = pixel >> 11 ; /* Sur 5 bits */
green = ( pixel >> 5 ) & 0x3F ; /* Sur 6 bits */
blue = pixel & 0x1F ; /* Sur 5 bits */
rsum += (unsigned long) red ;
gsum += (unsigned long) green ;
bsum += (unsigned long) blue ;
}
}
red = (unsigned short) (rsum / p2) ;
green = (unsigned short) (gsum / p2) ;
blue = (unsigned short) (bsum / p2) ;
pixel = RVB16( red, green, blue ) ;
return( pixel ) ;
}
LDV_STATUS Run16(LDV_IMAGE *in, LDV_PARAMS *params)
{
unsigned short new_pixel, *pt, *tmp_pt, *dpix ;
unsigned long po2 ;
long yoffset, nb_lpts ;
short power, x, y ;
short pc, cancel = 0 ;
short iter = 0 ;
power = params->Param[0].s ;
po2 = power * power ;
nb_lpts = in->Raster.fd_w ;
if ( nb_lpts % 16 ) nb_lpts++ ;
yoffset = nb_lpts * (long)(params->y1) ;
for ( y = params->y1; !cancel && (y < params->y2); y += power, yoffset += nb_lpts*power )
{
powerx = power ;
if ( y + power - 1 > params->y2 )
{
powery = 1 + params->y2 - y ;
p2 = powerx * powery ;
}
else
{
powery = power ;
p2 = po2 ;
}
pt = (unsigned short *)(in->Raster.fd_addr) + yoffset + params->x1 ;
for ( x = params->x1; x < params->x2 - powerx; x += powerx, pt += powerx )
{
new_pixel = Pixelize16( pt, nb_lpts ) ;
for ( tmp_pt = pt; tmp_pt < pt + powery*nb_lpts; tmp_pt += nb_lpts )
for ( dpix = tmp_pt; dpix < tmp_pt + powerx; dpix++ ) *dpix = new_pixel ;
}
/* Residuel sur x (evite un test pour chaque paquet power x power) */
if ( x < params->x2 )
{
powerx = params->x2 - x ;
p2 = powerx * powery ;
new_pixel = Pixelize16( pt, nb_lpts ) ;
for ( tmp_pt = pt; tmp_pt < pt + powery*nb_lpts; tmp_pt += nb_lpts )
for ( dpix = tmp_pt; dpix < tmp_pt + powerx; dpix++ ) *dpix = new_pixel ;
}
if ( Vapi && ( ( iter++ & 0x0F ) == 0x0F ) )
{
pc = (short) ( ( 100L * (long)(y - params->y1) ) / (long)(params->y2 - power- params->y1) ) ;
if ( Vapi->PrSetProgEx )
{
cancel = Vapi->PrSetProgEx( pc ) ;
}
else
Vapi->PrSetProg( pc ) ;
}
}
return( cancel ? ELDV_CANCELLED : ELDV_NOERROR ) ;
}
unsigned long Pixelize32(unsigned long *pt, long nb_lpts)
{
unsigned long *last_pt = pt ;
unsigned long rsum = 0 ;
unsigned long gsum = 0 ;
unsigned long bsum = 0 ;
unsigned long pixel, *ptu ;
unsigned long red, green, blue ;
short x, y ;
for ( y = 0; y < powery; y++, last_pt += nb_lpts )
{
ptu = last_pt ;
for ( x = 0; x < powerx; x++, ptu++ )
{
pixel = *ptu ;
pixel >>= 8 ;
bsum += pixel & 0xFF ;
pixel >>= 8 ;
gsum += pixel & 0xFF ;
pixel >>= 8 ;
rsum += pixel ;
}
}
red = rsum / p2 ;
green = gsum / p2 ;
blue = bsum / p2 ;
pixel = RVB32( red, green, blue ) ;
return( pixel ) ;
}
LDV_STATUS Run32(LDV_IMAGE *in, LDV_PARAMS *params)
{
unsigned long new_pixel, *pt, *tmp_pt, *dpix ;
unsigned long po2 ;
long yoffset, nb_lpts ;
short power, x, y ;
short pc, cancel = 0 ;
short iter = 0 ;
power = params->Param[0].s ;
po2 = power * power ;
nb_lpts = in->Raster.fd_w ;
if ( nb_lpts % 16 ) nb_lpts++ ;
yoffset = nb_lpts * (long)(params->y1) ;
for ( y = params->y1; !cancel && (y < params->y2); y += power, yoffset += nb_lpts*power )
{
powerx = power ;
if ( y + power - 1 > params->y2 )
{
powery = 1 + params->y2 - y ;
p2 = powerx * powery ;
}
else
{
powery = power ;
p2 = po2 ;
}
pt = (unsigned long *)(in->Raster.fd_addr) + yoffset + params->x1 ;
for ( x = params->x1; x < params->x2 - powerx; x += powerx, pt += powerx )
{
new_pixel = Pixelize32( pt, nb_lpts ) ;
for ( tmp_pt = pt; tmp_pt < pt + powery*nb_lpts; tmp_pt += nb_lpts )
for ( dpix = tmp_pt; dpix < tmp_pt + powerx; dpix++ ) *dpix = new_pixel ;
}
/* Residuel sur x (evite un test pour chaque paquet power x power) */
if ( x < params->x2 )
{
powerx = params->x2 - x ;
p2 = powerx * powery ;
new_pixel = Pixelize32( pt, nb_lpts ) ;
for ( tmp_pt = pt; tmp_pt < pt + powery*nb_lpts; tmp_pt += nb_lpts )
for ( dpix = tmp_pt; dpix < tmp_pt + powerx; dpix++ ) *dpix = new_pixel ;
}
if ( Vapi && ( ( iter++ & 0x0F ) == 0x0F ) )
{
pc = (short) ( ( 100L * (long)(y - params->y1) ) / (long)(params->y2 - power- params->y1) ) ;
if ( Vapi->PrSetProgEx )
{
cancel = Vapi->PrSetProgEx( pc ) ;
}
else
Vapi->PrSetProg( pc ) ;
}
}
return( cancel ? ELDV_CANCELLED : ELDV_NOERROR ) ;
}
#pragma warn -par
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
LDV_STATUS status ;
CHK_VAPIVERSION( Vapi ) ;
if ( ( in->RasterFormat & CAPS ) == 0 ) return( ELDV_IMGFORMATMISMATCH ) ;
/* if ( VDIHandle == -1 ) VDIHandle = vdihandle() ; (inutile) */
switch( in->Raster.fd_nplanes )
{
case 16 : status = Run16( in, params ) ;
break ;
/*
case 24 : status = Run24( in, params ) ;
break ;
*/
case 32 : status = Run32( in, params ) ;
break ;
default : status = ELDV_NBPLANESNOTSUPPORTED ;
break ;
}
return( status ) ;
}
#pragma warn +par
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
return( Run( in, params, out ) ) ;
}
int main(void)
{
ldg_init( Ldg ) ;
return( 0 ) ;
}

Binary file not shown.

View File

@@ -0,0 +1,12 @@
PIXEL.LDV
;.C[-Y- -G+]
;.L[-Y-]
=
pcstart.o
PIXEL.C
;PIXEL.S
pcgemlib.lib
pcstdlib.lib
pctoslib.lib
..\..\ldg.lib
..\..\mt_aes.lib

View File

@@ -0,0 +1,74 @@
.EXPORT Pixelize16
MACRO GET_FRGB16
MOVE.W (A0),D0
MOVE.W D0,D1
ROL.W #5,D1
ANDI.W #$1F,D1 ; D1.W = Composante ROUGE
MOVE.W D0,D2
LSR.W #5,D2
ANDI.W #$3F,D2 ; D2.W = Composante VERTE (0...63)
MOVE.W D0,D3
ANDI.W #$1F,D3 ; D3.W = Composante BLEU (0...31)
ENDM
MACRO SET_FRGB16
MOVE.W D3,D0 ; D3 = Composante Bleu
LSL.W #5,D2
ADD.W D2,D0 ; D0 += Composante Verte
ROR.W #5,D1
ADD.W D1,D0 ; D0 += Composante Rouge
ENDM
*unsigned short Pixelize16(unsigned short *pt, long nb_lpts, short powerx, short powery)
*
*{
* unsigned long rsum = 0 ;
* unsigned long gsum = 0 ;
* unsigned long bsum = 0 ;
* unsigned long p2 = powerx * powery ;
* unsigned short val, pixel, *ptu ;
* unsigned short red, green, blue ;
* short x, y ;
*
* for ( y = 0; y < powery; y++ )
* {
* ptu = pt + y * nb_lpts ;
* for ( x = 0; x < powerx; x++, ptu++ )
* {
* val = *ptu ;
* red = val >> 11 ; /* Sur 5 bits */
* green = ( val >> 5 ) & 0x3F ; /* Sur 6 bits */
* blue = val & 0x1F ; /* Sur 5 bits */
* rsum += (unsigned long) red ;
* gsum += (unsigned long) green ;
* bsum += (unsigned long) blue ;
* }
* }
*
* red = (unsigned short) (rsum / p2) ;
* green = (unsigned short) (gsum / p2) ;
* blue = (unsigned short) (bsum / p2) ;
* pixel = RVB16( red, green, blue ) ;
*
* return( pixel ) ;
}
* unsigned short Pixelize16(unsigned short *pt, long nb_lpts, long power)
* D0 A0 D0 D1
Pixelize16:
MOVEM.L D0-D7/A0-A6,-(SP)
MOVE.L D0,D4
MOVE.L D1,D5
MOVE.L A0,A1
GET_FRGB16
MOVEM.L (SP)+,D0-D7/A0-A6 ; Restauration du contexte

View File

@@ -0,0 +1,187 @@
/*
*
*
* Version PureC / Gcc
*/
#define PCGEMLIB 1 /* mettre 1 si les utilisateurs de Pure C
* utilise les librairies GEM Pure C */
/* Fichiers headers */
#include <portab.h>
#if PCGEMLIB
#include <aes.h>
#include <vdi.h>
#else
#include <aesbind.h>
#include <vdibind.h>
#endif
#include <string.h>
#include <math.h>
#include "..\..\ldg.h"
#include "..\..\vapi.h"
#include "..\..\ldv.h"
#include "..\..\mt_aes.h"
/* Prototypages */
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi) ;
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
void OnClose(void) ;
/* Variables globales */
PROC Proc[] = {
"GetLDVCapabilities", "Capacit<EFBFBD>s du LDV", (void *)GetLDVCapabilities,
"PreRun", "Init du Run", (void *)PreRun,
"Run", "Fonction du LDV", (void *)Run,
"Preview", "Pre-Visu", (void *)Preview,
} ;
char Info[] = "LDV";
LDGLIB Ldg[] = {
0x0101, /* version de la lib, recommand<6E> */
4, /* nombre de fonction dans la lib */
Proc, /* Pointeurs vers nos fonctions */
Info, /* Information sur la lib */
0x0, /* Flags de la lib, obligatoire */
OnClose, /* Fermeture, liberation de VDIHandle */
};
#define CAPS (LDVF_SPECFORMAT | LDVF_SUPPORTPREVIEW | LDVF_SUPPORTPROG | LDVF_REALTIMEPARAMS | LDVF_SUPPORTCANCEL)
LDV_INFOS LdvInfos = {
(short) sizeof(LDV_INFOS), /* Taille de cette structure */
TLDV_MODIFYIMG, /* Type du LDV */
"Jean Lusetti", /* Auteurs */
{
{ 1, 1, CAPS }, /* Capacites pour 1 plan */
{ 2, 2, CAPS }, /* Capacites pour 2 plans */
{ 4, 4, CAPS }, /* Capacites pour 4 plans */
{ 8, 8, CAPS }, /* Capacites pour 8 plans */
{ 16, 16, CAPS }, /* Capacites pour 16 plans */
{ 24, 24, CAPS }, /* Capacites pour 24 plans */
{ 32, 32, CAPS }, /* Capacites pour 32 plans */
{ 0, 0, 0UL } /* Fin de la liste des capacites */
},
} ;
VAPI *Vapi = NULL ;
int VDIHandle = -1 ;
void OnClose(void)
{
if ( VDIHandle != -1 ) v_clsvwk( VDIHandle ) ;
VDIHandle = -1 ;
}
/*
* Fonctions de la librairie
*/
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi)
{
Vapi = vapi ;
return( &LdvInfos ) ;
}
int vdihandle(void)
{
int work_in[11], work_out[57], i ;
for ( i = 0; i < 10; work_in[i++] = 1 ) ;
work_in[10] = 2 ;
v_opnvwk( work_in, &i, work_out ) ;
return( i ) ;
}
#pragma warn -par
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
out->Raster.fd_w = in->Raster.fd_w ;
out->Raster.fd_h = in->Raster.fd_h ;
return( ELDV_NOERROR ) ;
}
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
float angle, phi ;
float amplitude ;
int xy[8] ;
short line ;
short xoffset ;
short pc, cancel = 0 ;
if ( VDIHandle == -1 ) VDIHandle = vdihandle() ;
if (
( params->x1 != 0 ) || ( params->x2 != in->Raster.fd_w -1 ) ||
( params->y1 != 0 ) || ( params->y2 != in->Raster.fd_h -1 )
)
{
/* Bloc a l'interieur de l'image */
xy[0] = xy[4] = 0 ;
xy[1] = xy[5] = 0 ;
xy[2] = xy[6] = in->Raster.fd_w - 1 ;
xy[3] = xy[7] = in->Raster.fd_h - 1 ;
vro_cpyfm( VDIHandle, S_ONLY, xy, &in->Raster, &out->Raster ) ;
}
else
if ( Vapi && Vapi->RaImgWhite ) Vapi->RaImgWhite( &out->Raster ) ;
amplitude = (float)params->Param[0].s / 10.0 ;
phi = M_PI * (float)params->Param[1].s / 10.0 / (float)(params->y2 - params->y1) ;
for ( line = params->y1 ; !cancel && (line <= params->y2); line++ )
{
angle = (float) (line - params->y1) * phi ;
xoffset = (short) (amplitude * ( 1+ sin( angle ) ) ) ;
if ( params->x2 - xoffset < params->x1 ) xoffset = params->x2 - params->x1 ;
if ( params->x2 - xoffset > in->Raster.fd_w - 1 ) xoffset = params->x2 - in->Raster.fd_w + 1 ;
if ( params->x1 + xoffset > out->Raster.fd_w - 1 ) xoffset = out->Raster.fd_w - params->x1 - 1 ;
if ( params->x2 < params->x1 + xoffset ) xoffset = params->x2 - params->x1 ;
xy[0] = params->x1 ;
xy[1] = line ;
xy[2] = params->x2 - xoffset ;
xy[3] = line ;
xy[4] = params->x1 + xoffset ;
xy[5] = line ;
xy[6] = params->x2 ;
xy[7] = line ;
vro_cpyfm( VDIHandle, S_ONLY, xy, &in->Raster, &out->Raster ) ;
if ( Vapi && ( line & 0x0F) == 0x0F )
{
/* Appelle la routine de progression une fois sur 16 */
/* NB : en mode preview, VISION ignorera cet appel, */
/* inutile donc de s'en soucier */
pc = (short) ( ( 100L * (long)(line - params->y1) ) / (long)(params->y2 - params->y1) ) ;
if ( Vapi->PrSetProgEx )
{
cancel = Vapi->PrSetProgEx( pc ) ;
}
else
Vapi->PrSetProg( pc ) ;
}
}
return( cancel ? ELDV_CANCELLED : ELDV_NOERROR ) ;
}
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
return( Run( in, params, out ) ) ;
}
#pragma warn +par
int main(void)
{
ldg_init( Ldg ) ;
return( 0 ) ;
}

Binary file not shown.

View File

@@ -0,0 +1,12 @@
xwave.ldv
;.C[-Y- -G+]
;.L[-Y-]
=
pcstart.o
xwave.c
pcgemlib.lib
pcstdlib.lib
pctoslib.lib
pcfltlib.lib
..\..\ldg.lib
..\..\mt_aes.lib

View File

@@ -0,0 +1,269 @@
/*
*
*
* Version PureC / Gcc
*/
#define PCGEMLIB 1 /* mettre 1 si les utilisateurs de Pure C
* utilise les librairies GEM Pure C */
/* Fichiers headers */
#include <portab.h>
#if PCGEMLIB
#include <aes.h>
#include <vdi.h>
#else
#include <aesbind.h>
#include <vdibind.h>
#endif
#include <string.h>
#include <stdlib.h>
#include "..\..\ldg.h"
#include "..\..\vapi.h"
#include "..\..\ldv.h"
#include "..\..\mt_aes.h"
/* Prototypages */
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi) ;
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
void OnClose(void) ;
/* Variables globales */
PROC Proc[] = {
"GetLDVCapabilities", "Capacit<EFBFBD>s du LDV", (void *)GetLDVCapabilities,
"PreRun", "Init du Run", (void *)PreRun,
"Run", "Fonction du LDV", (void *)Run,
"Preview", "Pre-Visu", (void *)Preview,
} ;
char Info[] = "LDV";
LDGLIB Ldg[] = {
0x0100, /* version de la lib, recommand<6E> */
4, /* nombre de fonction dans la lib */
Proc, /* Pointeurs vers nos fonctions */
Info, /* Information sur la lib */
0x0, /* Flags de la lib, obligatoire */
OnClose, /* Fermeture, liberation de VDIHandle */
};
#define BP_CAPS (LDVF_ATARIFORMAT | LDVF_SUPPORTPREVIEW | LDVF_SUPPORTPROG | LDVF_REALTIMEPARAMS | LDVF_SUPPORTCANCEL | LDVF_NOSELECTION)
#define TC_CAPS (LDVF_SPECFORMAT | LDVF_SUPPORTPREVIEW | LDVF_SUPPORTPROG | LDVF_REALTIMEPARAMS | LDVF_SUPPORTCANCEL)
LDV_INFOS LdvInfos = {
(short) sizeof(LDV_INFOS), /* Taille de cette structure */
TLDV_MODIFYIMG, /* Type du LDV */
"Jean Lusetti", /* Auteurs */
{
{ 1, 1, BP_CAPS }, /* Capacites pour 1 plan */
{ 2, 2, BP_CAPS }, /* Capacites pour 2 plans */
{ 4, 4, BP_CAPS }, /* Capacites pour 4 plans */
{ 8, 8, BP_CAPS }, /* Capacites pour 8 plans */
{ 16, 16, TC_CAPS }, /* Capacites pour 16 plans */
{ 32, 32, TC_CAPS }, /* Capacites pour 32 plans */
{ 0, 0, 0UL } /* Fin de la liste des capacites */
},
} ;
VAPI *Vapi = NULL ;
int VDIHandle = -1 ;
void OnClose(void)
{
if ( VDIHandle != -1 ) v_clsvwk( VDIHandle ) ;
VDIHandle = -1 ;
}
/*
* Fonctions de la librairie
*/
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi)
{
Vapi = vapi ;
return( &LdvInfos ) ;
}
int vdihandle(void)
{
int work_in[11], work_out[57], i ;
for ( i = 0; i < 10; work_in[i++] = 1 ) ;
work_in[10] = 2 ;
v_opnvwk( work_in, &i, work_out ) ;
return( i ) ;
}
#pragma warn -par
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
out->Raster.fd_w = in->Raster.fd_w ;
out->Raster.fd_h = in->Raster.fd_h ;
return( ELDV_NOERROR ) ;
}
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
MFDB dst_line ;
int xy[8] ;
long *pt32_in, *pt32_out ;
short *pt16_in, *pt16_out ;
unsigned char *pt8_in = NULL, *pt8_out ;
long wscale, wout, wpixel, xpixel ;
long angle, depth, src_line32, yoffset, lo_line_in, lo_line_out ;
short line, y1, y2 ;
short wlen, pc, cancel = 0 ;
if ( Vapi->Header.Version < 0x102 ) return( ELDV_BADVAPIVERSION ) ;
if ( VDIHandle == -1 ) VDIHandle = vdihandle() ;
if (
( params->x1 != 0 ) || ( params->x2 != in->Raster.fd_w -1 ) ||
( params->y1 != 0 ) || ( params->y2 != in->Raster.fd_h -1 )
)
{
xy[0] = xy[4] = 0 ;
xy[1] = xy[5] = 0 ;
xy[2] = xy[6] = in->Raster.fd_w - 1 ;
xy[3] = xy[7] = in->Raster.fd_h - 1 ;
vro_cpyfm( VDIHandle, S_ONLY, xy, &in->Raster, &out->Raster ) ;
xy[0] = params->x1 ; xy[1] = params->y1 ;
xy[2] = params->x2 ; xy[3] = params->y2 ;
xy[4] = params->x1 ; xy[5] = params->y1 ;
xy[6] = params->x2 ; xy[7] = params->y2 ;
vro_cpyfm( VDIHandle, ALL_WHITE, xy, &in->Raster, &out->Raster ) ;
}
else
Vapi->RaImgWhite( &out->Raster ) ;
wpixel = 1+params->x2-params->x1 ;
lo_line_in = ALIGN16( in->Raster.fd_w ) ;
lo_line_out = ALIGN16( out->Raster.fd_w ) ;
angle = (long) params->Param[0].s ;
depth = (long) params->Param[1].s ;
y1 = (long) params->y1 + (long) ( ((long)(params->y2 - params->y1)*angle) / 1000 ) ;
y2 = (long) params->y1 + params->y2 - y1 ;
yoffset = ((long) (params->y2 - params->y1)) << 16 ;
yoffset /= (long) (y2 - y1 ) ;
if ( y1 > y2 )
{
short tmp ;
tmp = y1 ;
y1 = y2 ;
y2 = tmp ;
src_line32 = params->y2 ;
src_line32 <<= 16 ;
}
else
{
src_line32 = params->y1 ;
src_line32 <<= 16 ;
}
/* Mode bitplan : allocation memoire pour conversion index <--> format ATARI */
/* pt16_... est utilise pour le mode 16 bits et le mode bit-plan (avec reajustement) */
if ( in->Raster.fd_nplanes <= 8 )
{
size_t win, wout ;
win = ALIGN16( in->Raster.fd_w ) ;
wout = ALIGN16( out->Raster.fd_w ) ;
pt8_in = (unsigned char *) malloc( win + wout ) ; /* Car on alloue aussi pour la remise a l'echelle */
if ( pt8_in == NULL ) return ELDV_NOTENOUGHMEMORY ;
pt8_out = pt8_in + in->Raster.fd_w ;
/* Pour conversions conversion index --> format ATARI (Vapi->RaInd2raster) */
memcpy( &dst_line, &out->Raster, sizeof(MFDB) ) ;
dst_line.fd_h = 1 ;
lo_line_in /= ( 16 / in->Raster.fd_nplanes ) ;
lo_line_out /= ( 16 / in->Raster.fd_nplanes ) ;
pt16_in = (short *) in->Raster.fd_addr ;
pt16_out = (short *) out->Raster.fd_addr ;
pt16_out += (long)(y1) * lo_line_out ;
}
else if ( in->Raster.fd_nplanes == 16 )
{
pt16_in = (short *) in->Raster.fd_addr ;
pt16_out = (short *) out->Raster.fd_addr ;
pt16_out += (long)(y1) * lo_line_out ;
}
else
{
pt32_in = (long *) in->Raster.fd_addr ;
pt32_out = (long *) out->Raster.fd_addr ;
pt32_out += (long)(y1) * lo_line_out ;
}
wscale = ( wpixel * depth ) / 100L ;
wlen = ALIGN16( 1+params->x2 ) ;
for ( line = y1 ; !cancel && (line <= y2); line++, src_line32 += yoffset )
{
wout = wpixel - ( wscale * (line-y1) / (y2-y1) ) ;
xpixel = params->x1 + ( ( wpixel - wout ) >> 1 ) ;
switch( in->Raster.fd_nplanes )
{
case 1 :
case 2 :
case 4 :
case 8 :
Vapi->RaRaster2Ind( pt16_in + (src_line32 >> 16) * lo_line_in, wlen, in->Raster.fd_nplanes, pt8_in ) ;
memset( pt8_out, 0, xpixel ) ;
Vapi->MeSCopyMemory8( pt8_out + xpixel, pt8_in + params->x1, wout, wpixel ) ;
dst_line.fd_addr = pt16_out ;
Vapi->RaInd2RasterInit( &dst_line, xpixel+wout-1 ) ;
Vapi->RaInd2Raster( pt8_out, xpixel+wout-1 ) ;
pt16_out += lo_line_out ;
break ;
case 16 : Vapi->MeSCopyMemory16( pt16_out + xpixel,
pt16_in + (long)params->x1 + (src_line32 >> 16) * lo_line_in,
wout, wpixel ) ;
pt16_out += lo_line_out ;
break ;
case 32 : Vapi->MeSCopyMemory32( pt32_out + xpixel,
pt32_in + (long)params->x1 + (src_line32 >> 16) * lo_line_in,
wout, wpixel ) ;
pt32_out += lo_line_out ;
default: break ;
}
if ( Vapi && ( line & 0x0F) == 0x0F )
{
/* Appelle la routine de progression une fois sur 16 */
/* NB : en mode preview, VISION ignorera cet appel, */
/* inutile donc de s'en soucier */
pc = (short) ( ( 100L * (long)(line - y1) ) / (long)(y2 - y1) ) ;
cancel = Vapi->PrSetProgEx( pc ) ;
}
}
if ( pt8_in ) free( pt8_in ) ;
return( cancel ? ELDV_CANCELLED : ELDV_NOERROR ) ;
}
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
return( Run( in, params, out ) ) ;
}
#pragma warn +par
int main(void)
{
ldg_init( Ldg ) ;
return( 0 ) ;
}

Binary file not shown.

View File

@@ -0,0 +1,12 @@
YPERSC.LDV
;.C[-Y- -G+]
;.L[-Y-]
=
pcstart.o
YPERSC.C
pcgemlib.lib
pcstdlib.lib
pctoslib.lib
pcfltlib.lib
..\..\ldg.lib
..\..\mt_aes.lib

View File

@@ -0,0 +1,187 @@
/*
*
*
* Version PureC / Gcc
*/
#define PCGEMLIB 1 /* mettre 1 si les utilisateurs de Pure C
* utilise les librairies GEM Pure C */
/* Fichiers headers */
#include <portab.h>
#if PCGEMLIB
#include <aes.h>
#include <vdi.h>
#else
#include <aesbind.h>
#include <vdibind.h>
#endif
#include <string.h>
#include <math.h>
#include "..\..\ldg.h"
#include "..\..\vapi.h"
#include "..\..\ldv.h"
#include "..\..\mt_aes.h"
/* Prototypages */
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi) ;
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
void OnClose(void) ;
/* Variables globales */
PROC Proc[] = {
"GetLDVCapabilities", "Capacit<EFBFBD>s du LDV", (void *)GetLDVCapabilities,
"PreRun", "Init du Run", (void *)PreRun,
"Run", "Fonction du LDV", (void *)Run,
"Preview", "Pre-Visu", (void *)Preview,
} ;
char Info[] = "LDV";
LDGLIB Ldg[] = {
0x0100, /* version de la lib, recommand<6E> */
4, /* nombre de fonction dans la lib */
Proc, /* Pointeurs vers nos fonctions */
Info, /* Information sur la lib */
0x0, /* Flags de la lib, obligatoire */
OnClose, /* Fermeture, liberation de VDIHandle */
};
#define CAPS (LDVF_SPECFORMAT | LDVF_SUPPORTPREVIEW | LDVF_SUPPORTPROG | LDVF_REALTIMEPARAMS | LDVF_SUPPORTCANCEL)
LDV_INFOS LdvInfos = {
(short) sizeof(LDV_INFOS), /* Taille de cette structure */
TLDV_MODIFYIMG, /* Type du LDV */
"Jean Lusetti", /* Auteurs */
{
{ 1, 1, CAPS }, /* Capacites pour 1 plan */
{ 2, 2, CAPS }, /* Capacites pour 2 plans */
{ 4, 4, CAPS }, /* Capacites pour 4 plans */
{ 8, 8, CAPS }, /* Capacites pour 8 plans */
{ 16, 16, CAPS }, /* Capacites pour 16 plans */
{ 24, 24, CAPS }, /* Capacites pour 24 plans */
{ 32, 32, CAPS }, /* Capacites pour 32 plans */
{ 0, 0, 0UL } /* Fin de la liste des capacites */
},
} ;
VAPI *Vapi = NULL ;
int VDIHandle = -1 ;
void OnClose(void)
{
if ( VDIHandle != -1 ) v_clsvwk( VDIHandle ) ;
VDIHandle = -1 ;
}
/*
* Fonctions de la librairie
*/
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi)
{
Vapi = vapi ;
return( &LdvInfos ) ;
}
int vdihandle(void)
{
int work_in[11], work_out[57], i ;
for ( i = 0; i < 10; work_in[i++] = 1 ) ;
work_in[10] = 2 ;
v_opnvwk( work_in, &i, work_out ) ;
return( i ) ;
}
#pragma warn -par
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
out->Raster.fd_w = in->Raster.fd_w ;
out->Raster.fd_h = in->Raster.fd_h ;
return( ELDV_NOERROR ) ;
}
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
float angle, phi ;
float amplitude ;
int xy[8] ;
short row ;
short yoffset ;
short pc, cancel = 0 ;
if ( VDIHandle == -1 ) VDIHandle = vdihandle() ;
if (
( params->x1 != 0 ) || ( params->x2 != in->Raster.fd_w -1 ) ||
( params->y1 != 0 ) || ( params->y2 != in->Raster.fd_h -1 )
)
{
/* Bloc a l'interieur de l'image */
xy[0] = xy[4] = 0 ;
xy[1] = xy[5] = 0 ;
xy[2] = xy[6] = in->Raster.fd_w - 1 ;
xy[3] = xy[7] = in->Raster.fd_h - 1 ;
vro_cpyfm( VDIHandle, S_ONLY, xy, &in->Raster, &out->Raster ) ;
}
else
if ( Vapi && Vapi->RaImgWhite ) Vapi->RaImgWhite( &out->Raster ) ;
amplitude = (float)params->Param[0].s / 10.0 ;
phi = M_PI * (float)params->Param[1].s / 10.0 / (float)(params->x2 - params->x1) ;
for ( row = params->x1 ; !cancel && (row <= params->x2); row++ )
{
angle = (float) (row - params->x1) * phi ;
yoffset = (short) (amplitude * ( 1+ sin( angle ) ) ) ;
if ( params->y2 - yoffset < params->y1 ) yoffset = params->y2 - params->y1 ;
if ( params->y2 - yoffset > in->Raster.fd_h - 1 ) yoffset = params->y2 - in->Raster.fd_h + 1 ;
if ( params->y1 + yoffset > out->Raster.fd_h - 1 ) yoffset = out->Raster.fd_h - params->y1 - 1 ;
if ( params->y2 < params->y1 + yoffset ) yoffset = params->y2 - params->y1 ;
xy[0] = row ;
xy[1] = params->y1 ;
xy[2] = row ;
xy[3] = params->y2 - yoffset ;
xy[4] = row ;
xy[5] = params->y1 + yoffset ;
xy[6] = row ;
xy[7] = params->y2 ;
vro_cpyfm( VDIHandle, S_ONLY, xy, &in->Raster, &out->Raster ) ;
if ( Vapi && ( row & 0x0F) == 0x0F )
{
/* Appelle la routine de progression une fois sur 16 */
/* NB : en mode preview, VISION ignorera cet appel, */
/* inutile donc de s'en soucier */
pc = (short) ( ( 100L * (long)(row - params->x1) ) / (long)(params->x2 - params->x1) ) ;
if ( Vapi->PrSetProgEx )
{
cancel = Vapi->PrSetProgEx( pc ) ;
}
else
Vapi->PrSetProg( pc ) ;
}
}
return( cancel ? ELDV_CANCELLED : ELDV_NOERROR ) ;
}
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
return( Run( in, params, out ) ) ;
}
#pragma warn +par
int main(void)
{
ldg_init( Ldg ) ;
return( 0 ) ;
}

Binary file not shown.

View File

@@ -0,0 +1,12 @@
ywave.ldv
;.C[-Y- -G+]
;.L[-Y-]
=
pcstart.o
ywave.c
pcgemlib.lib
pcstdlib.lib
pctoslib.lib
pcfltlib.lib
..\..\ldg.lib
..\..\mt_aes.lib

View File

@@ -0,0 +1,852 @@
/*
*
*
* Version PureC / Gcc
*/
#define PCGEMLIB 1 /* mettre 1 si les utilisateurs de Pure C
* utilise les librairies GEM Pure C */
/* Fichiers headers */
#include <stdio.h> /* Forget this and sprintf will badly format numbers */
#include <portab.h>
#if PCGEMLIB
#include <aes.h>
#include <vdi.h>
#else
#include <aesbind.h>
#include <vdibind.h>
#endif
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include "..\..\ldg.h"
#include "..\..\vapi.h"
#include "..\..\ldv.h"
#include "..\..\mt_aes.h"
/* Prototypages */
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi) ;
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
void OnClose(void) ;
/* Variables globales */
PROC Proc[] = {
"GetLDVCapabilities", "LDV Capabilities", (void *)GetLDVCapabilities,
"PreRun", "Run Initiliaze", (void *)PreRun,
"Run", "LDV Feature", (void *)Run,
"Preview", "Preview", (void *)Preview,
} ;
char Info[] = "LDV";
LDGLIB Ldg[] = {
0x0100, /* LDV version */
4, /* Number of functions in the lib */
Proc, /* Pointers to LDV functions */
Info, /* Library Information */
0x0, /* Lib flags, mandatory */
OnClose, /* Closing, free VDIHandle */
};
#define BP_CAPS (LDVF_ATARIFORMAT | LDVF_SUPPORTPREVIEW | LDVF_SUPPORTPROG | LDVF_REALTIMEPARAMS | LDVF_SUPPORTCANCEL | LDVF_NOSELECTION)
#define TC_CAPS (LDVF_SPECFORMAT | LDVF_SUPPORTPREVIEW | LDVF_SUPPORTPROG | LDVF_REALTIMEPARAMS | LDVF_SUPPORTCANCEL | LDVF_NOSELECTION)
LDV_INFOS LdvInfos = {
(short) sizeof(LDV_INFOS), /* Size of this structure */
TLDV_MODIFYIMG, /* LDV Type */
"Jean Lusetti", /* Authors */
{
{ 1, 1, BP_CAPS }, /* 1 bit-plane capabilities */
{ 2, 2, BP_CAPS }, /* 2 bit-plane capabilities */
{ 4, 4, BP_CAPS }, /* 4 bit-plane capabilities */
{ 8, 8, BP_CAPS }, /* 8 bit-plane capabilities */
{ 16, 16, TC_CAPS }, /* 16 bit-plane capabilities */
{ 32, 32, TC_CAPS }, /* 32 bit-plane capabilities */
{ 0, 0, 0UL } /* End of capabilities list */
},
} ;
VAPI *Vapi = NULL ;
#define ITRIGO_ARRAY_NBITS 14
#define ITRIGO_ARRAY_SIZE (1 << ITRIGO_ARRAY_NBITS)
#define ITRIGO_ANGLE_MAX (ITRIGO_ARRAY_SIZE-1)
#define QUARTER (ITRIGO_ARRAY_SIZE/4)
#define ANGLE_ADD (M_PI/2.0/(double)QUARTER) ;
long* pre_cosin = NULL ; /* Array of pre-computed cosinus/sinus values */
long* pre_loffset = NULL ; /* To hold pre-computation of line offsets */
int lo_w=0, lo_h=0, lo_nplanes=0 ; /* Current parameters for line offset */
unsigned long VapiLogLevel = LL_DISABLED ;
unsigned long ProcMask = 0L ;
short UseSym = -1 ; /* By default use symmetry to save CPU calculations */
/* On Aranym, this is usually slower, so there is a */
/* Setting in bhole.ini to force no symetry usage */
/* Macro to access pre-computed cosinus/sinus array */
/* Sinus is right after cosinus value */
#define COS(i) (pre_cosin[(i)<<1])
#define SIN(i) (pre_cosin[1 + ( (i)<<1 )])
/* Back Hole computation parameters are not passed to speed up calculations, */
/* They are global to the module */
/* Black Hole symmetry rotation */
typedef struct _RECT
{
short x ;
short y ;
short w ;
short h ;
}
RECT, *PRECT ;
typedef struct _BH_SPROPERTIES
{
short estdpc ; /* Estimated duration in % (100 being the one without using symmetry) */
short nrect ;
short nsym ;
RECT rect[9] ;
}
BH_SPROPERTIES, *PBH_SPROPERTIES ;
extern long bh_xd, bh_yd, bh_rd2, bh_xs, bh_ys, bh_ref ;
extern long bh_xc, bh_yc ;
extern short bh_out_w, bh_out_h, bh_in_w, bh_in_h ;
extern short bh_out_x, bh_out_y ;
short bh_pc, bh_nrect ;
/* This is the routine address that will operate on a line basis */
static void (*BHLRoutine)(short use_sym, void* in, void* out) ;
/* Specific 68030 and FPU routines */
/* In BHOLE.S */
extern void BHL32_68030(short use_sym, void* in, void* out) ;
extern void BHL16_68030(short use_sym, void* in, void* out) ;
extern void BHLInd_68030(short use_sym, void* in, void* out) ;
extern void BHL32_F68030(short use_sym, void* in, void* out) ;
extern void BHL16_F68030(short use_sym, void* in, void* out) ;
extern void BHLInd_F68030(short use_sym, void* in, void* out) ;
extern void lcosin_fpu(long i, long* pcs) ;
/* GET/SET pixel macros for True Color 16 and 32bit */
#define SET_TCPIXEL(p,x,y,val) (p[pre_loffset[y]+x]=val)
#define GET_TCPIXEL(p,x,y) (p[pre_loffset[y]+x])
/* Rotation by 90° macro */
#define R90(x,y) { long _x=x; x=-y; y=_x; }
/* Macro to initialize calculations for a line */
#define BH_INIT_LINE\
bh_xd = bh_out_x-bh_xc ;\
bh_rd2 = (bh_xd*bh_xd + bh_yd*bh_yd) ;\
/* This is the routine that computes the resulting pixel (bh_xs,bh_ys) in source image */
/* From the pixel (bh_xd, bh_yd) in destination image */
/* (bh_xc,bh_yc) is the center pixel of the back hole */
/* This routine also returns if the resulting pixel is in the source image */
int rBH_68000(void)
{
int not_in_range = 1 ;
long alpha ;
bh_rd2 += ( bh_xd << 1 ) + 1 ;
alpha = bh_ref / (1+bh_rd2) ;
alpha &= ITRIGO_ANGLE_MAX ;
bh_xs = bh_xd * COS(alpha) - bh_yd * SIN(alpha) ;
bh_xs >>= 16 ;
if ( (bh_xs >= -bh_xc) && (bh_xs < -bh_xc+bh_in_w) )
{
bh_ys = bh_xd * SIN(alpha) + bh_yd * COS(alpha) ;
bh_ys >>= 16 ;
if ( (bh_ys >= -bh_yc) && (bh_ys < -bh_yc+bh_in_h) )
not_in_range = 0 ;
}
return not_in_range ;
}
/* For 68000/bit-planes organization: */
/* This routine returns the value of the pixel index in the source image */
/* Assuming (bh_xs,bh_ys) is within the source image */
#pragma warn -par
void BHLInd_68000(short use_sym, void* in, void* out)
{
unsigned char* in_ptr = (unsigned char*) in ;
unsigned char* out_ptr = (unsigned char*) out ;
short x ;
for ( x = bh_out_x; x < bh_out_w; x++, bh_xd++ )
{
if ( rBH_68000() == 0 )
out_ptr[x] = in_ptr[pre_loffset[bh_ys+bh_yc] + bh_xs+bh_xc] ;
else
out_ptr[x] = 0 ;
}
}
#pragma warn +par
/* For 68000/16bit TrueColor organization: */
/* This routine returns the value of the pixel index in the source image */
/* Assuming (bh_xs,bh_ys) is within the source image */
void BHL16_68000(short use_sym, void* in, void* out)
{
unsigned int* in_ptr = (unsigned int*) in ;
unsigned int* out_ptr = (unsigned int*) out ;
short x ;
if (use_sym)
{
unsigned long save_bh_xd, save_bh_yd ;
short n ;
for ( x = bh_out_x; x <= bh_out_x+bh_out_w/2; x++, bh_xd++ )
{
/* Save bh_xd and bh_yd as they will change */
save_bh_xd = bh_xd ;
save_bh_yd = bh_yd ;
if ( rBH_68000() == 0 ) /* Compute 1st pixel with Black Hole formula */
SET_TCPIXEL(out_ptr, bh_xd+bh_xc, bh_yd+bh_yc, GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc)) ;
else
SET_TCPIXEL(out_ptr, bh_xd+bh_xc, bh_yd+bh_yc, 0xFFFF) ;
/* Deduce 2nd, 3rd and 4th pixel */
for (n=0; n < 3; n++)
{
R90(bh_xd, bh_yd) ;
R90(bh_xs, bh_ys) ;
if ( (bh_xd>=-bh_xc) && (bh_xd < -bh_xc+bh_in_w) && (bh_yd >= -bh_yc) && (bh_yd < -bh_yc+bh_in_h))
{
if ( (bh_xs>=-bh_xc) && (bh_xs < -bh_xc+bh_in_w) && (bh_ys >= -bh_yc) && (bh_ys < -bh_yc+bh_in_h))
SET_TCPIXEL(out_ptr, bh_xd+bh_xc, bh_yd+bh_yc, GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc)) ;
else
SET_TCPIXEL(out_ptr, bh_xd+bh_xc, bh_yd+bh_yc, 0xFFFF) ;
}
}
/* Restore bh_xd and bh_yd */
bh_xd = save_bh_xd ;
bh_yd = save_bh_yd ;
}
}
else
{
for ( x = bh_out_x; x < bh_out_x+bh_out_w; x++, bh_xd++ )
{
if ( rBH_68000() == 0 )
out_ptr[x] = in_ptr[pre_loffset[bh_ys+bh_yc] + bh_xs+bh_xc] ;
else
out_ptr[x] = 0xFFFF ;
}
}
}
/* For 68000/32bit TrueColor organization: */
/* This routine returns the value of the pixel index in the source image */
/* Assuming (bh_xs,bh_ys) is within the source image */
void BHL32_68000(short use_sym, void* in, void* out)
{
unsigned long* in_ptr = (unsigned long*) in ;
unsigned long* out_ptr = (unsigned long*) out ;
short x ;
if (use_sym)
{
unsigned long save_bh_xd, save_bh_yd ;
short n ;
for ( x = bh_out_x; x <= bh_out_x+bh_out_w/2; x++, bh_xd++ )
{
/* Save bh_xd and bh_yd as they will change */
save_bh_xd = bh_xd ;
save_bh_yd = bh_yd ;
if ( rBH_68000() == 0 ) /* Compute 1st pixel with Black Hole formula */
SET_TCPIXEL(out_ptr, bh_xd+bh_xc, bh_yd+bh_yc, GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc)) ;
else
SET_TCPIXEL(out_ptr, bh_xd+bh_xc, bh_yd+bh_yc, 0xFFFFFFFFL) ;
/* Deduce 2nd, 3rd and 4th pixel */
for (n=0; n < 3; n++)
{
R90(bh_xd, bh_yd) ;
R90(bh_xs, bh_ys) ;
if ( (bh_xd>=-bh_xc) && (bh_xd < -bh_xc+bh_in_w) && (bh_yd >= -bh_yc) && (bh_yd < -bh_yc+bh_in_h))
{
if ( (bh_xs>=-bh_xc) && (bh_xs < -bh_xc+bh_in_w) && (bh_ys >= -bh_yc) && (bh_ys < -bh_yc+bh_in_h))
SET_TCPIXEL(out_ptr, bh_xd+bh_xc, bh_yd+bh_yc, GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc)) ;
else
SET_TCPIXEL(out_ptr, bh_xd+bh_xc, bh_yd+bh_yc, 0xFFFFFFFFL) ;
}
}
/* Restore bh_xd and bh_yd */
bh_xd = save_bh_xd ;
bh_yd = save_bh_yd ;
}
}
else
{
for ( x = bh_out_x; x < bh_out_x+bh_out_w; x++, bh_xd++ )
{
if ( rBH_68000() == 0 )
out_ptr[x] = in_ptr[pre_loffset[bh_ys+bh_yc] + bh_xs+bh_xc] ;
else
out_ptr[x] = 0xFFFFFFFFL ;
}
}
}
void lcosin(long i, long* pcs)
{
double angle = i*ANGLE_ADD ;
pcs[0] = (long) (65536.0 * cos(angle)) ;
pcs[1] = (long) (65536.0 * sin(angle)) ;
}
int InitTrigo(int fpu)
{
void (*rlcosin)(long i, long* pcs) ;
long cs[2] ;
long q, i;
clock_t t0 ;
/* if ( pre_cosin[0] == 65536L ) return 0 ; Used to detect init done before dynamic allocation design */
if ( pre_cosin ) return 0 ;
pre_cosin = (long*) calloc( ITRIGO_ARRAY_SIZE, 2*sizeof(long) ) ;
if ( pre_cosin == NULL ) return -1 ;
t0 = clock() ;
if (fpu) rlcosin = lcosin_fpu ;
else rlcosin = lcosin ;
for ( i = 0; i < QUARTER; i++ )
{
rlcosin( i, cs ) ;
COS(i) = cs[0] ;
SIN(i) = cs[1] ;
q = QUARTER ;
/* Set [PI/2;PI] */
COS(q+i) = -SIN(i) ;
SIN(q+i) = COS(i) ;
q += QUARTER ;
/* Set [PI;3*PI/2] */
COS(q+i) = -COS(i) ;
SIN(q+i) = -SIN(i) ;
q += QUARTER ;
/* Set [3*PI/2; 2*PI] */
COS(q+i) = COS(i) ;
SIN(q+i) = -SIN(i) ;
}
if (Vapi && Vapi->LoDoLog)
Vapi->LoDoLog(LL_INFO, "IniTrigo%s done in %ldms", fpu ? "(FPU)":"", 1000L * (clock()-t0)/CLK_TCK) ;
return 0 ;
}
/* Called when LDV is loaded, take this opportunity to get some */
/* Info about system: VAPI version and CPU/FPU availability */
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi)
{
Vapi = vapi ;
VapiLogLevel = LL_DISABLED ;
if ( Vapi && (Vapi->Header.Version >= 0x0104) && Vapi->LoDoLog && Vapi->LoGetLogLevel )
{
VapiLogLevel = Vapi->LoGetLogLevel() ;
if (Vapi->CoGetProcessors)
ProcMask = Vapi->CoGetProcessors() ;
if (ProcMask & CO_HAS_030)
Vapi->LoDoLog(LL_INFO, "%s", "68030 processor available") ;
if (ProcMask & CO_HAS_FPU)
Vapi->LoDoLog(LL_INFO, "%s", "Floating Point unit available") ;
}
return( &LdvInfos ) ;
}
/* Free allocated RunTime stuff */
void OnClose(void)
{
if ( pre_cosin ) free( pre_cosin ) ;
pre_cosin = NULL ;
if ( pre_loffset ) free( pre_loffset ) ;
pre_loffset = NULL ;
}
/* Pre-compute line offsets from source to speed-up computations */
int compute_loffset(MFDB* in, long** ppre_lo, int* plo_w, int* plo_h, int* plo_nplanes)
{
/* Sanity checks */
if ( (ppre_lo == NULL) || (plo_w == NULL) || (plo_h == NULL) || (plo_nplanes == NULL) )
return -2 ;
if ( *ppre_lo && (*plo_w == in->fd_w) && (*plo_h == in->fd_h) && (*plo_nplanes == in->fd_nplanes) )
{
/* Current line offsets are still valid */
return 0 ;
}
else
{
/* Need to compute line offsets */
*plo_w = *plo_h = *plo_nplanes = 0 ;
if (*ppre_lo) free(*ppre_lo) ;
*ppre_lo = (long*) malloc(sizeof(long) * (long)in->fd_h) ;
if (*ppre_lo)
{
long* pt_off ;
long add = (long) ALIGN16( in->fd_w ) ;
long offset = 0L ;
int y ;
pt_off = *ppre_lo ;
for ( y = 0; y < in->fd_h; y++ )
{
*pt_off++ = offset ;
offset += add ;
}
*plo_w = in->fd_w ;
*plo_h = in->fd_h ;
*plo_nplanes = in->fd_nplanes ;
return 0 ;
}
}
return -1 ;
}
#pragma warn -par
/* Just say that output image has same width/length than source */
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
out->Raster.fd_w = in->Raster.fd_w ;
out->Raster.fd_h = in->Raster.fd_h ;
return( ELDV_NOERROR ) ;
}
#pragma warn +par
/* Update progression window 1 time on 16 */
char check_prog(short y, short ymax)
{
char cancel = 0 ;
if ( ( y & 0x0F ) == 0 )
{
int pc = (short) ( ( 100L * (long)y ) / (long)ymax ) ;
cancel = Vapi->PrSetProgEx( bh_pc+pc/bh_nrect ) ;
}
return cancel ;
}
/* Initialize global variables for calculation */
void init_computation(short xc, short yc, long angle, MFDB* in, RECT* rect)
{
long maxrd2 ;
bh_xd = -xc ;
bh_yd = -yc ;
maxrd2 = bh_xd*bh_xd + bh_yd*bh_yd ;
if ( (ProcMask & (CO_HAS_030|CO_HAS_FPU)) == (CO_HAS_030|CO_HAS_FPU) )
maxrd2 = (long) sqrt(maxrd2) ;
bh_ref = (angle * maxrd2) ;
bh_xc = xc ;
bh_yc = yc ;
bh_in_w = in->fd_w ;
bh_in_h = in->fd_h ;
bh_out_x = rect->x ;
bh_out_y = rect->y ;
bh_out_w = rect->w ;
bh_out_h = rect->h ;
bh_yd = bh_out_y-bh_yc ;
}
/* 68000 routine for bit-plane images */
LDV_STATUS bpRun(MFDB *in, long angle, short xc, short yc, MFDB *out, RECT* rect, short use_sym)
{
MFDB dst_line ;
LDV_STATUS status = ELDV_NOERROR ;
size_t size_indexes, size_dst_line ;
short y ;
long wout, sizelout ;
unsigned char *index_in, *index_out, *out_ptr ;
char cancel = 0 ;
/* We will convert the whole image in indexes */
/* Allocate memory to convert then to bitplanes */
/* A line to destination tion */
size_indexes = (long) ALIGN16( in->fd_w ) ;
size_indexes *= (long) in->fd_h ;
size_dst_line = (long) ALIGN16( out->fd_w ) ;
index_in = (unsigned char *) malloc( size_indexes ) ;
if ( index_in == NULL ) return ELDV_NOTENOUGHMEMORY ;
index_out = (unsigned char *) malloc(size_dst_line) ;
if ( index_out == NULL )
{
free(index_in) ;
return ELDV_NOTENOUGHMEMORY ;
}
/* Convert all source to indexes */
Vapi->RaRaster2Ind( in->fd_addr, size_indexes, (long)in->fd_nplanes, index_in ) ;
memcpy( &dst_line, out, sizeof(MFDB) ) ;
dst_line.fd_wdwidth = out->fd_w / 16 ;
if ( out->fd_w % 16 ) dst_line.fd_wdwidth++ ;
dst_line.fd_h = 1 ;
wout = (long) ALIGN16( out->fd_w ) ;
out_ptr = out->fd_addr ;
sizelout = Vapi->RaGetImgSize( (long) dst_line.fd_w, (long) dst_line.fd_h, (long) out->fd_nplanes ) ;
init_computation(xc, yc, angle, in, rect) ;
for ( y = 0; !cancel && (y < out->fd_h); y++, bh_yd++, out_ptr += sizelout )
{
BH_INIT_LINE ;
BHLRoutine(use_sym, index_in, index_out) ;
dst_line.fd_addr = out_ptr ;
Vapi->RaInd2RasterInit( &dst_line, wout ) ;
Vapi->RaInd2Raster( index_out, wout ) ;
cancel = check_prog(y, out->fd_h) ;
}
free(index_in) ;
free(index_out) ;
if ( cancel ) status = ELDV_CANCELLED ;
return( status ) ;
}
/* 68000 routine for 16bit True Color images */
LDV_STATUS Run16(MFDB *in, long angle, short xc, short yc, MFDB *out, RECT* rect, short use_sym)
{
LDV_STATUS status = ELDV_NOERROR ;
unsigned int *in_ptr, *out_ptr ;
unsigned long sizelout = 0 ;
short y, hy ;
char cancel = 0 ;
in_ptr = (unsigned int*) in->fd_addr ;
out_ptr = (unsigned int*) out->fd_addr ;
init_computation(xc, yc, angle, in, rect) ;
hy = bh_out_y+bh_out_h/2 ;
if (!use_sym)
{
sizelout = (long) ALIGN16( out->fd_w ) ;
out_ptr += sizelout*(long)rect->y ;
hy = bh_out_y+bh_out_h ;
}
for ( y = bh_out_y; !cancel && (y < hy); y++, bh_yd++, out_ptr += sizelout )
{
BH_INIT_LINE ;
BHLRoutine(use_sym, in_ptr, out_ptr) ;
cancel = check_prog(y, hy-bh_out_y) ;
}
if ( cancel ) status = ELDV_CANCELLED ;
return( status ) ;
}
/* 68000 routine for 32bit True Color images */
LDV_STATUS Run32(MFDB *in, long angle, short xc, short yc, MFDB *out, RECT* rect, short use_sym)
{
LDV_STATUS status = ELDV_NOERROR ;
unsigned long *in_ptr, *out_ptr ;
unsigned long sizelout = 0 ;
short y, hy ;
char cancel = 0 ;
in_ptr = (unsigned long*) in->fd_addr ;
out_ptr = (unsigned long*) out->fd_addr ;
init_computation(xc, yc, angle, in, rect) ;
hy = bh_out_y+bh_out_h/2 ;
if (!use_sym)
{
sizelout = (long) ALIGN16( out->fd_w ) ;
out_ptr += sizelout*(long)rect->y ;
hy = bh_out_y+bh_out_h ;
}
for ( y = bh_out_y; !cancel && (y < hy); y++, bh_yd++, out_ptr += sizelout )
{
BH_INIT_LINE ;
BHLRoutine(use_sym, in_ptr, out_ptr) ;
cancel = check_prog(y, hy-bh_out_y) ;
}
if ( cancel ) status = ELDV_CANCELLED ;
return( status ) ;
}
int MayAddRect(RECT* subRect, BH_SPROPERTIES* sgProps)
{
int add = (subRect->w && subRect->h) ;
if (Vapi->LoDoLog)
Vapi->LoDoLog(LL_DEBUG,"MayAddRect (%d,%d,%d,%d)", subRect->x, subRect->y, subRect->w, subRect->h);
if ( add ) /* Sub Rectangle not empty */
memcpy( &sgProps->rect[sgProps->nrect++], subRect, sizeof(RECT) ) ;
return( add ) ;
}
/* Estimation of the expected gain by using rotation symmetry */
void SymmetrySplit(MFDB* img, short xc, short yc, BH_SPROPERTIES* sgProps)
{
long npts_insym, npts_total, npts_to_compute ;
short sw = 0 ;
if ( UseSym && ( (img->fd_nplanes == 16) || (img->fd_nplanes == 32) ) )
{
/* Bitplane organization would have make things too complicated */
/* By the way, who is using bitplanes nowadays ? */
sw = xc ;
if ( img->fd_w-xc < sw ) sw = img->fd_w-xc ;
if ( yc < sw ) sw = yc ;
if ( img->fd_h-yc < sw ) sw = img->fd_h-yc ;
if ( img->fd_h-yc < sw ) sw = img->fd_h-yc ;
/* Let's build the rectangle arrays to define the image */
/* First rectangle (square actually) is the one to use for symmetry */
/* On this one only 25% of pixels will be computed with Black Hole formula */
sgProps->nrect = 1 ;
sgProps->nsym = 0 ;
sgProps->rect[0].x = xc-sw ;
sgProps->rect[0].y = yc-sw ;
sgProps->rect[0].w = 2*sw ;
sgProps->rect[0].h = 2*sw ;
}
npts_total = (long)img->fd_w*(long)img->fd_h ;
npts_insym = 4L*(long)sw*(long)sw ;
npts_to_compute = npts_total-((3L*npts_insym)/4L) ;
sgProps->estdpc = (100L*npts_to_compute)/npts_total ;
if ( sgProps->estdpc > 70 )
{
/* Not worth make things complicated for that gain */
sgProps->nrect = 1 ;
sgProps->nsym = -1 ;
sgProps->rect[0].x = 0 ;
sgProps->rect[0].y = 0 ;
sgProps->rect[0].w = img->fd_w ;
sgProps->rect[0].h = img->fd_h ;
}
else
{
/* Let's build the remaining rectangles */
RECT* sRect = &sgProps->rect[0] ; /* Symmetry Rectangle */
RECT subRect ;
/*
|----------------------------------------|
| R1 | R2 | R3 |
|----------------------------------------|
| ****** |
| R4 ****** R5 |
| ****** |
| ****** |
|----------------------------------------|
| R6 | R7 | R8 |
|----------------------------------------|
*/
/* R1 */
subRect.x = 0 ; subRect.y = 0 ;
subRect.w = sRect->x ; subRect.h = sRect->y ;
if (MayAddRect( &subRect, sgProps ))
if (Vapi->LoDoLog)
Vapi->LoDoLog(LL_DEBUG,"Adding R1(%d,%d,%d,%d)", subRect.x, subRect.y, subRect.w, subRect.h);
/* R2 */
subRect.x = sRect->x ; subRect.y = 0 ;
subRect.w = sRect->w ; subRect.h = sRect->y ;
if (MayAddRect( &subRect, sgProps ))
if (Vapi->LoDoLog)
Vapi->LoDoLog(LL_DEBUG,"Adding R2(%d,%d,%d,%d)", subRect.x, subRect.y, subRect.w, subRect.h);
/* R3 */
subRect.x = sRect->x+sRect->w ; subRect.y = 0 ;
subRect.w = img->fd_w-sRect->x-sRect->w ; subRect.h = sRect->y ;
if (MayAddRect( &subRect, sgProps ))
if (Vapi->LoDoLog)
Vapi->LoDoLog(LL_DEBUG,"Adding R3(%d,%d,%d,%d)", subRect.x, subRect.y, subRect.w, subRect.h);
/* R4 */
subRect.x = 0 ; subRect.y = sRect->y ;
subRect.w = sRect->x ; subRect.h = sRect->h ;
if (MayAddRect( &subRect, sgProps ))
if (Vapi->LoDoLog)
Vapi->LoDoLog(LL_DEBUG,"Adding R4(%d,%d,%d,%d)", subRect.x, subRect.y, subRect.w, subRect.h);
/* R5 */
subRect.x = sRect->x+sRect->w ; subRect.y = sRect->y ;
subRect.w = img->fd_w-sRect->x-sRect->w ; subRect.h = sRect->h ;
if (MayAddRect( &subRect, sgProps ))
if (Vapi->LoDoLog)
Vapi->LoDoLog(LL_DEBUG,"Adding R5(%d,%d,%d,%d)", subRect.x, subRect.y, subRect.w, subRect.h);
/* R6 */
subRect.x = 0 ; subRect.y = sRect->y+sRect->h ;
subRect.w = sRect->x ; subRect.h = img->fd_h-sRect->y-sRect->h ;
if (MayAddRect( &subRect, sgProps ))
if (Vapi->LoDoLog)
Vapi->LoDoLog(LL_DEBUG,"Adding R6(%d,%d,%d,%d)", subRect.x, subRect.y, subRect.w, subRect.h);
/* R7 */
subRect.x = sRect->x ; subRect.y = sRect->y+sRect->h ;
subRect.w = sRect->w ; subRect.h = img->fd_h-sRect->y-sRect->h ;
if (MayAddRect( &subRect, sgProps ))
if (Vapi->LoDoLog)
Vapi->LoDoLog(LL_DEBUG,"Adding R7(%d,%d,%d,%d)", subRect.x, subRect.y, subRect.w, subRect.h);
/* R8 */
subRect.x = sRect->x+sRect->w ; subRect.y = sRect->y+sRect->h ;
subRect.w = img->fd_w-sRect->x-sRect->w ; subRect.h = img->fd_h-sRect->y-sRect->h ;
if (MayAddRect( &subRect, sgProps ))
if (Vapi->LoDoLog)
Vapi->LoDoLog(LL_DEBUG,"Adding R8(%d,%d,%d,%d)", subRect.x, subRect.y, subRect.w, subRect.h);
}
}
short GetSymetryUsageFromIni(void)
{
short use_sym = 1 ; /* Unless INI file say no, assume symetry usage */
long found = 0 ;
char *path_ldv, *language ;
char val_key[64] ;
path_ldv = Vapi->CoGetLDVPath() ;
language = Vapi->CoGetCurrentLanguage() ;
if ( path_ldv && language && Vapi->InGetKeyFromFile )
{
char filename[256] ;
sprintf( filename, "%s\\%s\\BHOLE.INI", path_ldv, language ) ;
if ( Vapi->LoDoLog ) Vapi->LoDoLog(LL_INFO,"Looking into %s to see symetry usage...", filename) ;
found = Vapi->InGetKeyFromFile( filename, "Private", "UseSym", val_key ) ;
if ( !found )
{
sprintf( filename, "%s\\BHOLE.INI", path_ldv ) ;
if ( Vapi->LoDoLog ) Vapi->LoDoLog(LL_INFO,"Looking into non language specific %s to see symetry usage...", filename) ;
found = Vapi->InGetKeyFromFile( filename, "Private", "UseSym", val_key ) ;
}
}
else if ( Vapi->LoDoLog ) Vapi->LoDoLog(LL_WARNING,"Can't access LDV (%s) or language path (%s)!", path_ldv, language) ;
if ( found ) use_sym = atoi( val_key ) ;
if ( Vapi->LoDoLog ) Vapi->LoDoLog(LL_INFO,"Symetry usage: %d (found=%ld)", use_sym, found) ;
return use_sym ;
}
/* LDV Run routine */
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
BH_SPROPERTIES sgProps ;
LDV_STATUS (*RunRoutine)(MFDB *in, long angle, short xc, short yc, MFDB *out, RECT* rect, short use_sym) ;
LDV_STATUS status = ELDV_NOERROR ;
long angle, np=0 ;
short xc, yc, n ;
if ( Vapi->Header.Version < 0x102 ) return ELDV_BADVAPIVERSION ;
if ( InitTrigo((ProcMask & CO_HAS_FPU) == CO_HAS_FPU) != 0 ) return ELDV_NOTENOUGHMEMORY ;
if ( compute_loffset(&in->Raster, &pre_loffset, &lo_w, &lo_h, &lo_nplanes) ) return ELDV_NOTENOUGHMEMORY ;
if ( UseSym == -1 ) UseSym = GetSymetryUsageFromIni() ;
if ( in->Raster.fd_nplanes <= 8 ) { BHLRoutine = BHLInd_68000 ; RunRoutine = bpRun ; }
else if ( in->Raster.fd_nplanes == 16 ) { BHLRoutine = BHL16_68000 ; RunRoutine = Run16 ; }
else if ( in->Raster.fd_nplanes == 32 ) { BHLRoutine = BHL32_68000 ; RunRoutine = Run32 ; }
else return ELDV_IMGFORMATMISMATCH ;
if (ProcMask & CO_HAS_030)
{
if (ProcMask & CO_HAS_FPU)
{
/* Note that FPU requires also a 68030 here */
/* To avoid having another set of macros in bhole.s */
/* And convert even 68000 routines to ASM */
/* FPU won't speed-up computations; it will just */
/* Make the angle proportional to the distance to */
/* Black Hole Center instead of its square */
Vapi->PrOptimize(0x05) ;
if ( in->Raster.fd_nplanes <= 8 ) BHLRoutine = BHLInd_F68030 ;
else if ( in->Raster.fd_nplanes == 16 ) BHLRoutine = BHL16_F68030 ;
else if ( in->Raster.fd_nplanes == 32 ) BHLRoutine = BHL32_F68030 ;
}
else
{
/* CPU 030 'only', note that it is about 2 times faster than 68000 */
/* Routine mostly because of 32x32x-->32 MULS.L instruction */
Vapi->PrOptimize(0x01) ;
if ( in->Raster.fd_nplanes <= 8 ) BHLRoutine = BHLInd_68030 ;
else if ( in->Raster.fd_nplanes == 16 ) BHLRoutine = BHL16_68030 ;
else if ( in->Raster.fd_nplanes == 32 ) BHLRoutine = BHL32_68030 ;
}
}
angle = (long) params->Param[0].s ;
xc = ((long)params->Param[1].s * (long)in->Raster.fd_w)/100L ;
yc = ((long)params->Param[2].s * (long)in->Raster.fd_h)/100L ;
SymmetrySplit(&in->Raster, xc, yc, &sgProps) ;
if (Vapi->LoDoLog)
{
Vapi->LoDoLog(LL_DEBUG, "100 being the time without using symmetry, using symmetry would be %d", sgProps.estdpc) ;
Vapi->LoDoLog(LL_DEBUG, "Image source : (0,0,+%d,+%d); %ld pixels", in->Raster.fd_w, in->Raster.fd_h, (long)in->Raster.fd_w * (long)in->Raster.fd_h) ;
Vapi->LoDoLog(LL_DEBUG, "Symmetry zone : (%d,%d,+%d,+%d), index:%d", sgProps.rect[0].x, sgProps.rect[0].y, sgProps.rect[0].w, sgProps.rect[0].h, sgProps.nsym) ;
}
bh_nrect = sgProps.nrect ;
for ( n=0; (status != ELDV_CANCELLED) && (n < sgProps.nrect); n++)
{
long npix ;
bh_pc = (100*n)/sgProps.nrect ; /* For progression indicator as we may have multiple loops */
npix = (long)sgProps.rect[n].w * (long)sgProps.rect[n].h ;
np += npix ;
if ( VapiLogLevel >= LL_PERF)
{
size_t t0, tms ;
t0 = clock() ;
status = RunRoutine( &in->Raster, angle, xc, yc, &out->Raster, &sgProps.rect[n], (sgProps.nsym == n) ) ;
tms = (1000L * (clock() - t0) ) / CLK_TCK ;
if (tms == 0 ) tms = 1 ;
if (Vapi->LoDoLog)
Vapi->LoDoLog(LL_PERF, "Run zone %d: (%d,%d,+%d,+%d), use_sym=%d, %ld pixels, done in %ldms, %ld Kpixels/s",
n, sgProps.rect[n].x, sgProps.rect[n].y, sgProps.rect[n].w, sgProps.rect[n].h, (sgProps.nsym == n), (long)sgProps.rect[n].w * (long)sgProps.rect[n].h, tms, npix/tms) ;
}
else
status = RunRoutine( &in->Raster, angle, xc, yc, &out->Raster, &sgProps.rect[n], (sgProps.nsym == n) ) ;
}
if (Vapi->LoDoLog)
Vapi->LoDoLog(LL_DEBUG, "%ld pixels computed or deduced", np) ;
return( status ) ;
}
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
return( Run( in, params, out ) ) ;
}
int main(void)
{
ldg_init( Ldg ) ;
return( 0 ) ;
}

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
BHOLE.LDV
;.C[-Y- -G+]
;.L[-Y-]
=
pcstart.o
BHOLE.C
BHOLE.S
pcgemlib.lib
pcstdlib.lib
pctoslib.lib
pcfltlib.lib
..\..\ldg.lib
;..\..\mt_aes.lib

View File

@@ -0,0 +1,635 @@
.IMPORT pre_cosin ; array of 2*ITRIGO_ARRAY_SIZE longs
.IMPORT pre_loffset ; long*
.EXPORT bh_xd, bh_yd, bh_rd2 ; long
.EXPORT bh_xs, bh_ys, bh_ref ; long
.EXPORT bh_xc, bh_yc ; long
.EXPORT bh_out_w, bh_out_h ; short
.EXPORT bh_in_w, bh_in_h ; short
.EXPORT bh_out_x, bh_out_y ; short
.EXPORT BHL32_68030,BHL16_68030,BHLInd_68030
.EXPORT BHL32_F68030,BHL16_F68030,BHLInd_F68030
.EXPORT lcosin_fpu
ITRIGO_ARRAY_SIZE EQU (1 << 14)
ITRIGO_ANGLE_MAX EQU (ITRIGO_ARRAY_SIZE-1)
QUARTER EQU (ITRIGO_ARRAY_SIZE/4)
; The black hole transformation consists of:
; Rotate the destination pixel around the black hole center
; The closest we are to the black hole, the bigger the rotation angle is
; We have 2 or 3 parts of computation angle for black hole transformation:
; 1: Just before dividing the maximum possible angle (depending on LDV paramter Rotation angle) by:
; CPU: the square of distance to black hole center
; FPU: the distance to black hole center; here we need 68881 instruction FSQRT
; So there are 3 parts in macro calculations:
; 1. Before dividing by distance or its square
; 1a. (FPU only) Compute distance
; 3. Divide by either distance or its square and state if the resulting pixel is in source image
; Dividing by distance instead of its square gives better visual results
MACRO BH_COMP_1
MOVE.L A6,D0 ; Remember A6=bh_xd
ADD.L D0,D0
ADDQ.L #1,D0
MOVE.L A5,D1 ; Remember A5=bh_rd2
ADD.L D0,D1 ; bh_rd2(D1)=1+2*bh_xd(D0)
MOVE.L bh_ref(PC),D2
MOVE.L D1,A5 ; Save bh_rd2, free D1
ADDQ.L #1,D1 ; We need bh_rd2+1 for divide
ENDM
MACRO BH_COMP_2 bail_out_addr
DIVU.L D1,D2 ; alpha(D2)=bh_ref/(1+bh_rd2)
ANDI.L #ITRIGO_ANGLE_MAX,D2 ; alpha &= ITRIGO_ANGLE_MAX
LSL.L #3,D2 ; D2=offset for pre_cosin array
MOVE.L A6,D0 ; D0=bh_xd
MOVE.L bh_yd(PC),D1 ; D1=bh_yd
MOVE.L 4(A2,D2.L),D3 ; A2->pre_cosin, D3.L=SIN(alpha)
MOVE.L (A2,D2.L),D2 ; A2->pre_cosin, D2.L=COS(alpha)
MOVEQ.L #16,D6 ; Prepare shifts/assume not in range
MOVE.L D0,D4
MULS.L D2,D4 ; D4=bh_xd * pre_cos[alpha]
MOVE.L D1,D5
MULS.L D3,D5 ; D5=bh_yd * pre_sin[alpha]
SUB.L D5,D4 ; D4=bh_xd * pre_cos[alpha] - bh_yd * pre_sin[alpha]
ASR.L D6,D4
ADD.L bh_xc(PC),D4 ; D6=16, assume pixel not in range
BLT.S bail_out_addr ; xs < 0: not in range
CMP.W bh_in_w(PC),D4
BGE.S bail_out_addr ; xs >= bh_in_w: not in range
MOVE.L D4,A3 ; A3=bh_xs= (D4 >> 16)
MOVE.L D0,D4
MULS.L D3,D4 ; D4=bh_xd * pre_sin[alpha]
MOVE.L D1,D5
MULS.L D2,D5 ; D5=bh_yd * pre_cos[alpha]
ADD.L D5,D4 ; D4=bh_xd * pre_sin[alpha] + bh_yd * pre_cos[alpha]
ASR.L D6,D4
ADD.L bh_yc(PC),D4 ; D4.L=bh_ys
BLT.S bail_out_addr ; ys < 0: not in range
CMP.W bh_in_h(PC),D4
BGE.S bail_out_addr ; ys >= bh_in_h: not in range
MOVEQ.L #0,D6 ; pixel in range
ENDM
; Macro for CPU 68030
MACRO BH_COMPUTE_CPU bail_out_addr
BH_COMP_1
BH_COMP_2 bail_out_addr
ENDM
; Macro for using FPU
; What we do with FPU is to compute the square root of D1 which
; Is then the distance to the back hole center instead of its square
MACRO BH_COMPUTE_FPU bail_out_addr
BH_COMP_1
FMOVE.L D1,FP0
FSQRT FP0
FMOVE.L FP0,D1
BH_COMP_2 bail_out_addr
ENDM
; Init parameters valid for the entire call
MACRO INIT_BHL
MOVE.L pre_cosin,A2
MOVE.L pre_loffset,A4 ; A4-->preoffset
MOVE.L bh_rd2(PC),A5 ; A5=bh_rd2
MOVE.L bh_xd(PC),A6 ; A6=bh_xd
MOVE.W bh_out_w(PC),D7
SUBQ.W #1,D7 ; For DBF
ENDM
MACRO INIT_BHL_SYM
MOVE.L pre_cosin,A2
MOVE.L pre_loffset,A4 ; A4-->preoffset
MOVE.L bh_rd2(PC),A5 ; A5=bh_rd2
MOVE.L bh_xd(PC),A6 ; A6=bh_xd
MOVE.W bh_out_w(PC),D7
LSR.W #1,D7 ; loop to bh_out_w/2 counts
ADD.W A6,D7 ; starting from bh_xd
MOVE.W D7,last_xd
ENDM
; Get pixel TC32 -->dest (Dx)
; A4-->pre_loffset
MACRO GET_TCPIXEL32 p,x,y,dest
MOVE.L (A4,y.L*4),dest
ADD.L x,dest
MOVE.L (p,dest.L*4),dest
ENDM
; Set pixel TC32 val(Dx) -->dest
; A4-->pre_loffset
; scratch_Dx scratch variable
MACRO SET_TCPIXEL32 p,x,y,val,scratch_Dx
MOVE.L (A4,y.L*4),scratch_Dx
ADD.L x,scratch_Dx
MOVE.L val,(p,scratch_Dx.L*4)
ENDM
; Get pixel TC16 -->dest (Dx)
; A4-->pre_loffset
MACRO GET_TCPIXEL16 p,x,y,dest
MOVE.L (A4,y.L*4),dest
ADD.L x,dest
MOVE.W (p,dest.L*2),dest
ENDM
; Set pixel TC16 val(Dx) -->dest
; A4-->pre_loffset
; scratch_Dx scratch variable
MACRO SET_TCPIXEL16 p,x,y,val,scratch_Dx
MOVE.L (A4,y.L*4),scratch_Dx
ADD.L x,scratch_Dx
MOVE.W val,(p,scratch_Dx.L*2)
ENDM
; Rotate 90
; x,y,scratch_Dx : registers, y has to be Dx
; #define R90(x,y) { long _x=x; x=-y; y=_x; }
MACRO R90 x,y,scratch_Dx
MOVE.L x,scratch_Dx
NEG.L y
MOVE.L y,x
MOVE.L scratch_Dx,y
ENDM
MACRO PIXINIMG x,y,w,h,bailout
TST.W x
BLT.S bailout
TST.W y
BLT.S bailout
CMP.W w,x
BGE.S bailout
CMP.W h,y
BGE.S bailout
ENDM
; On sample file 00_1480ms.jpg, Aranym 32bit:
; BHL32_68000 takes about 1450ms
; BHL32_68030 takes about 740ms
; 68030 routine for True Color 32bit
; BHL32_68030(short use_sym, void* in, void* out)
; D0, A0 A1
BHL32_68030:
MOVEM.L D0-D7/A2-A6,-(SP) ; Save context
TST.W D0
BNE BHL32_68030_sym
MOVEQ.L #0,D7
MOVE.W bh_out_x(PC),D7
LSL.L #2,D7
ADD.L D7,A1 ; A1-->&out[bh_out_x]
INIT_BHL
bhl32_l030:
BH_COMPUTE_CPU bhl32_tpir_030 ; -->D6=0:pixel in range
bhl32_tpir_030:
MOVEQ.L #-1,D0 ; Assume out of range
TST.W D6
BNE.S bhl32_setpix_030
MOVE.L (A4,D4.L*4),D0 ; D4=bh_ys, D0=pre_loffset[bh_ys]
ADD.L A3,D0 ; D0=pre_loffset[bh_ys] + bh_xs(A3)
MOVE.L (A0,D0.L*4),D0 ; D0=in_ptr[pre_loffset[bh_ys] + bh_xs]
bhl32_setpix_030:
MOVE.L D0,(A1)+
ADD.L #1,A6 ; bh_xd++
DBF D7,bhl32_l030
MOVEM.L (SP)+,D0-D7/A2-A6 ; Restore context
RTS
BHL32_68030_sym:
INIT_BHL_SYM
bhl32_l030_sym:
BH_COMPUTE_CPU bhl32_tpir_030_sym ; -->D6=0:pixel in range
bhl32_tpir_030_sym:
MOVEQ.L #-1,D0 ; Assume out of range
TST.W D6
BNE.S bhl32_setpix_030_sym
GET_TCPIXEL32 A0,A3,D4,D0 ; A0-->in_ptr, A3=bh_xs+bh_xc, D4=bh_ys+bh_yc
; D0=GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc)
bhl32_setpix_030_sym:
MOVE.L A6,-(SP) ; Save bh_xd
MOVE.L bh_xc(PC),D2 ; D2=bh_xc
MOVE.L bh_yc(PC),D3 ; D3=bh_yc
ADD.L D2,A6 ; A6=bh_xd+bh_xc
MOVE.L bh_yd(PC),D7
ADD.L D3,D7 ; D7=bh_yd+bh_yc
SET_TCPIXEL32 A1,A6,D7,D0,D5 ; SET_TCPIXEL(out_ptr, bh_xd+bh_xc, bh_yd+bh_yc, GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc))
MOVEQ.L #2,D1 ; 3 loops, -1 for DBF
deduc32_030:
SUB.L D2,A3 ; We need now bh_xs(A3) and bh_ys(D4) relative to
SUB.L D3,D4 ; Black Hole center to use R90
SUB.L D2,A6 ; We need now bh_xd(A6) and bh_yd(D7) relative to
SUB.L D3,D7 ; Black Hole center to use R90
R90 A6,D7,D0 ; Rotate (xd,yd) by PI/4
R90 A3,D4,D0 ; Rotate (xs,ys) by PI/4
ADD.L D2,A3 ; Now we need coords in image raster
ADD.L D3,D4
ADD.L D2,A6
ADD.L D3,D7
PIXINIMG A6,D7,bh_in_w(PC),bh_in_h(PC),dnotinimg32_030 ; Check if pixel in dest is within bounds
MOVEQ.L #-1,D0 ; Assume out of range
PIXINIMG A3,D4,bh_in_w(PC),bh_in_h(PC),plotdest32_030 ; Check if pixel in src is within bounds
GET_TCPIXEL32 A0,A3,D4,D0 ; A0-->in_ptr, A3=bh_xs+bh_xc, D4=bh_ys+bh_yc
; D0=GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc)
plotdest32_030:
SET_TCPIXEL32 A1,A6,D7,D0,D5 ; SET_TCPIXEL(out_ptr, bh_xd+bh_xc, bh_yd+bh_yc, GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc))
dnotinimg32_030:
DBF D1,deduc32_030
MOVE.L (SP)+,A6 ; Restore bh_xd
ADD.L #1,A6 ; bh_xd++
CMP.W last_xd(PC),A6
BLE bhl32_l030_sym
MOVEM.L (SP)+,D0-D7/A2-A6 ; Restore context
RTS
; 68030 routine for True Color 16bit
; BHL16_68030(short use_sym, void* in, void* out)
; D0, A0 A1
BHL16_68030:
MOVEM.L D0-D7/A2-A6,-(SP) ; Save context
TST.W D0
BNE BHL16_68030_sym
MOVEQ.L #0,D7
MOVE.W bh_out_x(PC),D7
ADD.L D7,D7
ADD.L D7,A1 ; A1-->&out[bh_out_x]
INIT_BHL
bhl16_l030:
BH_COMPUTE_CPU bhl16_tpir_030 ; -->D6=0:pixel in range
bhl16_tpir_030:
MOVEQ.L #-1,D0 ; Assume out of range
TST.W D6
BNE.S bhl16_setpix_030
MOVE.L (A4,D4.L*4),D0 ; D4=bh_ys, D0=pre_loffset[bh_ys]
ADD.L A3,D0 ; D0=pre_loffset[bh_ys] + bh_xs(A3)
MOVE.W (A0,D0.L*2),D0 ; D0=in_ptr[pre_loffset[bh_ys] + bh_xs]
bhl16_setpix_030:
MOVE.W D0,(A1)+
ADD.L #1,A6 ; bh_xd++
DBF D7,bhl16_l030
MOVEM.L (SP)+,D0-D7/A2-A6 ; Restore context
RTS
BHL16_68030_sym:
INIT_BHL_SYM
bhl16_l030_sym:
BH_COMPUTE_CPU bhl16_tpir_030_sym ; -->D6=0:pixel in range
bhl16_tpir_030_sym:
MOVEQ.L #-1,D0 ; Assume out of range
TST.W D6
BNE.S bhl16_setpix_030_sym
GET_TCPIXEL16 A0,A3,D4,D0 ; A0-->in_ptr, A3=bh_xs+bh_xc, D4=bh_ys+bh_yc
; D0=GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc)
bhl16_setpix_030_sym:
MOVE.L A6,-(SP) ; Save bh_xd
MOVE.L bh_xc(PC),D2 ; D2=bh_xc
MOVE.L bh_yc(PC),D3 ; D3=bh_yc
ADD.L D2,A6 ; A6=bh_xd+bh_xc
MOVE.L bh_yd(PC),D7
ADD.L D3,D7 ; D7=bh_yd+bh_yc
SET_TCPIXEL16 A1,A6,D7,D0,D5 ; SET_TCPIXEL(out_ptr, bh_xd+bh_xc, bh_yd+bh_yc, GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc))
MOVEQ.L #2,D1 ; 3 loops, -1 for DBF
deduc16_030:
SUB.L D2,A3 ; We need now bh_xs(A3) and bh_ys(D4) relative to
SUB.L D3,D4 ; Black Hole center to use R90
SUB.L D2,A6 ; We need now bh_xd(A6) and bh_yd(D7) relative to
SUB.L D3,D7 ; Black Hole center to use R90
R90 A6,D7,D0 ; Rotate (xd,yd) by PI/4
R90 A3,D4,D0 ; Rotate (xs,ys) by PI/4
ADD.L D2,A3 ; Now we need coords in image raster
ADD.L D3,D4
ADD.L D2,A6
ADD.L D3,D7
PIXINIMG A6,D7,bh_in_w(PC),bh_in_h(PC),dnotinimg16_030 ; Check if pixel in dest is within bounds
MOVEQ.L #-1,D0 ; Assume out of range
PIXINIMG A3,D4,bh_in_w(PC),bh_in_h(PC),plotdest16_030 ; Check if pixel in src is within bounds
GET_TCPIXEL16 A0,A3,D4,D0 ; A0-->in_ptr, A3=bh_xs+bh_xc, D4=bh_ys+bh_yc
; D0=GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc)
plotdest16_030:
SET_TCPIXEL16 A1,A6,D7,D0,D5 ; SET_TCPIXEL(out_ptr, bh_xd+bh_xc, bh_yd+bh_yc, GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc))
dnotinimg16_030:
DBF D1,deduc16_030
MOVE.L (SP)+,A6 ; Restore bh_xd
ADD.L #1,A6 ; bh_xd++
CMP.W last_xd(PC),A6
BLE bhl16_l030_sym
MOVEM.L (SP)+,D0-D7/A2-A6 ; Restore context
RTS
; 68030 routine for bitplances images, converted to indexes
; BHLInd_68030(short use_sym, void* in, void* out)
; D0, A0 A1
BHLInd_68030:
MOVEM.L D0-D7/A2-A6,-(SP) ; Save context
INIT_BHL
bhlind_l030:
BH_COMPUTE_CPU bhlind_tpir_030 ; -->D6=0:pixel in range
bhlind_tpir_030:
MOVEQ.L #-1,D0 ; Assume out of range
TST.W D6
BNE.S bhlind_setpix_030
MOVE.L (A4,D4.L*4),D0 ; D4=bh_ys, D0=pre_loffset[bh_ys]
ADD.L A3,D0 ; D0=pre_loffset[bh_ys] + bh_xs(A3)
MOVE.B (A0,D0.L),D0 ; D0=in_ptr[pre_loffset[bh_ys] + bh_xs]
bhlind_setpix_030:
MOVE.B D0,(A1)+
ADD.L #1,A6 ; bh_xd++
DBF D7,bhlind_l030
MOVEM.L (SP)+,D0-D7/A2-A6 ; Restore context
RTS
.EVEN
bh_xd:
DC.L 0
bh_yd:
DC.L 0
bh_rd2:
DC.L 0
bh_xs:
DC.L 0
bh_ys:
DC.L 0
bh_ref:
DC.L 0
bh_xc:
DC.L 0
bh_yc:
DC.L 0
bh_out_w:
DC.W 0
bh_out_h:
DC.W 0
bh_in_w:
DC.W 0
bh_in_h:
DC.W 0
bh_out_x:
DC.W 0
bh_out_y:
DC.W 0
last_xd:
DC.W 0
; 68030/FPU routine for True Color 32bit
; BHL32_F68030(short use_sym, void* in, void* out)
; D0, A0 A1
;BHL32_F68030:
; MOVEM.L D0-D7/A2-A6,-(SP) ; Save context
; FMOVE.X FP0,-(SP)
;
; INIT_BHL
;bhl32_lf030:
; BH_COMPUTE_FPU bhl32_tpir_f030 ; -->D6=0:pixel in range
;bhl32_tpir_f030:
; MOVEQ.L #-1,D0 ; Assume out of range
; TST.W D6
; BNE.S bhl32_setpix_f030
; MOVE.L (A4,D4.L*4),D0 ; D4=bh_ys, D0=pre_loffset[bh_ys]
; ADD.L A3,D0 ; D0=pre_loffset[bh_ys] + bh_xs(A3)
; MOVE.L (A0,D0.L*4),D0 ; D0=in_ptr[pre_loffset[bh_ys] + bh_xs]
;bhl32_setpix_f030:
; MOVE.L D0,(A1)+
; ADD.L #1,A6 ; bh_xd++
; DBF D7,bhl32_lf030
;
; FMOVE.X (SP)+,FP0
; MOVEM.L (SP)+,D0-D7/A2-A6 ; Restore context
; RTS
BHL32_F68030:
MOVEM.L D0-D7/A2-A6,-(SP) ; Save context
FMOVE.X FP0,-(SP)
TST.W D0
BNE BHL32_F68030_sym
MOVEQ.L #0,D7
MOVE.W bh_out_x(PC),D7
LSL.L #2,D7
ADD.L D7,A1 ; A1-->&out[bh_out_x]
INIT_BHL
bhl32_lf030:
BH_COMPUTE_FPU bhl32_tpir_f030 ; -->D6=0:pixel in range
bhl32_tpir_f030:
MOVEQ.L #-1,D0 ; Assume out of range
TST.W D6
BNE.S bhl32_setpix_f030
MOVE.L (A4,D4.L*4),D0 ; D4=bh_ys, D0=pre_loffset[bh_ys]
ADD.L A3,D0 ; D0=pre_loffset[bh_ys] + bh_xs(A3)
MOVE.L (A0,D0.L*4),D0 ; D0=in_ptr[pre_loffset[bh_ys] + bh_xs]
bhl32_setpix_f030:
MOVE.L D0,(A1)+
ADD.L #1,A6 ; bh_xd++
DBF D7,bhl32_lf030
FMOVE.X (SP)+,FP0
MOVEM.L (SP)+,D0-D7/A2-A6 ; Restore context
RTS
BHL32_F68030_sym:
INIT_BHL_SYM
bhl32_lf030_sym:
BH_COMPUTE_FPU bhl32_tpir_f030_sym ; -->D6=0:pixel in range
bhl32_tpir_f030_sym:
MOVEQ.L #-1,D0 ; Assume out of range
TST.W D6
BNE.S bhl32_setpix_f030_sym
GET_TCPIXEL32 A0,A3,D4,D0 ; A0-->in_ptr, A3=bh_xs+bh_xc, D4=bh_ys+bh_yc
; D0=GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc)
bhl32_setpix_f030_sym:
MOVE.L A6,-(SP) ; Save bh_xd
MOVE.L bh_xc(PC),D2 ; D2=bh_xc
MOVE.L bh_yc(PC),D3 ; D3=bh_yc
ADD.L D2,A6 ; A6=bh_xd+bh_xc
MOVE.L bh_yd(PC),D7
ADD.L D3,D7 ; D7=bh_yd+bh_yc
SET_TCPIXEL32 A1,A6,D7,D0,D5 ; SET_TCPIXEL(out_ptr, bh_xd+bh_xc, bh_yd+bh_yc, GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc))
MOVEQ.L #2,D1 ; 3 loops, -1 for DBF
deduc32_f030:
SUB.L D2,A3 ; We need now bh_xs(A3) and bh_ys(D4) relative to
SUB.L D3,D4 ; Black Hole center to use R90
SUB.L D2,A6 ; We need now bh_xd(A6) and bh_yd(D7) relative to
SUB.L D3,D7 ; Black Hole center to use R90
R90 A6,D7,D0 ; Rotate (xd,yd) by PI/4
R90 A3,D4,D0 ; Rotate (xs,ys) by PI/4
ADD.L D2,A3 ; Now we need coords in image raster
ADD.L D3,D4
ADD.L D2,A6
ADD.L D3,D7
PIXINIMG A6,D7,bh_in_w(PC),bh_in_h(PC),dnotinimg32_f030 ; Check if pixel in dest is within bounds
MOVEQ.L #-1,D0 ; Assume out of range
PIXINIMG A3,D4,bh_in_w(PC),bh_in_h(PC),plotdest32_f030 ; Check if pixel in src is within bounds
GET_TCPIXEL32 A0,A3,D4,D0 ; A0-->in_ptr, A3=bh_xs+bh_xc, D4=bh_ys+bh_yc
; D0=GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc)
plotdest32_f030:
SET_TCPIXEL32 A1,A6,D7,D0,D5 ; SET_TCPIXEL(out_ptr, bh_xd+bh_xc, bh_yd+bh_yc, GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc))
dnotinimg32_f030:
DBF D1,deduc32_f030
MOVE.L (SP)+,A6 ; Restore bh_xd
ADD.L #1,A6 ; bh_xd++
CMP.W last_xd(PC),A6
BLE bhl32_lf030_sym
FMOVE.X (SP)+,FP0
MOVEM.L (SP)+,D0-D7/A2-A6 ; Restore context
RTS
BHL16_F68030:
MOVEM.L D0-D7/A2-A6,-(SP) ; Save context
FMOVE.X FP0,-(SP)
TST.W D0
BNE BHL16_f68030_sym
MOVEQ.L #0,D7
MOVE.W bh_out_x(PC),D7
ADD.L D7,D7
ADD.L D7,A1 ; A1-->&out[bh_out_x]
INIT_BHL
bhl16_lf030:
BH_COMPUTE_FPU bhl16_tpir_f030 ; -->D6=0:pixel in range
bhl16_tpir_f030:
MOVEQ.L #-1,D0 ; Assume out of range
TST.W D6
BNE.S bhl16_setpix_f030
MOVE.L (A4,D4.L*4),D0 ; D4=bh_ys, D0=pre_loffset[bh_ys]
ADD.L A3,D0 ; D0=pre_loffset[bh_ys] + bh_xs(A3)
MOVE.W (A0,D0.L*2),D0 ; D0=in_ptr[pre_loffset[bh_ys] + bh_xs]
bhl16_setpix_f030:
MOVE.W D0,(A1)+
ADD.L #1,A6 ; bh_xd++
DBF D7,bhl16_lf030
FMOVE.X (SP)+,FP0
MOVEM.L (SP)+,D0-D7/A2-A6 ; Restore context
RTS
BHL16_f68030_sym:
INIT_BHL_SYM
bhl16_lf030_sym:
BH_COMPUTE_FPU bhl16_tpir_f030_sym ; -->D6=0:pixel in range
bhl16_tpir_f030_sym:
MOVEQ.L #-1,D0 ; Assume out of range
TST.W D6
BNE.S bhl16_setpix_f030_sym
GET_TCPIXEL16 A0,A3,D4,D0 ; A0-->in_ptr, A3=bh_xs+bh_xc, D4=bh_ys+bh_yc
; D0=GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc)
bhl16_setpix_f030_sym:
MOVE.L A6,-(SP) ; Save bh_xd
MOVE.L bh_xc(PC),D2 ; D2=bh_xc
MOVE.L bh_yc(PC),D3 ; D3=bh_yc
ADD.L D2,A6 ; A6=bh_xd+bh_xc
MOVE.L bh_yd(PC),D7
ADD.L D3,D7 ; D7=bh_yd+bh_yc
SET_TCPIXEL16 A1,A6,D7,D0,D5 ; SET_TCPIXEL(out_ptr, bh_xd+bh_xc, bh_yd+bh_yc, GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc))
MOVEQ.L #2,D1 ; 3 loops, -1 for DBF
deduc16_f030:
SUB.L D2,A3 ; We need now bh_xs(A3) and bh_ys(D4) relative to
SUB.L D3,D4 ; Black Hole center to use R90
SUB.L D2,A6 ; We need now bh_xd(A6) and bh_yd(D7) relative to
SUB.L D3,D7 ; Black Hole center to use R90
R90 A6,D7,D0 ; Rotate (xd,yd) by PI/4
R90 A3,D4,D0 ; Rotate (xs,ys) by PI/4
ADD.L D2,A3 ; Now we need coords in image raster
ADD.L D3,D4
ADD.L D2,A6
ADD.L D3,D7
PIXINIMG A6,D7,bh_in_w(PC),bh_in_h(PC),dnotinimg16_f030 ; Check if pixel in dest is within bounds
MOVEQ.L #-1,D0 ; Assume out of range
PIXINIMG A3,D4,bh_in_w(PC),bh_in_h(PC),plotdest16_f030 ; Check if pixel in src is within bounds
GET_TCPIXEL16 A0,A3,D4,D0 ; A0-->in_ptr, A3=bh_xs+bh_xc, D4=bh_ys+bh_yc
; D0=GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc)
plotdest16_f030:
SET_TCPIXEL16 A1,A6,D7,D0,D5 ; SET_TCPIXEL(out_ptr, bh_xd+bh_xc, bh_yd+bh_yc, GET_TCPIXEL(in_ptr, bh_xs+bh_xc, bh_ys+bh_yc))
dnotinimg16_f030:
DBF D1,deduc16_f030
MOVE.L (SP)+,A6 ; Restore bh_xd
ADD.L #1,A6 ; bh_xd++
CMP.W last_xd(PC),A6
BLE bhl16_lf030_sym
FMOVE.X (SP)+,FP0
MOVEM.L (SP)+,D0-D7/A2-A6 ; Restore context
RTS
; 68030/FPU routine for bitplances images, converted to indexes
; BHLInd_F68030(short use_sym, void* in, void* out)
; D0, A0 A1
BHLInd_F68030:
MOVEM.L D0-D7/A2-A6,-(SP) ; Save context
FMOVE.X FP0,-(SP)
INIT_BHL
bhlInd_lf030:
BH_COMPUTE_FPU bhlInd_tpir_f030 ; -->D6=0:pixel in range
bhlInd_tpir_f030:
MOVEQ.L #-1,D0 ; Assume out of range
TST.W D6
BNE.S bhlInd_setpix_f030
MOVE.L (A4,D4.L*4),D0 ; D4=bh_ys, D0=pre_loffset[bh_ys]
ADD.L A3,D0 ; D0=pre_loffset[bh_ys] + bh_xs
MOVE.B (A0,D0.L),D0 ; D0=in_ptr[pre_loffset[bh_ys] + bh_xs]
bhlInd_setpix_f030:
MOVE.B D0,(A1)+
ADD.L #1,A6 ; bh_xd++
DBF D7,bhlInd_lf030
FMOVE.X (SP)+,FP0
MOVEM.L (SP)+,D0-D7/A2-A6 ; Restore context
RTS
; Pre-calculation of cosinus/sinus table using FPU
; void lcosin_fpu(long i, long* pcs)
; D0 A0
; double angle = i*ANGLE_ADD ;
; pcs[0] = 65536.0 * cos( angle ) ;
; pcs[1] = 65536.0 * sin( angle ) ;
lcosin_fpu:
FMOVEM.X FP0-FP2,-(SP)
FMOVE D0,FP0
; 3.8349519697141030742952189737299e-4=M_PI/2.0/(double)QUARTER
; For some reason, I did not manage to use EQU with floating point constants
FMUL.X #3.8349519697141030742952189737299e-4,FP0
FSINCOS.X FP0,FP1:FP2
FMUL.X #65536.0,FP1
FMUL.X #65536.0,FP2
FMOVE.L FP1,(A0)+
FMOVE.L FP2,(A0)
FMOVEM.X (SP)+,FP0-FP2
RTS

View File

@@ -0,0 +1,86 @@
68000, TC32, 2016x1508
MagicC, SYM:
25/02/18 18:31:38 [INFO] MayAddRect (0,0,254,0)
25/02/18 18:31:38 [INFO] MayAddRect (254,0,1508,0)
25/02/18 18:31:38 [INFO] MayAddRect (1762,0,254,0)
25/02/18 18:31:38 [INFO] MayAddRect (0,0,254,1508)
25/02/18 18:31:38 [INFO] Adding R4(0,0,254,1508)
25/02/18 18:31:38 [INFO] MayAddRect (1762,0,254,1508)
25/02/18 18:31:38 [INFO] Adding R5(1762,0,254,1508)
25/02/18 18:31:38 [INFO] MayAddRect (0,1508,254,0)
25/02/18 18:31:38 [INFO] MayAddRect (254,1508,1508,0)
25/02/18 18:31:38 [INFO] MayAddRect (1762,1508,254,0)
25/02/18 18:31:38 [INFO] 100 being the time without using symmetry, using symmetry would be 43
25/02/18 18:31:38 [INFO] Image source : (0,0,+2016,+1508); 3040128 pixels
25/02/18 18:31:38 [INFO] Symmetry zone : (254,0,+1508,+1508), index:0
25/02/18 18:31:40 [INFO] Run zone 0: (254,0,+1508,+1508), use_sym=1, 2274064 pixels, done in 850ms, 2675 Kpixels/s
25/02/18 18:31:40 [INFO] Run zone 1: (0,0,+254,+1508), use_sym=0, 383032 pixels, done in 295ms, 1298 Kpixels/s
25/02/18 18:31:40 [INFO] Run zone 2: (1762,0,+254,+1508), use_sym=0, 383032 pixels, done in 295ms, 1298 Kpixels/s
25/02/18 18:31:40 [INFO] 3040128 pixels computed or deduced
25/02/18 18:31:40 [PERF] LDV Run took 1445ms
MagicC, NO SYM:
25/02/18 18:36:52 [INFO] 100 being the time without using symmetry, using symmetry would be 43
25/02/18 18:36:52 [INFO] Image source : (0,0,+2016,+1508); 3040128 pixels
25/02/18 18:36:52 [INFO] Symmetry zone : (0,0,+2016,+1508), index:-1
25/02/18 18:36:54 [INFO] Run zone 0: (0,0,+2016,+1508), use_sym=0, 3040128 pixels, done in 2270ms, 1339 Kpixels/s
25/02/18 18:36:54 [INFO] 3040128 pixels computed or deduced
25/02/18 18:36:54 [PERF] LDV Run took 2275ms
Aranym, NO SYM:
25/02/18 18:38:54 [INFO] 100 being the time without using symmetry, using symmetry would be 43
25/02/18 18:38:54 [INFO] Image source : (0,0,+2016,+1508); 3040128 pixels
25/02/18 18:38:54 [INFO] Symmetry zone : (0,0,+2016,+1508), index:-1
25/02/18 18:38:54 [INFO] Run zone 0: (0,0,+2016,+1508), use_sym=0, 3040128 pixels, done in 1710ms, 1777 Kpixels/s
25/02/18 18:38:54 [INFO] 3040128 pixels computed or deduced
25/02/18 18:38:54 [PERF] LDV Run took 1710ms
Aranym, SYM:
25/02/18 18:41:12 [INFO] MayAddRect (0,0,254,0)
25/02/18 18:41:12 [INFO] MayAddRect (254,0,1508,0)
25/02/18 18:41:12 [INFO] MayAddRect (1762,0,254,0)
25/02/18 18:41:12 [INFO] MayAddRect (0,0,254,1508)
25/02/18 18:41:12 [INFO] Adding R4(0,0,254,1508)
25/02/18 18:41:12 [INFO] MayAddRect (1762,0,254,1508)
25/02/18 18:41:12 [INFO] Adding R5(1762,0,254,1508)
25/02/18 18:41:12 [INFO] MayAddRect (0,1508,254,0)
25/02/18 18:41:12 [INFO] MayAddRect (254,1508,1508,0)
25/02/18 18:41:12 [INFO] MayAddRect (1762,1508,254,0)
25/02/18 18:41:12 [INFO] 100 being the time without using symmetry, using symmetry would be 43
25/02/18 18:41:12 [INFO] Image source : (0,0,+2016,+1508); 3040128 pixels
25/02/18 18:41:12 [INFO] Symmetry zone : (254,0,+1508,+1508), index:0
25/02/18 18:41:14 [INFO] Run zone 0: (254,0,+1508,+1508), use_sym=1, 2274064 pixels, done in 500ms, 4548 Kpixels/s
25/02/18 18:41:14 [INFO] Run zone 1: (0,0,+254,+1508), use_sym=0, 383032 pixels, done in 900ms, 425 Kpixels/s
25/02/18 18:41:14 [INFO] Run zone 2: (1762,0,+254,+1508), use_sym=0, 383032 pixels, done in 890ms, 430 Kpixels/s
25/02/18 18:41:14 [INFO] 3040128 pixels computed or deduced
25/02/18 18:41:14 [PERF] LDV Run took 2300ms
HATARI, Falcon 32Mhz, TC16, SYM:
25/02/18 19:07:02 [DEBUG] Running LDV with w=1008, h=754, P0=10, P1=50, P2=50
25/02/18 19:07:04 [INFO] MayAddRect (0,0,127,0)
25/02/18 19:07:04 [INFO] MayAddRect (127,0,754,0)
25/02/18 19:07:04 [INFO] MayAddRect (881,0,127,0)
25/02/18 19:07:04 [INFO] MayAddRect (0,0,127,754)
25/02/18 19:07:04 [INFO] Adding R4(0,0,127,754)
25/02/18 19:07:04 [INFO] MayAddRect (881,0,127,754)
25/02/18 19:07:04 [INFO] Adding R5(881,0,127,754)
25/02/18 19:07:04 [INFO] MayAddRect (0,754,127,0)
25/02/18 19:07:04 [INFO] MayAddRect (127,754,754,0)
25/02/18 19:07:04 [INFO] MayAddRect (881,754,127,0)
25/02/18 19:07:04 [INFO] 100 being the time without using symmetry, using symmetry would be 43
25/02/18 19:07:04 [INFO] Image source : (0,0,+1008,+754); 760032 pixels
25/02/18 19:07:04 [INFO] Symmetry zone : (127,0,+754,+754), index:0
25/02/18 19:07:20 [INFO] Run zone 0: (127,0,+754,+754), use_sym=1, 568516 pixels, done in 17260ms, 32 Kpixels/s
25/02/18 19:07:26 [INFO] Run zone 1: (0,0,+127,+754), use_sym=0, 95758 pixels, done in 6350ms, 15 Kpixels/s
25/02/18 19:07:34 [INFO] Run zone 2: (881,0,+127,+754), use_sym=0, 95758 pixels, done in 6400ms, 14 Kpixels/s
25/02/18 19:07:34 [INFO] 760032 pixels computed or deduced
25/02/18 19:07:34 [PERF] LDV Run took 30030ms
HATARI, Falcon 32Mhz, TC16, NO SYM:
25/02/18 19:11:00 [DEBUG] Running LDV with w=1008, h=754, P0=10, P1=50, P2=50
25/02/18 19:11:00 [INFO] 100 being the time without using symmetry, using symmetry would be 43
25/02/18 19:11:00 [INFO] Image source : (0,0,+1008,+754); 760032 pixels
25/02/18 19:11:00 [INFO] Symmetry zone : (0,0,+1008,+754), index:-1
25/02/18 19:11:46 [INFO] Run zone 0: (0,0,+1008,+754), use_sym=0, 760032 pixels, done in 46625ms, 16 Kpixels/s
25/02/18 19:11:46 [INFO] 760032 pixels computed or deduced
25/02/18 19:11:46 [PERF] LDV Run took 46901ms

View File

@@ -0,0 +1,222 @@
/*
*
*
* Version PureC / Gcc
*/
#define PCGEMLIB 1 /* mettre 1 si les utilisateurs de Pure C
* utilise les librairies GEM Pure C */
/* Fichiers headers */
#include <portab.h>
#if PCGEMLIB
#include <aes.h>
#include <vdi.h>
#else
#include <aesbind.h>
#include <vdibind.h>
#endif
#include <string.h>
#include <math.h>
#include "..\..\ldg.h"
#include "..\..\vapi.h"
#include "..\..\ldv.h"
#include "..\..\mt_aes.h"
/* Prototypages */
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi) ;
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
/* Variables globales */
PROC Proc[] = {
"GetLDVCapabilities", "Capacit<EFBFBD>s du LDV", (void *)GetLDVCapabilities,
"PreRun", "Init du Run", (void *)PreRun,
"Run", "Fonction du LDV", (void *)Run,
"Preview", "Pre-Visu", (void *)Preview,
} ;
char Info[] = "LDV";
LDGLIB Ldg[] = {
0x0100, /* version de la lib, recommand<6E> */
4, /* nombre de fonction dans la lib */
Proc, /* Pointeurs vers nos fonctions */
Info, /* Information sur la lib */
0x0, /* Flags de la lib, obligatoire */
NULL, /* Fermeture, liberation de VDIHandle */
};
#define BP_CAPS (LDVF_SPECFORMAT | LDVF_OPINPLACE | LDVF_SUPPORTPREVIEW | LDVF_AFFECTPALETTE | LDVF_REALTIMEPARAMS)
#define TC_CAPS (LDVF_SPECFORMAT | LDVF_OPINPLACE | LDVF_SUPPORTPREVIEW | LDVF_SUPPORTPROG | LDVF_SUPPORTCANCEL | LDVF_REALTIMEPARAMS)
LDV_INFOS LdvInfos = {
(short) sizeof(LDV_INFOS), /* Taille de cette structure */
TLDV_MODIFYIMG, /* Type du LDV */
"Jean Lusetti", /* Auteurs */
{
{ 1, 1, BP_CAPS }, /* Capacites pour 1 plan */
{ 2, 2, BP_CAPS }, /* Capacites pour 2 plans */
{ 4, 4, BP_CAPS }, /* Capacites pour 4 plans */
{ 8, 8, BP_CAPS }, /* Capacites pour 8 plans */
{ 16, 16, TC_CAPS }, /* Capacites pour 16 plans */
{ 32, 32, TC_CAPS }, /* Capacites pour 32 plans */
{ 0, 0, 0UL } /* Fin de la liste des capacites */
},
} ;
VAPI *Vapi = NULL ;
double gamma_rgb = 100.0 ;
double gamma_red = -1.0 ;
double gamma_green = -1.0 ;
double gamma_blue = -1.0 ;
unsigned char RedRemap[256] ; /* Tables de reaffectation des couleurs en True Color */
unsigned char GreenRemap[256] ;
unsigned char BlueRemap[256] ;
#define CHECK_VAPI(vapi) if ( (vapi == NULL ) || (vapi->Header.Version < 0x103) ) return( ELDV_BADVAPIVERSION ) ;
/*
* Fonctions de la librairie
*/
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi)
{
Vapi = vapi ;
return( &LdvInfos ) ;
}
#pragma warn -par
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
return( ELDV_NOERROR ) ;
}
double GammaFunc(double val, double val_max, double gamma)
{
return( val_max * pow( val/val_max, gamma ) ) ;
}
void ChangeColors(double gamma, unsigned char *tab, unsigned short nb_bits)
{
unsigned char *pnew_val = tab ;
double max_val = (double) ((1 << nb_bits) - 1) ;
unsigned short i ;
for ( i = 0; i <= max_val; i++, pnew_val++ )
*pnew_val = (short) ( 0.5 + GammaFunc( i, max_val, gamma ) ) ;
}
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
LDV_PALETTE *vdi_palette = &in->Palette ;
VDI_ELEMENTPAL *vdi_epal ;
double rgamma, ggamma, bgamma ;
short vdi_index ;
short cancel = 0 ;
if ( (params->Param[0].s / 100.0) != gamma_rgb )
{
gamma_rgb = params->Param[0].s / 100.0 ;
params->Param[1].s = params->Param[0].s ;
params->Param[2].s = params->Param[0].s ;
params->Param[3].s = params->Param[0].s ;
}
rgamma = params->Param[1].s / 100.0 ;
ggamma = params->Param[2].s / 100.0 ;
bgamma = params->Param[3].s / 100.0 ;
if ( in->Raster.fd_nplanes <= 8 )
{
if ( vdi_palette == NULL ) return( ELDV_GENERALFAILURE ) ;
vdi_epal = vdi_palette->Pal ;
if ( vdi_epal == NULL ) return( ELDV_GENERALFAILURE ) ;
for ( vdi_index = 0; vdi_index < vdi_palette->NbColors; vdi_index++, vdi_epal++ )
{
vdi_epal->Red = (short) ( 0.5 + GammaFunc( vdi_epal->Red, 1000.0, rgamma ) ) ;
if ( ggamma == rgamma ) vdi_epal->Green = vdi_epal->Red ;
else vdi_epal->Green = (short) ( 0.5 + GammaFunc( vdi_epal->Green, 1000.0, ggamma ) ) ;
if ( bgamma == rgamma ) vdi_epal->Blue = vdi_epal->Red ;
else vdi_epal->Blue = (short) ( 0.5 + GammaFunc( vdi_epal->Blue, 1000.0, bgamma ) ) ;
}
}
else
{
REMAP_COLORS rc ;
MFDB *img = &in->Raster ;
long *pt_line32, nb_pts_in_line ;
short *pt_line16, y, pc, is_15bits, cancel=0 ;
unsigned short nb_bits_red=8, nb_bits_green=8, nb_bits_blue=8 ; /* Sur 32 bits par defaut */
CHECK_VAPI(Vapi) ;
rc.red = RedRemap ;
rc.green = GreenRemap ;
rc.blue = BlueRemap ;
rc.nb_pts = (long) (1 + params->x2 - params->x1) ;
is_15bits = Vapi->RaIs15Bits() ;
if ( img->fd_nplanes == 16 )
{
nb_bits_red = 5 ;
nb_bits_green = is_15bits ? 5:6 ;
nb_bits_blue = 5 ;
}
/* Remet a jour les precalculs de pourcentage sur les composantes si necessaire */
if ( rgamma != gamma_red ) ChangeColors( rgamma, RedRemap, nb_bits_red ) ;
if ( ggamma != gamma_green ) ChangeColors( ggamma, GreenRemap, nb_bits_green ) ;
if ( bgamma != gamma_blue ) ChangeColors( bgamma, BlueRemap, nb_bits_blue ) ;
nb_pts_in_line = ALIGN16(img->fd_w) ;
pt_line16 = (short *) img->fd_addr ;
pt_line16 += (long)(params->y1) * nb_pts_in_line ;
pt_line16 += params->x1 ;
pt_line32 = (long *) img->fd_addr ;
pt_line32 += (long)(params->y1) * nb_pts_in_line ;
pt_line32 += params->x1 ;
for ( y = params->y1; !cancel && (y <= params->y2); y++ )
{
if ( img->fd_nplanes == 16 )
{
rc.pt_img = pt_line16 ;
pt_line16 += nb_pts_in_line ;
if ( is_15bits ) Vapi->RaTC15RemapColors( &rc ) ;
else Vapi->RaTC16RemapColors( &rc ) ;
}
else
{
rc.pt_img = pt_line32 ;
pt_line32 += nb_pts_in_line ;
Vapi->RaTC32RemapColors( &rc ) ;
}
if ( ( y & 0x0F ) == 0x0F )
{
pc = (short) ( ( 100L * (long)(y - params->y1) ) / (long)(params->y2 - params->y1) ) ;
cancel = Vapi->PrSetProgEx( pc ) ;
}
}
}
gamma_red = rgamma ;
gamma_green = ggamma ;
gamma_blue = bgamma ;
return( cancel ? ELDV_CANCELLED : ELDV_NOERROR ) ;
}
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
return( Run( in, params, out ) ) ;
}
#pragma warn +par
int main(void)
{
ldg_init( Ldg ) ;
return( 0 ) ;
}

Binary file not shown.

View File

@@ -0,0 +1,12 @@
GAMMA.LDV
;.C[-Y- -G+]
;.L[-Y-]
=
pcstart.o
GAMMA.C
pcgemlib.lib
pcstdlib.lib
pctoslib.lib
pcfltlib.lib
..\..\ldg.lib
..\..\mt_aes.lib

View File

@@ -0,0 +1,223 @@
/*
*
*
* Version PureC / Gcc
*/
#define PCGEMLIB 1 /* mettre 1 si les utilisateurs de Pure C
* utilise les librairies GEM Pure C */
/* Fichiers headers */
#include <portab.h>
#if PCGEMLIB
#include <aes.h>
#include <vdi.h>
#else
#include <aesbind.h>
#include <vdibind.h>
#endif
#include <string.h>
#include "..\..\ldg.h"
#include "..\..\vapi.h"
#include "..\..\ldv.h"
#include "..\..\mt_aes.h"
/* Prototypages */
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi) ;
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
/* Variables globales */
PROC Proc[] = {
"GetLDVCapabilities", "Capacit<EFBFBD>s du LDV", (void *)GetLDVCapabilities,
"PreRun", "Init du Run", (void *)PreRun,
"Run", "Fonction du LDV", (void *)Run,
"Preview", "Pre-Visu", (void *)Preview,
} ;
char Info[] = "LDV";
LDGLIB Ldg[] = {
0x0101, /* version de la lib, recommand<6E> */
4, /* nombre de fonction dans la lib */
Proc, /* Pointeurs vers nos fonctions */
Info, /* Information sur la lib */
0x0, /* Flags de la lib, obligatoire */
NULL, /* Fermeture, liberation de VDIHandle */
};
#define BP_CAPS (LDVF_SPECFORMAT | LDVF_OPINPLACE | LDVF_SUPPORTPREVIEW | LDVF_AFFECTPALETTE | LDVF_REALTIMEPARAMS)
#define TC_CAPS (LDVF_SPECFORMAT | LDVF_OPINPLACE | LDVF_SUPPORTPREVIEW | LDVF_SUPPORTPROG | LDVF_SUPPORTCANCEL | LDVF_REALTIMEPARAMS)
LDV_INFOS LdvInfos = {
(short) sizeof(LDV_INFOS), /* Taille de cette structure */
TLDV_MODIFYIMG, /* Type du LDV */
"Jean Lusetti", /* Auteurs */
{
{ 1, 1, BP_CAPS }, /* Capacites pour 1 plan */
{ 2, 2, BP_CAPS }, /* Capacites pour 2 plans */
{ 4, 4, BP_CAPS }, /* Capacites pour 4 plans */
{ 8, 8, BP_CAPS }, /* Capacites pour 8 plans */
{ 16, 16, TC_CAPS }, /* Capacites pour 16 plans */
{ 32, 32, TC_CAPS }, /* Capacites pour 32 plans */
{ 0, 0, 0UL } /* Fin de la liste des capacites */
},
} ;
VAPI *Vapi = NULL ;
short pc_rgb = 100 ;
short pc_red = -1 ; /* Pourcentages de lumiere sur les comosantes rouge, verte et bleue */
short pc_green = -1 ;
short pc_blue = -1 ;
unsigned char RedRemap[256] ; /* Tables de reaffectation des couleurs en True Color */
unsigned char GreenRemap[256] ;
unsigned char BlueRemap[256] ;
#define CHECK_VAPI(vapi) if ( (vapi == NULL ) || (vapi->Header.Version < 0x103) ) return( ELDV_BADVAPIVERSION ) ;
/*
* Fonctions de la librairie
*/
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi)
{
Vapi = vapi ;
return( &LdvInfos ) ;
}
#pragma warn -par
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
return( ELDV_NOERROR ) ;
}
void ChangeColors(unsigned short percent, unsigned char *tab, unsigned short nb_bits)
{
unsigned char *pnew_val = tab ;
unsigned short max_val = (1 << nb_bits) - 1 ;
unsigned short val, i ;
for ( i = 0; i <= max_val; i++, pnew_val++ )
{
val = ( i * percent ) / 100 ;
if ( val > max_val ) *pnew_val = max_val ;
else *pnew_val = val ;
}
}
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
LDV_PALETTE *vdi_palette = &in->Palette ;
VDI_ELEMENTPAL *vdi_epal ;
short vdi_index ;
short cancel = 0 ;
if ( params->Param[0].s != pc_rgb )
{
pc_rgb = params->Param[0].s ;
params->Param[1].s = pc_rgb ;
params->Param[2].s = pc_rgb ;
params->Param[3].s = pc_rgb ;
}
if ( in->Raster.fd_nplanes <= 8 )
{
long red_pc, green_pc, blue_pc ; /* Pour la palette */
if ( vdi_palette == NULL ) return( ELDV_GENERALFAILURE ) ;
vdi_epal = vdi_palette->Pal ;
if ( vdi_epal == NULL ) return( ELDV_GENERALFAILURE ) ;
red_pc = (long) params->Param[1].s ;
green_pc = (long) params->Param[2].s ;
blue_pc = (long) params->Param[3].s ;
for ( vdi_index = 0; vdi_index < vdi_palette->NbColors; vdi_index++, vdi_epal++ )
{
/* Le calcul se fait sur des entiers 32 bits pour eviter d'exploser la plage -32K...32K */
vdi_epal->Red = (short) ( ( (long)vdi_epal->Red * red_pc ) / 100L ) ;
if ( vdi_epal->Red > 1000 ) vdi_epal->Red = 1000 ;
vdi_epal->Green = (short) ( ( (long)vdi_epal->Green * green_pc ) / 100L ) ; ;
if ( vdi_epal->Green > 1000 ) vdi_epal->Green = 1000 ;
vdi_epal->Blue = (short) ( ( (long)vdi_epal->Blue * blue_pc ) / 100L ) ; ;
if ( vdi_epal->Blue > 1000 ) vdi_epal->Blue = 1000 ;
}
}
else
{
REMAP_COLORS rc ;
MFDB *img = &in->Raster ;
long *pt_line32, nb_pts_in_line ;
short *pt_line16, y, pc, is_15bits, cancel=0 ;
unsigned short nb_bits_red=8, nb_bits_green=8, nb_bits_blue=8 ; /* Sur 32 bits par defaut */
CHECK_VAPI(Vapi) ;
rc.red = RedRemap ;
rc.green = GreenRemap ;
rc.blue = BlueRemap ;
rc.nb_pts = (long) (1 + params->x2 - params->x1) ;
is_15bits = Vapi->RaIs15Bits() ;
if ( img->fd_nplanes == 16 )
{
nb_bits_red = 5 ;
nb_bits_green = is_15bits ? 5:6 ;
nb_bits_blue = 5 ;
}
/* Remet a jour les precalculs de pourcentage sur les composantes si necessaire */
if ( pc_red != params->Param[1].s ) ChangeColors( (unsigned short) (params->Param[1].s), RedRemap, nb_bits_red ) ;
if ( pc_green != params->Param[2].s ) ChangeColors( (unsigned short) (params->Param[2].s), GreenRemap, nb_bits_green ) ;
if ( pc_blue != params->Param[3].s ) ChangeColors( (unsigned short) (params->Param[3].s), BlueRemap, nb_bits_blue ) ;
pc_red = params->Param[1].s ;
pc_green = params->Param[2].s ;
pc_blue = params->Param[3].s ;
nb_pts_in_line = ALIGN16(img->fd_w) ;
pt_line16 = (short *) img->fd_addr ;
pt_line16 += (long)(params->y1) * nb_pts_in_line ;
pt_line16 += params->x1 ;
pt_line32 = (long *) img->fd_addr ;
pt_line32 += (long)(params->y1) * nb_pts_in_line ;
pt_line32 += params->x1 ;
for ( y = params->y1; !cancel && (y <= params->y2); y++ )
{
if ( img->fd_nplanes == 16 )
{
rc.pt_img = pt_line16 ;
pt_line16 += nb_pts_in_line ;
if ( is_15bits ) Vapi->RaTC15RemapColors( &rc ) ;
else Vapi->RaTC16RemapColors( &rc ) ;
}
else
{
rc.pt_img = pt_line32 ;
pt_line32 += nb_pts_in_line ;
Vapi->RaTC32RemapColors( &rc ) ;
}
if ( ( y & 0x0F ) == 0x0F )
{
pc = (short) ( ( 100L * (long)(y - params->y1) ) / (long)(params->y2 - params->y1) ) ;
cancel = Vapi->PrSetProgEx( pc ) ;
}
}
}
return( cancel ? ELDV_CANCELLED : ELDV_NOERROR ) ;
}
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
return( Run( in, params, out ) ) ;
}
#pragma warn +par
int main(void)
{
ldg_init( Ldg ) ;
return( 0 ) ;
}

Binary file not shown.

View File

@@ -0,0 +1,12 @@
LIGHT.LDV
;.C[-Y- -G+]
;.L[-Y-]
=
pcstart.o
LIGHT.C
pcgemlib.lib
pcstdlib.lib
pctoslib.lib
pcfltlib.lib
..\..\ldg.lib
..\..\mt_aes.lib

View File

@@ -0,0 +1,224 @@
/*
*
*
* Version PureC / Gcc
*/
#define PCGEMLIB 1 /* mettre 1 si les utilisateurs de Pure C
* utilise les librairies GEM Pure C */
/* Fichiers headers */
#include <portab.h>
#if PCGEMLIB
#include <aes.h>
#include <vdi.h>
#else
#include <aesbind.h>
#include <vdibind.h>
#endif
#include <string.h>
#include <stdlib.h>
#include "..\..\ldg.h"
#include "..\..\vapi.h"
#include "..\..\ldv.h"
#include "..\..\mt_aes.h"
/* Prototypages */
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi) ;
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
void OnClose(void) ;
/* Variables globales */
PROC Proc[] = {
"GetLDVCapabilities", "Capacit<EFBFBD>s du LDV", (void *)GetLDVCapabilities,
"PreRun", "Init du Run", (void *)PreRun,
"Run", "Fonction du LDV", (void *)Run,
"Preview", "Pre-Visu", (void *)Preview,
} ;
char Info[] = "LDV";
LDGLIB Ldg[] = {
0x0100, /* version de la lib, recommand<6E> */
4, /* nombre de fonction dans la lib */
Proc, /* Pointeurs vers nos fonctions */
Info, /* Information sur la lib */
0x0, /* Flags de la lib, obligatoire */
OnClose, /* Fermeture, liberation de VDIHandle */
};
#define CAPS (LDVF_SPECFORMAT | LDVF_SUPPORTPREVIEW | LDVF_SUPPORTPROG | LDVF_REALTIMEPARAMS | LDVF_SUPPORTCANCEL | LDVF_NOSELECTION)
LDV_INFOS LdvInfos = {
(short) sizeof(LDV_INFOS), /* Taille de cette structure */
TLDV_MODIFYIMG, /* Type du LDV */
"Jean Lusetti", /* Auteurs */
{
{ 1, 1, CAPS }, /* Capacites pour 1 plan */
{ 2, 2, CAPS }, /* Capacites pour 2 plans */
{ 4, 4, CAPS }, /* Capacites pour 4 plans */
{ 8, 8, CAPS }, /* Capacites pour 8 plans */
{ 16, 16, CAPS }, /* Capacites pour 16 plans */
{ 24, 24, CAPS }, /* Capacites pour 24 plans */
{ 32, 32, CAPS }, /* Capacites pour 32 plans */
{ 0, 0, 0UL } /* Fin de la liste des capacites */
},
} ;
VAPI *Vapi = NULL ;
int VDIHandle = -1 ;
short *ToBeMixed = NULL ; /* Tableau (1,2,...) a melanger */
short Nw, Nh, Entropy ;
void OnClose(void)
{
if ( VDIHandle != -1 ) v_clsvwk( VDIHandle ) ;
VDIHandle = -1 ;
if ( ToBeMixed ) free( ToBeMixed ) ;
ToBeMixed = NULL ;
}
/*
* Fonctions de la librairie
*/
LDV_INFOS * cdecl GetLDVCapabilities(VAPI *vapi)
{
Vapi = vapi ;
return( &LdvInfos ) ;
}
int vdihandle(void)
{
int work_in[11], work_out[57], i ;
for ( i = 0; i < 10; work_in[i++] = 1 ) ;
work_in[10] = 2 ;
v_opnvwk( work_in, &i, work_out ) ;
return( i ) ;
}
void SetMixedArray(short Nw, short Nh, short entropy)
{
short nb = Nw * Nh ;
if ( ToBeMixed ) free( ToBeMixed ) ;
ToBeMixed = (short *) malloc( nb * sizeof(short) ) ;
if ( ToBeMixed )
{
short i, j, k, l, *pt ;
pt = ToBeMixed ;
for ( i = 0; i < nb; i++ ) *pt++ = i ; /* Un tableau bien trie ... */
for ( i = 0; i < entropy*entropy; i++ )
{
j = rand() % nb ; /* On prend 2 elements au hasard */
k = rand() % nb ;
l = ToBeMixed[j] ; /* Et on les permute ... */
ToBeMixed[j] = ToBeMixed[k] ;
ToBeMixed[k] = l ;
}
}
}
#pragma warn -par
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
Nw = params->Param[0].s ;
Nh = params->Param[1].s ;
Entropy = params->Param[2].s ;
out->Raster.fd_w = in->Raster.fd_w ;
out->Raster.fd_h = in->Raster.fd_h ;
return( ELDV_NOERROR ) ;
}
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
LDV_STATUS status = ELDV_NOERROR ;
long cancel, pc ;
short *src_num = ToBeMixed ;
short dst_num ;
int xy[8] ;
int x, y, w, h ;
int nw, nh, mw, mh ;
if ( ToBeMixed == NULL ) return( ELDV_NOTENOUGHMEMORY ) ;
if ( VDIHandle == -1 ) VDIHandle = vdihandle() ;
cancel = 0 ;
w = in->Raster.fd_w / Nw ;
h = in->Raster.fd_h / Nh ;
mw = in->Raster.fd_w % Nw ;
if ( mw )
{
/* Les "restes" de bloc sont recopies tels quels */
xy[0] = xy[4] = in->Raster.fd_w - mw - 1 ;
xy[1] = xy[5] = 0 ;
xy[2] = xy[6] = in->Raster.fd_w - 1 ;
xy[3] = xy[7] = in->Raster.fd_h - 1 ;
vro_cpyfm( VDIHandle, S_ONLY, xy, &in->Raster, &out->Raster ) ;
}
mh = in->Raster.fd_h % Nh ;
if ( mh )
{
/* Les "restes" de bloc sont recopies tels quels */
xy[0] = xy[4] = 0 ;
xy[1] = xy[5] = in->Raster.fd_h - mh - 1 ;
xy[2] = xy[6] = in->Raster.fd_w - 1 ;
xy[3] = xy[7] = in->Raster.fd_h - 1 ;
vro_cpyfm( VDIHandle, S_ONLY, xy, &in->Raster, &out->Raster ) ;
}
y = 0 ;
for ( nh = 0; !cancel && ( nh < Nh ); nh++, y += h )
{
xy[1] = y ;
xy[3] = y + h - 1 ;
x = 0 ;
for ( nw = 0; nw < Nw; nw++, x += w )
{
dst_num = *src_num++ ;
xy[0] = x ;
xy[2] = x + w - 1 ;
xy[4] = ( dst_num % Nw ) * w ;
xy[5] = ( dst_num / Nw ) * h ;
xy[6] = xy[4] + w - 1 ;
xy[7] = xy[5] + h - 1 ;
vro_cpyfm( VDIHandle, S_ONLY, xy, &in->Raster, &out->Raster ) ;
}
pc = ( 100L * y ) / in->Raster.fd_h ;
cancel = Vapi->PrSetProgEx( pc ) ;
}
if ( cancel ) status = ELDV_CANCELLED ;
return( status ) ;
}
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
SetMixedArray( Nw, Nh, Entropy ) ;
if ( ToBeMixed == NULL ) return( ELDV_NOTENOUGHMEMORY ) ;
return( Run( in, params, out ) ) ;
}
#pragma warn +par
int main(void)
{
ldg_init( Ldg ) ;
srand( 256 ) ;
return( 0 ) ;
}

Binary file not shown.

View File

@@ -0,0 +1,11 @@
PUZZLE.LDV
;.C[-Y- -G+]
;.L[-Y-]
=
pcstart.o
PUZZLE.C
pcgemlib.lib
pcstdlib.lib
pctoslib.lib
..\..\ldg.lib
..\..\mt_aes.lib

View File

@@ -0,0 +1,128 @@
/*
*
*
* Version PureC / Gcc
*/
#define PCGEMLIB 1 /* mettre 1 si les utilisateurs de Pure C
* utilise les librairies GEM Pure C */
/* Fichiers headers */
#include <portab.h>
#if PCGEMLIB
#include <aes.h>
#include <vdi.h>
#else
#include <aesbind.h>
#include <vdibind.h>
#endif
#include <string.h>
#include <stdlib.h>
#include "..\..\ldg.h"
#include "..\..\vapi.h"
#include "..\..\ldv.h"
#include "..\..\mt_aes.h"
/* Prototypages */
LDV_INFOS* cdecl GetLDVCapabilities(VAPI *vapi) ;
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out) ;
void OnClose(void) ;
/* Variables globales */
PROC Proc[] = {
"GetLDVCapabilities", "Capacit<EFBFBD>s du LDV", (void *)GetLDVCapabilities,
"PreRun", "Init du Run", (void *)PreRun,
"Run", "Fonction du LDV", (void *)Run,
"Preview", "Pre-Visu", (void *)Preview,
} ;
char Info[] = "LDV";
LDGLIB Ldg[] = {
0x0100, /* version de la lib, recommand<6E> */
4, /* nombre de fonction dans la lib */
Proc, /* Pointeurs vers nos fonctions */
Info, /* Information sur la lib */
0x0, /* Flags de la lib, obligatoire */
NULL,
};
#define BP_CAPS (LDVF_SPECFORMAT | LDVF_SUPPORTPREVIEW | LDVF_SUPPORTPROG | LDVF_REALTIMEPARAMS | LDVF_SUPPORTCANCEL | LDVF_NOSELECTION)
#define TC_CAPS (LDVF_SPECFORMAT | LDVF_SUPPORTPREVIEW | LDVF_SUPPORTPROG | LDVF_REALTIMEPARAMS | LDVF_SUPPORTCANCEL | LDVF_NOSELECTION)
LDV_INFOS LdvInfos = {
(short) sizeof(LDV_INFOS), /* Taille de cette structure */
TLDV_MODIFYIMG, /* Type du LDV */
"Jean Lusetti", /* Auteurs */
{
{ 1, 1, BP_CAPS }, /* Capacites pour 1 plan */
{ 2, 2, BP_CAPS }, /* Capacites pour 2 plans */
{ 4, 4, BP_CAPS }, /* Capacites pour 4 plans */
{ 8, 8, BP_CAPS }, /* Capacites pour 8 plans */
{ 16, 16, TC_CAPS }, /* Capacites pour 16 plans */
{ 32, 32, TC_CAPS }, /* Capacites pour 32 plans */
{ 0, 0, 0UL } /* Fin de la liste des capacites */
},
} ;
VAPI *Vapi = NULL ;
/* Petite macro de verification pour VAPI */
#define CHECK_VAPI(vapi) if ( ( vapi == NULL ) || ( vapi->Header.Version < 0x0103 ) ) return( ELDV_BADVAPIVERSION ) ;
/*
* Fonctions de la librairie
*/
LDV_INFOS* cdecl GetLDVCapabilities(VAPI *vapi)
{
Vapi = vapi ;
return( &LdvInfos ) ;
}
#pragma warn -par
LDV_STATUS cdecl PreRun(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
long angle ;
CHECK_VAPI( Vapi ) ;
angle = (long) params->Param[0].s ;
Vapi->RaRasterRotateGetDstMFDB( &in->Raster, &out->Raster, angle ) ;
return( ELDV_NOERROR ) ;
}
LDV_STATUS cdecl Run(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
LDV_STATUS status ;
long angle ;
CHECK_VAPI( Vapi ) ;
angle = (long) params->Param[0].s ;
status = Vapi->RaRasterRotate( &in->Raster, &out->Raster, angle, 0x03 ) ; /* 0x03 = 0x01 (progress) | 0x02 (cancel) */
return( status ) ;
}
LDV_STATUS cdecl Preview(LDV_IMAGE *in, LDV_PARAMS *params, LDV_IMAGE *out)
{
return( Run( in, params, out ) ) ;
}
#pragma warn +par
int main(void)
{
ldg_init( Ldg ) ;
return( 0 ) ;
}

Binary file not shown.

View File

@@ -0,0 +1,12 @@
ROTATE.LDV
;.C[-Y- -G+]
;.L[-Y-]
=
pcstart.o
ROTATE.C
pcgemlib.lib
pcstdlib.lib
pctoslib.lib
pcfltlib.lib
..\..\ldg.lib
..\..\mt_aes.lib