home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FreeWare Collection 3
/
FreeSoftwareCollection3pd199x-jp.img
/
oh_fm
/
inkyoku
/
gload.c
< prev
next >
Wrap
Text File
|
1980-01-02
|
2KB
|
122 lines
/*
graphics image loader & viewer
*/
#include <stdio.h>
#include <egb.h>
#include <stdlib.h>
#include "crtc.h"
char work[1540] ;
ldram(fp,work,sx,sy,wx,wy ) /* VRAMへファイルからロード */
FILE *fp ;
char *work ;
int sx,sy,wx,wy ;
{
char *bp ;
int size ;
char para[16] ;
size = wx * wy * 2 ;
if( (bp = (char *)malloc( size )) == 0 ) return -1 ;
fread( bp, 1, size, fp ) ;
DWORD(para + 0) = (unsigned int)bp ;
WORD (para + 4) = 0x14 ;
WORD (para + 6) = sx ;
WORD (para + 8) = sy ;
WORD (para +10) = sx + wx - 1 ;
WORD (para +12) = sy + wy - 1 ;
EGB_putBlock(work,0,para) ;
free(bp) ;
return 0 ;
}
void padzoom() /* パッドでスクロール&拡大 */
{
int p,x ;
int dsx,dsy,mag = 1 ;
dsx = dsy = 0 ;
while((( p = getpad( 0 )) & 0xF) != 3 ) {
if( (p & 0xF) == 0xc ) return ;
if( !(p & 0x8) )
dsx = ++dsx & 0xFF ;
if( !(p & 0x4) )
dsx = --dsx & 0xFF ;
if( !(p & 0x2) )
dsy = ++dsy & 0xFF ;
if( !(p & 0x1) )
dsy = --dsy & 0xFF ;
if((p & 0x30) == 0 ) {
dsx = dsy = 0;
mag = 1 ;
} else {
if(!(p & 0x10) ) {
if( ++mag > 15 ) mag = 15 ;
while(!(getpad(0) & 0x10)) ;
}
if(!(p & 0x20) ) {
if( --mag < 0 ) mag = 0 ;
while(!(getpad(0) & 0x20)) ;
}
}
CRTC_ScreenOffset( dsx,dsy ) ;
CRTC_ZoomScreen( mag, mag ) ;
for( x = 0 ; x < 0x1000 ;x++ ) ; /* WAIT */
}
}
CRTC_ScreenOffset( sx,sy ) /* CRTCのFA0,FA1をセット */
int sx,sy ;
{
int ofs ;
ofs = (sy << 8) + (sx) ;
CRTC( CA_FA0, ofs ) ;
CRTC( CA_FA1, ofs ) ;
}
CRTC_ZoomScreen( wx, wy )
int wx,wy ;
{
int z ;
z = (wy << 4)+ wx ;
z = (z << 8) + z ;
CRTC( CA_ZOOM,z ) ;
}
getpad( port ) /* read pad port */
int port ;
{
OUTPB( 0x4d6 , 0x3F ) ;
return( INPB( 0x4d0 + port * 2 ) ) ;
}
main(ac,av)
int ac ;
char **av ;
{
FILE *fp ;
long offset ;
offset = 0 ;
if( ac > 2 ) offset = atoi( av[ 2 ] ) ;
if( (fp = fopen( av[1], "rb" )) == NULL ) return ;
EGB_init( work, 1536 ) ;
EGB_resolution( work, 0, 10 ) ;
EGB_resolution( work, 1, 10 ) ;
EGB_displayPage( work, 0,3 ) ;
EGB_writePage( work , 0 ) ;
EGB_displayStart( work, 2, 2, 2 ) ;
EGB_displayStart( work, 3, 320, 240 ) ;
fseek( fp, offset, SEEK_SET ) ;
if( ldram(fp,work,0,0,320,240 ) != -1 )
padzoom() ;
fclose( fp ) ;
screenterm( work ) ;
}