1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-31 05:42:25 +00:00

Reformat all C source files with Clang-format in Google style w/ 100 col width.

This commit is contained in:
Nick Briggs
2017-05-28 18:08:18 -07:00
parent 691645d048
commit 156c3292f8
167 changed files with 40520 additions and 48069 deletions

481
src/testdsp.c Executable file → Normal file
View File

@@ -1,9 +1,7 @@
/* $Id: testdsp.c,v 1.2 1999/01/03 02:07:36 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */
/* $Id: testdsp.c,v 1.2 1999/01/03 02:07:36 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved
*/
static char *id = "$Id: testdsp.c,v 1.2 1999/01/03 02:07:36 sybalsky Exp $ Copyright (C) Venue";
/************************************************************************/
/* */
/* (C) Copyright 1989-95 Venue. All Rights Reserved. */
@@ -18,7 +16,6 @@ static char *id = "$Id: testdsp.c,v 1.2 1999/01/03 02:07:36 sybalsky Exp $ Copyr
#include "version.h"
#include <stdio.h>
#include <sunwindow/window_hs.h>
#include <sunwindow/cms.h>
@@ -59,7 +56,7 @@ int KeyboardFd;
int DisplayWidth, DisplayHeight, DisplayRasterWidth, DisplayType;
int DisplayByteSize;
short *DisplayRegion68k; /* 68k addr of #{}22,0 */
short *DisplayRegion68k; /* 68k addr of #{}22,0 */
struct cursor CurrentCursor, InvisibleCursor;
struct winlock DisplayLockArea;
@@ -72,332 +69,300 @@ extern IFPAGE *InterfacePage;
int DebugDSP = T;
******************************************/
/************** provide below so can skip the include files *******/
#define BITSPER_DLWORD 16
#define SUN2BW 1
#define SUN4COLOR 2
#define CURSORWIDTH 16
#define CURSORHEIGHT 16
#define DBPRINT(X) printf X
#define BITSPER_DLWORD 16
#define SUN2BW 1
#define SUN4COLOR 2
#define CURSORWIDTH 16
#define CURSORHEIGHT 16
#define DBPRINT(X) printf X
/************** provide above so can skip the include files *******/
/* ================================================================ */
init_display2(display_addr, display_max)
int display_addr, display_max;
init_display2(display_addr, display_max) int display_addr, display_max;
{
int mmapstat;
int ioctlresult;
char *texture_base, *malloc();
struct fbtype my_screen;
char groups[PIXPG_OVERLAY+1];
struct fbgattr FBattr;
struct pixrect *ColorFb;
int mask, kbtype;
int mmapstat;
int ioctlresult;
char *texture_base, *malloc();
struct fbtype my_screen;
char groups[PIXPG_OVERLAY + 1];
struct fbgattr FBattr;
struct pixrect *ColorFb;
int mask, kbtype;
if( (LispWindowFd = win_screennew( &LispScreen )) == -1){
perror("init_display: can't create LispWindow\n");
exit( -1 );
}
else {
if ((LispWindowFd = win_screennew(&LispScreen)) == -1) {
perror("init_display: can't create LispWindow\n");
exit(-1);
} else {
#ifdef KBINT
int_io_open(LispWindowFd);
int_io_open(LispWindowFd);
#endif
fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0)| FNDELAY);
}
fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0) | FNDELAY);
}
DisplayRegion68k = (short *) display_addr;
DisplayRegion68k = (short *)display_addr;
if( (FrameBufferFd = open( LispScreen.scr_fbname, 2 )) == -1){
perror("init_display: can't open FrameBuffer\n");
exit( -1 );
}
if ((FrameBufferFd = open(LispScreen.scr_fbname, 2)) == -1) {
perror("init_display: can't open FrameBuffer\n");
exit(-1);
}
if( (KeyboardFd = open( LispScreen.scr_kbdname, 2 )) == -1){
perror("init_display: can't open Keyboard\n");
exit( -1 );
}
if ((KeyboardFd = open(LispScreen.scr_kbdname, 2)) == -1) {
perror("init_display: can't open Keyboard\n");
exit(-1);
}
DBPRINT(("LispScreen.scr_kbdname %s\n", LispScreen.scr_kbdname));
DBPRINT(("LispScreen.scr_fbname %s\n", LispScreen.scr_fbname ));
DBPRINT(("LispScreen.scr_kbdname %s\n", LispScreen.scr_kbdname));
DBPRINT(("LispScreen.scr_fbname %s\n", LispScreen.scr_fbname));
if ( ioctl ( KeyboardFd, KIOCTYPE, &kbtype ) != 0 ) {
perror ( "ioctl(KIOCTYPE,..) fails" );
}
else {
DBPRINT(("ioctl(KIOCTYPE): %d\n", kbtype ));
}
if (ioctl(KeyboardFd, KIOCTYPE, &kbtype) != 0) {
perror("ioctl(KIOCTYPE,..) fails");
} else {
DBPRINT(("ioctl(KIOCTYPE): %d\n", kbtype));
}
/* initialize Display parameters */
if (ioctl(FrameBufferFd, FBIOGTYPE , &my_screen)== -1) {
perror("init_display: can't find screen parameters\n");
exit( -1 );
}
DisplayWidth = my_screen.fb_width;
DisplayHeight = my_screen.fb_height;
DisplayRasterWidth = DisplayWidth / BITSPER_DLWORD;
if ((DisplayWidth * DisplayHeight) > display_max){
DisplayHeight = display_max / DisplayWidth;
}
/* initialize Display parameters */
if (ioctl(FrameBufferFd, FBIOGTYPE, &my_screen) == -1) {
perror("init_display: can't find screen parameters\n");
exit(-1);
}
DisplayWidth = my_screen.fb_width;
DisplayHeight = my_screen.fb_height;
DisplayRasterWidth = DisplayWidth / BITSPER_DLWORD;
if ((DisplayWidth * DisplayHeight) > display_max) { DisplayHeight = display_max / DisplayWidth; }
DBPRINT(("FBIOGTYPE w x h = %d x %d\n", DisplayWidth, DisplayHeight));
DBPRINT((" type = %d\n", my_screen.fb_type ));
DBPRINT((" bpp = %d\n", my_screen.fb_depth ));
DBPRINT(("FBIOGTYPE w x h = %d x %d\n", DisplayWidth, DisplayHeight));
DBPRINT((" type = %d\n", my_screen.fb_type));
DBPRINT((" bpp = %d\n", my_screen.fb_depth));
/** now attempt to use the FBIOGATTR call for more information **/
/** now attempt to use the FBIOGATTR call for more information **/
ioctlresult = ioctl(FrameBufferFd, FBIOGATTR, &FBattr);
if(ioctlresult >= 0 ) {
DBPRINT(("FBIOGATTR realtype = %d\n", FBattr.real_type));
DBPRINT((" (real) w x h = %d x %d\n", FBattr.fbtype.fb_width,
FBattr.fbtype.fb_height));
DBPRINT((" (real) type = %d\n", FBattr.fbtype.fb_type ));
DBPRINT((" (real) bpp = %d\n", FBattr.fbtype.fb_depth ));
DBPRINT((" emuls = %d %d %d %d %d\n",
FBattr.emu_types[0],
FBattr.emu_types[1],
FBattr.emu_types[2],
FBattr.emu_types[3],
FBattr.emu_types[4] ));
}
else {
DBPRINT(("ioctl(fd,FBIOGATTR,&FBattr) => %d\n", ioctlresult));
}
ioctlresult = ioctl(FrameBufferFd, FBIOGATTR, &FBattr);
if (ioctlresult >= 0) {
DBPRINT(("FBIOGATTR realtype = %d\n", FBattr.real_type));
DBPRINT((" (real) w x h = %d x %d\n", FBattr.fbtype.fb_width, FBattr.fbtype.fb_height));
DBPRINT((" (real) type = %d\n", FBattr.fbtype.fb_type));
DBPRINT((" (real) bpp = %d\n", FBattr.fbtype.fb_depth));
DBPRINT((" emuls = %d %d %d %d %d\n", FBattr.emu_types[0], FBattr.emu_types[1],
FBattr.emu_types[2], FBattr.emu_types[3], FBattr.emu_types[4]));
} else {
DBPRINT(("ioctl(fd,FBIOGATTR,&FBattr) => %d\n", ioctlresult));
}
ColorFb = pr_open("/dev/fb");
ColorFb = pr_open("/dev/fb");
DBPRINT(("pixrect w, h, depth = %d %d %d\n",
ColorFb->pr_size.x,
ColorFb->pr_size.y, ColorFb->pr_depth ));
DBPRINT(("pixrect w, h, depth = %d %d %d\n", ColorFb->pr_size.x, ColorFb->pr_size.y,
ColorFb->pr_depth));
pr_getattributes( ColorFb, &mask );
DBPRINT((" getattrmask = %d\n", mask ));
pr_getattributes(ColorFb, &mask);
DBPRINT((" getattrmask = %d\n", mask));
groups[0]=0; groups[1]=0; groups[2]=0; groups[3]=0; groups[4]=0;
pr_available_plane_groups( ColorFb, sizeof(groups), groups);
DBPRINT(("plane groups = current: %d\n", groups[0] ));
DBPRINT((" mono : %d\n", groups[1] ));
DBPRINT((" 8bitcol: %d\n", groups[2] ));
DBPRINT((" ovrlyen: %d\n", groups[3] ));
DBPRINT((" ovrly : %d\n", groups[4] ));
groups[0] = 0;
groups[1] = 0;
groups[2] = 0;
groups[3] = 0;
groups[4] = 0;
pr_available_plane_groups(ColorFb, sizeof(groups), groups);
DBPRINT(("plane groups = current: %d\n", groups[0]));
DBPRINT((" mono : %d\n", groups[1]));
DBPRINT((" 8bitcol: %d\n", groups[2]));
DBPRINT((" ovrlyen: %d\n", groups[3]));
DBPRINT((" ovrly : %d\n", groups[4]));
pr_available_plane_groups( ColorFb, sizeof(groups), groups);
pr_available_plane_groups(ColorFb, sizeof(groups), groups);
/* try to clear enable plane if it exists */
/* try to clear enable plane if it exists */
if (groups[PIXPG_OVERLAY] &&
groups[PIXPG_OVERLAY_ENABLE] ){
pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE);
pr_rop(ColorFb, 0, 0, ColorFb->pr_width,
ColorFb->pr_height, PIX_SET, 0, 0, 0);
pr_set_plane_group(ColorFb, PIXPG_OVERLAY);
}
if (groups[PIXPG_OVERLAY] && groups[PIXPG_OVERLAY_ENABLE]) {
pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE);
pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, PIX_SET, 0, 0, 0);
pr_set_plane_group(ColorFb, PIXPG_OVERLAY);
}
{ int currgroup;
currgroup = pr_get_plane_group( ColorFb );
DBPRINT(("current planegroup: %d, unknown: %d\n",
currgroup, currgroup == PIXPG_CURRENT ));
}
{
int currgroup;
currgroup = pr_get_plane_group(ColorFb);
DBPRINT(("current planegroup: %d, unknown: %d\n", currgroup, currgroup == PIXPG_CURRENT));
}
/* ================================================================ */
#ifdef NOTUSED
if (my_screen.fb_type == FBTYPE_SUN2BW){
if ( ioctlresult ) >= 0) {
if (FBattr.real_type == FBTYPE_SUN4COLOR) {
/* must be color display cgfour */
/* we've already gotten the plane groups from above */
if (groups[PIXPG_OVERLAY] &&
groups[PIXPG_OVERLAY_ENABLE] ){
pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE);
pr_rop(ColorFb, 0, 0,
ColorFb->pr_width,
ColorFb->pr_height, PIX_SET, 0, 0, 0);
pr_set_plane_group(ColorFb, PIXPG_OVERLAY);
}
}
else { /* not cgfour */
printf("initdisplay: Unsupported FBTYPE %d\n",
FBattr.real_type);
}
} /* if ioctlresult...... */
}/* if ...FBTYPE_SUN2BW end */
if (my_screen.fb_type == FBTYPE_SUN2BW) {
if (ioctlresult) >= 0) {
if (FBattr.real_type == FBTYPE_SUN4COLOR) {
/* must be color display cgfour */
/* we've already gotten the plane groups from above */
if (groups[PIXPG_OVERLAY] && groups[PIXPG_OVERLAY_ENABLE]) {
pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE);
pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, PIX_SET, 0, 0, 0);
pr_set_plane_group(ColorFb, PIXPG_OVERLAY);
}
} else { /* not cgfour */
printf("initdisplay: Unsupported FBTYPE %d\n", FBattr.real_type);
}
} /* if ioctlresult...... */
} /* if ...FBTYPE_SUN2BW end */
#endif
/* ================================================================ */
/* ================================================================ */
DisplayLockArea.wl_rect.r_width = DisplayWidth;
DisplayLockArea.wl_rect.r_height = DisplayHeight;
init_cursor();
DisplayByteSize= ((DisplayWidth * DisplayHeight / 8 + (getpagesize()-1) )
& -getpagesize());
DisplayLockArea.wl_rect.r_width = DisplayWidth;
DisplayLockArea.wl_rect.r_height = DisplayHeight;
init_cursor();
DisplayByteSize = ((DisplayWidth * DisplayHeight / 8 + (getpagesize() - 1)) & -getpagesize());
DBPRINT(("Display Addr: 0x%x\n",DisplayRegion68k));
DBPRINT(("length: 0x%x\n",DisplayByteSize));
DBPRINT(("page size: 0x%x\n",getpagesize()));
DBPRINT(("Display Addr: 0x%x\n", DisplayRegion68k));
DBPRINT(("length: 0x%x\n", DisplayByteSize));
DBPRINT(("page size: 0x%x\n", getpagesize()));
mmapstat = (int)mmap( DisplayRegion68k,
DisplayByteSize,
PROT_READ | PROT_WRITE,
mmapstat = (int)mmap(DisplayRegion68k, DisplayByteSize, PROT_READ | PROT_WRITE,
#ifdef OS4
MAP_FIXED |
MAP_FIXED |
#endif
MAP_SHARED,
FrameBufferFd, 0 );
MAP_SHARED,
FrameBufferFd, 0);
DBPRINT(("after mmap: 0x%x\n",mmapstat));
DBPRINT(("after mmap: 0x%x\n", mmapstat));
if(mmapstat == -1){
perror("init_display: ERROR at mmap system call\n");
exit( 0 );
}
if (mmapstat == -1) {
perror("init_display: ERROR at mmap system call\n");
exit(0);
}
DBPRINT(("before clear display()\n"));
DBPRINT(("before clear display()\n"));
clear_display();
clear_display();
DBPRINT(("after clear_display()\n"));
DBPRINT(("after clear_display()\n"));
/* initialize pixrects used in pilotbitblt (internal will change) */
SrcePixRect = mem_point( 0, 0, 1, NULL );
DestPixRect = mem_point( 0, 0, 1, NULL );
/* initialize pixrects used in pilotbitblt (internal will change) */
SrcePixRect = mem_point(0, 0, 1, NULL);
DestPixRect = mem_point(0, 0, 1, NULL);
DBPRINT(("before set_cursor\n"));
DBPRINT(("before set_cursor\n"));
}
/* ================================================================ */
init_cursor()
{
CursorBitMap = mem_create( CURSORWIDTH, CURSORHEIGHT, 1 );
mpr_mdlinebytes(CursorBitMap) = CURSORWIDTH >> 3;/* 2(byte) */
CurrentCursor.cur_xhot = 0;
CurrentCursor.cur_yhot = 0;
CurrentCursor.cur_shape = CursorBitMap;
CurrentCursor.cur_function = PIX_SRC | PIX_DST;
init_cursor() {
CursorBitMap = mem_create(CURSORWIDTH, CURSORHEIGHT, 1);
mpr_mdlinebytes(CursorBitMap) = CURSORWIDTH >> 3; /* 2(byte) */
CurrentCursor.cur_xhot = 0;
CurrentCursor.cur_yhot = 0;
CurrentCursor.cur_shape = CursorBitMap;
CurrentCursor.cur_function = PIX_SRC | PIX_DST;
/* Invisible Cursor */
InvisibleCursorBitMap = mem_create( 0, 0, 1 );
InvisibleCursor.cur_xhot = 0;
InvisibleCursor.cur_yhot = 0;
InvisibleCursor.cur_shape = InvisibleCursorBitMap;
InvisibleCursor.cur_function = /*PIX_SRC |*/ PIX_DST;
/* Invisible Cursor */
InvisibleCursorBitMap = mem_create(0, 0, 1);
InvisibleCursor.cur_xhot = 0;
InvisibleCursor.cur_yhot = 0;
InvisibleCursor.cur_shape = InvisibleCursorBitMap;
InvisibleCursor.cur_function = /*PIX_SRC |*/ PIX_DST;
win_setcursor( LispWindowFd, &InvisibleCursor);
win_setmouseposition(LispWindowFd, 0, 0);
}
win_setcursor(LispWindowFd, &InvisibleCursor);
win_setmouseposition(LispWindowFd, 0, 0);
}
/* ================================================================ */
display_before_exit()
{
clear_display();
display_before_exit() {
clear_display();
win_screendestroy( LispWindowFd );
win_screendestroy(LispWindowFd);
#ifdef KBINT
int_io_close(LispWindowFd);
int_io_close(LispWindowFd);
#endif
close( LispWindowFd );
}
close(LispWindowFd);
}
/* ================================================================ */
clear_display()
{
register short *word;
register int w, h;
word = DisplayRegion68k;
for (h = DisplayHeight; (h--);)
{
for (w = DisplayRasterWidth; (w--);) {*word++ = 0;}
}
}
clear_display() {
register short *word;
register int w, h;
word = DisplayRegion68k;
for (h = DisplayHeight; (h--);) {
for (w = DisplayRasterWidth; (w--);) { *word++ = 0; }
}
}
/* ================================================================ */
paint_display()
{
register short *word;
register int w, h;
word = DisplayRegion68k;
for (h = DisplayHeight; (h--);)
{
for (w = DisplayRasterWidth; (w--);) {*word++ = w;}
}
}
paint_display() {
register short *word;
register int w, h;
word = DisplayRegion68k;
for (h = DisplayHeight; (h--);) {
for (w = DisplayRasterWidth; (w--);) { *word++ = w; }
}
}
/* ================================================================ */
#define BYTESPER_PAGE 512
read_datum( lispworld )
char *lispworld;
{
int srcefile; /* fd */
int i, j, sysout_size;
int lispworld_offset;
struct stat stat_buf;
char *charptr;
int readresult;
char bigbuff [ BYTESPER_PAGE ];
read_datum(lispworld) char *lispworld;
{
int srcefile; /* fd */
int i, j, sysout_size;
int lispworld_offset;
struct stat stat_buf;
char *charptr;
int readresult;
char bigbuff[BYTESPER_PAGE];
srcefile = open("fake.sysout", O_RDONLY, NULL);
srcefile = open("fake.sysout", O_RDONLY, NULL);
/* get sysout file size in halfpage(256) */
if (fstat( srcefile, &stat_buf) == -1) {
perror("read_datum: can't get srcefile size (fstat fails)");
exit(-1);
}
sysout_size = stat_buf.st_size / BYTESPER_PAGE * 2;
/* get sysout file size in halfpage(256) */
if (fstat(srcefile, &stat_buf) == -1) {
perror("read_datum: can't get srcefile size (fstat fails)");
exit(-1);
}
sysout_size = stat_buf.st_size / BYTESPER_PAGE * 2;
DBPRINT(("file size = %d\n", stat_buf.st_size ));
DBPRINT(("sysout size / 2 = 0x%x\n", sysout_size / 2));
DBPRINT(("file size = %d\n", stat_buf.st_size));
DBPRINT(("sysout size / 2 = 0x%x\n", sysout_size / 2));
lispworld_offset = 0;
for (i = 0; i < (sysout_size / 2); i++) {
lispworld_offset += BYTESPER_PAGE;
charptr = (char *) lispworld + lispworld_offset;
lispworld_offset = 0;
for (i = 0; i < (sysout_size / 2); i++) {
lispworld_offset += BYTESPER_PAGE;
charptr = (char *)lispworld + lispworld_offset;
#ifdef BUFFER
readresult = read(srcefile, bigbuff, BYTESPER_PAGE);
for ( j = 0; j < BYTESPER_PAGE; j++ ) {
*(charptr + j) = bigbuff [ j ];
}
readresult = read(srcefile, bigbuff, BYTESPER_PAGE);
for (j = 0; j < BYTESPER_PAGE; j++) { *(charptr + j) = bigbuff[j]; }
#else
readresult = read(srcefile, charptr, BYTESPER_PAGE);
readresult = read(srcefile, charptr, BYTESPER_PAGE);
#endif
if ( readresult == -1) {
printf("read_datum: can't read srcefile file at %d\n", i);
perror("read() error was");
exit(-1);
};
};
DBPRINT(("srcefile is read completely\n"));
close(srcefile);
}
if (readresult == -1) {
printf("read_datum: can't read srcefile file at %d\n", i);
perror("read() error was");
exit(-1);
};
};
DBPRINT(("srcefile is read completely\n"));
close(srcefile);
}
/* ================================================================ */
int_io_open() {}; /* stubs for other parts of our prog. */
int_io_close() {}; /* stubs for other parts of our prog. */
int_io_open(){}; /* stubs for other parts of our prog. */
int_io_close(){}; /* stubs for other parts of our prog. */
main() {
int maxdisplayregion; /* in what units? */
int realaddr;
main()
{
int maxdisplayregion; /* in what units? */
int realaddr;
realaddr = valloc(5000000);
if (realaddr == 0) {
printf("valloc returns 0\n");
} else {
maxdisplayregion = 4000000; /* assume 4Mb display reg. */
init_display2(realaddr, maxdisplayregion);
paint_display();
sleep(4);
realaddr = valloc( 5000000 );
if ( realaddr == 0 ) {
printf ( "valloc returns 0\n" );
}
else {
maxdisplayregion = 4000000; /* assume 4Mb display reg. */
init_display2( realaddr, maxdisplayregion );
paint_display();
sleep ( 4 );
DBPRINT(("before read_datum\n"));
read_datum(realaddr);
DBPRINT(("before read_datum\n"));
read_datum( realaddr );
sleep ( 4 );
display_before_exit();
}
}
sleep(4);
display_before_exit();
}
}