You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(35) |
Dec
(2) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(37) |
Feb
(10) |
Mar
|
Apr
(2) |
May
(17) |
Jun
(1) |
Jul
(14) |
Aug
(14) |
Sep
(4) |
Oct
|
Nov
(14) |
Dec
(4) |
2005 |
Jan
(6) |
Feb
|
Mar
|
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
(92) |
Dec
(12) |
2006 |
Jan
(3) |
Feb
(4) |
Mar
|
Apr
(5) |
May
(3) |
Jun
(15) |
Jul
(3) |
Aug
(1) |
Sep
(29) |
Oct
(1) |
Nov
(6) |
Dec
(5) |
2007 |
Jan
(2) |
Feb
(2) |
Mar
|
Apr
(3) |
May
(14) |
Jun
(2) |
Jul
(16) |
Aug
(73) |
Sep
(12) |
Oct
(9) |
Nov
(27) |
Dec
(3) |
2008 |
Jan
(4) |
Feb
(4) |
Mar
(3) |
Apr
(8) |
May
(23) |
Jun
(4) |
Jul
(1) |
Aug
(3) |
Sep
(7) |
Oct
(5) |
Nov
(1) |
Dec
(1) |
2009 |
Jan
|
Feb
(10) |
Mar
|
Apr
(4) |
May
(4) |
Jun
(10) |
Jul
|
Aug
(1) |
Sep
|
Oct
(7) |
Nov
|
Dec
(1) |
2010 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
|
Jun
(3) |
Jul
(11) |
Aug
(1) |
Sep
|
Oct
(15) |
Nov
(1) |
Dec
(5) |
2011 |
Jan
(4) |
Feb
(1) |
Mar
(6) |
Apr
|
May
(22) |
Jun
|
Jul
(8) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2012 |
Jan
|
Feb
(10) |
Mar
(1) |
Apr
(6) |
May
(27) |
Jun
(48) |
Jul
(30) |
Aug
(4) |
Sep
|
Oct
(3) |
Nov
(1) |
Dec
(11) |
2013 |
Jan
(4) |
Feb
(7) |
Mar
(6) |
Apr
(18) |
May
(28) |
Jun
(20) |
Jul
|
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
(2) |
Dec
(7) |
2014 |
Jan
(3) |
Feb
(2) |
Mar
(4) |
Apr
(9) |
May
(11) |
Jun
(10) |
Jul
|
Aug
(18) |
Sep
(12) |
Oct
(17) |
Nov
(10) |
Dec
(16) |
2015 |
Jan
(5) |
Feb
(1) |
Mar
(5) |
Apr
(4) |
May
(28) |
Jun
(2) |
Jul
|
Aug
|
Sep
(6) |
Oct
|
Nov
(2) |
Dec
(1) |
2016 |
Jan
(14) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
(1) |
2017 |
Jan
(11) |
Feb
|
Mar
(21) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(2) |
Sep
(4) |
Oct
(4) |
Nov
|
Dec
(1) |
2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(13) |
Sep
(4) |
Oct
|
Nov
|
Dec
|
2020 |
Jan
(10) |
Feb
(9) |
Mar
(5) |
Apr
(4) |
May
(3) |
Jun
(18) |
Jul
(4) |
Aug
(2) |
Sep
(20) |
Oct
(2) |
Nov
|
Dec
|
2021 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2022 |
Jan
(1) |
Feb
(2) |
Mar
(2) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
(1) |
2023 |
Jan
(10) |
Feb
(7) |
Mar
(29) |
Apr
(31) |
May
(29) |
Jun
(34) |
Jul
(3) |
Aug
(24) |
Sep
(22) |
Oct
(10) |
Nov
(38) |
Dec
(27) |
2024 |
Jan
(15) |
Feb
(8) |
Mar
(4) |
Apr
(20) |
May
(33) |
Jun
(18) |
Jul
(15) |
Aug
(23) |
Sep
(26) |
Oct
(32) |
Nov
(6) |
Dec
(4) |
2025 |
Jan
(7) |
Feb
(1) |
Mar
(1) |
Apr
(4) |
May
(46) |
Jun
(19) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <at...@us...> - 2007-08-12 20:48:17
|
Revision: 440 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=440&view=rev Author: atani Date: 2007-08-12 13:48:09 -0700 (Sun, 12 Aug 2007) Log Message: ----------- adding wrapper Makefile to call vcbuild Added Paths: ----------- tiki/win32/Makefile Added: tiki/win32/Makefile =================================================================== --- tiki/win32/Makefile (rev 0) +++ tiki/win32/Makefile 2007-08-12 20:48:09 UTC (rev 440) @@ -0,0 +1,3 @@ + +all: + vcbuild /rebuild tiki_vc80.sln $$ALL This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <at...@us...> - 2007-08-10 05:04:04
|
Revision: 439 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=439&view=rev Author: atani Date: 2007-08-09 22:03:51 -0700 (Thu, 09 Aug 2007) Log Message: ----------- add Tiki::Thread namespace declaration Modified Paths: -------------- tiki/include/Tiki/tiki.h Modified: tiki/include/Tiki/tiki.h =================================================================== --- tiki/include/Tiki/tiki.h 2007-08-10 01:42:22 UTC (rev 438) +++ tiki/include/Tiki/tiki.h 2007-08-10 05:03:51 UTC (rev 439) @@ -11,18 +11,19 @@ // Lay out the namespaces up front. namespace Tiki { -namespace Time { } -namespace Debug { } -namespace Math { } -namespace GL { -namespace Plxcompat { } -namespace Frame { } + namespace Time { } + namespace Thread { } + namespace Debug { } + namespace Math { } + namespace GL { + namespace Plxcompat { } + namespace Frame { } + } + namespace Hid { } + namespace Audio { + namespace OggVorbis { } + } } -namespace Hid { } -namespace Audio { -namespace OggVorbis { } -} -} // Define our supported platforms #define TIKI_OSX 0 @@ -41,22 +42,22 @@ #include <string> namespace Tiki { -// Bring STL string into the namespace. -using std::string; + // Bring STL string into the namespace. + using std::string; -// Global init/shutdown functions. -bool init( int argc, char **argv ); -void shutdown(); -void setName( const char *name, const char *icon ); -namespace GL { -void showCursor( bool visible ); + // Global init/shutdown functions. + bool init( int argc, char **argv ); + void shutdown(); + void setName( const char *name, const char *icon ); + namespace GL { + void showCursor( bool visible ); + } + // Endian swapping functions. + uint16 swaple( uint16 src ); + uint32 swaple( uint32 src ); + uint16 swapbe( uint16 src ); + uint32 swapbe( uint32 src ); } -// Endian swapping functions. -uint16 swaple( uint16 src ); -uint32 swaple( uint32 src ); -uint16 swapbe( uint16 src ); -uint32 swapbe( uint32 src ); -} // Bring in debug stuff, we'll use it everywhere. #include "Tiki/debug.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <at...@us...> - 2007-08-10 01:42:23
|
Revision: 438 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=438&view=rev Author: atani Date: 2007-08-09 18:42:22 -0700 (Thu, 09 Aug 2007) Log Message: ----------- reset ansiptr in clear() Modified Paths: -------------- tiki/src/gl/drawables/console.cpp Modified: tiki/src/gl/drawables/console.cpp =================================================================== --- tiki/src/gl/drawables/console.cpp 2007-08-09 23:13:03 UTC (rev 437) +++ tiki/src/gl/drawables/console.cpp 2007-08-10 01:42:22 UTC (rev 438) @@ -48,7 +48,6 @@ m_autoWrap = true; m_ansi = false; m_autoRefresh = false; - ansiptr = 0; color(GREY,BLACK); clear(); @@ -76,6 +75,7 @@ m_cursor_x = 0; m_cursor_y = 0; + ansiptr = 0; if(m_autoRefresh) refresh(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <at...@us...> - 2007-08-09 23:13:05
|
Revision: 437 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=437&view=rev Author: atani Date: 2007-08-09 16:13:03 -0700 (Thu, 09 Aug 2007) Log Message: ----------- astyle cleanups Modified Paths: -------------- tiki/3rdparty/libjpeg/jquant2.c tiki/3rdparty/libpng/png.h tiki/3rdparty/libpng/pngconf.h tiki/gp2x/Makefile tiki/sdl/Makefile Modified: tiki/3rdparty/libjpeg/jquant2.c =================================================================== --- tiki/3rdparty/libjpeg/jquant2.c 2007-08-09 22:51:20 UTC (rev 436) +++ tiki/3rdparty/libjpeg/jquant2.c 2007-08-09 23:13:03 UTC (rev 437) @@ -0,0 +1,1332 @@ +/* +* jquant2.c +* +* Copyright (C) 1991-1996, Thomas G. Lane. +* This file is part of the Independent JPEG Group's software. +* For conditions of distribution and use, see the accompanying README file. +* +* This file contains 2-pass color quantization (color mapping) routines. +* These routines provide selection of a custom color map for an image, +* followed by mapping of the image to that color map, with optional +* Floyd-Steinberg dithering. +* It is also possible to use just the second pass to map to an arbitrary +* externally-given color map. +* +* Note: ordered dithering is not supported, since there isn't any fast +* way to compute intercolor distances; it's unclear that ordered dither's +* fundamental assumptions even hold with an irregularly spaced color map. +*/ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + +#ifdef QUANT_2PASS_SUPPORTED + + +/* + * This module implements the well-known Heckbert paradigm for color + * quantization. Most of the ideas used here can be traced back to + * Heckbert's seminal paper + * Heckbert, Paul. "Color Image Quantization for Frame Buffer Display", + * Proc. SIGGRAPH '82, Computer Graphics v.16 #3 (July 1982), pp 297-304. + * + * In the first pass over the image, we accumulate a histogram showing the + * usage count of each possible color. To keep the histogram to a reasonable + * size, we reduce the precision of the input; typical practice is to retain + * 5 or 6 bits per color, so that 8 or 4 different input values are counted + * in the same histogram cell. + * + * Next, the color-selection step begins with a box representing the whole + * color space, and repeatedly splits the "largest" remaining box until we + * have as many boxes as desired colors. Then the mean color in each + * remaining box becomes one of the possible output colors. + * + * The second pass over the image maps each input pixel to the closest output + * color (optionally after applying a Floyd-Steinberg dithering correction). + * This mapping is logically trivial, but making it go fast enough requires + * considerable care. + * + * Heckbert-style quantizers vary a good deal in their policies for choosing + * the "largest" box and deciding where to cut it. The particular policies + * used here have proved out well in experimental comparisons, but better ones + * may yet be found. + * + * In earlier versions of the IJG code, this module quantized in YCbCr color + * space, processing the raw upsampled data without a color conversion step. + * This allowed the color conversion math to be done only once per colormap + * entry, not once per pixel. However, that optimization precluded other + * useful optimizations (such as merging color conversion with upsampling) + * and it also interfered with desired capabilities such as quantizing to an + * externally-supplied colormap. We have therefore abandoned that approach. + * The present code works in the post-conversion color space, typically RGB. + * + * To improve the visual quality of the results, we actually work in scaled + * RGB space, giving G distances more weight than R, and R in turn more than + * B. To do everything in integer math, we must use integer scale factors. + * The 2/3/1 scale factors used here correspond loosely to the relative + * weights of the colors in the NTSC grayscale equation. + * If you want to use this code to quantize a non-RGB color space, you'll + * probably need to change these scale factors. + */ + +#define R_SCALE 2 /* scale R distances by this much */ +#define G_SCALE 3 /* scale G distances by this much */ +#define B_SCALE 1 /* and B by this much */ + +/* Relabel R/G/B as components 0/1/2, respecting the RGB ordering defined + * in jmorecfg.h. As the code stands, it will do the right thing for R,G,B + * and B,G,R orders. If you define some other weird order in jmorecfg.h, + * you'll get compile errors until you extend this logic. In that case + * you'll probably want to tweak the histogram sizes too. + */ + +#if RGB_RED == 0 +#define C0_SCALE R_SCALE +#endif +#if RGB_BLUE == 0 +#define C0_SCALE B_SCALE +#endif +#if RGB_GREEN == 1 +#define C1_SCALE G_SCALE +#endif +#if RGB_RED == 2 +#define C2_SCALE R_SCALE +#endif +#if RGB_BLUE == 2 +#define C2_SCALE B_SCALE +#endif + + +/* + * First we have the histogram data structure and routines for creating it. + * + * The number of bits of precision can be adjusted by changing these symbols. + * We recommend keeping 6 bits for G and 5 each for R and B. + * If you have plenty of memory and cycles, 6 bits all around gives marginally + * better results; if you are short of memory, 5 bits all around will save + * some space but degrade the results. + * To maintain a fully accurate histogram, we'd need to allocate a "long" + * (preferably unsigned long) for each cell. In practice this is overkill; + * we can get by with 16 bits per cell. Few of the cell counts will overflow, + * and clamping those that do overflow to the maximum value will give close- + * enough results. This reduces the recommended histogram size from 256Kb + * to 128Kb, which is a useful savings on PC-class machines. + * (In the second pass the histogram space is re-used for pixel mapping data; + * in that capacity, each cell must be able to store zero to the number of + * desired colors. 16 bits/cell is plenty for that too.) + * Since the JPEG code is intended to run in small memory model on 80x86 + * machines, we can't just allocate the histogram in one chunk. Instead + * of a true 3-D array, we use a row of pointers to 2-D arrays. Each + * pointer corresponds to a C0 value (typically 2^5 = 32 pointers) and + * each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries. Note that + * on 80x86 machines, the pointer row is in near memory but the actual + * arrays are in far memory (same arrangement as we use for image arrays). + */ + +#define MAXNUMCOLORS (MAXJSAMPLE+1) /* maximum size of colormap */ + +/* These will do the right thing for either R,G,B or B,G,R color order, + * but you may not like the results for other color orders. + */ +#define HIST_C0_BITS 5 /* bits of precision in R/B histogram */ +#define HIST_C1_BITS 6 /* bits of precision in G histogram */ +#define HIST_C2_BITS 5 /* bits of precision in B/R histogram */ + +/* Number of elements along histogram axes. */ +#define HIST_C0_ELEMS (1<<HIST_C0_BITS) +#define HIST_C1_ELEMS (1<<HIST_C1_BITS) +#define HIST_C2_ELEMS (1<<HIST_C2_BITS) + +/* These are the amounts to shift an input value to get a histogram index. */ +#define C0_SHIFT (BITS_IN_JSAMPLE-HIST_C0_BITS) +#define C1_SHIFT (BITS_IN_JSAMPLE-HIST_C1_BITS) +#define C2_SHIFT (BITS_IN_JSAMPLE-HIST_C2_BITS) + + +typedef UINT16 histcell; /* histogram cell; prefer an unsigned type */ + +typedef histcell FAR * histptr; /* for pointers to histogram cells */ + +typedef histcell hist1d[ HIST_C2_ELEMS ]; /* typedefs for the array */ +typedef hist1d FAR * hist2d; /* type for the 2nd-level pointers */ +typedef hist2d * hist3d; /* type for top-level pointer */ + + +/* Declarations for Floyd-Steinberg dithering. + * + * Errors are accumulated into the array fserrors[], at a resolution of + * 1/16th of a pixel count. The error at a given pixel is propagated + * to its not-yet-processed neighbors using the standard F-S fractions, + * ... (here) 7/16 + * 3/16 5/16 1/16 + * We work left-to-right on even rows, right-to-left on odd rows. + * + * We can get away with a single array (holding one row's worth of errors) + * by using it to store the current row's errors at pixel columns not yet + * processed, but the next row's errors at columns already processed. We + * need only a few extra variables to hold the errors immediately around the + * current column. (If we are lucky, those variables are in registers, but + * even if not, they're probably cheaper to access than array elements are.) + * + * The fserrors[] array has (#columns + 2) entries; the extra entry at + * each end saves us from special-casing the first and last pixels. + * Each entry is three values long, one value for each color component. + * + * Note: on a wide image, we might not have enough room in a PC's near data + * segment to hold the error array; so it is allocated with alloc_large. + */ + +#if BITS_IN_JSAMPLE == 8 +typedef INT16 FSERROR; /* 16 bits should be enough */ +typedef int LOCFSERROR; /* use 'int' for calculation temps */ +#else +typedef INT32 FSERROR; /* may need more than 16 bits */ +typedef INT32 LOCFSERROR; /* be sure calculation temps are big enough */ +#endif + +typedef FSERROR FAR *FSERRPTR; /* pointer to error array (in FAR storage!) */ + + +/* Private subobject */ + +typedef struct { + struct jpeg_color_quantizer pub; /* public fields */ + + /* Space for the eventually created colormap is stashed here */ + JSAMPARRAY sv_colormap; /* colormap allocated at init time */ + int desired; /* desired # of colors = size of colormap */ + + /* Variables for accumulating image statistics */ + hist3d histogram; /* pointer to the histogram */ + + boolean needs_zeroed; /* TRUE if next pass must zero histogram */ + + /* Variables for Floyd-Steinberg dithering */ + FSERRPTR fserrors; /* accumulated errors */ + boolean on_odd_row; /* flag to remember which row we are on */ + int * error_limiter; /* table for clamping the applied error */ +} +my_cquantizer; + +typedef my_cquantizer * my_cquantize_ptr; + + +/* + * Prescan some rows of pixels. + * In this module the prescan simply updates the histogram, which has been + * initialized to zeroes by start_pass. + * An output_buf parameter is required by the method signature, but no data + * is actually output (in fact the buffer controller is probably passing a + * NULL pointer). + */ + +METHODDEF( void ) +prescan_quantize ( j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows ) { + my_cquantize_ptr cquantize = ( my_cquantize_ptr ) cinfo->cquantize; + register JSAMPROW ptr; + register histptr histp; + register hist3d histogram = cquantize->histogram; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for ( row = 0; row < num_rows; row++ ) { + ptr = input_buf[ row ]; + for ( col = width; col > 0; col-- ) { + /* get pixel value and index into the histogram */ + histp = & histogram[ GETJSAMPLE( ptr[ 0 ] ) >> C0_SHIFT ] + [ GETJSAMPLE( ptr[ 1 ] ) >> C1_SHIFT ] + [ GETJSAMPLE( ptr[ 2 ] ) >> C2_SHIFT ]; + /* increment, check for overflow and undo increment if so. */ + if ( ++( *histp ) <= 0 ) + ( *histp ) --; + ptr += 3; + } + } +} + + +/* + * Next we have the really interesting routines: selection of a colormap + * given the completed histogram. + * These routines work with a list of "boxes", each representing a rectangular + * subset of the input color space (to histogram precision). + */ + +typedef struct { + /* The bounds of the box (inclusive); expressed as histogram indexes */ + int c0min, c0max; + int c1min, c1max; + int c2min, c2max; + /* The volume (actually 2-norm) of the box */ + INT32 volume; + /* The number of nonzero histogram cells within this box */ + long colorcount; +} +box; + +typedef box * boxptr; + + +LOCAL( boxptr ) +find_biggest_color_pop ( boxptr boxlist, int numboxes ) +/* Find the splittable box with the largest color population */ +/* Returns NULL if no splittable boxes remain */ +{ + register boxptr boxp; + register int i; + register long maxc = 0; + boxptr which = NULL; + + for ( i = 0, boxp = boxlist; i < numboxes; i++, boxp++ ) { + if ( boxp->colorcount > maxc && boxp->volume > 0 ) { + which = boxp; + maxc = boxp->colorcount; + } + } + return which; +} + + +LOCAL( boxptr ) +find_biggest_volume ( boxptr boxlist, int numboxes ) +/* Find the splittable box with the largest (scaled) volume */ +/* Returns NULL if no splittable boxes remain */ +{ + register boxptr boxp; + register int i; + register INT32 maxv = 0; + boxptr which = NULL; + + for ( i = 0, boxp = boxlist; i < numboxes; i++, boxp++ ) { + if ( boxp->volume > maxv ) { + which = boxp; + maxv = boxp->volume; + } + } + return which; +} + + +LOCAL( void ) +update_box ( j_decompress_ptr cinfo, boxptr boxp ) +/* Shrink the min/max bounds of a box to enclose only nonzero elements, */ +/* and recompute its volume and population */ +{ + my_cquantize_ptr cquantize = ( my_cquantize_ptr ) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + histptr histp; + int c0, c1, c2; + int c0min, c0max, c1min, c1max, c2min, c2max; + INT32 dist0, dist1, dist2; + long ccount; + + c0min = boxp->c0min; + c0max = boxp->c0max; + c1min = boxp->c1min; + c1max = boxp->c1max; + c2min = boxp->c2min; + c2max = boxp->c2max; + + if ( c0max > c0min ) + for ( c0 = c0min; c0 <= c0max; c0++ ) + for ( c1 = c1min; c1 <= c1max; c1++ ) { + histp = & histogram[ c0 ][ c1 ][ c2min ]; + for ( c2 = c2min; c2 <= c2max; c2++ ) + if ( *histp++ != 0 ) { + boxp->c0min = c0min = c0; + goto have_c0min; + } + } +have_c0min: + if ( c0max > c0min ) + for ( c0 = c0max; c0 >= c0min; c0-- ) + for ( c1 = c1min; c1 <= c1max; c1++ ) { + histp = & histogram[ c0 ][ c1 ][ c2min ]; + for ( c2 = c2min; c2 <= c2max; c2++ ) + if ( *histp++ != 0 ) { + boxp->c0max = c0max = c0; + goto have_c0max; + } + } +have_c0max: + if ( c1max > c1min ) + for ( c1 = c1min; c1 <= c1max; c1++ ) + for ( c0 = c0min; c0 <= c0max; c0++ ) { + histp = & histogram[ c0 ][ c1 ][ c2min ]; + for ( c2 = c2min; c2 <= c2max; c2++ ) + if ( *histp++ != 0 ) { + boxp->c1min = c1min = c1; + goto have_c1min; + } + } +have_c1min: + if ( c1max > c1min ) + for ( c1 = c1max; c1 >= c1min; c1-- ) + for ( c0 = c0min; c0 <= c0max; c0++ ) { + histp = & histogram[ c0 ][ c1 ][ c2min ]; + for ( c2 = c2min; c2 <= c2max; c2++ ) + if ( *histp++ != 0 ) { + boxp->c1max = c1max = c1; + goto have_c1max; + } + } +have_c1max: + if ( c2max > c2min ) + for ( c2 = c2min; c2 <= c2max; c2++ ) + for ( c0 = c0min; c0 <= c0max; c0++ ) { + histp = & histogram[ c0 ][ c1min ][ c2 ]; + for ( c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS ) + if ( *histp != 0 ) { + boxp->c2min = c2min = c2; + goto have_c2min; + } + } +have_c2min: + if ( c2max > c2min ) + for ( c2 = c2max; c2 >= c2min; c2-- ) + for ( c0 = c0min; c0 <= c0max; c0++ ) { + histp = & histogram[ c0 ][ c1min ][ c2 ]; + for ( c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS ) + if ( *histp != 0 ) { + boxp->c2max = c2max = c2; + goto have_c2max; + } + } +have_c2max: + + /* Update box volume. + * We use 2-norm rather than real volume here; this biases the method + * against making long narrow boxes, and it has the side benefit that + * a box is splittable iff norm > 0. + * Since the differences are expressed in histogram-cell units, + * we have to shift back to JSAMPLE units to get consistent distances; + * after which, we scale according to the selected distance scale factors. + */ + dist0 = ( ( c0max - c0min ) << C0_SHIFT ) * C0_SCALE; + dist1 = ( ( c1max - c1min ) << C1_SHIFT ) * C1_SCALE; + dist2 = ( ( c2max - c2min ) << C2_SHIFT ) * C2_SCALE; + boxp->volume = dist0 * dist0 + dist1 * dist1 + dist2 * dist2; + + /* Now scan remaining volume of box and compute population */ + ccount = 0; + for ( c0 = c0min; c0 <= c0max; c0++ ) + for ( c1 = c1min; c1 <= c1max; c1++ ) { + histp = & histogram[ c0 ][ c1 ][ c2min ]; + for ( c2 = c2min; c2 <= c2max; c2++, histp++ ) + if ( *histp != 0 ) { + ccount++; + } + } + boxp->colorcount = ccount; +} + + +LOCAL( int ) +median_cut ( j_decompress_ptr cinfo, boxptr boxlist, int numboxes, + int desired_colors ) +/* Repeatedly select and split the largest box until we have enough boxes */ +{ + int n, lb; + int c0, c1, c2, cmax; + register boxptr b1, b2; + + while ( numboxes < desired_colors ) { + /* Select box to split. + * Current algorithm: by population for first half, then by volume. + */ + if ( numboxes * 2 <= desired_colors ) { + b1 = find_biggest_color_pop( boxlist, numboxes ); + } else { + b1 = find_biggest_volume( boxlist, numboxes ); + } + if ( b1 == NULL ) /* no splittable boxes left! */ + break; + b2 = &boxlist[ numboxes ]; /* where new box will go */ + /* Copy the color bounds to the new box. */ + b2->c0max = b1->c0max; + b2->c1max = b1->c1max; + b2->c2max = b1->c2max; + b2->c0min = b1->c0min; + b2->c1min = b1->c1min; + b2->c2min = b1->c2min; + /* Choose which axis to split the box on. + * Current algorithm: longest scaled axis. + * See notes in update_box about scaling distances. + */ + c0 = ( ( b1->c0max - b1->c0min ) << C0_SHIFT ) * C0_SCALE; + c1 = ( ( b1->c1max - b1->c1min ) << C1_SHIFT ) * C1_SCALE; + c2 = ( ( b1->c2max - b1->c2min ) << C2_SHIFT ) * C2_SCALE; + /* We want to break any ties in favor of green, then red, blue last. + * This code does the right thing for R,G,B or B,G,R color orders only. + */ +#if RGB_RED == 0 + + cmax = c1; + n = 1; + if ( c0 > cmax ) { + cmax = c0; + n = 0; + } + if ( c2 > cmax ) { + n = 2; + } +#else + cmax = c1; + n = 1; + if ( c2 > cmax ) { + cmax = c2; + n = 2; + } + if ( c0 > cmax ) { + n = 0; + } +#endif + /* Choose split point along selected axis, and update box bounds. + * Current algorithm: split at halfway point. + * (Since the box has been shrunk to minimum volume, + * any split will produce two nonempty subboxes.) + * Note that lb value is max for lower box, so must be < old max. + */ + switch ( n ) { + case 0: + lb = ( b1->c0max + b1->c0min ) / 2; + b1->c0max = lb; + b2->c0min = lb + 1; + break; + case 1: + lb = ( b1->c1max + b1->c1min ) / 2; + b1->c1max = lb; + b2->c1min = lb + 1; + break; + case 2: + lb = ( b1->c2max + b1->c2min ) / 2; + b1->c2max = lb; + b2->c2min = lb + 1; + break; + } + /* Update stats for boxes */ + update_box( cinfo, b1 ); + update_box( cinfo, b2 ); + numboxes++; + } + return numboxes; +} + + +LOCAL( void ) +compute_color ( j_decompress_ptr cinfo, boxptr boxp, int icolor ) +/* Compute representative color for a box, put it in colormap[icolor] */ +{ + /* Current algorithm: mean weighted by pixels (not colors) */ + /* Note it is important to get the rounding correct! */ + my_cquantize_ptr cquantize = ( my_cquantize_ptr ) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + histptr histp; + int c0, c1, c2; + int c0min, c0max, c1min, c1max, c2min, c2max; + long count; + long total = 0; + long c0total = 0; + long c1total = 0; + long c2total = 0; + + c0min = boxp->c0min; + c0max = boxp->c0max; + c1min = boxp->c1min; + c1max = boxp->c1max; + c2min = boxp->c2min; + c2max = boxp->c2max; + + for ( c0 = c0min; c0 <= c0max; c0++ ) + for ( c1 = c1min; c1 <= c1max; c1++ ) { + histp = & histogram[ c0 ][ c1 ][ c2min ]; + for ( c2 = c2min; c2 <= c2max; c2++ ) { + if ( ( count = *histp++ ) != 0 ) { + total += count; + c0total += ( ( c0 << C0_SHIFT ) + ( ( 1 << C0_SHIFT ) >> 1 ) ) * count; + c1total += ( ( c1 << C1_SHIFT ) + ( ( 1 << C1_SHIFT ) >> 1 ) ) * count; + c2total += ( ( c2 << C2_SHIFT ) + ( ( 1 << C2_SHIFT ) >> 1 ) ) * count; + } + } + } + + cinfo->colormap[ 0 ][ icolor ] = ( JSAMPLE ) ( ( c0total + ( total >> 1 ) ) / total ); + cinfo->colormap[ 1 ][ icolor ] = ( JSAMPLE ) ( ( c1total + ( total >> 1 ) ) / total ); + cinfo->colormap[ 2 ][ icolor ] = ( JSAMPLE ) ( ( c2total + ( total >> 1 ) ) / total ); +} + + +LOCAL( void ) +select_colors ( j_decompress_ptr cinfo, int desired_colors ) +/* Master routine for color selection */ +{ + boxptr boxlist; + int numboxes; + int i; + + /* Allocate workspace for box list */ + boxlist = ( boxptr ) ( *cinfo->mem->alloc_small ) + ( ( j_common_ptr ) cinfo, JPOOL_IMAGE, desired_colors * SIZEOF( box ) ); + /* Initialize one box containing whole space */ + numboxes = 1; + boxlist[ 0 ].c0min = 0; + boxlist[ 0 ].c0max = MAXJSAMPLE >> C0_SHIFT; + boxlist[ 0 ].c1min = 0; + boxlist[ 0 ].c1max = MAXJSAMPLE >> C1_SHIFT; + boxlist[ 0 ].c2min = 0; + boxlist[ 0 ].c2max = MAXJSAMPLE >> C2_SHIFT; + /* Shrink it to actually-used volume and set its statistics */ + update_box( cinfo, & boxlist[ 0 ] ); + /* Perform median-cut to produce final box list */ + numboxes = median_cut( cinfo, boxlist, numboxes, desired_colors ); + /* Compute the representative color for each box, fill colormap */ + for ( i = 0; i < numboxes; i++ ) + compute_color( cinfo, & boxlist[ i ], i ); + cinfo->actual_number_of_colors = numboxes; + TRACEMS1( cinfo, 1, JTRC_QUANT_SELECTED, numboxes ); +} + + +/* + * These routines are concerned with the time-critical task of mapping input + * colors to the nearest color in the selected colormap. + * + * We re-use the histogram space as an "inverse color map", essentially a + * cache for the results of nearest-color searches. All colors within a + * histogram cell will be mapped to the same colormap entry, namely the one + * closest to the cell's center. This may not be quite the closest entry to + * the actual input color, but it's almost as good. A zero in the cache + * indicates we haven't found the nearest color for that cell yet; the array + * is cleared to zeroes before starting the mapping pass. When we find the + * nearest color for a cell, its colormap index plus one is recorded in the + * cache for future use. The pass2 scanning routines call fill_inverse_cmap + * when they need to use an unfilled entry in the cache. + * + * Our method of efficiently finding nearest colors is based on the "locally + * sorted search" idea described by Heckbert and on the incremental distance + * calculation described by Spencer W. Thomas in chapter III.1 of Graphics + * Gems II (James Arvo, ed. Academic Press, 1991). Thomas points out that + * the distances from a given colormap entry to each cell of the histogram can + * be computed quickly using an incremental method: the differences between + * distances to adjacent cells themselves differ by a constant. This allows a + * fairly fast implementation of the "brute force" approach of computing the + * distance from every colormap entry to every histogram cell. Unfortunately, + * it needs a work array to hold the best-distance-so-far for each histogram + * cell (because the inner loop has to be over cells, not colormap entries). + * The work array elements have to be INT32s, so the work array would need + * 256Kb at our recommended precision. This is not feasible in DOS machines. + * + * To get around these problems, we apply Thomas' method to compute the + * nearest colors for only the cells within a small subbox of the histogram. + * The work array need be only as big as the subbox, so the memory usage + * problem is solved. Furthermore, we need not fill subboxes that are never + * referenced in pass2; many images use only part of the color gamut, so a + * fair amount of work is saved. An additional advantage of this + * approach is that we can apply Heckbert's locality criterion to quickly + * eliminate colormap entries that are far away from the subbox; typically + * three-fourths of the colormap entries are rejected by Heckbert's criterion, + * and we need not compute their distances to individual cells in the subbox. + * The speed of this approach is heavily influenced by the subbox size: too + * small means too much overhead, too big loses because Heckbert's criterion + * can't eliminate as many colormap entries. Empirically the best subbox + * size seems to be about 1/512th of the histogram (1/8th in each direction). + * + * Thomas' article also describes a refined method which is asymptotically + * faster than the brute-force method, but it is also far more complex and + * cannot efficiently be applied to small subboxes. It is therefore not + * useful for programs intended to be portable to DOS machines. On machines + * with plenty of memory, filling the whole histogram in one shot with Thomas' + * refined method might be faster than the present code --- but then again, + * it might not be any faster, and it's certainly more complicated. + */ + + +/* log2(histogram cells in update box) for each axis; this can be adjusted */ +#define BOX_C0_LOG (HIST_C0_BITS-3) +#define BOX_C1_LOG (HIST_C1_BITS-3) +#define BOX_C2_LOG (HIST_C2_BITS-3) + +#define BOX_C0_ELEMS (1<<BOX_C0_LOG) /* # of hist cells in update box */ +#define BOX_C1_ELEMS (1<<BOX_C1_LOG) +#define BOX_C2_ELEMS (1<<BOX_C2_LOG) + +#define BOX_C0_SHIFT (C0_SHIFT + BOX_C0_LOG) +#define BOX_C1_SHIFT (C1_SHIFT + BOX_C1_LOG) +#define BOX_C2_SHIFT (C2_SHIFT + BOX_C2_LOG) + + +/* + * The next three routines implement inverse colormap filling. They could + * all be folded into one big routine, but splitting them up this way saves + * some stack space (the mindist[] and bestdist[] arrays need not coexist) + * and may allow some compilers to produce better code by registerizing more + * inner-loop variables. + */ + +LOCAL( int ) +find_nearby_colors ( j_decompress_ptr cinfo, int minc0, int minc1, int minc2, + JSAMPLE colorlist[] ) +/* Locate the colormap entries close enough to an update box to be candidates + * for the nearest entry to some cell(s) in the update box. The update box + * is specified by the center coordinates of its first cell. The number of + * candidate colormap entries is returned, and their colormap indexes are + * placed in colorlist[]. + * This routine uses Heckbert's "locally sorted search" criterion to select + * the colors that need further consideration. + */ +{ + int numcolors = cinfo->actual_number_of_colors; + int maxc0, maxc1, maxc2; + int centerc0, centerc1, centerc2; + int i, x, ncolors; + INT32 minmaxdist, min_dist, max_dist, tdist; + INT32 mindist[ MAXNUMCOLORS ]; /* min distance to colormap entry i */ + + /* Compute true coordinates of update box's upper corner and center. + * Actually we compute the coordinates of the center of the upper-corner + * histogram cell, which are the upper bounds of the volume we care about. + * Note that since ">>" rounds down, the "center" values may be closer to + * min than to max; hence comparisons to them must be "<=", not "<". + */ + maxc0 = minc0 + ( ( 1 << BOX_C0_SHIFT ) - ( 1 << C0_SHIFT ) ); + centerc0 = ( minc0 + maxc0 ) >> 1; + maxc1 = minc1 + ( ( 1 << BOX_C1_SHIFT ) - ( 1 << C1_SHIFT ) ); + centerc1 = ( minc1 + maxc1 ) >> 1; + maxc2 = minc2 + ( ( 1 << BOX_C2_SHIFT ) - ( 1 << C2_SHIFT ) ); + centerc2 = ( minc2 + maxc2 ) >> 1; + + /* For each color in colormap, find: + * 1. its minimum squared-distance to any point in the update box + * (zero if color is within update box); + * 2. its maximum squared-distance to any point in the update box. + * Both of these can be found by considering only the corners of the box. + * We save the minimum distance for each color in mindist[]; + * only the smallest maximum distance is of interest. + */ + minmaxdist = 0x7FFFFFFFL; + + for ( i = 0; i < numcolors; i++ ) { + /* We compute the squared-c0-distance term, then add in the other two. */ + x = GETJSAMPLE( cinfo->colormap[ 0 ][ i ] ); + if ( x < minc0 ) { + tdist = ( x - minc0 ) * C0_SCALE; + min_dist = tdist * tdist; + tdist = ( x - maxc0 ) * C0_SCALE; + max_dist = tdist * tdist; + } else if ( x > maxc0 ) { + tdist = ( x - maxc0 ) * C0_SCALE; + min_dist = tdist * tdist; + tdist = ( x - minc0 ) * C0_SCALE; + max_dist = tdist * tdist; + } else { + /* within cell range so no contribution to min_dist */ + min_dist = 0; + if ( x <= centerc0 ) { + tdist = ( x - maxc0 ) * C0_SCALE; + max_dist = tdist * tdist; + } else { + tdist = ( x - minc0 ) * C0_SCALE; + max_dist = tdist * tdist; + } + } + + x = GETJSAMPLE( cinfo->colormap[ 1 ][ i ] ); + if ( x < minc1 ) { + tdist = ( x - minc1 ) * C1_SCALE; + min_dist += tdist * tdist; + tdist = ( x - maxc1 ) * C1_SCALE; + max_dist += tdist * tdist; + } else if ( x > maxc1 ) { + tdist = ( x - maxc1 ) * C1_SCALE; + min_dist += tdist * tdist; + tdist = ( x - minc1 ) * C1_SCALE; + max_dist += tdist * tdist; + } else { + /* within cell range so no contribution to min_dist */ + if ( x <= centerc1 ) { + tdist = ( x - maxc1 ) * C1_SCALE; + max_dist += tdist * tdist; + } else { + tdist = ( x - minc1 ) * C1_SCALE; + max_dist += tdist * tdist; + } + } + + x = GETJSAMPLE( cinfo->colormap[ 2 ][ i ] ); + if ( x < minc2 ) { + tdist = ( x - minc2 ) * C2_SCALE; + min_dist += tdist * tdist; + tdist = ( x - maxc2 ) * C2_SCALE; + max_dist += tdist * tdist; + } else if ( x > maxc2 ) { + tdist = ( x - maxc2 ) * C2_SCALE; + min_dist += tdist * tdist; + tdist = ( x - minc2 ) * C2_SCALE; + max_dist += tdist * tdist; + } else { + /* within cell range so no contribution to min_dist */ + if ( x <= centerc2 ) { + tdist = ( x - maxc2 ) * C2_SCALE; + max_dist += tdist * tdist; + } else { + tdist = ( x - minc2 ) * C2_SCALE; + max_dist += tdist * tdist; + } + } + + mindist[ i ] = min_dist; /* save away the results */ + if ( max_dist < minmaxdist ) + minmaxdist = max_dist; + } + + /* Now we know that no cell in the update box is more than minmaxdist + * away from some colormap entry. Therefore, only colors that are + * within minmaxdist of some part of the box need be considered. + */ + ncolors = 0; + for ( i = 0; i < numcolors; i++ ) { + if ( mindist[ i ] <= minmaxdist ) + colorlist[ ncolors++ ] = ( JSAMPLE ) i; + } + return ncolors; +} + + +LOCAL( void ) +find_best_colors ( j_decompress_ptr cinfo, int minc0, int minc1, int minc2, + int numcolors, JSAMPLE colorlist[], JSAMPLE bestcolor[] ) +/* Find the closest colormap entry for each cell in the update box, + * given the list of candidate colors prepared by find_nearby_colors. + * Return the indexes of the closest entries in the bestcolor[] array. + * This routine uses Thomas' incremental distance calculation method to + * find the distance from a colormap entry to successive cells in the box. + */ +{ + int ic0, ic1, ic2; + int i, icolor; + register INT32 * bptr; /* pointer into bestdist[] array */ + JSAMPLE * cptr; /* pointer into bestcolor[] array */ + INT32 dist0, dist1; /* initial distance values */ + register INT32 dist2; /* current distance in inner loop */ + INT32 xx0, xx1; /* distance increments */ + register INT32 xx2; + INT32 inc0, inc1, inc2; /* initial values for increments */ + /* This array holds the distance to the nearest-so-far color for each cell */ + INT32 bestdist[ BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS ]; + + /* Initialize best-distance for each cell of the update box */ + bptr = bestdist; + for ( i = BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS - 1; i >= 0; i-- ) + *bptr++ = 0x7FFFFFFFL; + + /* For each color selected by find_nearby_colors, + * compute its distance to the center of each cell in the box. + * If that's less than best-so-far, update best distance and color number. + */ + + /* Nominal steps between cell centers ("x" in Thomas article) */ +#define STEP_C0 ((1 << C0_SHIFT) * C0_SCALE) +#define STEP_C1 ((1 << C1_SHIFT) * C1_SCALE) +#define STEP_C2 ((1 << C2_SHIFT) * C2_SCALE) + + for ( i = 0; i < numcolors; i++ ) { + icolor = GETJSAMPLE( colorlist[ i ] ); + /* Compute (square of) distance from minc0/c1/c2 to this color */ + inc0 = ( minc0 - GETJSAMPLE( cinfo->colormap[ 0 ][ icolor ] ) ) * C0_SCALE; + dist0 = inc0 * inc0; + inc1 = ( minc1 - GETJSAMPLE( cinfo->colormap[ 1 ][ icolor ] ) ) * C1_SCALE; + dist0 += inc1 * inc1; + inc2 = ( minc2 - GETJSAMPLE( cinfo->colormap[ 2 ][ icolor ] ) ) * C2_SCALE; + dist0 += inc2 * inc2; + /* Form the initial difference increments */ + inc0 = inc0 * ( 2 * STEP_C0 ) + STEP_C0 * STEP_C0; + inc1 = inc1 * ( 2 * STEP_C1 ) + STEP_C1 * STEP_C1; + inc2 = inc2 * ( 2 * STEP_C2 ) + STEP_C2 * STEP_C2; + /* Now loop over all cells in box, updating distance per Thomas method */ + bptr = bestdist; + cptr = bestcolor; + xx0 = inc0; + for ( ic0 = BOX_C0_ELEMS - 1; ic0 >= 0; ic0-- ) { + dist1 = dist0; + xx1 = inc1; + for ( ic1 = BOX_C1_ELEMS - 1; ic1 >= 0; ic1-- ) { + dist2 = dist1; + xx2 = inc2; + for ( ic2 = BOX_C2_ELEMS - 1; ic2 >= 0; ic2-- ) { + if ( dist2 < *bptr ) { + *bptr = dist2; + *cptr = ( JSAMPLE ) icolor; + } + dist2 += xx2; + xx2 += 2 * STEP_C2 * STEP_C2; + bptr++; + cptr++; + } + dist1 += xx1; + xx1 += 2 * STEP_C1 * STEP_C1; + } + dist0 += xx0; + xx0 += 2 * STEP_C0 * STEP_C0; + } + } +} + + +LOCAL( void ) +fill_inverse_cmap ( j_decompress_ptr cinfo, int c0, int c1, int c2 ) +/* Fill the inverse-colormap entries in the update box that contains */ +/* histogram cell c0/c1/c2. (Only that one cell MUST be filled, but */ +/* we can fill as many others as we wish.) */ +{ + my_cquantize_ptr cquantize = ( my_cquantize_ptr ) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + int minc0, minc1, minc2; /* lower left corner of update box */ + int ic0, ic1, ic2; + register JSAMPLE * cptr; /* pointer into bestcolor[] array */ + register histptr cachep; /* pointer into main cache array */ + /* This array lists the candidate colormap indexes. */ + JSAMPLE colorlist[ MAXNUMCOLORS ]; + int numcolors; /* number of candidate colors */ + /* This array holds the actually closest colormap index for each cell. */ + JSAMPLE bestcolor[ BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS ]; + + /* Convert cell coordinates to update box ID */ + c0 >>= BOX_C0_LOG; + c1 >>= BOX_C1_LOG; + c2 >>= BOX_C2_LOG; + + /* Compute true coordinates of update box's origin corner. + * Actually we compute the coordinates of the center of the corner + * histogram cell, which are the lower bounds of the volume we care about. + */ + minc0 = ( c0 << BOX_C0_SHIFT ) + ( ( 1 << C0_SHIFT ) >> 1 ); + minc1 = ( c1 << BOX_C1_SHIFT ) + ( ( 1 << C1_SHIFT ) >> 1 ); + minc2 = ( c2 << BOX_C2_SHIFT ) + ( ( 1 << C2_SHIFT ) >> 1 ); + + /* Determine which colormap entries are close enough to be candidates + * for the nearest entry to some cell in the update box. + */ + numcolors = find_nearby_colors( cinfo, minc0, minc1, minc2, colorlist ); + + /* Determine the actually nearest colors. */ + find_best_colors( cinfo, minc0, minc1, minc2, numcolors, colorlist, + bestcolor ); + + /* Save the best color numbers (plus 1) in the main cache array */ + c0 <<= BOX_C0_LOG; /* convert ID back to base cell indexes */ + c1 <<= BOX_C1_LOG; + c2 <<= BOX_C2_LOG; + cptr = bestcolor; + for ( ic0 = 0; ic0 < BOX_C0_ELEMS; ic0++ ) { + for ( ic1 = 0; ic1 < BOX_C1_ELEMS; ic1++ ) { + cachep = & histogram[ c0 + ic0 ][ c1 + ic1 ][ c2 ]; + for ( ic2 = 0; ic2 < BOX_C2_ELEMS; ic2++ ) { + *cachep++ = ( histcell ) ( GETJSAMPLE( *cptr++ ) + 1 ); + } + } + } +} + + +/* + * Map some rows of pixels to the output colormapped representation. + */ + +METHODDEF( void ) +pass2_no_dither ( j_decompress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows ) +/* This version performs no dithering */ +{ + my_cquantize_ptr cquantize = ( my_cquantize_ptr ) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + register JSAMPROW inptr, outptr; + register histptr cachep; + register int c0, c1, c2; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for ( row = 0; row < num_rows; row++ ) { + inptr = input_buf[ row ]; + outptr = output_buf[ row ]; + for ( col = width; col > 0; col-- ) { + /* get pixel value and index into the cache */ + c0 = GETJSAMPLE( *inptr++ ) >> C0_SHIFT; + c1 = GETJSAMPLE( *inptr++ ) >> C1_SHIFT; + c2 = GETJSAMPLE( *inptr++ ) >> C2_SHIFT; + cachep = & histogram[ c0 ][ c1 ][ c2 ]; + /* If we have not seen this color before, find nearest colormap entry */ + /* and update the cache */ + if ( *cachep == 0 ) + fill_inverse_cmap( cinfo, c0, c1, c2 ); + /* Now emit the colormap index for this cell */ + *outptr++ = ( JSAMPLE ) ( *cachep - 1 ); + } + } +} + + +METHODDEF( void ) +pass2_fs_dither ( j_decompress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows ) +/* This version performs Floyd-Steinberg dithering */ +{ + my_cquantize_ptr cquantize = ( my_cquantize_ptr ) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + register LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */ + LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */ + LOCFSERROR bpreverr0, bpreverr1, bpreverr2; /* error for below/prev col */ + register FSERRPTR errorptr; /* => fserrors[] at column before current */ + JSAMPROW inptr; /* => current input pixel */ + JSAMPROW outptr; /* => current output pixel */ + histptr cachep; + int dir; /* +1 or -1 depending on direction */ + int dir3; /* 3*dir, for advancing inptr & errorptr */ + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + JSAMPLE *range_limit = cinfo->sample_range_limit; + int *error_limit = cquantize->error_limiter; + JSAMPROW colormap0 = cinfo->colormap[ 0 ]; + JSAMPROW colormap1 = cinfo->colormap[ 1 ]; + JSAMPROW colormap2 = cinfo->colormap[ 2 ]; + SHIFT_TEMPS + + for ( row = 0; row < num_rows; row++ ) { + inptr = input_buf[ row ]; + outptr = output_buf[ row ]; + if ( cquantize->on_odd_row ) { + /* work right to left in this row */ + inptr += ( width - 1 ) * 3; /* so point to rightmost pixel */ + outptr += width - 1; + dir = -1; + dir3 = -3; + errorptr = cquantize->fserrors + ( width + 1 ) * 3; /* => entry after last column */ + cquantize->on_odd_row = FALSE; /* flip for next time */ + } else { + /* work left to right in this row */ + dir = 1; + dir3 = 3; + errorptr = cquantize->fserrors; /* => entry before first real column */ + cquantize->on_odd_row = TRUE; /* flip for next time */ + } + /* Preset error values: no error propagated to first pixel from left */ + cur0 = cur1 = cur2 = 0; + /* and no error propagated to row below yet */ + belowerr0 = belowerr1 = belowerr2 = 0; + bpreverr0 = bpreverr1 = bpreverr2 = 0; + + for ( col = width; col > 0; col-- ) { + /* curN holds the error propagated from the previous pixel on the + * current line. Add the error propagated from the previous line + * to form the complete error correction term for this pixel, and + * round the error term (which is expressed * 16) to an integer. + * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct + * for either sign of the error value. + * Note: errorptr points to *previous* column's array entry. + */ + cur0 = RIGHT_SHIFT( cur0 + errorptr[ dir3 + 0 ] + 8, 4 ); + cur1 = RIGHT_SHIFT( cur1 + errorptr[ dir3 + 1 ] + 8, 4 ); + cur2 = RIGHT_SHIFT( cur2 + errorptr[ dir3 + 2 ] + 8, 4 ); + /* Limit the error using transfer function set by init_error_limit. + * See comments with init_error_limit for rationale. + */ + cur0 = error_limit[ cur0 ]; + cur1 = error_limit[ cur1 ]; + cur2 = error_limit[ cur2 ]; + /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. + * The maximum error is +- MAXJSAMPLE (or less with error limiting); + * this sets the required size of the range_limit array. + */ + cur0 += GETJSAMPLE( inptr[ 0 ] ); + cur1 += GETJSAMPLE( inptr[ 1 ] ); + cur2 += GETJSAMPLE( inptr[ 2 ] ); + cur0 = GETJSAMPLE( range_limit[ cur0 ] ); + cur1 = GETJSAMPLE( range_limit[ cur1 ] ); + cur2 = GETJSAMPLE( range_limit[ cur2 ] ); + /* Index into the cache with adjusted pixel value */ + cachep = & histogram[ cur0 >> C0_SHIFT ][ cur1 >> C1_SHIFT ][ cur2 >> C2_SHIFT ]; + /* If we have not seen this color before, find nearest colormap */ + /* entry and update the cache */ + if ( *cachep == 0 ) + fill_inverse_cmap( cinfo, cur0 >> C0_SHIFT, cur1 >> C1_SHIFT, cur2 >> C2_SHIFT ); + /* Now emit the colormap index for this cell */ + { register int pixcode = *cachep - 1; + *outptr = ( JSAMPLE ) pixcode; + /* Compute representation error for this pixel */ + cur0 -= GETJSAMPLE( colormap0[ pixcode ] ); + cur1 -= GETJSAMPLE( colormap1[ pixcode ] ); + cur2 -= GETJSAMPLE( colormap2[ pixcode ] ); + } + /* Compute error fractions to be propagated to adjacent pixels. + * Add these into the running sums, and simultaneously shift the + * next-line error sums left by 1 column. + */ + { register LOCFSERROR bnexterr, delta; + + bnexterr = cur0; /* Process component 0 */ + delta = cur0 * 2; + cur0 += delta; /* form error * 3 */ + errorptr[ 0 ] = ( FSERROR ) ( bpreverr0 + cur0 ); + cur0 += delta; /* form error * 5 */ + bpreverr0 = belowerr0 + cur0; + belowerr0 = bnexterr; + cur0 += delta; /* form error * 7 */ + bnexterr = cur1; /* Process component 1 */ + delta = cur1 * 2; + cur1 += delta; /* form error * 3 */ + errorptr[ 1 ] = ( FSERROR ) ( bpreverr1 + cur1 ); + cur1 += delta; /* form error * 5 */ + bpreverr1 = belowerr1 + cur1; + belowerr1 = bnexterr; + cur1 += delta; /* form error * 7 */ + bnexterr = cur2; /* Process component 2 */ + delta = cur2 * 2; + cur2 += delta; /* form error * 3 */ + errorptr[ 2 ] = ( FSERROR ) ( bpreverr2 + cur2 ); + cur2 += delta; /* form error * 5 */ + bpreverr2 = belowerr2 + cur2; + belowerr2 = bnexterr; + cur2 += delta; /* form error * 7 */ + } + /* At this point curN contains the 7/16 error value to be propagated + * to the next pixel on the current line, and all the errors for the + * next line have been shifted over. We are therefore ready to move on. + */ + inptr += dir3; /* Advance pixel pointers to next column */ + outptr += dir; + errorptr += dir3; /* advance errorptr to current column */ + } + /* Post-loop cleanup: we must unload the final error values into the + * final fserrors[] entry. Note we need not unload belowerrN because + * it is for the dummy column before or after the actual array. + */ + errorptr[ 0 ] = ( FSERROR ) bpreverr0; /* unload prev errs into array */ + errorptr[ 1 ] = ( FSERROR ) bpreverr1; + errorptr[ 2 ] = ( FSERROR ) bpreverr2; + } +} + + +/* + * Initialize the error-limiting transfer function (lookup table). + * The raw F-S error computation can potentially compute error values of up to + * +- MAXJSAMPLE. But we want the maximum correction applied to a pixel to be + * much less, otherwise obviously wrong pixels will be created. (Typical + * effects include weird fringes at color-area boundaries, isolated bright + * pixels in a dark area, etc.) The standard advice for avoiding this problem + * is to ensure that the "corners" of the color cube are allocated as output + * colors; then repeated errors in the same direction cannot cause cascading + * error buildup. However, that only prevents the error from getting + * completely out of hand; Aaron Giles reports that error limiting improves + * the results even with corner colors allocated. + * A simple clamping of the error values to about +- MAXJSAMPLE/8 works pretty + * well, but the smoother transfer function used below is even better. Thanks + * to Aaron Giles for this idea. + */ + +LOCAL( void ) +init_error_limit ( j_decompress_ptr cinfo ) +/* Allocate and fill in the error_limiter table */ +{ + my_cquantize_ptr cquantize = ( my_cquantize_ptr ) cinfo->cquantize; + int * table; + int in, out; + + table = ( int * ) ( *cinfo->mem->alloc_small ) + ( ( j_common_ptr ) cinfo, JPOOL_IMAGE, ( MAXJSAMPLE * 2 + 1 ) * SIZEOF( int ) ); + table += MAXJSAMPLE; /* so can index -MAXJSAMPLE .. +MAXJSAMPLE */ + cquantize->error_limiter = table; + +#define STEPSIZE ((MAXJSAMPLE+1)/16) + /* Map errors 1:1 up to +- MAXJSAMPLE/16 */ + out = 0; + for ( in = 0; in < STEPSIZE; in++, out++ ) { + table[ in ] = out; + table[ -in ] = -out; + } + /* Map errors 1:2 up to +- 3*MAXJSAMPLE/16 */ + for ( ; in < STEPSIZE*3; in++, out += ( in & 1 ) ? 0 : 1 ) { + table[ in ] = out; + table[ -in ] = -out; + } + /* Clamp the rest to final out value (which is (MAXJSAMPLE+1)/8) */ + for ( ; in <= MAXJSAMPLE; in++ ) { + table[ in ] = out; + table[ -in ] = -out; + } +#undef STEPSIZE +} + + +/* + * Finish up at the end of each pass. + */ + +METHODDEF( void ) +finish_pass1 ( j_decompress_ptr cinfo ) { + my_cquantize_ptr cquantize = ( my_cquantize_ptr ) cinfo->cquantize; + + /* Select the representative colors and fill in cinfo->colormap */ + cinfo->colormap = cquantize->sv_colormap; + select_colors( cinfo, cquantize->desired ); + /* Force next pass to zero the color index table */ + cquantize->needs_zeroed = TRUE; +} + + +METHODDEF( void ) +finish_pass2 ( j_decompress_ptr cinfo ) { + /* no work */ +} + + +/* + * Initialize for each processing pass. + */ + +METHODDEF( void ) +start_pass_2_quant ( j_decompress_ptr cinfo, boolean is_pre_scan ) { + my_cquantize_ptr cquantize = ( my_cquantize_ptr ) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + int i; + + /* Only F-S dithering or no dithering is supported. */ + /* If user asks for ordered dither, give him F-S. */ + if ( cinfo->dither_mode != JDITHER_NONE ) + cinfo->dither_mode = JDITHER_FS; + + if ( is_pre_scan ) { + /* Set up method pointers */ + cquantize->pub.color_quantize = prescan_quantize; + cquantize->pub.finish_pass = finish_pass1; + cquantize->needs_zeroed = TRUE; /* Always zero histogram */ + } else { + /* Set up method pointers */ + if ( cinfo->dither_mode == JDITHER_FS ) + cquantize->pub.color_quantize = pass2_fs_dither; + else + cquantize->pub.color_quantize = pass2_no_dither; + cquantize->pub.finish_pass = finish_pass2; + + /* Make sure color count is acceptable */ + i = cinfo->actual_number_of_colors; + if ( i < 1 ) + ERREXIT1( cinfo, JERR_QUANT_FEW_COLORS, 1 ); + if ( i > MAXNUMCOLORS ) + ERREXIT1( cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS ); + + if ( cinfo->dither_mode == JDITHER_FS ) { + size_t arraysize = ( size_t ) ( ( cinfo->output_width + 2 ) * + ( 3 * SIZEOF( FSERROR ) ) ); + /* Allocate Floyd-Steinberg workspace if we didn't already. */ + if ( cquantize->fserrors == NULL ) + cquantize->fserrors = ( FSERRPTR ) ( *cinfo->mem->alloc_large ) + ( ( j_common_ptr ) cinfo, JPOOL_IMAGE, arraysize ); + /* Initialize the propagated errors to zero. */ + jzero_far( ( void FAR * ) cquantize->fserrors, arraysize ); + /* Make the error-limit table if we didn't already. */ + if ( cquantize->error_limiter == NULL ) + init_error_limit( cinfo ); + cquantize->on_odd_row = FALSE; + } + + } + /* Zero the histogram or inverse color map, if necessary */ + if ( cquantize->needs_zeroed ) { + for ( i = 0; i < HIST_C0_ELEMS; i++ ) { + jzero_far( ( void FAR * ) histogram[ i ], + HIST_C1_ELEMS * HIST_C2_ELEMS * SIZEOF( histcell ) ); + } + cquantize->needs_zeroed = FALSE; + } +} + + +/* + * Switch to a new external colormap between output passes. + */ + +METHODDEF( void ) +new_color_map_2_quant ( j_decompress_ptr cinfo ) { + my_cquantize_ptr cquantize = ( my_cquantize_ptr ) cinfo->cquantize; + + /* Reset the inverse color map */ + cquantize->needs_zeroed = TRUE; +} + + +/* + * Module initialization routine for 2-pass color quantization. + */ + +GLOBAL( void ) +jinit_2pass_quantizer ( j_decompress_ptr cinfo ) { + my_cquantize_ptr cquantize; + int i; + + cquantize = ( my_cquantize_ptr ) + ( *cinfo->mem->alloc_small ) ( ( j_common_ptr ) cinfo, JPOOL_IMAGE, + SIZEOF( my_cquantizer ) ); + cinfo->cquantize = ( struct jpeg_color_quantizer * ) cquantize; + cquantize->pub.start_pass = start_pass_2_quant; + cquantize->pub.new_color_map = new_color_map_2_quant; + cquantize->fserrors = NULL; /* flag optional arrays not allocated */ + cquantize->error_limiter = NULL; + + /* Make sure jdmaster didn't give me a case I can't handle */ + if ( cinfo->out_color_components != 3 ) + ERREXIT( cinfo, JERR_NOTIMPL ); + + /* Allocate the histogram/inverse colormap storage */ + cquantize->histogram = ( hist3d ) ( *cinfo->mem->alloc_small ) + ( ( j_common_ptr ) cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * SIZEOF( hist2d ) ); + for ( i = 0; i < HIST_C0_ELEMS; i++ ) { + cquantize->histogram[ i ] = ( hist2d ) ( *cinfo->mem->alloc_large ) + ( ( j_common_ptr ) cinfo, JPOOL_IMAGE, + HIST_C1_ELEMS * HIST_C2_ELEMS * SIZEOF( histcell ) ); + } + cquantize->needs_zeroed = TRUE; /* histogram is garbage now */ + + /* Allocate storage for the completed colormap, if required. + * We do this now since it is FAR storage and may affect + * the memory manager's space calculations. + */ + if ( cinfo->enable_2pass_quant ) { + /* Make sure color count is acceptable */ + int desired = cinfo->desired_number_of_colors; + /* Lower bound on # of colors ... somewhat arbitrary as long as > 0 */ + if ( desired < 8 ) + ERREXIT1( cinfo, JERR_QUANT_FEW_COLORS, 8 ); + /* Make sure colormap indexes can be represented by JSAMPLEs */ + if ( desired > MAXNUMCOLORS ) + ERREXIT1( cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS ); + cquantize->sv_colormap = ( *cinfo->mem->alloc_sarray ) + ( ( j_common_ptr ) cinfo, JPOOL_IMAGE, ( JDIMENSION ) desired, ( JDIMENSION ) 3 ); + cquantize->desired = desired; + } else + cquantize->sv_colormap = NULL; + + /* Only F-S dithering or no dithering is supported. */ + /* If user asks for ordered dither, give him F-S. */ + if ( cinfo->dither_mode != JDITHER_NONE ) + cinfo->dither_mode = JDITHER_FS; + + /* Allocate Floyd-Steinberg workspace if necessary. + * This isn't really needed until pass 2, but again it is FAR storage. + * Although we will cope with a later change in dither_mode, + * we do not promise to honor max_memory_to_use if dither_mode changes. + */ + if ( cinfo->dither_mode == JDITHER_FS ) { + cquantize->fserrors = ( FSERRPTR ) ( *cinfo->mem->alloc_large ) + ( ( j_common_ptr ) cinfo, JPOOL_IMAGE, + ( size_t ) ( ( cinfo->output_width + 2 ) * ( 3 * SIZEOF( FSERROR ) ) ) ); + /* Might as well create the error-limiting table too. */ + init_error_limit( cinfo ); + } +} + +#endif /* QUANT_2PASS_SUPPORTED */ Modified: tiki/3rdparty/libpng/png.h =================================================================== --- tiki/3rdparty/libpng/png.h 2007-08-09 22:51:20 UTC (rev 436) +++ tiki/3rdparty/libpng/png.h 2007-08-09 23:13:03 UTC (rev 437) @@ -338,12 +338,9 @@ #define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7 /* Release-Specific Flags */ -#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with -PNG_LIBPNG_BUILD_STABLE only * / -#define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with -PNG_LIBPNG_BUILD_SPECIAL * / -#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with -PNG_LIBPNG_BUILD_PRIVATE * / +#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with PNG_LIBPNG_BUILD_STABLE only */ +#define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with PNG_LIBPNG_BUILD_SPECIAL */ +#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with PNG_LIBPNG_BUILD_PRIVATE */ #define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE Modified: tiki/3rdparty/libpng/pngconf.h =================================================================== --- tiki/3rdparty/libpng/pngconf.h 2007-08-09 22:51:20 UTC (rev 436) +++ tiki/3rdparty/libpng/pngconf.h 2007-08-09 23:13:03 UTC (rev 437) @@ -1273,8 +1273,7 @@ # endif # endif -# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \ - 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */) +# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */) # define PNG_IMPEXP # endif @@ -1292,15 +1291,10 @@ # if defined(PNG_BUILD_DLL) # define PNG_IMPEXP __export # else -# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in - -VC++ * / -# endif /* Exists in Borland C++ for -C++ classes ( == huge ) -* / +# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in VC++ */ +# endif /* Exists in Borland C++ for C++ classes ( == huge ) */ # endif # endif - # if !defined(PNG_IMPEXP) # if defined(PNG_BUILD_DLL) # define PNG_IMPEXP __declspec(dllexport) Modified: tiki/gp2x/Makefile =================================================================== --- tiki/gp2x/Makefile 2007-08-09 22:51:20 UTC (rev 436) +++ tiki/gp2x/Makefile 2007-08-09 23:13:03 UTC (rev 437) @@ -52,6 +52,6 @@ $(AR) ru libtiki.a $(BASE_OBJS) $(THIRD_PARTY_OBJS) clean: clean_subdirs - -rm -f $(BASE_OBJS) libtiki.a + -rm -f $(BASE_OBJS) $(THIRD_PARTY_OBJS) libtiki.a include Makefile.rules Modified: tiki/sdl/Makefile =================================================================== --- tiki/sdl/Makefile 2007-08-09 22:51:20 UTC (rev 436) +++ tiki/sdl/Makefile 2007-08-09 23:13:03 UTC (rev 437) @@ -52,6 +52,6 @@ $(AR) ru libtiki.a $(BASE_OBJS) $(THIRD_PARTY_OBJS) clean: clean_subdirs - -rm -f $(BASE_OBJS) libtiki.a + -rm -f $(BASE_OBJS) $(THIRD_PARTY_OBJS) libtiki.a include Makefile.rules This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <at...@us...> - 2007-08-09 22:51:40
|
Revision: 436 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=436&view=rev Author: atani Date: 2007-08-09 15:51:20 -0700 (Thu, 09 Aug 2007) Log Message: ----------- astyle --style=kr -t -P -K -a Modified Paths: -------------- tiki/examples/TikiTest/TikiTest_Prefix.pch tiki/examples/TikiTest/src/Controller.h tiki/examples/TikiTest/src/TikiTest.cpp tiki/examples/TikiTest/src/test.cpp tiki/examples/TikiTest/src/testobj.cpp tiki/examples/TikiTest/src/testobj.h tiki/examples/console/TikiSnake/TikiSnake_Prefix.pch tiki/examples/console/TikiSnake/src/Controller.h tiki/examples/console/TikiSnake/src/TikiSnake.cpp tiki/examples/console/TikiSnake/src/snake.cpp Modified: tiki/examples/TikiTest/TikiTest_Prefix.pch =================================================================== --- tiki/examples/TikiTest/TikiTest_Prefix.pch 2007-08-09 22:48:59 UTC (rev 435) +++ tiki/examples/TikiTest/TikiTest_Prefix.pch 2007-08-09 22:51:20 UTC (rev 436) @@ -3,5 +3,5 @@ // #ifdef __OBJC__ - #import <Cocoa/Cocoa.h> + #import <Cocoa/Cocoa.h> #endif Modified: tiki/examples/TikiTest/src/Controller.h =================================================================== --- tiki/examples/TikiTest/src/Controller.h 2007-08-09 22:48:59 UTC (rev 435) +++ tiki/examples/TikiTest/src/Controller.h 2007-08-09 22:51:20 UTC (rev 436) @@ -3,12 +3,11 @@ #import <Cocoa/Cocoa.h> #import <Tiki/TikiMain.h> -@interface Controller : NSObject -{ +@interface Controller : NSObject { IBOutlet NSView *mainView; IBOutlet NSWindow *mainWindow; - + TikiMain * tm; - NSString * openFileName; + NSString * openFileName; } @end Modified: tiki/examples/TikiTest/src/TikiTest.cpp =================================================================== --- tiki/examples/TikiTest/src/TikiTest.cpp 2007-08-09 22:48:59 UTC (rev 435) +++ tiki/examples/TikiTest/src/TikiTest.cpp 2007-08-09 22:51:20 UTC (rev 436) @@ -1,10 +1,10 @@ /* - * TikiTest.cpp - * TikiTest - * - * Copyright 2005 Cryptic Allusion, LLC. All rights reserved. - * - */ +* TikiTest.cpp +* TikiTest +* +* Copyright 2005 Cryptic Allusion, LLC. All rights reserved. +* +*/ #include <Tiki/tiki.h> #include <pch.h> @@ -13,15 +13,16 @@ #include <windows.h> static char szAppName[] = "TikiTest"; -int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +int APIENTRY WinMain( HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) #else -extern "C" int tiki_main(int argc, char *argv[]); -int main(int argc, char *argv[]) +extern "C" int tiki_main( int argc, char *argv[] ); +int main( int argc, char *argv[] ) #endif { #if TIKI_PLAT != TIKI_WIN32 - return tiki_main(argc, argv); + return tiki_main( argc, argv ); #else - return Tiki::DoMain(szAppName, hInst, hPrevInstance, lpCmdLine, nCmdShow); + + return Tiki::DoMain( szAppName, hInst, hPrevInstance, lpCmdLine, nCmdShow ); #endif } Modified: tiki/examples/TikiTest/src/test.cpp =================================================================== --- tiki/examples/TikiTest/src/test.cpp 2007-08-09 22:48:59 UTC (rev 435) +++ tiki/examples/TikiTest/src/test.cpp 2007-08-09 22:51:20 UTC (rev 436) @@ -1,11 +1,11 @@ /* - * test.cpp - * TikiTest - * - * Created by Dan Potter on 1/11/05. - * Copyright 2005 Cryptic Allusion, LLC. All rights reserved. - * - */ +* test.cpp +* TikiTest +* +* Created by Dan Potter on 1/11/05. +* Copyright 2005 Cryptic Allusion, LLC. All rights reserved. +* +*/ #include <Tiki/tiki.h> #include <Tiki/plxcompat.h> @@ -22,10 +22,10 @@ using namespace Tiki::Audio::OggVorbis; /* - + This is a Parallax version of the "bubbles" KGL demo. The speed is about the same, but it uses the Parallax functions instead of KGL. - + */ struct mouse_pos_t { @@ -34,56 +34,56 @@ int valid; }; -volatile mouse_pos_t mp[4]; //Woah, 4 mice! +volatile mouse_pos_t mp[ 4 ]; //Woah, 4 mice! //Draw the mouse pointer, parallax-style! -void draw_mouse(volatile mouse_pos_t *pos) { +void draw_mouse( volatile mouse_pos_t *pos ) { plx_vertex_t vert; plx_mat3d_identity(); - vert.argb = Color(0, 0, 0); + vert.argb = Color( 0, 0, 0 ); vert.z = 0.3f; vert.flags = PLX_VERT; - vert.x = static_cast<float>(pos->x - 2); - vert.y = static_cast<float>(pos->y - 4); - plx_prim(&vert, sizeof(vert)); + vert.x = static_cast<float>( pos->x - 2 ); + vert.y = static_cast<float>( pos->y - 4 ); + plx_prim( &vert, sizeof( vert ) ); vert.flags = PLX_VERT; - vert.x = static_cast<float>(pos->x + 18); - vert.y = static_cast<float>(pos->y + 16); - plx_prim(&vert, sizeof(vert)); + vert.x = static_cast<float>( pos->x + 18 ); + vert.y = static_cast<float>( pos->y + 16 ); + plx_prim( &vert, sizeof( vert ) ); vert.flags = PLX_VERT_EOS; - vert.x = static_cast<float>(pos->x - 2); - vert.y = static_cast<float>(pos->y + 24); - plx_prim(&vert, sizeof(vert)); + vert.x = static_cast<float>( pos->x - 2 ); + vert.y = static_cast<float>( pos->y + 24 ); + plx_prim( &vert, sizeof( vert ) ); - vert.argb = Color(0.8f, 0.2f, 0.1f); + vert.argb = Color( 0.8f, 0.2f, 0.1f ); vert.z = 0.31f; vert.flags = PLX_VERT; - vert.x = static_cast<float>(pos->x); - vert.y = static_cast<float>(pos->y); - plx_prim(&vert, sizeof(vert)); + vert.x = static_cast<float>( pos->x ); + vert.y = static_cast<float>( pos->y ); + plx_prim( &vert, sizeof( vert ) ); vert.flags = PLX_VERT; - vert.x = static_cast<float>(pos->x + 15); - vert.y = static_cast<float>(pos->y + 15); - plx_prim(&vert, sizeof(vert)); + vert.x = static_cast<float>( pos->x + 15 ); + vert.y = static_cast<float>( pos->y + 15 ); + plx_prim( &vert, sizeof( vert ) ); vert.flags = PLX_VERT_EOS; - vert.x = static_cast<float>(pos->x); - vert.y = static_cast<float>(pos->y + 21); - plx_prim(&vert, sizeof(vert)); + vert.x = static_cast<float>( pos->x ); + vert.y = static_cast<float>( pos->y + 21 ); + plx_prim( &vert, sizeof( vert ) ); } /* Draws a sphere out of GL_QUADS according to the syntax of glutSolidSphere - + This now uses triangle strips and PVR Direct Rendering for the best possible performance. - + Based very loosely on a routine from James Susinno. */ static float phase = 0.0f; @@ -98,51 +98,51 @@ /* Initialize xmtrx with the values from KGL */ plx_mat_identity(); - plx_mat3d_apply(PLX_MAT_SCREENVIEW); - plx_mat3d_apply(PLX_MAT_PROJECTION); - plx_mat3d_apply(PLX_MAT_MODELVIEW); + plx_mat3d_apply( PLX_MAT_SCREENVIEW ); + plx_mat3d_apply( PLX_MAT_PROJECTION ); + plx_mat3d_apply( PLX_MAT_MODELVIEW ); /* Put our own polygon header */ // pvr_prim(&hdr, sizeof(hdr)); /* Iterate over stacks */ - for ( i=0; i<stacks; i++ ) { - pitch = static_cast<float>(2*M_PI * ( (float)i/(float)stacks )); - pitch2 = static_cast<float>(2*M_PI * ( (float)(i+1)/(float)stacks )); + for ( i = 0; i < stacks; i++ ) { + pitch = static_cast<float>( 2 * M_PI * ( ( float ) i / ( float ) stacks ) ); + pitch2 = static_cast<float>( 2 * M_PI * ( ( float ) ( i + 1 ) / ( float ) stacks ) ); /* Iterate over slices: each entire stack will be one long triangle strip. */ - for ( j=0; j<=slices/2; j++ ) { - yaw = static_cast<float>(2*M_PI * ( (float)j/(float)slices )); - yaw2 = static_cast<float>(2*M_PI * ( (float)(j+1)/(float)slices )); + for ( j = 0; j <= slices / 2; j++ ) { + yaw = static_cast<float>( 2 * M_PI * ( ( float ) j / ( float ) slices ) ); + yaw2 = static_cast<float>( 2 * M_PI * ( ( float ) ( j + 1 ) / ( float ) slices ) ); /* x, y+1 */ x = radius * fcos( yaw ) * fcos( pitch2 ); y = radius * fsin( pitch2 ); z = radius * fsin( yaw ) * fcos( pitch2 ); - plx_mat_tfip_3d(x, y, z); /* Use ftrv to transform */ - g = fcos( yaw*2 ) / 2.0f + 0.5f; + plx_mat_tfip_3d( x, y, z ); /* Use ftrv to transform */ + g = fcos( yaw * 2 ) / 2.0f + 0.5f; b = fsin( phase + pitch2 ) / 2.0f + 0.5f; - plx_vert_fnd(&dr_state, PLX_VERT, - x, y, z, 1.0f, - 0.0f, g, b); + plx_vert_fnd( &dr_state, PLX_VERT, + x, y, z, 1.0f, + 0.0f, g, b ); /* x, y */ x = radius * fcos( yaw ) * fcos( pitch ); y = radius * fsin( pitch ); z = radius * fsin( yaw ) * fcos( pitch ); - plx_mat_tfip_3d(x, y, z); - g = fcos( yaw*2 ) / 2.0f + 0.5f; + plx_mat_tfip_3d( x, y, z ); + g = fcos( yaw * 2 ) / 2.0f + 0.5f; b = fsin( phase + pitch ) / 2.0f + 0.5f; - if (j == (slices/2)) { - plx_vert_fnd(&dr_state, PLX_VERT_EOS, - x, y, z, 1.0f, - 0.0f, g, b); + if ( j == ( slices / 2 ) ) { + plx_vert_fnd( &dr_state, PLX_VERT_EOS, + x, y, z, 1.0f, + 0.0f, g, b ); } else { - plx_vert_fnd(&dr_state, PLX_VERT, - x, y, z, 1.0f, - 0.0f, g, b); + plx_vert_fnd( &dr_state, PLX_VERT, + x, y, z, 1.0f, + 0.0f, g, b ); } } } @@ -154,116 +154,115 @@ static void sphere_frame_opaque() { int i; -// vid_border_color(255, 0, 0); + // vid_border_color(255, 0, 0); Frame::begin(); -// vid_border_color(0, 255, 0); + // vid_border_color(0, 255, 0); //Draw the mice - for (i=0; i<4; i++) { - if(mp[i].valid) { - draw_mouse(&mp[i]); + for ( i = 0; i < 4; i++ ) { + if ( mp[ i ].valid ) { + draw_mouse( &mp[ i ] ); } } plx_mat3d_identity(); - plx_mat3d_translate(0.0f, 0.0f, -12.0f); - plx_mat3d_rotate(r * 2, 0.75f, 1.0f, 0.5f); + plx_mat3d_translate( 0.0f, 0.0f, -12.0f ); + plx_mat3d_rotate( r * 2, 0.75f, 1.0f, 0.5f ); plx_mat3d_push(); - for (i=0; i<SPHERE_CNT; i++) { - plx_mat3d_translate(6.0f * fcos(static_cast<float>(i * 2*M_PI / SPHERE_CNT)), 0.0f, 6.0f * fsin(static_cast<float>(i * 2*M_PI / SPHERE_CNT))); - plx_mat3d_rotate(r, 1.0f, 1.0f, 1.0f); - sphere(1.2f, 20, 20); - if (i < (SPHERE_CNT-1)) + for ( i = 0; i < SPHERE_CNT; i++ ) { + plx_mat3d_translate( 6.0f * fcos( static_cast<float>( i * 2 * M_PI / SPHERE_CNT ) ), 0.0f, 6.0f * fsin( static_cast<float>( i * 2 * M_PI / SPHERE_CNT ) ) ); + plx_mat3d_rotate( r, 1.0f, 1.0f, 1.0f ); + sphere( 1.2f, 20, 20 ); + if ( i < ( SPHERE_CNT - 1 ) ) plx_mat3d_peek(); } plx_mat3d_pop(); plx_mat3d_identity(); - plx_mat3d_translate(0.0f, 0.0f, -12.0f); - plx_mat3d_rotate(-r * 2, 0.75f, 1.0f, 0.5f); + plx_mat3d_translate( 0.0f, 0.0f, -12.0f ); + plx_mat3d_rotate( -r * 2, 0.75f, 1.0f, 0.5f ); plx_mat3d_push(); - for (i=0; i<SPHERE_CNT; i++) { - plx_mat3d_translate(3.0f * fcos(static_cast<float>(i * 2*M_PI / SPHERE_CNT)), 0.0f, 3.0f * fsin(static_cast<float>(i * 2*M_PI / SPHERE_CNT))); - plx_mat3d_rotate(r, 1.0f, 1.0f, 1.0f); - sphere(0.8f, 20, 20); - if (i < (SPHERE_CNT-1)) + for ( i = 0; i < SPHERE_CNT; i++ ) { + plx_mat3d_translate( 3.0f * fcos( static_cast<float>( i * 2 * M_PI / SPHERE_CNT ) ), 0.0f, 3.0f * fsin( static_cast<float>( i * 2 * M_PI / SPHERE_CNT ) ) ); + plx_mat3d_rotate( r, 1.0f, 1.0f, 1.0f ); + sphere( 0.8f, 20, 20 ); + if ( i < ( SPHERE_CNT - 1 ) ) plx_mat3d_peek(); } plx_mat3d_pop(); -// vid_border_color(0, 0, 255); + // vid_border_color(0, 0, 255); Frame::finish(); - r+=dir; - phase += static_cast<float>(2*M_PI / 240); + r += dir; + phase += static_cast<float>( 2 * M_PI / 240 ); } volatile bool quitting = false; -void tkCallback(const Hid::Event & evt, void * data) { - if (evt.type == Hid::Event::EvtQuit) { +void tkCallback( const Hid::Event & evt, void * data ) { + if ( evt.type == Hid::Event::EvtQuit ) { quitting = true; - } else if (evt.type == Event::EvtKeypress || (evt.type == Event::EvtBtnRelease && evt.btn == Event::MouseLeftBtn)) { + } else if ( evt.type == Event::EvtKeypress || ( evt.type == Event::EvtBtnRelease && evt.btn == Event::MouseLeftBtn ) ) { dir = -dir; } int port = evt.port; - if(evt.port < 0 && evt.port > 4) { + if ( evt.port < 0 && evt.port > 4 ) { port = 0; } - if (evt.type == Event::EvtAttach) { - printf("Device attached: %s\n",evt.dev->getName().c_str()); - if(evt.dev->getType() == Device::TypeMouse) { - mp[port].valid=1; - mp[port].x=320; - mp[port].y=240; + if ( evt.type == Event::EvtAttach ) { + printf( "Device attached: %s\n", evt.dev->getName().c_str() ); + if ( evt.dev->getType() == Device::TypeMouse ) { + mp[ port ].valid = 1; + mp[ port ].x = 320; + mp[ port ].y = 240; } } - if (evt.type == Event::EvtDetach) { - printf("Device detached: %s\n",evt.dev->getName().c_str()); - mp[port].valid=0; + if ( evt.type == Event::EvtDetach ) { + printf( "Device detached: %s\n", evt.dev->getName().c_str() ); + mp[ port ].valid = 0; } - if (evt.type == Event::EvtMouseMove) { - mp[port].x=evt.x; - mp[port].y=evt.y; + if ( evt.type == Event::EvtMouseMove ) { + mp[ port ].x = evt.x; + mp[ port ].y = evt.y; } } -extern "C" int tiki_main(int argc, char **argv) { +extern "C" int tiki_main( int argc, char **argv ) { // Init Tiki - if(!Tiki::init(argc, argv)) - { - exit(-1); + if ( !Tiki::init( argc, argv ) ) { + exit( -1 ); } - Tiki::setName("TikiTest", NULL); - Tiki::GL::showCursor(false); - Hid::callbackReg(tkCallback, NULL); + Tiki::setName( "TikiTest", NULL ); + Tiki::GL::showCursor( false ); + Hid::callbackReg( tkCallback, NULL ); - Debug::printf("argc: %i\n", argc); - for(int i=0; i<argc; i++) { - Debug::printf("argv[%i]: %s\n",i,argv[i]); + Debug::printf( "argc: %i\n", argc ); + for ( int i = 0; i < argc; i++ ) { + Debug::printf( "argv[%i]: %s\n", i, argv[ i ] ); } - + #if TIKI_PLAT != TIKI_DC //Attach events happen before we start :( - mp[0].valid=1; - mp[0].x=320; - mp[0].y=240; + mp[ 0 ].valid = 1; + mp[ 0 ].x = 320; + mp[ 0 ].y = 240; #endif - RefPtr<TestObject> test = new TestObject("1"); - RefPtr<TestObject> test2 = new TestObject("2"); - test->connect("testevent", test2); - test->perform("testmessage", NULL, NULL); - test->perform("anothermessage", NULL, NULL); + RefPtr<TestObject> test = new TestObject( "1" ); + RefPtr<TestObject> test2 = new TestObject( "2" ); + test->connect( "testevent", test2 ); + test->perform( "testmessage", NULL, NULL ); + test->perform( "anothermessage", NULL, NULL ); - plx_mat3d_mode(PLX_MAT_PROJECTION); + plx_mat3d_mode( PLX_MAT_PROJECTION ); plx_mat3d_identity(); - plx_mat3d_perspective(45.0f, 640.0f / 480.0f, 0.1f, 100.0f); - plx_mat3d_mode(PLX_MAT_MODELVIEW); + plx_mat3d_perspective( 45.0f, 640.0f / 480.0f, 0.1f, 100.0f ); + plx_mat3d_mode( PLX_MAT_MODELVIEW ); - while (!quitting) + while ( !quitting ) sphere_frame_opaque(); // Shut down Tiki Modified: tiki/examples/TikiTest/src/testobj.cpp =================================================================== --- tiki/examples/TikiTest/src/testobj.cpp 2007-08-09 22:48:59 UTC (rev 435) +++ tiki/examples/TikiTest/src/testobj.cpp 2007-08-09 22:51:20 UTC (rev 436) @@ -1,9 +1,9 @@ /* - Tiki + Tiki - object.cpp + object.cpp - Copyright (C)2005 Cryptic Allusion, LLC + Copyright (C)2005 Cryptic Allusion, LLC */ #include <Tiki/tiki.h> @@ -14,35 +14,34 @@ using namespace Tiki; using std::string; -TIKI_OBJECT_NAME(TestObject) -TIKI_OBJECT_BEGIN(Object, TestObject) - TIKI_OBJECT_RECEIVER("testmessage", TestObject::testMessage) - TIKI_OBJECT_RECEIVER("anothermessage", TestObject::anotherMessage) - TIKI_OBJECT_RECEIVER("testevent", TestObject::testEvent) - TIKI_OBJECT_OUTLET("testevent") -TIKI_OBJECT_END(TestObject) +TIKI_OBJECT_NAME( TestObject ) +TIKI_OBJECT_BEGIN( Object, TestObject ) +TIKI_OBJECT_RECEIVER( "testmessage", TestObject::testMessage ) +TIKI_OBJECT_RECEIVER( "anothermessage", TestObject::anotherMessage ) +TIKI_OBJECT_RECEIVER( "testevent", TestObject::testEvent ) +TIKI_OBJECT_OUTLET( "testevent" ) +TIKI_OBJECT_END( TestObject ) -TestObject::TestObject(string name) { - Debug::printf("TestObject::TestObject(%s)\n", name.c_str()); +TestObject::TestObject( string name ) { + Debug::printf( "TestObject::TestObject(%s)\n", name.c_str() ); m_name = name; } - -TestObject::~TestObject() { -} - -int TestObject::testMessage(Object * sender, Object * arg) { - Debug::printf("TestObject(%s)::testMessage(%p, %p)\n", m_name.c_str(), sender, arg); + +TestObject::~TestObject() {} + +int TestObject::testMessage( Object * sender, Object * arg ) { + Debug::printf( "TestObject(%s)::testMessage(%p, %p)\n", m_name.c_str(), sender, arg ); return 0; } -int TestObject::anotherMessage(Object * sender, Object * arg) { - Debug::printf("TestObject(%s)::anotherMessage(%p, %p)\n", m_name.c_str(), sender, arg); - return emit("testevent", arg); +int TestObject::anotherMessage( Object * sender, Object * arg ) { + Debug::printf( "TestObject(%s)::anotherMessage(%p, %p)\n", m_name.c_str(), sender, arg ); + return emit( "testevent", arg ); } - -int TestObject::testEvent(Object * sender, Object * arg) { - Debug::printf("TestObject(%s)::testEvent(%p, %p)\n", m_name.c_str(), sender, arg); + +int TestObject::testEvent( Object * sender, Object * arg ) { + Debug::printf( "TestObject(%s)::testEvent(%p, %p)\n", m_name.c_str(), sender, arg ); return 0; } Modified: tiki/examples/TikiTest/src/testobj.h =================================================================== --- tiki/examples/TikiTest/src/testobj.h 2007-08-09 22:48:59 UTC (rev 435) +++ tiki/examples/TikiTest/src/testobj.h 2007-08-09 22:51:20 UTC (rev 436) @@ -6,15 +6,15 @@ class TestObject : public Tiki::Object { public: - TestObject(std::string name); + TestObject( std::string name ); virtual ~TestObject(); - int testMessage(Object * sender, Object * arg); - int anotherMessage(Object * sender, Object * arg); - int testEvent(Object * sender, Object * arg); + int testMessage( Object * sender, Object * arg ); + int anotherMessage( Object * sender, Object * arg ); + int testEvent( Object * sender, Object * arg ); protected: - TIKI_OBJECT_DECLS(TestObject) - + TIKI_OBJECT_DECLS( TestObject ) + std::string m_name; }; Modified: tiki/examples/console/TikiSnake/TikiSnake_Prefix.pch =================================================================== --- tiki/examples/console/TikiSnake/TikiSnake_Prefix.pch 2007-08-09 22:48:59 UTC (rev 435) +++ tiki/examples/console/TikiSnake/TikiSnake_Prefix.pch 2007-08-09 22:51:20 UTC (rev 436) @@ -3,5 +3,5 @@ // #ifdef __OBJC__ - #import <Cocoa/Cocoa.h> + #import <Cocoa/Cocoa.h> #endif Modified: tiki/examples/console/TikiSnake/src/Controller.h =================================================================== --- tiki/examples/console/TikiSnake/src/Controller.h 2007-08-09 22:48:59 UTC (rev 435) +++ tiki/examples/console/TikiSnake/src/Controller.h 2007-08-09 22:51:20 UTC (rev 436) @@ -3,11 +3,10 @@ #import <Cocoa/Cocoa.h> #import <Tiki/TikiMain.h> -@interface Controller : NSObject -{ +@interface Controller : NSObject { IBOutlet NSView *mainView; IBOutlet NSWindow *mainWindow; - + TikiMain * tm; } @end Modified: tiki/examples/console/TikiSnake/src/TikiSnake.cpp =================================================================== --- tiki/examples/console/TikiSnake/src/TikiSnake.cpp 2007-08-09 22:48:59 UTC (rev 435) +++ tiki/examples/console/TikiSnake/src/TikiSnake.cpp 2007-08-09 22:51:20 UTC (rev 436) @@ -1,10 +1,10 @@ /* - * TikiSnake.cpp - * TikiSnake - * - * Copyright 2006 Sam Steele. All rights reserved. - * - */ +* TikiSnake.cpp +* TikiSnake +* +* Copyright 2006 Sam Steele. All rights reserved. +* +*/ #include <Tiki/tiki.h> @@ -13,15 +13,16 @@ #include "pch.h" static char szAppName[] = "TikiSnake"; -int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +int APIENTRY WinMain( HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) #else -extern "C" int tiki_main(int argc, char *argv[]); -int main(int argc, char *argv[]) +extern "C" int tiki_main( int argc, char *argv[] ); +int main( int argc, char *argv[] ) #endif { #if TIKI_PLAT != TIKI_WIN32 - return tiki_main(argc, argv); + return tiki_main( argc, argv ); #else - return Tiki::DoMain(szAppName, hInst, hPrevInstance, lpCmdLine, nCmdShow); + + return Tiki::DoMain( szAppName, hInst, hPrevInstance, lpCmdLine, nCmdShow ); #endif } Modified: tiki/examples/console/TikiSnake/src/snake.cpp =================================================================== --- tiki/examples/console/TikiSnake/src/snake.cpp 2007-08-09 22:48:59 UTC (rev 435) +++ tiki/examples/console/TikiSnake/src/snake.cpp 2007-08-09 22:51:20 UTC (rev 436) @@ -1,10 +1,10 @@ /* - * snake.cpp - * TikiSnake - a Tiki version of the classic snake game - * - * Copyright (C)2006 Sam Steele - * - */ +* snake.cpp +* TikiSnake - a Tiki version of the classic snake game +* +* Copyright (C)2006 Sam Steele +* +*/ #include <Tiki/tiki.h> #include <Tiki/plxcompat.h> @@ -20,182 +20,192 @@ #define BOARD_X 77 #define BOARD_Y 20 -int board[BOARD_X][BOARD_Y]; +int board[ BOARD_X ][ BOARD_Y ]; -int sx=3,sy=3,sdx=1,sdy=0,ssize=3; -int sscore=0,slives=3; +int sx = 3, sy = 3, sdx = 1, sdy = 0, ssize = 3; +int sscore = 0, slives = 3; volatile bool quitting = false; -void tkCallback(const Hid::Event & evt, void * data) { - if (evt.type == Hid::Event::EvtQuit) { +void tkCallback( const Hid::Event & evt, void * data ) { + if ( evt.type == Hid::Event::EvtQuit ) { quitting = true; - } else if (evt.type == Hid::Event::EvtKeypress) { - switch(evt.key) { + } else if ( evt.type == Hid::Event::EvtKeypress ) { + switch ( evt.key ) { case 27: - quitting = true; - break; + quitting = true; + break; case Event::KeyUp: - sdx = 0; - sdy = -1; - break; + sdx = 0; + sdy = -1; + break; case Event::KeyDown: - sdx = 0; - sdy = 1; - break; + sdx = 0; + sdy = 1; + break; case Event::KeyLeft: - sdx = -1; - sdy = 0; - break; + sdx = -1; + sdy = 0; + break; case Event::KeyRight: - sdx = 1; - sdy = 0; - break; + sdx = 1; + sdy = 0; + break; } } } -extern "C" int tiki_main(int argc, char **argv) { - int x,y; - bool go=1; - bool dead=0; - +extern "C" int tiki_main( int argc, char **argv ) { + int x, y; + bool go = 1; + bool dead = 0; + //srand(time(NULL)); - + // Init Tiki - if(!Tiki::init(argc, argv)) - { - exit(-1); + if ( !Tiki::init( argc, argv ) ) { + exit( -1 ); } - Tiki::setName("SnakeyGame", NULL); - Hid::callbackReg(tkCallback, NULL); + Tiki::setName( "SnakeyGame", NULL ); + Hid::callbackReg( tkCallback, NULL ); - //initialize the screen - ConsoleText *ct = new ConsoleText(80,25,new Texture("pc-ascii.png", true)); - - ct->setSize(640,480); - ct->translate(Vector(320,240,0)); - ct->setAutoScroll(0); - ct->setAutoWrap(0); + //initialize the screen + ConsoleText *ct = new ConsoleText( 80, 25, new Texture( "pc-ascii.png", true ) ); + ct->setSize( 640, 480 ); + ct->translate( Vector( 320, 240, 0 ) ); + ct->setAutoScroll( 0 ); + ct->setAutoWrap( 0 ); + //initialize the board - for(x=0;x<BOARD_X;x++) { - for(y=0;y<BOARD_Y;y++) { - board[x][y]=0; + for ( x = 0;x < BOARD_X;x++ ) { + for ( y = 0;y < BOARD_Y;y++ ) { + board[ x ][ y ] = 0; } } - + //place an item do { - x=rand()%BOARD_X; y=rand()%BOARD_Y; - } while(board[x][y]!=0); - board[x][y]=999; - - while(!quitting) { + x = rand() % BOARD_X; + y = rand() % BOARD_Y; + } while ( board[ x ][ y ] != 0 ); + board[ x ][ y ] = 999; + + while ( !quitting ) { //move head - if(!dead) { - sx+=sdx; - sy+=sdy; + if ( !dead ) { + sx += sdx; + sy += sdy; } //check bounds - if(sx>=BOARD_X || sx<0 || sy>=BOARD_Y || sy<0) { - slives--; - ssize=3; - for(x=0;x<BOARD_X;x++) { - for(y=0;y<BOARD_Y;y++) { - board[x][y]=0; + if ( sx >= BOARD_X || sx < 0 || sy >= BOARD_Y || sy < 0 ) { + slives--; + ssize = 3; + for ( x = 0;x < BOARD_X;x++ ) { + for ( y = 0;y < BOARD_Y;y++ ) { + board[ x ][ y ] = 0; } } - sx=rand()%BOARD_X; - sy=rand()%BOARD_Y; + sx = rand() % BOARD_X; + sy = rand() % BOARD_Y; do { //place a new item in an empty spot - x=rand()%BOARD_X; y=rand()%BOARD_Y; - } while(board[x][y]!=0); - board[x][y]=999; + x = rand() % BOARD_X; + y = rand() % BOARD_Y; + } while ( board[ x ][ y ] != 0 ); + board[ x ][ y ] = 999; } - + //check collisions - if(board[sx][sy]>0) { - if(board[sx][sy]==999) { //item - ssize+=2; //increment snake size + if ( board[ sx ][ sy ] > 0 ) { + if ( board[ sx ][ sy ] == 999 ) { //item + ssize += 2; //increment snake size sscore++; //and score do { //place a new item in an empty spot - x=rand()%BOARD_X; y=rand()%BOARD_Y; - } while(board[x][y]!=0); - board[x][y]=999; + x = rand() % BOARD_X; + y = rand() % BOARD_Y; + } while ( board[ x ][ y ] != 0 ); + board[ x ][ y ] = 999; //make the stretch work correctly - for(x=0;x<BOARD_X;x++) { - for(y=0;y<BOARD_Y;y++) { - if(board[x][y]>0&&board[x][y]!=999) board[x][y]+=2; + for ( x = 0;x < BOARD_X;x++ ) { + for ( y = 0;y < BOARD_Y;y++ ) { + if ( board[ x ][ y ] > 0 && board[ x ][ y ] != 999 ) + board[ x ][ y ] += 2; } } } else { //snake - slives--; - ssize=3; - for(x=0;x<BOARD_X;x++) { - for(y=0;y<BOARD_Y;y++) { - board[x][y]=0; + slives--; + ssize = 3; + for ( x = 0;x < BOARD_X;x++ ) { + for ( y = 0;y < BOARD_Y;y++ ) { + board[ x ][ y ] = 0; } } - sx=rand()%BOARD_X; - sy=rand()%BOARD_Y; + sx = rand() % BOARD_X; + sy = rand() % BOARD_Y; } } - if(slives<=0) dead=1; - board[sx][sy]=ssize+1; - + if ( slives <= 0 ) + dead = 1; + board[ sx ][ sy ] = ssize + 1; + //decrement the array (simulates motion) - for(x=0;x<BOARD_X;x++) { - for(y=0;y<BOARD_Y;y++) { - if(board[x][y]>0&&board[x][y]!=999) board[x][y]--; + for ( x = 0;x < BOARD_X;x++ ) { + for ( y = 0;y < BOARD_Y;y++ ) { + if ( board[ x ][ y ] > 0 && board[ x ][ y ] != 999 ) + board[ x ][ y ] --; } } - + //render the screen - ct->locate(0,0); - ct->color(GREY | HIGH_INTENSITY, BLACK); + ct->locate( 0, 0 ); + ct->color( GREY | HIGH_INTENSITY, BLACK ); *ct << "Score: " << sscore << endl; - ct->locate(70,0); - if(dead==0) *ct << "Lives: " << slives << endl; - ct->color(YELLOW | HIGH_INTENSITY, BLACK); - *ct << (char)218; - for(x=0;x<BOARD_X;x++) - *ct << (char)196; - *ct << (char)191 << endl; - for(y=0;y<BOARD_Y;y++) { - ct->color(YELLOW | HIGH_INTENSITY, BLACK); - *ct << (char)179; - for(x=0;x<BOARD_X;x++) { - ct->color(GREY | HIGH_INTENSITY, BLACK); - if(board[x][y]==999 && dead==0) { //draw an item - ct->color(5,0); - *ct << (char)4; - } else if(board[x][y]>0&&dead==0) *ct << "*"; //draw a snake piece - else *ct << " "; //draw a space - } - ct->color(YELLOW | HIGH_INTENSITY, BLACK); - *ct << (char)179 << endl; + ct->locate( 70, 0 ); + if ( dead == 0 ) + * ct << "Lives: " << slives << endl; + ct->color( YELLOW | HIGH_INTENSITY, BLACK ); + *ct << ( char ) 218; + for ( x = 0;x < BOARD_X;x++ ) + *ct << ( char ) 196; + *ct << ( char ) 191 << endl; + for ( y = 0;y < BOARD_Y;y++ ) { + ct->color( YELLOW | HIGH_INTENSITY, BLACK ); + *ct << ( char ) 179; + for ( x = 0;x < BOARD_X;x++ ) { + ct->color( GREY | HIGH_INTENSITY, BLACK ); + if ( board[ x ][ y ] == 999 && dead == 0 ) { //draw an item + ct->color( 5, 0 ); + *ct << ( char ) 4; + } else if ( board[ x ][ y ] > 0 && dead == 0 ) + * ct << "*"; //draw a snake piece + else + *ct << " "; //draw a space } - *ct << (char)192; - for(x=0;x<BOARD_X;x++) - *ct << (char)196; - *ct << (char)217<<endl; - ct->color(GREY | HIGH_INTENSITY, BLACK); - *ct << "TikiSnake (C) 2006 Sam Steele"; - if(dead) { - ct->color(RED, BLACK); - ct->locate(36,11); *ct << "You Died!"; - ct->locate(36,12); *ct << "Press ESC"; - } - - Frame::begin(); - ct->draw(Drawable::Opaque); - Frame::transEnable(); - ct->draw(Drawable::Trans); - Frame::finish(); - - Time::sleep(80000); - } - + ct->color( YELLOW | HIGH_INTENSITY, BLACK ); + *ct << ( char ) 179 << endl; + } + *ct << ( char ) 192; + for ( x = 0;x < BOARD_X;x++ ) + *ct << ( char ) 196; + *ct << ( char ) 217 << endl; + ct->color( GREY | HIGH_INTENSITY, BLACK ); + *ct << "TikiSnake (C) 2006 Sam Steele"; + if ( dead ) { + ct->color( RED, BLACK ); + ct->locate( 36, 11 ); + *ct << "You Died!"; + ct->locate( 36, 12 ); + *ct << "Press ESC"; + } + + Frame::begin(); + ct->draw( Drawable::Opaque ); + Frame::transEnable(); + ct->draw( Drawable::Trans ); + Frame::finish(); + + Time::sleep( 80000 ); + } + Tiki::shutdown(); return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <at...@us...> - 2007-08-09 22:49:07
|
Revision: 435 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=435&view=rev Author: atani Date: 2007-08-09 15:48:59 -0700 (Thu, 09 Aug 2007) Log Message: ----------- astyle --style=kr -t -P -K -a Modified Paths: -------------- tiki/3rdparty/libjpeg/README tiki/3rdparty/libjpeg/jcapimin.c tiki/3rdparty/libjpeg/jcapistd.c tiki/3rdparty/libjpeg/jccoefct.c tiki/3rdparty/libjpeg/jccolor.c tiki/3rdparty/libjpeg/jcdctmgr.c tiki/3rdparty/libjpeg/jchuff.c tiki/3rdparty/libjpeg/jchuff.h tiki/3rdparty/libjpeg/jcinit.c tiki/3rdparty/libjpeg/jcmainct.c tiki/3rdparty/libjpeg/jcmarker.c tiki/3rdparty/libjpeg/jcmaster.c tiki/3rdparty/libjpeg/jcomapi.c tiki/3rdparty/libjpeg/jconfig.h tiki/3rdparty/libjpeg/jcparam.c tiki/3rdparty/libjpeg/jcphuff.c tiki/3rdparty/libjpeg/jcprepct.c tiki/3rdparty/libjpeg/jcsample.c tiki/3rdparty/libjpeg/jctrans.c tiki/3rdparty/libjpeg/jdapimin.c tiki/3rdparty/libjpeg/jdapistd.c tiki/3rdparty/libjpeg/jdatadst.c tiki/3rdparty/libjpeg/jdatasrc.c tiki/3rdparty/libjpeg/jdcoefct.c tiki/3rdparty/libjpeg/jdcolor.c tiki/3rdparty/libjpeg/jdct.h tiki/3rdparty/libjpeg/jddctmgr.c tiki/3rdparty/libjpeg/jdhuff.c tiki/3rdparty/libjpeg/jdhuff.h tiki/3rdparty/libjpeg/jdinput.c tiki/3rdparty/libjpeg/jdmainct.c tiki/3rdparty/libjpeg/jdmarker.c tiki/3rdparty/libjpeg/jdmaster.c tiki/3rdparty/libjpeg/jdmerge.c tiki/3rdparty/libjpeg/jdphuff.c tiki/3rdparty/libjpeg/jdpostct.c tiki/3rdparty/libjpeg/jdsample.c tiki/3rdparty/libjpeg/jdtrans.c tiki/3rdparty/libjpeg/jerror.c tiki/3rdparty/libjpeg/jerror.h tiki/3rdparty/libjpeg/jfdctflt.c tiki/3rdparty/libjpeg/jfdctfst.c tiki/3rdparty/libjpeg/jfdctint.c tiki/3rdparty/libjpeg/jidctflt.c tiki/3rdparty/libjpeg/jidctfst.c tiki/3rdparty/libjpeg/jidctint.c tiki/3rdparty/libjpeg/jidctred.c tiki/3rdparty/libjpeg/jinclude.h tiki/3rdparty/libjpeg/jmemmgr.c tiki/3rdparty/libjpeg/jmemnobs.c tiki/3rdparty/libjpeg/jmemsys.h tiki/3rdparty/libjpeg/jmorecfg.h tiki/3rdparty/libjpeg/jpegint.h tiki/3rdparty/libjpeg/jpeglib.h tiki/3rdparty/libjpeg/jquant1.c tiki/3rdparty/libjpeg/jquant2.c tiki/3rdparty/libjpeg/jversion.h tiki/3rdparty/libpng/png.h tiki/3rdparty/libpng/pngconf.h tiki/3rdparty/libvorbis/lib/backends.h tiki/3rdparty/libvorbis/lib/bitrate.h tiki/3rdparty/libvorbis/lib/codebook.h tiki/3rdparty/libvorbis/lib/codec_internal.h tiki/3rdparty/libvorbis/lib/envelope.h tiki/3rdparty/libvorbis/lib/highlevel.h tiki/3rdparty/libvorbis/lib/lookup.h tiki/3rdparty/libvorbis/lib/lookup_data.h tiki/3rdparty/libvorbis/lib/lpc.h tiki/3rdparty/libvorbis/lib/lsp.h tiki/3rdparty/libvorbis/lib/masking.h tiki/3rdparty/libvorbis/lib/mdct.h tiki/3rdparty/libvorbis/lib/misc.h tiki/3rdparty/libvorbis/lib/os.h tiki/3rdparty/libvorbis/lib/psy.h tiki/3rdparty/libvorbis/lib/registry.h tiki/3rdparty/libvorbis/lib/scales.h tiki/3rdparty/libvorbis/lib/smallft.h tiki/3rdparty/libvorbis/lib/window.h tiki/3rdparty/zlib/crc32.h tiki/3rdparty/zlib/deflate.h tiki/3rdparty/zlib/inffast.h tiki/3rdparty/zlib/inffixed.h tiki/3rdparty/zlib/inflate.h tiki/3rdparty/zlib/inftrees.h tiki/3rdparty/zlib/trees.h tiki/3rdparty/zlib/zconf.h tiki/3rdparty/zlib/zlib.h tiki/3rdparty/zlib/zutil.h tiki/dc/include/Tiki/glhdrs.h tiki/dc/include/Tiki/platthread.h tiki/dc/include/Tiki/tikitypes.h tiki/dc/include/pch.h tiki/dc/include/sys/queue.h tiki/dc/src/audio/sound.cpp tiki/dc/src/audio/stream.cpp tiki/dc/src/init_shutdown.cpp tiki/dc/src/platgl.cpp tiki/dc/src/plathid.cpp tiki/dc/src/platthread.cpp tiki/dc/src/tikitime.cpp tiki/gp2x/include/GLES/egl.h tiki/gp2x/include/GLES/egltypes.h tiki/gp2x/include/GLES/gl.h tiki/gp2x/include/GLES/glext.h tiki/gp2x/include/Tiki/glhdrs.h tiki/gp2x/include/Tiki/platthread.h tiki/gp2x/include/Tiki/tikitypes.h tiki/gp2x/include/minimal.h tiki/gp2x/include/minimal_940t.h tiki/gp2x/include/pch.h tiki/gp2x/include/sys/queue.h tiki/gp2x/src/init_shutdown.cpp tiki/gp2x/src/platgl.cpp tiki/gp2x/src/plathid.cpp tiki/gp2x/src/platthread.cpp tiki/gp2x/src/rlyeh-minimal.cpp tiki/gp2x/src/tikitime.cpp tiki/include/Tiki/animation.h tiki/include/Tiki/bspline.h tiki/include/Tiki/color.h tiki/include/Tiki/color3.h tiki/include/Tiki/debug.h tiki/include/Tiki/drawable.h tiki/include/Tiki/endian.h tiki/include/Tiki/eventcollector.h tiki/include/Tiki/file.h tiki/include/Tiki/font.h tiki/include/Tiki/genmenu.h tiki/include/Tiki/gl.h tiki/include/Tiki/hid.h tiki/include/Tiki/image.h tiki/include/Tiki/imgjpg.h tiki/include/Tiki/imgpng.h tiki/include/Tiki/list.h tiki/include/Tiki/matrix.h tiki/include/Tiki/object.h tiki/include/Tiki/oggvorbis.h tiki/include/Tiki/plxcompat.h tiki/include/Tiki/refcnt.h tiki/include/Tiki/scene.h tiki/include/Tiki/sound.h tiki/include/Tiki/stream.h tiki/include/Tiki/tee.h tiki/include/Tiki/texture.h tiki/include/Tiki/thread.h tiki/include/Tiki/tiki.h tiki/include/Tiki/tikimath.h tiki/include/Tiki/tikitime.h tiki/include/Tiki/timeline.h tiki/include/Tiki/timepoint.h tiki/include/Tiki/trigger.h tiki/include/Tiki/vector.h tiki/include/Tiki/vector3.h tiki/nds/arm7_template/source/dssoundstream.h tiki/nds/include/Tiki/glhdrs.h tiki/nds/include/Tiki/platthread.h tiki/nds/include/Tiki/tikitypes.h tiki/nds/include/dssoundstream.h tiki/nds/include/pch.h tiki/nds/src/audio/sound.cpp tiki/nds/src/audio/stream.cpp tiki/nds/src/init_shutdown.cpp tiki/nds/src/platgl.cpp tiki/nds/src/plathid.cpp tiki/nds/src/platthread.cpp tiki/nds/src/tikitime.cpp tiki/osx/include/Tiki/TikiMain.h tiki/osx/include/Tiki/glhdrs.h tiki/osx/include/Tiki/platthread.h tiki/osx/include/Tiki/tikitypes.h tiki/osx/include/pch.h tiki/osx/src/init_shutdown.cpp tiki/osx/src/platgl.cpp tiki/osx/src/platthread.cpp tiki/osx/src/tikitime.cpp tiki/sdl/include/Tiki/glhdrs.h tiki/sdl/include/Tiki/platthread.h tiki/sdl/include/Tiki/tikitypes.h tiki/sdl/include/pch.h tiki/sdl/include/sys/queue.h tiki/sdl/src/init_shutdown.cpp tiki/sdl/src/platgl.cpp tiki/sdl/src/plathid.cpp tiki/sdl/src/platthread.cpp tiki/sdl/src/tikitime.cpp tiki/src/audio/oggvorbis/misc.h tiki/src/audio/oggvorbis/sndoggvorbis.cpp tiki/src/audio/sound.cpp tiki/src/audio/stream.cpp tiki/src/base/debug.cpp tiki/src/base/endian.cpp tiki/src/base/file.cpp tiki/src/base/object.cpp tiki/src/base/timeline.cpp tiki/src/base/timepoint.cpp tiki/src/gl/animation.cpp tiki/src/gl/drawable.cpp tiki/src/gl/font.cpp tiki/src/gl/genmenu.cpp tiki/src/gl/gl.cpp tiki/src/gl/plxcompat.cpp tiki/src/gl/texture.cpp tiki/src/gl/trigger.cpp tiki/src/hid/eventcollector.cpp tiki/src/hid/hid.cpp tiki/src/image/image.cpp tiki/src/image/loadjpg.cpp tiki/src/image/loadpng.cpp tiki/src/math/bspline.cpp tiki/src/math/math.cpp tiki/src/math/matrix.cpp tiki/src/math/vector.cpp tiki/src/math/vector3.cpp tiki/src/thread/thread.cpp tiki/win32/include/Tiki/glhdrs.h tiki/win32/include/Tiki/tikitypes.h tiki/win32/include/pch.h tiki/win32/include/sys/cdefs.h tiki/win32/include/sys/queue.h tiki/win32/src/init_shutdown.cpp tiki/win32/src/platgl.cpp tiki/win32/src/plathid.cpp tiki/win32/src/platthread.cpp tiki/win32/src/tikitime.cpp Modified: tiki/3rdparty/libjpeg/README =================================================================== --- tiki/3rdparty/libjpeg/README 2007-08-09 21:57:40 UTC (rev 434) +++ tiki/3rdparty/libjpeg/README 2007-08-09 22:48:59 UTC (rev 435) @@ -5,381 +5,392 @@ ==================================== This distribution contains the sixth public release of the Independent JPEG -Group's free JPEG software. You are welcome to redistribute this software and +Group's free JPEG software. You are welcome to redistribute this software and to use it for any purpose, subject to the conditions under LEGAL ISSUES, below. -Serious users of this software (particularly those incorporating it into -larger programs) should contact IJG at jpe...@uu... to be added to -our electronic mailing list. Mailing list members are notified of updates -and have a chance to participate in technical discussions, etc. +Serious users of this software ( particularly those incorporating it into + larger programs ) + should contact IJG at jpeg - in...@uu... to be added to + our electronic mailing list. Mailing list members are notified of updates + and have a chance to participate in technical discussions, etc. -This software is the work of Tom Lane, Philip Gladstone, Jim Boucher, -Lee Crocker, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, -Guido Vollbeding, Ge' Weijers, and other members of the Independent JPEG -Group. + This software is the work of Tom Lane, Philip Gladstone, Jim Boucher, + Lee Crocker, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, + Guido Vollbeding, Ge' Weijers, and other members of the Independent JPEG + Group. -IJG is not affiliated with the official ISO JPEG standards committee. + IJG is not affiliated with the official ISO JPEG standards committee. -DOCUMENTATION ROADMAP -===================== + DOCUMENTATION ROADMAP + ===================== -This file contains the following sections: + This file contains the following sections: -OVERVIEW General description of JPEG and the IJG software. -LEGAL ISSUES Copyright, lack of warranty, terms of distribution. -REFERENCES Where to learn more about JPEG. -ARCHIVE LOCATIONS Where to find newer versions of this software. -RELATED SOFTWARE Other stuff you should get. -FILE FORMAT WARS Software *not* to get. -TO DO Plans for future IJG releases. + OVERVIEW General description of JPEG and the IJG software. + LEGAL ISSUES Copyright, lack of warranty, terms of distribution. + REFERENCES Where to learn more about JPEG. + ARCHIVE LOCATIONS Where to find newer versions of this software. + RELATED SOFTWARE Other stuff you should get. + FILE FORMAT WARS Software *not* to get. + TO DO Plans for future IJG releases. -Other documentation files in the distribution are: + Other documentation files in the distribution are: -User documentation: - install.doc How to configure and install the IJG software. - usage.doc Usage instructions for cjpeg, djpeg, jpegtran, - rdjpgcom, and wrjpgcom. - *.1 Unix-style man pages for programs (same info as usage.doc). - wizard.doc Advanced usage instructions for JPEG wizards only. - change.log Version-to-version change highlights. -Programmer and internal documentation: - libjpeg.doc How to use the JPEG library in your own programs. - example.c Sample code for calling the JPEG library. - structure.doc Overview of the JPEG library's internal structure. - filelist.doc Road map of IJG files. - coderules.doc Coding style rules --- please read if you contribute code. + User documentation: + install.doc How to configure and install the IJG software. + usage.doc Usage instructions for cjpeg, djpeg, jpegtran, + rdjpgcom, and wrjpgcom. + *.1 Unix-style man pages for programs (same info as usage.doc). + wizard.doc Advanced usage instructions for JPEG wizards only. + change.log Version-to-version change highlights. + Programmer and internal documentation: + libjpeg.doc How to use the JPEG library in your own programs. + example.c Sample code for calling the JPEG library. + structure.doc Overview of the JPEG library's internal structure. + filelist.doc Road map of IJG files. + coderules.doc Coding style rules -- - please read if you contribute code. -Please read at least the files install.doc and usage.doc. Useful information -can also be found in the JPEG FAQ (Frequently Asked Questions) article. See -ARCHIVE LOCATIONS below to find out where to obtain the FAQ article. + Please read at least the files install.doc and usage.doc. Useful information + can also be found in the JPEG FAQ ( Frequently Asked Questions ) + article. See + ARCHIVE LOCATIONS below to find out where to obtain the FAQ article. -If you want to understand how the JPEG code works, we suggest reading one or -more of the REFERENCES, then looking at the documentation files (in roughly -the order listed) before diving into the code. + If you want to understand how the JPEG code works, we suggest reading one or + more of the REFERENCES, then looking at the documentation files ( in roughly + the order listed ) before diving into the code. -OVERVIEW -======== + OVERVIEW + == == == == -This package contains C software to implement JPEG image compression and -decompression. JPEG (pronounced "jay-peg") is a standardized compression -method for full-color and gray-scale images. JPEG is intended for compressing -"real-world" scenes; line drawings, cartoons and other non-realistic images -are not its strong suit. JPEG is lossy, meaning that the output image is not -exactly identical to the input image. Hence you must not use JPEG if you -have to have identical output bits. However, on typical photographic images, + This package contains C software to implement JPEG image compression and + decompression. JPEG ( pronounced "jay-peg" ) is a standardized compression + method for full - color and gray - scale images. JPEG is intended for compressing + "real-world" scenes; +line drawings, cartoons and other non - realistic images +are not its strong suit. JPEG is lossy, meaning that the output image is not +exactly identical to the input image. Hence you must not use JPEG if you +have to have identical output bits. However, on typical photographic images, very good compression levels can be obtained with no visible change, and remarkably high compression levels are possible if you can tolerate a -low-quality image. For more details, see the references, or just experiment -with various compression settings. + low - quality image. For more details, see the references, or just experiment + with various compression settings. -This software implements JPEG baseline, extended-sequential, and progressive -compression processes. Provision is made for supporting all variants of these -processes, although some uncommon parameter settings aren't implemented yet. -For legal reasons, we are not distributing code for the arithmetic-coding -variants of JPEG; see LEGAL ISSUES. We have made no provision for supporting -the hierarchical or lossless processes defined in the standard. + This software implements JPEG baseline, extended - sequential, and progressive + compression processes. Provision is made for supporting all variants of these + processes, although some uncommon parameter settings aren't implemented yet. + For legal reasons, we are not distributing code for the arithmetic-coding + variants of JPEG; see LEGAL ISSUES. We have made no provision for supporting + the hierarchical or lossless processes defined in the standard. -We provide a set of library routines for reading and writing JPEG image files, -plus two sample applications "cjpeg" and "djpeg", which use the library to -perform conversion between JPEG and some other popular image file formats. -The library is intended to be reused in other applications. + We provide a set of library routines for reading and writing JPEG image files, + plus two sample applications "cjpeg" and "djpeg", which use the library to + perform conversion between JPEG and some other popular image file formats. + The library is intended to be reused in other applications. -In order to support file conversion and viewing software, we have included -considerable functionality beyond the bare JPEG coding/decoding capability; -for example, the color quantization modules are not strictly part of JPEG -decoding, but they are essential for output to colormapped file formats or -colormapped displays. These extra functions can be compiled out of the -library if not required for a particular application. We have also included -"jpegtran", a utility for lossless transcoding between different JPEG -processes, and "rdjpgcom" and "wrjpgcom", two simple applications for -inserting and extracting textual comments in JFIF files. + In order to support file conversion and viewing software, we have included + considerable functionality beyond the bare JPEG coding/decoding capability; + for example, the color quantization modules are not strictly part of JPEG + decoding, but they are essential for output to colormapped file formats or + colormapped displays. These extra functions can be compiled out of the + library if not required for a particular application. We have also included + "jpegtran", a utility for lossless transcoding between different JPEG + processes, and "rdjpgcom" and "wrjpgcom", two simple applications for + inserting and extracting textual comments in JFIF files. -The emphasis in designing this software has been on achieving portability and -flexibility, while also making it fast enough to be useful. In particular, -the software is not intended to be read as a tutorial on JPEG. (See the -REFERENCES section for introductory material.) Rather, it is intended to -be reliable, portable, industrial-strength code. We do not claim to have -achieved that goal in every aspect of the software, but we strive for it. + The emphasis in designing this software has been on achieving portability and + flexibility, while also making it fast enough to be useful. In particular, + the software is not intended to be read as a tutorial on JPEG. (See the + REFERENCES section for introductory material.) Rather, it is intended to + be reliable, portable, industrial-strength code. We do not claim to have + achieved that goal in every aspect of the software, but we strive for it. -We welcome the use of this software as a component of commercial products. -No royalty is required, but we do ask for an acknowledgement in product -documentation, as described under LEGAL ISSUES. + We welcome the use of this software as a component of commercial products. + No royalty is required, but we do ask for an acknowledgement in product + documentation, as described under LEGAL ISSUES. -LEGAL ISSUES -============ + LEGAL ISSUES + ============ -In plain English: + In plain English: -1. We don't promise that this software works. (But if you find any bugs, - please let us know!) -2. You can use this software for whatever you want. You don't have to pay us. -3. You may not pretend that you wrote this software. If you use it in a - program, you must acknowledge somewhere in your documentation that - you've used the IJG code. + 1. We don't promise that this software works. ( But if you find any bugs, + please let us know! ) + 2. You can use this software for whatever you want. You don't have to pay us. + 3. You may not pretend that you wrote this software. If you use it in a + program, you must acknowledge somewhere in your documentation that + you've used the IJG code. In legalese: -The authors make NO WARRANTY or representation, either express or implied, -with respect to this software, its quality, accuracy, merchantability, or -fitness for a particular purpose. This software is provided "AS IS", and you, -its user, assume the entire risk as to its quality and accuracy. + The authors make NO WARRANTY or representation, either express or implied, + with respect to this software, its quality, accuracy, merchantability, or + fitness for a particular purpose. This software is provided "AS IS", and you, + its user, assume the entire risk as to its quality and accuracy. -This software is copyright (C) 1991-1998, Thomas G. Lane. -All Rights Reserved except as specified below. + This software is copyright ( C ) + 1991 - 1998, Thomas G. Lane. + All Rights Reserved except as specified below. -Permission is hereby granted to use, copy, modify, and distribute this -software (or portions thereof) for any purpose, without fee, subject to these + Permission is hereby granted to use, copy, modify, and distribute this + software ( or portions thereof ) for any purpose, without fee, subject to these conditions: -(1) If any part of the source code for this software is distributed, then this -README file must be included, with this copyright and no-warranty notice -unaltered; and any additions, deletions, or changes to the original files + ( 1 ) + If any part of the source code for this software is distributed, then this + README file must be included, with this copyright and no - warranty notice + unaltered; +and any additions, deletions, or changes to the original files must be clearly indicated in accompanying documentation. -(2) If only executable code is distributed, then the accompanying +( 2 ) +If only executable code is distributed, then the accompanying documentation must state that "this software is based in part on the work of the Independent JPEG Group". -(3) Permission for use of this software is granted only if the user accepts -full responsibility for any undesirable consequences; the authors accept +( 3 ) Permission for use of this software is granted only if the user accepts + full responsibility for any undesirable consequences; +the authors accept NO LIABILITY for damages of any kind. These conditions apply to any software derived from or based on the IJG code, -not just to the unmodified library. If you use our work, you ought to +not just to the unmodified library. If you use our work, you ought to acknowledge us. Permission is NOT granted for the use of any IJG author's name or company name -in advertising or publicity relating to this software or products derived from -it. This software may be referred to only as "the Independent JPEG Group's -software". + in advertising or publicity relating to this software or products derived from + it. This software may be referred to only as "the Independent JPEG Group's + software". -We specifically permit and encourage the use of this software as the basis of -commercial products, provided that all warranty or liability claims are -assumed by the product vendor. + We specifically permit and encourage the use of this software as the basis of + commercial products, provided that all warranty or liability claims are + assumed by the product vendor. -ansi2knr.c is included in this distribution by permission of L. Peter Deutsch, -sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA. -ansi2knr.c is NOT covered by the above copyright and conditions, but instead -by the usual distribution terms of the Free Software Foundation; principally, -that you must include source code if you redistribute it. (See the file -ansi2knr.c for full details.) However, since ansi2knr.c is not needed as part -of any program generated from the IJG code, this does not limit you more than -the foregoing paragraphs do. + ansi2knr.c is included in this distribution by permission of L. Peter Deutsch, + sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA. + ansi2knr.c is NOT covered by the above copyright and conditions, but instead + by the usual distribution terms of the Free Software Foundation; principally, + that you must include source code if you redistribute it. (See the file + ansi2knr.c for full details.) However, since ansi2knr.c is not needed as part + of any program generated from the IJG code, this does not limit you more than + the foregoing paragraphs do. -The Unix configuration script "configure" was produced with GNU Autoconf. -It is copyright by the Free Software Foundation but is freely distributable. -The same holds for its supporting scripts (config.guess, config.sub, -ltconfig, ltmain.sh). Another support script, install-sh, is copyright -by M.I.T. but is also freely distributable. + The Unix configuration script "configure" was produced with GNU Autoconf. + It is copyright by the Free Software Foundation but is freely distributable. + The same holds for its supporting scripts (config.guess, config.sub, + ltconfig, ltmain.sh). Another support script, install-sh, is copyright + by M.I.T. but is also freely distributable. -It appears that the arithmetic coding option of the JPEG spec is covered by -patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot -legally be used without obtaining one or more licenses. For this reason, -support for arithmetic coding has been removed from the free JPEG software. -(Since arithmetic coding provides only a marginal gain over the unpatented -Huffman mode, it is unlikely that very many implementations will support it.) -So far as we are aware, there are no patent restrictions on the remaining -code. + It appears that the arithmetic coding option of the JPEG spec is covered by + patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot + legally be used without obtaining one or more licenses. For this reason, + support for arithmetic coding has been removed from the free JPEG software. + (Since arithmetic coding provides only a marginal gain over the unpatented + Huffman mode, it is unlikely that very many implementations will support it.) + So far as we are aware, there are no patent restrictions on the remaining + code. -The IJG distribution formerly included code to read and write GIF files. -To avoid entanglement with the Unisys LZW patent, GIF reading support has -been removed altogether, and the GIF writer has been simplified to produce -"uncompressed GIFs". This technique does not use the LZW algorithm; the -resulting GIF files are larger than usual, but are readable by all standard -GIF decoders. + The IJG distribution formerly included code to read and write GIF files. + To avoid entanglement with the Unisys LZW patent, GIF reading support has + been removed altogether, and the GIF writer has been simplified to produce + "uncompressed GIFs". This technique does not use the LZW algorithm; the + resulting GIF files are larger than usual, but are readable by all standard + GIF decoders. -We are required to state that - "The Graphics Interchange Format(c) is the Copyright property of - CompuServe Incorporated. GIF(sm) is a Service Mark property of - CompuServe Incorporated." + We are required to state that + "The Graphics Interchange Format( c ) + is the Copyright property of + CompuServe Incorporated. GIF( sm ) is a Service Mark property of + CompuServe Incorporated." -REFERENCES -========== + REFERENCES + ========== -We highly recommend reading one or more of these references before trying to -understand the innards of the JPEG software. + We highly recommend reading one or more of these references before trying to + understand the innards of the JPEG software. -The best short technical introduction to the JPEG compression algorithm is - Wallace, Gregory K. "The JPEG Still Picture Compression Standard", - Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44. -(Adjacent articles in that issue discuss MPEG motion picture compression, -applications of JPEG, and related topics.) If you don't have the CACM issue -handy, a PostScript file containing a revised version of Wallace's article is -available at ftp://ftp.uu.net/graphics/jpeg/wallace.ps.gz. The file (actually -a preprint for an article that appeared in IEEE Trans. Consumer Electronics) -omits the sample images that appeared in CACM, but it includes corrections -and some added material. Note: the Wallace article is copyright ACM and IEEE, -and it may not be used for commercial purposes. + The best short technical introduction to the JPEG compression algorithm is + Wallace, Gregory K. "The JPEG Still Picture Compression Standard", + Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44. + (Adjacent articles in that issue discuss MPEG motion picture compression, + applications of JPEG, and related topics.) If you don't have the CACM issue + handy, a PostScript file containing a revised version of Wallace's article is + available at ftp://ftp.uu.net/graphics/jpeg/wallace.ps.gz. The file (actually + a preprint for an article that appeared in IEEE Trans. Consumer Electronics) + omits the sample images that appeared in CACM, but it includes corrections + and some added material. Note: the Wallace article is copyright ACM and IEEE, + and it may not be used for commercial purposes. -A somewhat less technical, more leisurely introduction to JPEG can be found in -"The Data Compression Book" by Mark Nelson and Jean-loup Gailly, published by -M&T Books (New York), 2nd ed. 1996, ISBN 1-55851-434-1. This book provides -good explanations and example C code for a multitude of compression methods -including JPEG. It is an excellent source if you are comfortable reading C -code but don't know much about data compression in general. The book's JPEG -sample code is far from industrial-strength, but when you are ready to look -at a full implementation, you've got one here... + A somewhat less technical, more leisurely introduction to JPEG can be found in + "The Data Compression Book" by Mark Nelson and Jean-loup Gailly, published by + M&T Books (New York), 2nd ed. 1996, ISBN 1-55851-434-1. This book provides + good explanations and example C code for a multitude of compression methods + including JPEG. It is an excellent source if you are comfortable reading C + code but don't know much about data compression in general. The book's JPEG + sample code is far from industrial-strength, but when you are ready to look + at a full implementation, you've got one here... -The best full description of JPEG is the textbook "JPEG Still Image Data -Compression Standard" by William B. Pennebaker and Joan L. Mitchell, published -by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1. Price US$59.95, 638 pp. -The book includes the complete text of the ISO JPEG standards (DIS 10918-1 -and draft DIS 10918-2). This is by far the most complete exposition of JPEG -in existence, and we highly recommend it. + The best full description of JPEG is the textbook "JPEG Still Image Data + Compression Standard" by William B. Pennebaker and Joan L. Mitchell, published + by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1. Price US$59.95, 638 pp. + The book includes the complete text of the ISO JPEG standards (DIS 10918-1 + and draft DIS 10918-2). This is by far the most complete exposition of JPEG + in existence, and we highly recommend it. -The JPEG standard itself is not available electronically; you must order a -paper copy through ISO or ITU. (Unless you feel a need to own a certified -official copy, we recommend buying the Pennebaker and Mitchell book instead; -it's much cheaper and includes a great deal of useful explanatory material.) -In the USA, copies of the standard may be ordered from ANSI Sales at (212) -642-4900, or from Global Engineering Documents at (800) 854-7179. (ANSI -doesn't take credit card orders, but Global does.) It's not cheap: as of -1992, ANSI was charging $95 for Part 1 and $47 for Part 2, plus 7% -shipping/handling. The standard is divided into two parts, Part 1 being the -actual specification, while Part 2 covers compliance testing methods. Part 1 -is titled "Digital Compression and Coding of Continuous-tone Still Images, -Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS -10918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of -Continuous-tone Still Images, Part 2: Compliance testing" and has document -numbers ISO/IEC IS 10918-2, ITU-T T.83. + The JPEG standard itself is not available electronically; you must order a + paper copy through ISO or ITU. (Unless you feel a need to own a certified + official copy, we recommend buying the Pennebaker and Mitchell book instead; + it's much cheaper and includes a great deal of useful explanatory material.) + In the USA, copies of the standard may be ordered from ANSI Sales at (212) + 642-4900, or from Global Engineering Documents at (800) 854-7179. (ANSI + doesn't take credit card orders, but Global does.) It's not cheap: as of + 1992, ANSI was charging $95 for Part 1 and $47 for Part 2, plus 7% + shipping/handling. The standard is divided into two parts, Part 1 being the + actual specification, while Part 2 covers compliance testing methods. Part 1 + is titled "Digital Compression and Coding of Continuous - tone Still Images, +Part 1: + Requirements and guidelines" and has document numbers ISO/IEC IS + 10918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of +Continuous - tone Still Images, Part 2: + Compliance testing" and has document + numbers ISO/IEC IS 10918-2, ITU-T T.83. -Some extensions to the original JPEG standard are defined in JPEG Part 3, -a newer ISO standard numbered ISO/IEC IS 10918-3 and ITU-T T.84. IJG -currently does not support any Part 3 extensions. + Some extensions to the original JPEG standard are defined in JPEG Part 3, + a newer ISO standard numbered ISO/IEC IS 10918-3 and ITU-T T.84. IJG + currently does not support any Part 3 extensions. -The JPEG standard does not specify all details of an interchangeable file -format. For the omitted details we follow the "JFIF" conventions, revision -1.02. A copy of the JFIF spec is available from: - Literature Department - C-Cube Microsystems, Inc. - 1778 McCarthy Blvd. - Milpitas, CA 95035 - phone (408) 944-6300, fax (408) 944-6314 -A PostScript version of this document is available by FTP at -ftp://ftp.uu.net/graphics/jpeg/jfif.ps.gz. There is also a plain text -version at ftp://ftp.uu.net/graphics/jpeg/jfif.txt.gz, but it is missing -the figures. + The JPEG standard does not specify all details of an interchangeable file + format. For the omitted details we follow the "JFIF" conventions, revision + 1.02. A copy of the JFIF spec is available from: + Literature Department + C-Cube Microsystems, Inc. + 1778 McCarthy Blvd. + Milpitas, CA 95035 + phone (408) 944-6300, fax (408) 944-6314 + A PostScript version of this document is available by FTP at + ftp://ftp.uu.net/graphics/jpeg/jfif.ps.gz. There is also a plain text + version at ftp://ftp.uu.net/graphics/jpeg/jfif.txt.gz, but it is missing + the figures. -The TIFF 6.0 file format specification can be obtained by FTP from -ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme -found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems. -IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6). -Instead, we recommend the JPEG design proposed by TIFF Technical Note #2 -(Compression tag 7). Copies of this Note can be obtained from ftp.sgi.com or -from ftp://ftp.uu.net/graphics/jpeg/. It is expected that the next revision -of the TIFF spec will replace the 6.0 JPEG design with the Note's design. -Although IJG's own code does not support TIFF/JPEG, the free libtiff library -uses our library to implement TIFF/JPEG per the Note. libtiff is available -from ftp://ftp.sgi.com/graphics/tiff/. + The TIFF 6.0 file format specification can be obtained by FTP from + ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme + found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems. + IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6). + Instead, we recommend the JPEG design proposed by TIFF Technical Note #2 + (Compression tag 7). Copies of this Note can be obtained from ftp.sgi.com or + from ftp://ftp.uu.net/graphics/jpeg/. It is expected that the next revision + of the TIFF spec will replace the 6.0 JPEG design with the Note's design. + Although IJG's own code does not support TIFF/JPEG, the free libtiff library + uses our library to implement TIFF/JPEG per the Note. libtiff is available + from ftp://ftp.sgi.com/graphics/tiff/. -ARCHIVE LOCATIONS -================= + ARCHIVE LOCATIONS + ================= -The "official" archive site for this software is ftp.uu.net (Internet -address 192.48.96.9). The most recent released version can always be found -there in directory graphics/jpeg. This particular version will be archived -as ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz. If you don't have -direct Internet access, UUNET's archives are also available via UUCP; contact -h...@uu... for information on retrieving files that way. + The "official" archive site for this software is ftp.uu.net (Internet + address 192.48.96.9). The most recent released version can always be found + there in directory graphics/jpeg. This particular version will be archived + as ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz. If you don't have + direct Internet access, UUNET's archives are also available via UUCP; contact + he...@uu... for information on retrieving files that way. -Numerous Internet sites maintain copies of the UUNET files. However, only -ftp.uu.net is guaranteed to have the latest official version. + Numerous Internet sites maintain copies of the UUNET files. However, only + ftp.uu.net is guaranteed to have the latest official version. -You can also obtain this software in DOS-compatible "zip" archive format from -the SimTel archives (ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/), or -on CompuServe in the Graphics Support forum (GO CIS:GRAPHSUP), library 12 -"JPEG Tools". Again, these versions may sometimes lag behind the ftp.uu.net -release. + You can also obtain this software in DOS-compatible "zip" archive format from + the SimTel archives (ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/), or + on CompuServe in the Graphics Support forum (GO CIS:GRAPHSUP), library 12 + "JPEG Tools". Again, these versions may sometimes lag behind the ftp.uu.net + release. -The JPEG FAQ (Frequently Asked Questions) article is a useful source of -general information about JPEG. It is updated constantly and therefore is -not included in this distribution. The FAQ is posted every two weeks to -Usenet newsgroups comp.graphics.misc, news.answers, and other groups. -It is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/ -and other news.answers archive sites, including the official news.answers -archive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/. -If you don't have Web or FTP access, send e-mail to mai...@rt... -with body - send usenet/news.answers/jpeg-faq/part1 - send usenet/news.answers/jpeg-faq/part2 + The JPEG FAQ (Frequently Asked Questions) article is a useful source of + general information about JPEG. It is updated constantly and therefore is + not included in this distribution. The FAQ is posted every two weeks to + Usenet newsgroups comp.graphics.misc, news.answers, and other groups. + It is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/ + and other news.answers archive sites, including the official news.answers + archive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/. + If you don't have Web or FTP access, send e-mail to mai...@rt... + with body + send usenet/news.answers/jpeg-faq/part1 + send usenet/news.answers/jpeg-faq/part2 -RELATED SOFTWARE -================ + RELATED SOFTWARE + ================ -Numerous viewing and image manipulation programs now support JPEG. (Quite a -few of them use this library to do so.) The JPEG FAQ described above lists -some of the more popular free and shareware viewers, and tells where to -obtain them on Internet. + Numerous viewing and image manipulation programs now support JPEG. (Quite a + few of them use this library to do so.) The JPEG FAQ described above lists + some of the more popular free and shareware viewers, and tells where to + obtain them on Internet. -If you are on a Unix machine, we highly recommend Jef Poskanzer's free -PBMPLUS software, which provides many useful operations on PPM-format image -files. In particular, it can convert PPM images to and from a wide range of -other formats, thus making cjpeg/djpeg considerably more useful. The latest -version is distributed by the NetPBM group, and is available from numerous -sites, notably ftp://wuarchive.wustl.edu/graphics/graphics/packages/NetPBM/. -Unfortunately PBMPLUS/NETPBM is not nearly as portable as the IJG software is; -you are likely to have difficulty making it work on any non-Unix machine. + If you are on a Unix machine, we highly recommend Jef Poskanzer's free + PBMPLUS software, which provides many useful operations on PPM-format image + files. In particular, it can convert PPM images to and from a wide range of + other formats, thus making cjpeg/djpeg considerably more useful. The latest + version is distributed by the NetPBM group, and is available from numerous + sites, notably ftp://wuarchive.wustl.edu/graphics/graphics/packages/NetPBM/. + Unfortunately PBMPLUS/NETPBM is not nearly as portable as the IJG software is; + you are likely to have difficulty making it work on any non-Unix machine. -A different free JPEG implementation, written by the PVRG group at Stanford, -is available from ftp://havefun.stanford.edu/pub/jpeg/. This program -is designed for research and experimentation rather than production use; -it is slower, harder to use, and less portable than the IJG code, but it -is easier to read and modify. Also, the PVRG code supports lossless JPEG, -which we do not. (On the other hand, it doesn't do progressive JPEG.) + A different free JPEG implementation, written by the PVRG group at Stanford, + is available from ftp://havefun.stanford.edu/pub/jpeg/. This program + is designed for research and experimentation rather than production use; + it is slower, harder to use, and less portable than the IJG code, but it + is easier to read and modify. Also, the PVRG code supports lossless JPEG, + which we do not. (On the other hand, it doesn't do progressive JPEG.) -FILE FORMAT WARS -================ + FILE FORMAT WARS + ================ -Some JPEG programs produce files that are not compatible with our library. -The root of the problem is that the ISO JPEG committee failed to specify a -concrete file format. Some vendors "filled in the blanks" on their own, -creating proprietary formats that no one else could read. (For example, none -of the early commercial JPEG implementations for the Macintosh were able to -exchange compressed files.) + Some JPEG programs produce files that are not compatible with our library. + The root of the problem is that the ISO JPEG committee failed to specify a + concrete file format. Some vendors "filled in the blanks" on their own, + creating proprietary formats that no one else could read. (For example, none + of the early commercial JPEG implementations for the Macintosh were able to + exchange compressed files.) -The file format we have adopted is called JFIF (see REFERENCES). This format -has been agreed to by a number of major commercial JPEG vendors, and it has -become the de facto standard. JFIF is a minimal or "low end" representation. -We recommend the use of TIFF/JPEG (TIFF revision 6.0 as modified by TIFF -Technical Note #2) for "high end" applications that need to record a lot of -additional data about an image. TIFF/JPEG is fairly new and not yet widely -supported, unfortunately. + The file format we have adopted is called JFIF (see REFERENCES). This format + has been agreed to by a number of major commercial JPEG vendors, and it has + become the de facto standard. JFIF is a minimal or "low end" representation. + We recommend the use of TIFF/JPEG (TIFF revision 6.0 as modified by TIFF + Technical Note #2) for "high end" applications that need to record a lot of + additional data about an image. TIFF/JPEG is fairly new and not yet widely + supported, unfortunately. -The upcoming JPEG Part 3 standard defines a file format called SPIFF. -SPIFF is interoperable with JFIF, in the sense that most JFIF decoders should -be able to read the most common variant of SPIFF. SPIFF has some technical -advantages over JFIF, but its major claim to fame is simply that it is an -official standard rather than an informal one. At this point it is unclear -whether SPIFF will supersede JFIF or whether JFIF will remain the de-facto -standard. IJG intends to support SPIFF once the standard is frozen, but we -have not decided whether it should become our default output format or not. -(In any case, our decoder will remain capable of reading JFIF indefinitely.) + The upcoming JPEG Part 3 standard defines a file format called SPIFF. + SPIFF is interoperable with JFIF, in the sense that most JFIF decoders should + be able to read the most common variant of SPIFF. SPIFF has some technical + advantages over JFIF, but its major claim to fame is simply that it is an + official standard rather than an informal one. At this point it is unclear + whether SPIFF will supersede JFIF or whether JFIF will remain the de-facto + standard. IJG intends to support SPIFF once the standard is frozen, but we + have not decided whether it should become our default output format or not. + (In any case, our decoder will remain capable of reading JFIF indefinitely.) -Various proprietary file formats incorporating JPEG compression also exist. -We have little or no sympathy for the existence of these formats. Indeed, -one of the original reasons for developing this free software was to help -force convergence on common, open format standards for JPEG files. Don't -use a proprietary file format! + Various proprietary file formats incorporating JPEG compression also exist. + We have little or no sympathy for the existence of these formats. Indeed, + one of the original reasons for developing this free software was to help + force convergence on common, open format standards for JPEG files. Don't + use a proprietary file format! -TO DO -===== + TO DO + ===== -The major thrust for v7 will probably be improvement of visual quality. -The current method for scaling the quantization tables is known not to be -very good at low Q values. We also intend to investigate block boundary -smoothing, "poor man's variable quantization", and other means of improving -quality-vs-file-size performance without sacrificing compatibility. + The major thrust for v7 will probably be improvement of visual quality. + The current method for scaling the quantization tables is known not to be + very good at low Q values. We also intend to investigate block boundary + smoothing, "poor man's variable quantization", and other means of improving + quality-vs-file-size performance without sacrificing compatibility. -In future versions, we are considering supporting some of the upcoming JPEG -Part 3 extensions --- principally, variable quantization and the SPIFF file -format. + In future versions, we are considering supporting some of the upcoming JPEG + Part 3 extensions --- principally, variable quantization and the SPIFF file + format. -As always, speeding things up is of great interest. + As always, speeding things up is of great interest. -Please send bug reports, offers of help, etc. to jpe...@uu.... + Please send bug reports, offers of help, etc. to jpe...@uu.... Modified: tiki/3rdparty/libjpeg/jcapimin.c =================================================================== --- tiki/3rdparty/libjpeg/jcapimin.c 2007-08-09 21:57:40 UTC (rev 434) +++ tiki/3rdparty/libjpeg/jcapimin.c 2007-08-09 22:48:59 UTC (rev 435) @@ -1,20 +1,20 @@ /* - * jcapimin.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the compression half - * of the JPEG library. These are the "minimum" API routines that may be - * needed in either the normal full-compression case or the transcoding-only - * case. - * - * Most of the routines intended to be called directly by an application - * are in this file or in jcapistd.c. But also see jcparam.c for - * parameter-setup helper routines, jcomapi.c for routines shared by - * compression and decompression, and jctrans.c for the transcoding case. - */ +* jcapimin.c +* +* Copyright (C) 1994-1998, Thomas G. Lane. +* This file is part of the Independent JPEG Group's software. +* For conditions of distribution and use, see the accompanying README file. +* +* This file contains application interface code for the compression half +* of the JPEG library. These are the "minimum" API routines that may be +* needed in either the normal full-compression case or the transcoding-only +* case. +* +* Most of the routines intended to be called directly by an application +* are in this file or in jcapistd.c. But also see jcparam.c for +* parameter-setup helper routines, jcomapi.c for routines shared by +* compression and decompression, and jctrans.c for the transcoding case. +*/ #define JPEG_INTERNALS #include "jinclude.h" @@ -26,57 +26,56 @@ * The error manager must already be set up (in case memory manager fails). */ -GLOBAL(void) -jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize) -{ - int i; +GLOBAL( void ) +jpeg_CreateCompress ( j_compress_ptr cinfo, int version, size_t structsize ) { + int i; - /* Guard against version mismatches between library and caller. */ - cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ - if (version != JPEG_LIB_VERSION) - ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); - if (structsize != SIZEOF(struct jpeg_compress_struct)) - ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, - (int) SIZEOF(struct jpeg_compress_struct), (int) structsize); + /* Guard against version mismatches between library and caller. */ + cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ + if ( version != JPEG_LIB_VERSION ) + ERREXIT2( cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version ); + if ( structsize != SIZEOF( struct jpeg_compress_struct ) ) + ERREXIT2( cinfo, JERR_BAD_STRUCT_SIZE, + ( int ) SIZEOF( struct jpeg_compress_struct ), ( int ) structsize ); - /* For debugging purposes, we zero the whole master structure. - * But the application has already set the err pointer, and may have set - * client_data, so we have to save and restore those fields. - * Note: if application hasn't set client_data, tools like Purify may - * complain here. - */ - { - struct jpeg_error_mgr * err = cinfo->err; - void * client_data = cinfo->client_data; /* ignore Purify complaint here */ - MEMZERO(cinfo, SIZEOF(struct jpeg_compress_struct)); - cinfo->err = err; - cinfo->client_data = client_data; - } - cinfo->is_decompressor = FALSE; + /* For debugging purposes, we zero the whole master structure. + * But the application has already set the err pointer, and may have set + * client_data, so we have to save and restore those fields. + * Note: if application hasn't set client_data, tools like Purify may + * complain here. + */ + { + struct jpeg_error_mgr * err = cinfo->err; + void * client_data = cinfo->client_data; /* ignore Purify complaint here */ + MEMZERO( cinfo, SIZEOF( struct jpeg_compress_struct ) ); + cinfo->err = err; + cinfo->client_data = client_data; + } + cinfo->is_decompressor = FALSE; - /* Initialize a memory manager instance for this object */ - jinit_memory_mgr((j_common_ptr) cinfo); + /* Initialize a memory manager instance for this object */ + jinit_memory_mgr( ( j_common_ptr ) cinfo ); - /* Zero out pointers to permanent structures. */ - cinfo->progress = NULL; - cinfo->dest = NULL; + /* Zero out pointers to permanent structures. */ + cinfo->progress = NULL; + cinfo->dest = NULL; - cinfo->comp_info = NULL; + cinfo->comp_info = NULL; - for (i = 0; i < NUM_QUANT_TBLS; i++) - cinfo->quant_tbl_ptrs[i] = NULL; + for ( i = 0; i < NUM_QUANT_TBLS; i++ ) + cinfo->quant_tbl_ptrs[ i ] = NULL; - for (i = 0; i < NUM_HUFF_TBLS; i++) { - cinfo->dc_huff_tbl_ptrs[i] = NULL; - cinfo->ac_huff_tbl_ptrs[i] = NULL; - } + for ( i = 0; i < NUM_HUFF_TBLS; i++ ) { + cinfo->dc_huff_tbl_ptrs[ i ] = NULL; + cinfo->ac_huff_tbl_ptrs[ i ] = NULL; + } - cinfo->script_space = NULL; + cinfo->script_space = NULL; - cinfo->input_gamma = 1.0; /* in case application forgets */ + cinfo->input_gamma = 1.0; /* in case application forgets */ - /* OK, I'm ready */ - cinfo->global_state = CSTATE_START; + /* OK, I'm ready */ + cinfo->global_state = CSTATE_START; } @@ -84,10 +83,9 @@ * Destruction of a JPEG compression object */ -GLOBAL(void) -jpeg_destroy_compress (j_compress_ptr cinfo) -{ - jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ +GLOBAL( void ) +jpeg_destroy_compress ( j_compress_ptr cinfo ) { + jpeg_destroy( ( j_common_ptr ) cinfo ); /* use common routine */ } @@ -96,10 +94,9 @@ * but don't destroy the object itself. */ -GLOBAL(void) -jpeg_abort_compress (j_compress_ptr cinfo) -{ - jpeg_abort((j_common_ptr) cinfo); /* use common routine */ +GLOBAL( void ) +jpeg_abort_compress ( j_compress_ptr cinfo ) { + jpeg_abort( ( j_common_ptr ) cinfo ); /* use common routine */ } @@ -115,24 +112,23 @@ * jcparam.o would be linked whether the application used it or not. */ -GLOBAL(void) -jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress) -{ - int i; - JQUANT_TBL * qtbl; - JHUFF_TBL * htbl; +GLOBAL( void ) +jpeg_suppress_tables ( j_compress_ptr cinfo, boolean suppress ) { + int i; + JQUANT_TBL * qtbl; + JHUFF_TBL * htbl; - for (i = 0; i < NUM_QUANT_TBLS; i++) { - if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL) - qtbl->sent_table = suppress; - } + for ( i = 0; i < NUM_QUANT_TBLS; i++ ) { + if ( ( qtbl = cinfo->quant_tbl_ptrs[ i ] ) != NULL ) + qtbl->sent_table = suppress; + } - for (i = 0; i < NUM_HUFF_TBLS; i++) { - if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL) - htbl->sent_table = suppress; - if ((htbl = cinfo->ac_huff_tbl_ptrs[i]) != NULL) - htbl->sent_table = suppress; - } + for ( i = 0; i < NUM_HUFF_TBLS; i++ ) { + if ( ( htbl = cinfo->dc_huff_tbl_ptrs[ i ] ) != NULL ) + htbl->sent_table = suppress; + if ( ( htbl = cinfo->ac_huff_tbl_ptrs[ i ] ) != NULL ) + htbl->sent_table = suppress; + } } @@ -143,41 +139,40 @@ * work including most of the actual output. */ -GLOBAL(void) -jpeg_finish_compress (j_compress_ptr cinfo) -{ - JDIMENSION iMCU_row; +GLOBAL( void ) +jpeg_finish_compress ( j_compress_ptr cinfo ) { + JDIMENSION iMCU_row; - if (cinfo->global_state == CSTATE_SCANNING || - cinfo->global_state == CSTATE_RAW_OK) { - /* Terminate first pass */ - if (cinfo->next_scanline < cinfo->image_height) - ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); - (*cinfo->master->finish_pass) (cinfo); - } else if (cinfo->global_state != CSTATE_WRCOEFS) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Perform any remaining passes */ - while (! cinfo->master->is_last_pass) { - (*cinfo->master->prepare_for_pass) (cinfo); - for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) { - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) iMCU_row; - cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - /* We bypass the main controller and invoke coef controller directly; - * all work is being done from the coefficient buffer. - */ - if (! (*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE) NULL)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - } - (*cinfo->master->finish_pass) (cinfo); - } - /* Write EOI, do final cleanup */ - (*cinfo->marker->write_file_trailer) (cinfo); - (*cinfo->dest->term_destination) (cinfo); - /* We can use jpeg_abort to release memory and reset global_state */ - jpeg_abort((j_common_ptr) cinfo); + if ( cinfo->global_state == CSTATE_SCANNING || + cinfo->global_state == CSTATE_RAW_OK ) { + /* Terminate first pass */ + if ( cinfo->next_scanline < cinfo->image_height ) + ERREXIT( cinfo, JERR_TOO_LITTLE_DATA ); + ( *cinfo->master->finish_pass ) ( cinfo ); + } else if ( cinfo->global_state != CSTATE_WRCOEFS ) + ERREXIT1( cinfo, JERR_BAD_STATE, cinfo->global_state ); + /* Perform any remaining passes */ + while ( ! cinfo->master->is_last_pass ) { + ( *cinfo->master->prepare_for_pass ) ( cinfo ); + for ( iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++ ) { + if ( cinfo->progress != NULL ) { + cinfo->progress->pass_counter = ( long ) iMCU_row; + cinfo->progress->pass_limit = ( long ) cinfo->total_iMCU_rows; + ( *cinfo->progress->progress_monitor ) ( ( j_common_ptr ) cinfo ); + } + /* We bypass the main controller and invoke coef controller directly; + * all work is being done from the coefficient buffer. + */ + if ( ! ( *cinfo->coef->compress_data ) ( cinfo, ( JSAMPIMAGE ) NULL ) ) + ERREXIT( cinfo, JERR_CANT_SUSPEND ); + } + ( *cinfo->master->finish_pass ) ( cinfo ); + } + /* Write EOI, do final cleanup */ + ( *cinfo->marker->write_file_trailer ) ( cinfo ); + ( *cinfo->dest->term_destination ) ( cinfo ); + /* We can use jpeg_abort to release memory and reset global_state */ + jpeg_abort( ( j_common_ptr ) cinfo ); } @@ -188,44 +183,41 @@ * first call to jpeg_write_scanlines() or jpeg_write_raw_data(). */ -GLOBAL(void) -jpeg_write_marker (j_compress_ptr cinfo, int marker, - const JOCTET *dataptr, unsigned int datalen) -{ - JMETHOD(void, write_marker_byte, (j_compress_ptr info, int val)); +GLOBAL( void ) +jpeg_write_marker ( j_compress_ptr cinfo, int marker, + const JOCTET *dataptr, unsigned int datalen ) { + JMETHOD( void, write_marker_byte, ( j_compress_ptr info, int val ) ); - if (cinfo->next_scanline != 0 || - (cinfo->global_state != CSTATE_SCANNING && - cinfo->global_state != CSTATE_RAW_OK && - cinfo->global_state != CSTATE_WRCOEFS)) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + if ( cinfo->next_scanline != 0 || + ( cinfo->global_state != CSTATE_SCANNING && + cinfo->global_state != CSTATE_RAW_OK && + cinfo->global_state != CSTATE_WRCOEFS ) ) + ERREXIT1( cinfo, JERR_BAD_STATE, cinfo->global_state ); - (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); - write_marker_byte = cinfo->marker->write_marker_byte; /* copy for speed */ - while (datalen--) { - (*write_marker_byte) (cinfo, *dataptr); - dataptr++; - } + ( *cinfo->marker->write_marker_header ) ( cinfo, marker, datalen ); + write_marker_byte = cinfo->marker->write_marker_byte; /* copy for speed */ + while ( datalen-- ) { + ( *write_marker_byte ) ( cinfo, *dataptr ); + dataptr++; + } } /* Same, but piecemeal. */ -GLOBAL(void) -jpeg_write_m_header (j_compress_ptr cinfo, int marker, unsigned int datalen) -{ - if (cinfo->next_scanline != 0 || - (cinfo->global_state != CSTATE_SCANNING && - cinfo->global_state != CSTATE_RAW_OK && - cinfo->global_state != CSTATE_WRCOEFS)) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); +GLOBAL( void ) +jpeg_write_m_header ( j_compress_ptr cinfo, int marker, unsigned int datalen ) { + if ( cinfo->next_scanline != 0 || + ( cinfo->global_state != CSTATE_SCANNING && + cinfo->global_state != CSTATE_RAW_OK && + cinfo->global_state != CSTATE_WRCOEFS ) ) + ERREXIT1( cinfo, JERR_BAD_STATE, cinfo->global_state ); - (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); + ( *cinfo->marker->write_marker_header ) ( cinfo, marker, datalen ); } -GLOBAL(void) -jpeg_write_m_byte (j_co... [truncated message content] |
From: <at...@us...> - 2007-08-09 21:57:42
|
Revision: 434 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=434&view=rev Author: atani Date: 2007-08-09 14:57:40 -0700 (Thu, 09 Aug 2007) Log Message: ----------- initialize ansiptr in constructor, fixes ansi parsing to not ignore first ESC character Modified Paths: -------------- tiki/src/gl/drawables/console.cpp Modified: tiki/src/gl/drawables/console.cpp =================================================================== --- tiki/src/gl/drawables/console.cpp 2007-08-04 17:39:47 UTC (rev 433) +++ tiki/src/gl/drawables/console.cpp 2007-08-09 21:57:40 UTC (rev 434) @@ -48,6 +48,7 @@ m_autoWrap = true; m_ansi = false; m_autoRefresh = false; + ansiptr = 0; color(GREY,BLACK); clear(); @@ -136,34 +137,34 @@ } if(ansiptr) { - if(ansiptr > 50) { - ansiptr = 0; - } - ansistr[ansiptr++] = buf[i]; - ansistr[ansiptr] = 0; - if(!isdigit(buf[i]) && ((buf[i] != '[') && (buf[i] != ';'))) { - processAnsiString(); - } - } else if(buf[i] == '\x1b' && m_ansi) { - ansistr[0] = buf[i]; - ansiptr = 1; - ansistr[ansiptr] = 0; - } else { - if(buf[i] == '\n') { - m_cursor_y++; - m_cursor_x=0; - continue; - } else if(buf[i] == '\r') { - m_cursor_x = 0; - continue; - } else if(buf[i] == '\b') { - m_cursor_x--; - if(m_cursor_x < 0) m_cursor_x = 0; - continue; - } else if(buf[i] == 12) { // funky old style clearscreen - clear(); - continue; - } + if(ansiptr > 50) { + ansiptr = 0; + } + ansistr[ansiptr++] = buf[i]; + ansistr[ansiptr] = 0; + if(!isdigit(buf[i]) && ((buf[i] != '[') && (buf[i] != ';'))) { + processAnsiString(); + } + } else if(buf[i] == '\x1b' && m_ansi) { + ansistr[0] = buf[i]; + ansiptr = 1; + ansistr[ansiptr] = 0; + } else { + if(buf[i] == '\n') { + m_cursor_y++; + m_cursor_x=0; + continue; + } else if(buf[i] == '\r') { + m_cursor_x = 0; + continue; + } else if(buf[i] == '\b') { + m_cursor_x--; + if(m_cursor_x < 0) m_cursor_x = 0; + continue; + } else if(buf[i] == 12) { // funky old style clearscreen + clear(); + continue; + } assert(m_cursor_x >= 0 && m_cursor_y >= 0 && m_cursor_x < m_cols && m_cursor_y < m_rows); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2007-08-04 17:39:52
|
Revision: 433 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=433&view=rev Author: ljsebald Date: 2007-08-04 10:39:47 -0700 (Sat, 04 Aug 2007) Log Message: ----------- A little cleaner way of dealing with those lvalue casts. Modified Paths: -------------- kos/kernel/arch/dreamcast/kernel/exec.c kos/kernel/arch/dreamcast/kernel/init.c Modified: kos/kernel/arch/dreamcast/kernel/exec.c =================================================================== --- kos/kernel/arch/dreamcast/kernel/exec.c 2007-08-04 02:42:38 UTC (rev 432) +++ kos/kernel/arch/dreamcast/kernel/exec.c 2007-08-04 17:39:47 UTC (rev 433) @@ -84,8 +84,9 @@ /* Jump to the trampoline */ { - void (*trampoline)() __noreturn; - *((uint32 *) &trampoline) = (uint32)buffer; + typedef void (*trampoline_func)() __noreturn; + trampoline_func trampoline = (trampoline_func)buffer; + trampoline(); } } Modified: kos/kernel/arch/dreamcast/kernel/init.c =================================================================== --- kos/kernel/arch/dreamcast/kernel/init.c 2007-08-04 02:42:38 UTC (rev 432) +++ kos/kernel/arch/dreamcast/kernel/init.c 2007-08-04 17:39:47 UTC (rev 433) @@ -253,14 +253,15 @@ /* Called to jump back to the BIOS menu; assumes a normal shutdown is possible */ void arch_menu() { - void (*menu)(int) __noreturn; + typedef void (*menufunc)(int) __noreturn; + menufunc menu; /* Shut down */ arch_shutdown(); /* Jump to the menus */ dbglog(DBG_CRITICAL, "arch: exiting the system to the BIOS menu\n"); - *((uint32 *) &menu) = *((uint32 *) 0x8c0000e0); + menu = (menufunc)(*((uint32 *) 0x8c0000e0)); menu(1); } @@ -291,7 +292,8 @@ /* Called to reboot the system; assume the system is in peril and don't try to call the dtors */ void arch_reboot() { - void (*rb)() __noreturn; + typedef void (*reboot_func)() __noreturn; + reboot_func rb; dbglog(DBG_CRITICAL, "arch: rebooting the system\n"); @@ -299,6 +301,6 @@ irq_disable(); /* Reboot */ - *((uint32 *) &rb) = 0xa0000000; + rb = (reboot_func)0xa0000000; rb(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2007-08-04 02:42:39
|
Revision: 432 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=432&view=rev Author: ljsebald Date: 2007-08-03 19:42:38 -0700 (Fri, 03 Aug 2007) Log Message: ----------- No more cast expressions as lvalues... Modified Paths: -------------- kos/kernel/arch/dreamcast/kernel/exec.c kos/kernel/arch/dreamcast/kernel/init.c Modified: kos/kernel/arch/dreamcast/kernel/exec.c =================================================================== --- kos/kernel/arch/dreamcast/kernel/exec.c 2007-08-03 04:26:06 UTC (rev 431) +++ kos/kernel/arch/dreamcast/kernel/exec.c 2007-08-04 02:42:38 UTC (rev 432) @@ -85,7 +85,7 @@ /* Jump to the trampoline */ { void (*trampoline)() __noreturn; - ((uint32 *)trampoline) = buffer; + *((uint32 *) &trampoline) = (uint32)buffer; trampoline(); } } Modified: kos/kernel/arch/dreamcast/kernel/init.c =================================================================== --- kos/kernel/arch/dreamcast/kernel/init.c 2007-08-03 04:26:06 UTC (rev 431) +++ kos/kernel/arch/dreamcast/kernel/init.c 2007-08-04 02:42:38 UTC (rev 432) @@ -23,6 +23,8 @@ extern int _bss_start, end; +void _atexit_call_all(); + /* Ditto */ int main(int argc, char **argv); @@ -251,13 +253,15 @@ /* Called to jump back to the BIOS menu; assumes a normal shutdown is possible */ void arch_menu() { + void (*menu)(int) __noreturn; + /* Shut down */ arch_shutdown(); /* Jump to the menus */ dbglog(DBG_CRITICAL, "arch: exiting the system to the BIOS menu\n"); - - { void (*menu)(int) __noreturn; ((uint32 *)menu) = *((uint32 *)0x8c0000e0); menu(1); } + *((uint32 *) &menu) = *((uint32 *) 0x8c0000e0); + menu(1); } /* Called to shut down non-gracefully; assume the system is in peril @@ -287,11 +291,14 @@ /* Called to reboot the system; assume the system is in peril and don't try to call the dtors */ void arch_reboot() { + void (*rb)() __noreturn; + dbglog(DBG_CRITICAL, "arch: rebooting the system\n"); /* Ensure that interrupts are disabled */ irq_disable(); /* Reboot */ - { void (*rb)() __noreturn; ((uint32*)rb) = (uint32 *)0xa0000000; rb(); } + *((uint32 *) &rb) = 0xa0000000; + rb(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2007-08-03 04:26:09
|
Revision: 431 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=431&view=rev Author: ljsebald Date: 2007-08-02 21:26:06 -0700 (Thu, 02 Aug 2007) Log Message: ----------- A small fix for the texture_render example. Modified Paths: -------------- kos/examples/dreamcast/pvr/texture_render/ta.c Modified: kos/examples/dreamcast/pvr/texture_render/ta.c =================================================================== --- kos/examples/dreamcast/pvr/texture_render/ta.c 2007-08-03 04:19:54 UTC (rev 430) +++ kos/examples/dreamcast/pvr/texture_render/ta.c 2007-08-03 04:26:06 UTC (rev 431) @@ -28,7 +28,7 @@ int i; polyplace_t *p; - for (i=0; i<12; i++) { + for (i=0; i<6; i++) { p = polys+i; p->x += p->dx; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2007-08-03 04:19:58
|
Revision: 430 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=430&view=rev Author: ljsebald Date: 2007-08-02 21:19:54 -0700 (Thu, 02 Aug 2007) Log Message: ----------- Adding in a few more inet functions for dealing with parsing and packing internet addresses. Modified Paths: -------------- kos/include/arpa/inet.h kos/include/netinet/in.h kos/kernel/libc/koslib/Makefile kos/kernel/libc/koslib/inet_addr.c Added Paths: ----------- kos/kernel/libc/koslib/inet_aton.c kos/kernel/libc/koslib/inet_ntoa.c kos/kernel/libc/koslib/inet_ntop.c kos/kernel/libc/koslib/inet_pton.c Modified: kos/include/arpa/inet.h =================================================================== --- kos/include/arpa/inet.h 2007-07-29 03:21:16 UTC (rev 429) +++ kos/include/arpa/inet.h 2007-08-03 04:19:54 UTC (rev 430) @@ -1,7 +1,7 @@ /* KallistiOS ##version## arpa/inet.h - Copyright (C)2006 Lawrence Sebald + Copyright (C) 2006, 2007 Lawrence Sebald */ @@ -9,10 +9,13 @@ #define __ARPA_INET_H #include <sys/cdefs.h> -#include <netinet/in.h> __BEGIN_DECLS +#include <sys/types.h> +#include <netinet/in.h> +#include <sys/socket.h> + uint32 htonl(uint32 value); uint32 ntohl(uint32 value); @@ -20,7 +23,14 @@ uint16 ntohs(uint16 value); in_addr_t inet_addr(const char *cp); +int inet_aton(const char *cp, struct in_addr *pin); +int inet_pton(int af, const char *src, void *dst); +const char *inet_ntop(int af, const void *src, char *dst, socklen_t size); + +/* Non-reentrant */ +char *inet_ntoa(struct in_addr addr); + __END_DECLS #endif /* __ARPA_INET_H */ Modified: kos/include/netinet/in.h =================================================================== --- kos/include/netinet/in.h 2007-07-29 03:21:16 UTC (rev 429) +++ kos/include/netinet/in.h 2007-08-03 04:19:54 UTC (rev 430) @@ -1,7 +1,7 @@ /* KallistiOS ##version## netinet/in.h - Copyright (C)2006 Lawrence Sebald + Copyright (C) 2006, 2007 Lawrence Sebald */ @@ -13,8 +13,15 @@ __BEGIN_DECLS +#ifndef __IN_PORT_T_DEFINED +#define __IN_PORT_T_DEFINED typedef uint16 in_port_t; +#endif + +#ifndef __IN_ADDR_T_DEFINED +#define __IN_ADDR_T_DEFINED typedef uint32 in_addr_t; +#endif #ifndef __SA_FAMILY_T_DEFINED #define __SA_FAMILY_T_DEFINED @@ -34,10 +41,13 @@ #define INADDR_ANY 0x00000000 #define INADDR_BROADCAST 0xFFFFFFFF +#define INADDR_NONE 0xFFFFFFFF /* IP Protocols */ -#define IPPROTO_IP 0 -#define IPPROTO_UDP 17 +#define IPPROTO_IP 0 +#define IPPROTO_ICMP 1 +#define IPPROTO_TCP 6 +#define IPPROTO_UDP 17 __END_DECLS Modified: kos/kernel/libc/koslib/Makefile =================================================================== --- kos/kernel/libc/koslib/Makefile 2007-07-29 03:21:16 UTC (rev 429) +++ kos/kernel/libc/koslib/Makefile 2007-08-03 04:19:54 UTC (rev 430) @@ -11,6 +11,7 @@ assert.o dbglog.o malloc.o crtbegin.o crtend.o atexit.o \ opendir.o readdir.o closedir.o rewinddir.o scandir.o seekdir.o \ telldir.o usleep.o inet_addr.o realpath.o getcwd.o chdir.o mkdir.o \ - creat.o sleep.o rmdir.o rename.o + creat.o sleep.o rmdir.o rename.o inet_pton.o inet_ntop.o \ + inet_ntoa.o inet_aton.o include $(KOS_BASE)/Makefile.prefab Modified: kos/kernel/libc/koslib/inet_addr.c =================================================================== --- kos/kernel/libc/koslib/inet_addr.c 2007-07-29 03:21:16 UTC (rev 429) +++ kos/kernel/libc/koslib/inet_addr.c 2007-08-03 04:19:54 UTC (rev 430) @@ -1,49 +1,19 @@ /* KallistiOS ##version## inet_addr.c - Copyright (C)2006 Lawrence Sebald + Copyright (C) 2006, 2007 Lawrence Sebald */ #include <arpa/inet.h> -#include <stdlib.h> in_addr_t inet_addr(const char *cp) { - in_addr_t result = 0; - long tmp; - char *ptr; + struct in_addr addr; - tmp = strtoul(cp, &ptr, 10); - if(tmp > 0xFF || cp == ptr) { - return (in_addr_t) -1; + /* inet_aton() returns 0 on failure, 1 on success */ + if(inet_aton(cp, &addr)) { + return addr.s_addr; } - else { - result = tmp << 24; - } - tmp = strtoul(ptr + 1, &ptr, 10); - if(tmp > 0xFF || cp == ptr) { - return (in_addr_t) -1; - } - else { - result |= tmp << 16; - } - - tmp = strtoul(ptr + 1, &ptr, 10); - if(tmp > 0xFF || cp == ptr) { - return (in_addr_t) -1; - } - else { - result |= tmp << 8; - } - - tmp = strtoul(ptr + 1, &ptr, 10); - if(tmp > 0xFF || cp == ptr) { - return (in_addr_t) -1; - } - else { - result |= tmp; - } - - return (in_addr_t) htonl(result); + return INADDR_NONE; } Added: kos/kernel/libc/koslib/inet_aton.c =================================================================== --- kos/kernel/libc/koslib/inet_aton.c (rev 0) +++ kos/kernel/libc/koslib/inet_aton.c 2007-08-03 04:19:54 UTC (rev 430) @@ -0,0 +1,118 @@ +/* KallistiOS ##version## + + inet_aton.c + Copyright (C) 2007 Lawrence Sebald + +*/ + +#include <arpa/inet.h> + +int inet_aton(const char *cp, struct in_addr *pin) { + int parts[4] = { 0 }; + int count = 0; + int base = 0; + char tmp; + + for(; *cp && count < 4; ++cp) { + if(*cp == '.') { + ++count; + base = 0; + } + else if(base == 0) { + /* Determine which base this part is in */ + if(*cp == '0') { + tmp = *++cp; + + if(tmp == '.') { + base = 0; + parts[count++] = 0; + } + else if(tmp == '\0') { + base = 0; + parts[count] = 0; + --cp; + } + else if(tmp != 'x' && tmp != 'X') { + /* Octal, handle the character just read too. */ + base = 8; + parts[count] = *cp - '0'; + } + else { + /* Hexadecimal */ + base = 16; + } + } + else if(*cp > '0' && *cp <= '9') { + /* Decimal, handle the digit */ + base = 10; + parts[count] = *cp - '0'; + } + else { + /* Non-number starting character... bail out. */ + return 0; + } + } + else if(base == 10 && *cp >= '0' && *cp <= '9') { + parts[count] *= 10; + parts[count] += *cp - '0'; + } + else if(base == 8 && *cp >= '0' && *cp <= '7') { + parts[count] <<= 3; + parts[count] += *cp - '0'; + } + else if(base == 16) { + parts[count] <<= 4; + + if(*cp >= '0' && *cp <= '9') { + parts[count] += *cp - '0'; + } + else if(*cp >= 'A' && *cp <= 'F') { + parts[count] += *cp - 'A' + 10; + } + else if(*cp >= 'a' && *cp <= 'f') { + parts[count] += *cp - 'a' + 10; + } + else { + /* Invalid hex digit */ + return 0; + } + } + else { + /* Invalid digit, and not a dot... bail */ + return 0; + } + } + + if(count == 4) { + /* Too many dots, bail out */ + return 0; + } + + /* Validate each part */ + if(count == 0) { + /* Easiest case, store our computed part, and it's done */ + pin->s_addr = htonl(parts[0]); + } + else if(count == 1) { + if(parts[0] > 0xFF || parts[1] > 0xFFFFFF) + return 0; + + pin->s_addr = htonl(parts[0] << 24 | parts[1]); + } + else if(count == 2) { + if(parts[0] > 0xFF || parts[1] > 0xFF || parts[2] > 0xFFFF) + return 0; + + pin->s_addr = htonl(parts[0] << 24 | parts[1] << 16 | parts[2]); + } + else { + if(parts[0] > 0xFF || parts[1] > 0xFF || + parts[2] > 0xFF || parts[3] > 0xFF) + return 0; + + pin->s_addr = htonl(parts[0] << 24 | parts[1] << 16 | + parts[2] << 8 | parts[3]); + } + + return 1; +} Added: kos/kernel/libc/koslib/inet_ntoa.c =================================================================== --- kos/kernel/libc/koslib/inet_ntoa.c (rev 0) +++ kos/kernel/libc/koslib/inet_ntoa.c 2007-08-03 04:19:54 UTC (rev 430) @@ -0,0 +1,45 @@ +/* KallistiOS ##version## + + inet_ntoa.c + Copyright (C) 2007 Lawrence Sebald + +*/ + +#include <arpa/inet.h> + +char *inet_ntoa(struct in_addr addr) { + static char str[16]; /* XXX.XXX.XXX.XXX = 15 chars + 1 for NUL */ + char tmp[3]; + int i, part; + char *ch = tmp; + char *ch2 = str; + + /* Parse each 8 bits individually. */ + for(i = 0; i < 4; ++i) { + /* Treat the 32-bit address value as if it were an array of 8-bit + values. This works, regardless of the endianness of the host system + because the specs require the address passed in here to be in + network byte order (big endian). */ + part = ((uint8 *) &addr.s_addr)[i]; + + do { + *ch++ = '0' + (char)(part % 10); + part /= 10; + } while(part); + + /* tmp now contains the inverse of the number that is in the given + 8 bits. Reverse it for the final result, rewinding ch to the + beginning of tmp in the process. */ + while(ch != tmp) { + *ch2++ = *--ch; + } + + *ch2++ = '.'; + } + + /* There's a trailing '.' at the end of the address, change it to the + required NUL character */ + *--ch2 = 0; + + return str; +} Added: kos/kernel/libc/koslib/inet_ntop.c =================================================================== --- kos/kernel/libc/koslib/inet_ntop.c (rev 0) +++ kos/kernel/libc/koslib/inet_ntop.c 2007-08-03 04:19:54 UTC (rev 430) @@ -0,0 +1,58 @@ +/* KallistiOS ##version## + + inet_ntop.c + Copyright (C) 2007 Lawrence Sebald + +*/ + +#include <arpa/inet.h> +#include <errno.h> + +const char *inet_ntop(int af, const void *src, char *dst, socklen_t size) { + char tmp[3]; + int i, part; + char *ch = tmp; + char *ch2 = dst; + struct in_addr *addr = (struct in_addr *)src; + + if(af != AF_INET) { + errno = EAFNOSUPPORT; + return NULL; + } + + /* Parse each 8 bits individually. */ + for(i = 0; i < 4; ++i) { + /* Treat the 32-bit address value as if it were an array of 8-bit + values. This works, regardless of the endianness of the host system + because the specs require the address passed in here to be in + network byte order (big endian). */ + part = ((uint8 *) &addr->s_addr)[i]; + + do { + *ch++ = '0' + (char)(part % 10); + part /= 10; + } while(part); + + /* tmp now contains the inverse of the number that is in the given + 8 bits. Reverse it for the final result, rewinding ch to the + beginning of tmp in the process. */ + while(ch != tmp && size) { + *ch2++ = *--ch; + --size; + } + + if(!size) { + errno = ENOSPC; + return NULL; + } + + *ch2++ = '.'; + --size; + } + + /* There's a trailing '.' at the end of the address, change it to the + required NUL character */ + *--ch2 = 0; + + return dst; +} Added: kos/kernel/libc/koslib/inet_pton.c =================================================================== --- kos/kernel/libc/koslib/inet_pton.c (rev 0) +++ kos/kernel/libc/koslib/inet_pton.c 2007-08-03 04:19:54 UTC (rev 430) @@ -0,0 +1,51 @@ +/* KallistiOS ##version## + + inet_pton.c + Copyright (C) 2007 Lawrence Sebald + +*/ + +#include <arpa/inet.h> +#include <errno.h> + +int inet_pton(int af, const char *src, void *dst) { + int parts[4] = { 0 }; + int count = 0; + struct in_addr *addr = (struct in_addr *)dst; + + if(af != AF_INET) { + errno = EAFNOSUPPORT; + return -1; + } + + for(; *src && count < 4; ++src) { + if(*src == '.') { + ++count; + } + /* Unlike inet_aton(), inet_pton() only supports decimal parts */ + else if(*src >= '0' && *src <= '9') { + parts[count] *= 10; + parts[count] += *src - '0'; + } + else { + /* Invalid digit, and not a dot... bail */ + return 0; + } + } + + if(count != 3) { + /* Not the right number of parts, bail */ + return 0; + } + + /* Validate each part, note that unlike inet_aton(), inet_pton() only + supports the standard xxx.xxx.xxx.xxx addresses. */ + if(parts[0] > 0xFF || parts[1] > 0xFF || + parts[2] > 0xFF || parts[3] > 0xFF) + return 0; + + addr->s_addr = htonl(parts[0] << 24 | parts[1] << 16 | + parts[2] << 8 | parts[3]); + + return 1; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <c99...@us...> - 2007-07-29 03:21:18
|
Revision: 429 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=429&view=rev Author: c99koder Date: 2007-07-28 20:21:16 -0700 (Sat, 28 Jul 2007) Log Message: ----------- Tiki: NDS: Keep interrupts enabled during sound mixing, move wifi update into its own timer, include missing header file Modified Paths: -------------- tiki/nds/arm7_template/source/arm7main.c tiki/nds/src/audio/stream.cpp tiki/nds/src/init_shutdown.cpp tiki/nds/src/plathid.cpp Added Paths: ----------- tiki/nds/include/dssoundstream.h Modified: tiki/nds/arm7_template/source/arm7main.c =================================================================== --- tiki/nds/arm7_template/source/arm7main.c 2007-07-28 19:00:43 UTC (rev 428) +++ tiki/nds/arm7_template/source/arm7main.c 2007-07-29 03:21:16 UTC (rev 429) @@ -152,6 +152,7 @@ } void arm7_synctoarm9() { // send fifo message + SendCommandToArm9(0x87654321); } //--------------------------------------------------------------------------------- Added: tiki/nds/include/dssoundstream.h =================================================================== --- tiki/nds/include/dssoundstream.h (rev 0) +++ tiki/nds/include/dssoundstream.h 2007-07-29 03:21:16 UTC (rev 429) @@ -0,0 +1,66 @@ +/* + Tiki + + dssoundstream.h + + based on the ARM9/ARM7 streaming code from + http://forum.gbadev.org/viewtopic.php?t=10739 +*/ + +#ifndef __NDSSOUND_H +#define __NDSSOUND_H + +#include <nds.h> + +#define CLOCK (1 << 25) + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum +{ + NONE = 0, + INIT = 1, + MIX = 2, + MIXING = 4, + STOP = 8 +}CommandType; + +typedef enum +{ + FIFO_NONE = 0, + UPDATEON_ARM9 = 1, + MIXCOMPLETE_ONARM9 = 2 +}FifoType; + +typedef struct +{ + s8 *mixbuffer; + u32 rate; + u32 buffersize; + u32 cmd; + u8 channel,format; + u32 soundcursor,numsamples; + s32 prevtimer; + s16 period; +}S_SoundSystem; + +#define soundsystem ((S_SoundSystem*)((u32)(IPC)+sizeof(TransferRegion))) + +#ifdef ARM9 +extern void SoundSystemInit(u32 rate,u32 buffersize,u8 channel,u8 format); +extern void SoundStartMixer(void); +extern void SendCommandToArm7(u32 command); +#else +extern void SoundVBlankIrq(void); +extern void SoundSwapAndMix(void); +extern void SoundSetTimer(int period); +extern void SoundFifoHandler(void); +extern void SendCommandToArm9(u32 command); +#endif + +#ifdef __cplusplus +} +#endif +#endif Property changes on: tiki/nds/include/dssoundstream.h ___________________________________________________________________ Name: svn:eol-style + native Modified: tiki/nds/src/audio/stream.cpp =================================================================== --- tiki/nds/src/audio/stream.cpp 2007-07-28 19:00:43 UTC (rev 428) +++ tiki/nds/src/audio/stream.cpp 2007-07-29 03:21:16 UTC (rev 429) @@ -52,8 +52,11 @@ { case FIFO_NONE: break; + case 0x87654321: + Wifi_Sync(); + break; case UPDATEON_ARM9: - REG_IME = 0; + //REG_IME = 0; for(streams_iter = streams.begin(); streams_iter != streams.end(); streams_iter++) { if(soundsystem->format == 8) { @@ -82,12 +85,11 @@ } } } - REG_IME = 1; + //REG_IME = 1; SendCommandToArm7(MIXCOMPLETE_ONARM9); break; } } - Wifi_Sync(); } void SendCommandToArm7(u32 command) @@ -114,7 +116,7 @@ Stream::Stream() { // Default our members. - m_bufSize = 16384; + m_bufSize = 4096; m_chnCount = 2; m_freq = 44100; m_queueing = false; Modified: tiki/nds/src/init_shutdown.cpp =================================================================== --- tiki/nds/src/init_shutdown.cpp 2007-07-28 19:00:43 UTC (rev 428) +++ tiki/nds/src/init_shutdown.cpp 2007-07-29 03:21:16 UTC (rev 429) @@ -16,12 +16,16 @@ #include <nds.h> #include <fat.h> #include <dswifi9.h> +#include <dssoundstream.h> // notification function to send fifo message to arm7 void arm9_synctoarm7() { // send fifo message - //This is a NO-OP because the sound streaming code will constantly communicate with the ARM7 over the FIFO anyway + SendCommandToArm7(0x87654321); } - +// wifi timer function, to update internals of sgIP +void Timer_50ms(void) { + Wifi_Timer(50); +} namespace Tiki { bool init(int argc, char **argv) { @@ -46,7 +50,8 @@ GL::Plxcompat::plx_mat3d_init(256, 192); Audio::Stream::initGlobal(); Hid::init(); - + irqSet(IRQ_TIMER3, Timer_50ms); // setup timer IRQ + irqEnable(IRQ_TIMER3); { // send fifo message to initialize the arm7 wifi REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; // enable & clear FIFO @@ -59,6 +64,10 @@ REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ; // enable FIFO IRQ Wifi_SetSyncHandler(arm9_synctoarm7); // tell wifi lib to use our handler to notify arm7 + + // set timer3 + *((volatile u16 *)0x0400010C) = -6553; // 6553.1 * 256 cycles = ~50ms; + *((volatile u16 *)0x0400010E) = 0x00C2; // enable, irq, 1/256 clock while(Wifi_CheckInit()==0) { // wait for arm7 to be initted successfully swiWaitForVBlank(); Modified: tiki/nds/src/plathid.cpp =================================================================== --- tiki/nds/src/plathid.cpp 2007-07-28 19:00:43 UTC (rev 428) +++ tiki/nds/src/plathid.cpp 2007-07-29 03:21:16 UTC (rev 429) @@ -117,12 +117,11 @@ } oldkeys = keys; - Wifi_Timer(50); __timecounter += 15000; } bool platInit() { - irqSet(IRQ_VCOUNT,&TikiVBlank); + irqSet(IRQ_VBLANK,&TikiVBlank); irqEnable(IRQ_VBLANK | IRQ_VCOUNT); NDSjs = new JsDevice; NDSmouse = new MouseDevice; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <c99...@us...> - 2007-07-28 19:00:44
|
Revision: 428 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=428&view=rev Author: c99koder Date: 2007-07-28 12:00:43 -0700 (Sat, 28 Jul 2007) Log Message: ----------- Tiki: NDS: Touchscreen support Modified Paths: -------------- tiki/nds/src/plathid.cpp Modified: tiki/nds/src/plathid.cpp =================================================================== --- tiki/nds/src/plathid.cpp 2007-07-28 06:27:21 UTC (rev 427) +++ tiki/nds/src/plathid.cpp 2007-07-28 19:00:43 UTC (rev 428) @@ -3,46 +3,76 @@ #include "Tiki/hid.h" #include <dswifi9.h> +using namespace Tiki::Hid; + volatile uint64 __timecounter = 0; +class MouseDevice : public Device { +public: + MouseDevice() { } + virtual ~MouseDevice() { } + + virtual Type getType() const { return TypeMouse; } + virtual string getName() const { return "NDS Touchscreen"; } +}; + +class JsDevice : public Device { +public: + JsDevice() { } + virtual ~JsDevice() { } + + virtual Type getType() const { return TypeJoystick; } + virtual string getName() const { return "NDS Controller"; } +}; + +static RefPtr<MouseDevice> NDSmouse; +static RefPtr<JsDevice> NDSjs; + namespace Tiki { namespace Hid { #define CONTROLLER_BUTTON_MAP(OLDSTATE, NEWSTATE, BUTTON, EVENT) \ - if((NEWSTATE & BUTTON) && !(OLDSTATE & BUTTON)) { \ - Event evt(Event::EvtBtnPress); \ - evt.btn = EVENT; \ - evt.port = 1; \ - sendEvent(evt); \ - } \ - if(!(NEWSTATE & BUTTON) && (OLDSTATE & BUTTON)) { \ - Event evt(Event::EvtBtnRelease); \ - evt.btn = EVENT; \ - evt.port = 1; \ - sendEvent(evt); \ - } + if((NEWSTATE & BUTTON) && !(OLDSTATE & BUTTON)) { \ + Event evt(Event::EvtBtnPress); \ + evt.dev = NDSjs; \ + evt.btn = EVENT; \ + evt.port = 1; \ + sendEvent(evt); \ + } \ + if(!(NEWSTATE & BUTTON) && (OLDSTATE & BUTTON)) { \ + Event evt(Event::EvtBtnRelease); \ + evt.dev = NDSjs; \ + evt.btn = EVENT; \ + evt.port = 1; \ + sendEvent(evt); \ + } #define CONTROLLER_KEY_MAP(OLDSTATE, NEWSTATE, BUTTON, EVENT) \ - if((NEWSTATE & BUTTON) && !(OLDSTATE & BUTTON)) { \ - Event evtPress(Event::EvtKeypress); \ - evtPress.key = EVENT; \ - evtPress.port = 1; \ - sendEvent(evtPress); \ - \ - Event evt(Event::EvtKeyDown); \ - evt.key = EVENT; \ - evt.port = 1; \ - sendEvent(evt); \ - } \ - if(!(NEWSTATE & BUTTON) && (OLDSTATE & BUTTON)) { \ - Event evt(Event::EvtKeyUp); \ - evt.key = EVENT; \ - evt.port = 1; \ - sendEvent(evt); \ - } + if((NEWSTATE & BUTTON) && !(OLDSTATE & BUTTON)) { \ + Event evtPress(Event::EvtKeypress); \ + evtPress.dev = NDSjs; \ + evtPress.key = EVENT; \ + evtPress.port = 1; \ + sendEvent(evtPress); \ + \ + Event evt(Event::EvtKeyDown); \ + evt.dev = NDSjs; \ + evt.key = EVENT; \ + evt.port = 1; \ + sendEvent(evt); \ + } \ + if(!(NEWSTATE & BUTTON) && (OLDSTATE & BUTTON)) { \ + Event evt(Event::EvtKeyUp); \ + evt.dev = NDSjs; \ + evt.key = EVENT; \ + evt.port = 1; \ + sendEvent(evt); \ + } void TikiVBlank(void) { static u32 oldkeys = 0; + static u16 mouseX = 0, mouseY = 0; + touchPosition tp; scanKeys(); u32 keys = keysHeld(); @@ -66,6 +96,26 @@ CONTROLLER_KEY_MAP(oldkeys, keys, KEY_A, 32); CONTROLLER_KEY_MAP(oldkeys, keys, KEY_B, Event::KeyEsc); + //Touchscreen + if(keys & KEY_TOUCH) { + tp = touchReadXY(); + Event evt(Event::EvtBtnPress); + evt.dev = NDSmouse; + evt.btn = Event::MouseLeftBtn; + evt.port = 1; + evt.x = mouseX = tp.px; + evt.y = mouseY = tp.py; + sendEvent(evt); + } else if(oldkeys & KEY_TOUCH) { + Event evt(Event::EvtBtnRelease); + evt.dev = NDSmouse; + evt.btn = Event::MouseLeftBtn; + evt.port = 1; + evt.x = mouseX; + evt.y = mouseY; + sendEvent(evt); + } + oldkeys = keys; Wifi_Timer(50); __timecounter += 15000; @@ -74,6 +124,8 @@ bool platInit() { irqSet(IRQ_VCOUNT,&TikiVBlank); irqEnable(IRQ_VBLANK | IRQ_VCOUNT); + NDSjs = new JsDevice; + NDSmouse = new MouseDevice; return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <c99...@us...> - 2007-07-28 06:27:23
|
Revision: 427 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=427&view=rev Author: c99koder Date: 2007-07-27 23:27:21 -0700 (Fri, 27 Jul 2007) Log Message: ----------- NDS: Enable optimizations, wifi, and use an interrupt for a higher-resolution Tiki::gettime() Modified Paths: -------------- tiki/nds/Makefile.rules tiki/nds/arm7_template/source/arm7main.c tiki/nds/src/audio/stream.cpp tiki/nds/src/init_shutdown.cpp tiki/nds/src/plathid.cpp tiki/nds/src/tikitime.cpp Modified: tiki/nds/Makefile.rules =================================================================== --- tiki/nds/Makefile.rules 2007-07-22 22:22:43 UTC (rev 426) +++ tiki/nds/Makefile.rules 2007-07-28 06:27:21 UTC (rev 427) @@ -12,7 +12,7 @@ $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitARM) endif -TIKI_BASE_LIBS=-ltiki -L$(DEVKITPRO)/libnds/lib -lfat -lnds9 +TIKI_BASE_LIBS=-ltiki -L$(DEVKITPRO)/libnds/lib -ldswifi9 -lfat -lnds9 CXXFLAGS=-I$(DEVKITPRO)/libnds/include @@ -25,7 +25,7 @@ CXXFLAGS+=-I$(TIKI_DIR)/3rdparty/libvorbis/include CXXFLAGS+=-I$(TIKI_DIR)/3rdparty/libvorbis/lib CXXFLAGS+=-DARM9 -CXXFLAGS+=-march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -mthumb -mthumb-interwork +CXXFLAGS+=-march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -mthumb -mthumb-interwork -O2 CFLAGS=$(CXXFLAGS) CXXFLAGS+=-fno-rtti Modified: tiki/nds/arm7_template/source/arm7main.c =================================================================== --- tiki/nds/arm7_template/source/arm7main.c 2007-07-22 22:22:43 UTC (rev 426) +++ tiki/nds/arm7_template/source/arm7main.c 2007-07-28 06:27:21 UTC (rev 427) @@ -9,6 +9,7 @@ #include <nds.h> #include <stdlib.h> +#include <dswifi7.h> #include "dssoundstream.h" //--------------------------------------------------------------------------------- @@ -138,20 +139,26 @@ } } } - + Wifi_Update(); } void FiFoHandler(void) //--------------------------------------------------------------------------------- { while ( !(REG_IPC_FIFO_CR & (IPC_FIFO_RECV_EMPTY)) ) { + Wifi_Sync(); SoundFifoHandler(); } } + +void arm7_synctoarm9() { // send fifo message +} + //--------------------------------------------------------------------------------- int main(int argc, char ** argv) { //--------------------------------------------------------------------------------- - + u32 fifo_temp; + // Reset the clock if needed rtcReset(); @@ -159,16 +166,33 @@ powerON(POWER_SOUND); SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F); IPC->soundData = 0; + IPC->mailBusy = 0; irqInit(); irqSet(IRQ_VBLANK, VblankHandler); SetYtrigger(80); vcount = 80; irqSet(IRQ_VCOUNT, VcountHandler); - REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR | IPC_FIFO_RECV_IRQ; - irqSet(IRQ_FIFO_NOT_EMPTY, FiFoHandler); - irqEnable(IRQ_VBLANK | IRQ_VCOUNT|IRQ_FIFO_NOT_EMPTY); + REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; + irqEnable(IRQ_VBLANK | IRQ_VCOUNT); + irqSet(IRQ_WIFI, Wifi_Interrupt); + irqEnable(IRQ_WIFI); + + // trade some mail, to get a pointer from arm9 + while(1) { + while(REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY) swiWaitForVBlank(); + fifo_temp=REG_IPC_FIFO_RX; + if(fifo_temp==0x12345678) break; + } + while(REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY) swiWaitForVBlank(); + fifo_temp=REG_IPC_FIFO_RX; + Wifi_Init(fifo_temp); + irqSet(IRQ_FIFO_NOT_EMPTY,FiFoHandler); + irqEnable(IRQ_FIFO_NOT_EMPTY); + REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ; + + Wifi_SetSyncHandler(arm7_synctoarm9); SoundSetTimer(0); // Keep the ARM7 idle Modified: tiki/nds/src/audio/stream.cpp =================================================================== --- tiki/nds/src/audio/stream.cpp 2007-07-22 22:22:43 UTC (rev 426) +++ tiki/nds/src/audio/stream.cpp 2007-07-28 06:27:21 UTC (rev 427) @@ -14,6 +14,7 @@ #include <string.h> #include <nds.h> +#include <dswifi9.h> #include "dssoundstream.h" using namespace Tiki::Audio; @@ -86,6 +87,7 @@ break; } } + Wifi_Sync(); } void SendCommandToArm7(u32 command) Modified: tiki/nds/src/init_shutdown.cpp =================================================================== --- tiki/nds/src/init_shutdown.cpp 2007-07-22 22:22:43 UTC (rev 426) +++ tiki/nds/src/init_shutdown.cpp 2007-07-28 06:27:21 UTC (rev 427) @@ -15,7 +15,13 @@ #include <nds.h> #include <fat.h> +#include <dswifi9.h> +// notification function to send fifo message to arm7 +void arm9_synctoarm7() { // send fifo message + //This is a NO-OP because the sound streaming code will constantly communicate with the ARM7 over the FIFO anyway +} + namespace Tiki { bool init(int argc, char **argv) { @@ -37,9 +43,30 @@ fatInitDefault(); // initialize parallax - GL::Plxcompat::plx_mat3d_init(640, 480); + GL::Plxcompat::plx_mat3d_init(256, 192); Audio::Stream::initGlobal(); - return Hid::init(); + Hid::init(); + + { // send fifo message to initialize the arm7 wifi + REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; // enable & clear FIFO + + u32 Wifi_pass= Wifi_Init(WIFIINIT_OPTION_USELED); + REG_IPC_FIFO_TX=0x12345678; + REG_IPC_FIFO_TX=Wifi_pass; + + irqEnable(IRQ_FIFO_NOT_EMPTY); + + REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ; // enable FIFO IRQ + + Wifi_SetSyncHandler(arm9_synctoarm7); // tell wifi lib to use our handler to notify arm7 + + while(Wifi_CheckInit()==0) { // wait for arm7 to be initted successfully + swiWaitForVBlank(); + } + + } // wifi init complete - wifi lib can now be used! + + return true; } void shutdown() { Modified: tiki/nds/src/plathid.cpp =================================================================== --- tiki/nds/src/plathid.cpp 2007-07-22 22:22:43 UTC (rev 426) +++ tiki/nds/src/plathid.cpp 2007-07-28 06:27:21 UTC (rev 427) @@ -1,7 +1,10 @@ #include "pch.h" #include "Tiki/glhdrs.h" #include "Tiki/hid.h" +#include <dswifi9.h> +volatile uint64 __timecounter = 0; + namespace Tiki { namespace Hid { #define CONTROLLER_BUTTON_MAP(OLDSTATE, NEWSTATE, BUTTON, EVENT) \ @@ -64,11 +67,13 @@ CONTROLLER_KEY_MAP(oldkeys, keys, KEY_B, Event::KeyEsc); oldkeys = keys; + Wifi_Timer(50); + __timecounter += 15000; } bool platInit() { - irqSet(IRQ_VBLANK,&TikiVBlank); - irqEnable(IRQ_VBLANK); + irqSet(IRQ_VCOUNT,&TikiVBlank); + irqEnable(IRQ_VBLANK | IRQ_VCOUNT); return true; } Modified: tiki/nds/src/tikitime.cpp =================================================================== --- tiki/nds/src/tikitime.cpp 2007-07-22 22:22:43 UTC (rev 426) +++ tiki/nds/src/tikitime.cpp 2007-07-28 06:27:21 UTC (rev 427) @@ -13,16 +13,12 @@ #include <unistd.h> #include <nds.h> +extern volatile uint64 __timecounter; + namespace Tiki { namespace Time { uint64 gettime() { - timeval tv; - gettimeofday(&tv, NULL); - - uint64 rv = tv.tv_sec; rv *= 1000000; - rv += tv.tv_usec; - - return rv; + return __timecounter; } void sleep(uint64 us) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <c99...@us...> - 2007-07-22 22:22:44
|
Revision: 426 http://svn.sourceforge.net/cadcdev/?rev=426&view=rev Author: c99koder Date: 2007-07-22 15:22:43 -0700 (Sun, 22 Jul 2007) Log Message: ----------- Tiki: NDS: Fix a typo Modified Paths: -------------- tiki/nds/src/audio/stream.cpp Modified: tiki/nds/src/audio/stream.cpp =================================================================== --- tiki/nds/src/audio/stream.cpp 2007-07-21 17:52:01 UTC (rev 425) +++ tiki/nds/src/audio/stream.cpp 2007-07-22 22:22:43 UTC (rev 426) @@ -14,7 +14,7 @@ #include <string.h> #include <nds.h> -#include "soundcommon.h" +#include "dssoundstream.h" using namespace Tiki::Audio; using namespace Tiki::Thread; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <c99...@us...> - 2007-07-21 17:52:07
|
Revision: 425 http://svn.sourceforge.net/cadcdev/?rev=425&view=rev Author: c99koder Date: 2007-07-21 10:52:01 -0700 (Sat, 21 Jul 2007) Log Message: ----------- NDS: arm7/arm9 streaming code (mono only) Modified Paths: -------------- tiki/nds/Makefile.rules tiki/nds/src/audio/stream.cpp tiki/nds/src/init_shutdown.cpp tiki/nds/src/platgl.cpp Added Paths: ----------- tiki/nds/arm7_template/ tiki/nds/arm7_template/Makefile tiki/nds/arm7_template/source/ tiki/nds/arm7_template/source/arm7main.c tiki/nds/arm7_template/source/dssoundstream.h tiki/nds/arm7_template/source/sound7.c Modified: tiki/nds/Makefile.rules =================================================================== --- tiki/nds/Makefile.rules 2007-07-18 23:45:51 UTC (rev 424) +++ tiki/nds/Makefile.rules 2007-07-21 17:52:01 UTC (rev 425) @@ -27,7 +27,7 @@ CXXFLAGS+=-DARM9 CXXFLAGS+=-march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -mthumb -mthumb-interwork CFLAGS=$(CXXFLAGS) -CXXFLAGS+=-fno-rtti -fno-exceptions +CXXFLAGS+=-fno-rtti LDFLAGS=-specs=ds_arm9.specs -mthumb -mthumb-interwork -mno-fpu -L$(DEVKITPRO)/lib -lgcc Added: tiki/nds/arm7_template/Makefile =================================================================== --- tiki/nds/arm7_template/Makefile (rev 0) +++ tiki/nds/arm7_template/Makefile 2007-07-21 17:52:01 UTC (rev 425) @@ -0,0 +1,138 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM) +endif + +include $(DEVKITARM)/ds_rules + +#--------------------------------------------------------------------------------- +# BUILD is the directory where object files & intermediate files will be placed +# SOURCES is a list of directories containing source code +# INCLUDES is a list of directories containing extra header files +# DATA is a list of directories containing binary files +# all directories are relative to this makefile +#--------------------------------------------------------------------------------- +BUILD := build +SOURCES := source +INCLUDES := include build +DATA := +TARGET := tikiarm7 + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -mthumb-interwork + +CFLAGS := -g -Wall -O2\ + -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer\ + -ffast-math \ + $(ARCH) + +CFLAGS += $(INCLUDE) -DARM7 +CXXFLAGS := $(CFLAGS) + + +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=ds_arm7.specs -g $(ARCH) -mno-fpu -Wl,-Map,$(notdir $*).map + +LIBS := -lnds7 + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBNDS) + + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export ARM7BIN := $(TOPDIR)/$(TARGET).arm7 +export ARM7ELF := $(CURDIR)/$(TARGET).arm7.elf +export DEPSDIR := $(CURDIR)/$(BUILD) + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) + +export CC := $(PREFIX)gcc +export CXX := $(PREFIX)g++ +export AR := $(PREFIX)ar +export OBJCOPY := $(PREFIX)objcopy + +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) + +export OFILES := $(addsuffix .o,$(BINFILES)) \ + $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) + +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) +#--------------------------------------------------------------------------------- + export LD := $(CC) +#--------------------------------------------------------------------------------- +else +#--------------------------------------------------------------------------------- + export LD := $(CXX) +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) *.elf + + +#--------------------------------------------------------------------------------- +else + +DEPENDS := $(OFILES:.o=.d) + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(ARM7BIN) : $(ARM7ELF) + @$(OBJCOPY) -O binary $< $@ + @echo built ... $(notdir $@) + + +$(ARM7ELF) : $(OFILES) + @echo linking $(notdir $@) + @$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@ + + +#--------------------------------------------------------------------------------- +# you need a rule like this for each extension you use as binary data +#--------------------------------------------------------------------------------- +%.bin.o : %.bin +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) + +-include $(DEPENDS) + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- Property changes on: tiki/nds/arm7_template/Makefile ___________________________________________________________________ Name: svn:eol-style + native Added: tiki/nds/arm7_template/source/arm7main.c =================================================================== --- tiki/nds/arm7_template/source/arm7main.c (rev 0) +++ tiki/nds/arm7_template/source/arm7main.c 2007-07-21 17:52:01 UTC (rev 425) @@ -0,0 +1,180 @@ +/* + Tiki + + arm7main.c + + Based on the libnds arm7 template and the ARM9/ARM7 streaming code from + http://forum.gbadev.org/viewtopic.php?t=10739 +*/ + +#include <nds.h> +#include <stdlib.h> +#include "dssoundstream.h" + +//--------------------------------------------------------------------------------- +void startSound(int sampleRate, const void* data, u32 bytes, u8 channel, u8 vol, u8 pan, u8 format) { +//--------------------------------------------------------------------------------- + SCHANNEL_TIMER(channel) = SOUND_FREQ(sampleRate); + SCHANNEL_SOURCE(channel) = (u32)data; + SCHANNEL_LENGTH(channel) = bytes >> 2 ; + SCHANNEL_CR(channel) = SCHANNEL_ENABLE | SOUND_ONE_SHOT | SOUND_VOL(vol) | SOUND_PAN(pan) | (format==1?SOUND_8BIT:SOUND_16BIT); +} + + +//--------------------------------------------------------------------------------- +s32 getFreeSoundChannel() { +//--------------------------------------------------------------------------------- + int i; + for (i=0; i<16; i++) { + if ( (SCHANNEL_CR(i) & SCHANNEL_ENABLE) == 0 ) return i; + } + return -1; +} + +int vcount; +touchPosition first,tempPos; + +//--------------------------------------------------------------------------------- +void VcountHandler() { +//--------------------------------------------------------------------------------- + static int lastbut = -1; + + uint16 but=0, x=0, y=0, xpx=0, ypx=0, z1=0, z2=0; + + but = REG_KEYXY; + + // Check if the lid has been closed. + if(but & BIT(7)) { + // Save the current interrupt sate. + u32 ie_save = REG_IE; + // Turn the speaker down. + swiChangeSoundBias(0,0x400); + // Save current power state. + int power = readPowerManagement(PM_CONTROL_REG); + // Set sleep LED. + writePowerManagement(PM_CONTROL_REG, PM_LED_CONTROL(1)); + // Register for the lid interrupt. + REG_IE = IRQ_LID; + + // Power down till we get our interrupt. + swiSleep(); //waits for PM (lid open) interrupt + + REG_IF = ~0; + // Restore the interrupt state. + REG_IE = ie_save; + // Restore power state. + writePowerManagement(PM_CONTROL_REG, power); + + // Turn the speaker up. + swiChangeSoundBias(1,0x400); + } + + if (!( (but ^ lastbut) & (1<<6))) { + + tempPos = touchReadXY(); + + if ( tempPos.x == 0 || tempPos.y == 0 ) { + but |= (1 <<6); + lastbut = but; + } else { + x = tempPos.x; + y = tempPos.y; + xpx = tempPos.px; + ypx = tempPos.py; + z1 = tempPos.z1; + z2 = tempPos.z2; + } + + } else { + lastbut = but; + but |= (1 <<6); + } + + if ( vcount == 80 ) { + first = tempPos; + } else { + if ( abs( xpx - first.px) > 10 || abs( ypx - first.py) > 10 || + (but & ( 1<<6)) ) { + + but |= (1 <<6); + lastbut = but; + + } else { + IPC->mailBusy = 1; + IPC->touchX = x; + IPC->touchY = y; + IPC->touchXpx = xpx; + IPC->touchYpx = ypx; + IPC->touchZ1 = z1; + IPC->touchZ2 = z2; + IPC->mailBusy = 0; + } + } + IPC->buttons = but; + vcount ^= (80 ^ 130); + SetYtrigger(vcount); + +} + +//--------------------------------------------------------------------------------- +void VblankHandler(void) { +//--------------------------------------------------------------------------------- + + u32 i; + + SoundVBlankIrq(); + + //sound code :) + TransferSound *snd = IPC->soundData; + IPC->soundData = 0; + + if (0 != snd) { + + for (i=0; i<snd->count; i++) { + s32 chan = getFreeSoundChannel(); + + if (chan >= 0) { + startSound(snd->data[i].rate, snd->data[i].data, snd->data[i].len, chan, snd->data[i].vol, snd->data[i].pan, snd->data[i].format); + } + } + } + +} +void FiFoHandler(void) +//--------------------------------------------------------------------------------- +{ + while ( !(REG_IPC_FIFO_CR & (IPC_FIFO_RECV_EMPTY)) ) + { + SoundFifoHandler(); + } +} +//--------------------------------------------------------------------------------- +int main(int argc, char ** argv) { +//--------------------------------------------------------------------------------- + + // Reset the clock if needed + rtcReset(); + + //enable sound + powerON(POWER_SOUND); + SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F); + IPC->soundData = 0; + + irqInit(); + irqSet(IRQ_VBLANK, VblankHandler); + SetYtrigger(80); + vcount = 80; + irqSet(IRQ_VCOUNT, VcountHandler); + REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR | IPC_FIFO_RECV_IRQ; + irqSet(IRQ_FIFO_NOT_EMPTY, FiFoHandler); + irqEnable(IRQ_VBLANK | IRQ_VCOUNT|IRQ_FIFO_NOT_EMPTY); + + SoundSetTimer(0); + + // Keep the ARM7 idle + while (1){ + swiWaitForVBlank(); + } +} + + Property changes on: tiki/nds/arm7_template/source/arm7main.c ___________________________________________________________________ Name: svn:eol-style + native Added: tiki/nds/arm7_template/source/dssoundstream.h =================================================================== --- tiki/nds/arm7_template/source/dssoundstream.h (rev 0) +++ tiki/nds/arm7_template/source/dssoundstream.h 2007-07-21 17:52:01 UTC (rev 425) @@ -0,0 +1,66 @@ +/* + Tiki + + dssoundstream.h + + based on the ARM9/ARM7 streaming code from + http://forum.gbadev.org/viewtopic.php?t=10739 +*/ + +#ifndef __NDSSOUND_H +#define __NDSSOUND_H + +#include <nds.h> + +#define CLOCK (1 << 25) + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum +{ + NONE = 0, + INIT = 1, + MIX = 2, + MIXING = 4, + STOP = 8 +}CommandType; + +typedef enum +{ + FIFO_NONE = 0, + UPDATEON_ARM9 = 1, + MIXCOMPLETE_ONARM9 = 2 +}FifoType; + +typedef struct +{ + s8 *mixbuffer; + u32 rate; + u32 buffersize; + u32 cmd; + u8 channel,format; + u32 soundcursor,numsamples; + s32 prevtimer; + s16 period; +}S_SoundSystem; + +#define soundsystem ((S_SoundSystem*)((u32)(IPC)+sizeof(TransferRegion))) + +#ifdef ARM9 +extern void SoundSystemInit(u32 rate,u32 buffersize,u8 channel,u8 format); +extern void SoundStartMixer(void); +extern void SendCommandToArm7(u32 command); +#else +extern void SoundVBlankIrq(void); +extern void SoundSwapAndMix(void); +extern void SoundSetTimer(int period); +extern void SoundFifoHandler(void); +extern void SendCommandToArm9(u32 command); +#endif + +#ifdef __cplusplus +} +#endif +#endif Property changes on: tiki/nds/arm7_template/source/dssoundstream.h ___________________________________________________________________ Name: svn:eol-style + native Added: tiki/nds/arm7_template/source/sound7.c =================================================================== --- tiki/nds/arm7_template/source/sound7.c (rev 0) +++ tiki/nds/arm7_template/source/sound7.c 2007-07-21 17:52:01 UTC (rev 425) @@ -0,0 +1,123 @@ +/* + Tiki + + sound7.c + + Based on the ARM9/ARM7 streaming code from + http://forum.gbadev.org/viewtopic.php?t=10739 +*/ + +#include <nds.h> +#include <arm7/serial.h> +#include "dssoundstream.h" + +void SoundVBlankIrq(void) +{ + //REG_IME = 0; + int channel,i; + + if(soundsystem->cmd & INIT) + { + SoundSetTimer(soundsystem->period); + soundsystem->cmd &= ~INIT; + } + else if(soundsystem->cmd & MIXING) + { + SoundSwapAndMix(); + } + if(soundsystem->cmd & MIX) + { + channel = soundsystem->channel; + + if(soundsystem->format == 8) + { + SCHANNEL_CR(0) = 0; + SCHANNEL_TIMER(0) = 0x10000 - soundsystem->period; + SCHANNEL_SOURCE(0) = (u32)soundsystem->mixbuffer; + SCHANNEL_REPEAT_POINT(0) = 0; + SCHANNEL_LENGTH(0) = soundsystem->buffersize >> 2; + SCHANNEL_CR(0) = SCHANNEL_ENABLE | SOUND_REPEAT | SOUND_VOL(127) | SOUND_PAN(64) | SOUND_8BIT; + } + if(soundsystem->format == 16) + { + SCHANNEL_CR(0) = 0; + SCHANNEL_TIMER(0) = 0x10000 - soundsystem->period; + SCHANNEL_SOURCE(0) = (u32)soundsystem->mixbuffer; + SCHANNEL_REPEAT_POINT(0) = 0; + SCHANNEL_LENGTH(0) = soundsystem->buffersize >> 2; + SCHANNEL_CR(0) = SCHANNEL_ENABLE | SOUND_REPEAT | SOUND_VOL(127) | SOUND_PAN(64) | SOUND_16BIT; + } + + soundsystem->cmd &= ~MIX; + soundsystem->cmd |= MIXING; + } + //REG_IME = 1; +} +void SoundSetTimer(int period) +{ + if(!period) + { + TIMER0_DATA = 0; + TIMER0_CR = 0; + TIMER1_DATA = 0; + TIMER1_CR = 0; + } + else + { + TIMER0_DATA = 0x10000 - (period * 2); + TIMER0_CR = TIMER_ENABLE | TIMER_DIV_1; + + TIMER1_DATA = 0; + TIMER1_CR = TIMER_ENABLE | TIMER_CASCADE | TIMER_DIV_1; + } +} + +void SoundSwapAndMix(void) +{ + s32 curtimer,numsamples,remaining,tries; + + curtimer = TIMER1_DATA; + + numsamples = curtimer - soundsystem->prevtimer; + + if(numsamples < 0) numsamples += 65536; + + soundsystem->prevtimer = curtimer; + soundsystem->numsamples = numsamples; + + SendCommandToArm9(UPDATEON_ARM9); +} +void SoundFifoHandler(void) +{ + u32 command; + + if (!(REG_IPC_FIFO_CR & IPC_FIFO_RECV_EMPTY)) + { + command = REG_IPC_FIFO_RX; + + switch(command) + { + case FIFO_NONE: + break; + case MIXCOMPLETE_ONARM9: + //REG_IME = 0; + soundsystem->soundcursor += soundsystem->numsamples; + if(soundsystem->format == 8) + while (soundsystem->soundcursor > soundsystem->buffersize) soundsystem->soundcursor -= soundsystem->buffersize; + else + while (soundsystem->soundcursor > (soundsystem->buffersize >> 1)) soundsystem->soundcursor -= (soundsystem->buffersize >> 1); + //REG_IME = 1; + break; + } + } +} +void SendCommandToArm9(u32 command) +{ + while (REG_IPC_FIFO_CR & IPC_FIFO_SEND_FULL); + if (REG_IPC_FIFO_CR & IPC_FIFO_ERROR) + { + REG_IPC_FIFO_CR |= IPC_FIFO_SEND_CLEAR; + } + + REG_IPC_FIFO_TX = command; +} Property changes on: tiki/nds/arm7_template/source/sound7.c ___________________________________________________________________ Name: svn:eol-style + native Modified: tiki/nds/src/audio/stream.cpp =================================================================== --- tiki/nds/src/audio/stream.cpp 2007-07-18 23:45:51 UTC (rev 424) +++ tiki/nds/src/audio/stream.cpp 2007-07-21 17:52:01 UTC (rev 425) @@ -4,13 +4,18 @@ stream.cpp Copyright (C)2005 Cryptic Allusion, LLC + + Portions based on the ARM9/ARM7 streaming code from + http://forum.gbadev.org/viewtopic.php?t=10739 */ #include "pch.h" #include "Tiki/stream.h" - #include <string.h> +#include <nds.h> +#include "soundcommon.h" + using namespace Tiki::Audio; using namespace Tiki::Thread; @@ -20,8 +25,85 @@ TIKI_OBJECT_RECEIVER("stop", Stream::objectStop) TIKI_OBJECT_END(Stream) +std::list<Stream *> streams; +void MixTikiStream(Stream *s, void *stream,u32 len) +{ + int samples = len; + memset(stream,0,len); + if(s->isPlaying()) { + if(s->getData((uint16*)stream,&samples) != Stream::GDSuccess) { + s->stop(); + } + } +} + +void TikiStreamFiFoHandler(void) +{ + u32 command,remain; + std::list<Stream *>::iterator streams_iter; + + while ( !(REG_IPC_FIFO_CR & (IPC_FIFO_RECV_EMPTY)) ) + { + command = REG_IPC_FIFO_RX; + + switch(command) + { + case FIFO_NONE: + break; + case UPDATEON_ARM9: + REG_IME = 0; + for(streams_iter = streams.begin(); streams_iter != streams.end(); streams_iter++) { + if(soundsystem->format == 8) + { + if((soundsystem->soundcursor + soundsystem->numsamples) > soundsystem->buffersize) + { + MixTikiStream((*streams_iter),&soundsystem->mixbuffer[soundsystem->soundcursor],soundsystem->buffersize - soundsystem->soundcursor); + remain = soundsystem->numsamples - (soundsystem->buffersize - soundsystem->soundcursor); + MixTikiStream((*streams_iter),soundsystem->mixbuffer,remain); + } + else + { + MixTikiStream((*streams_iter),&soundsystem->mixbuffer[soundsystem->soundcursor],soundsystem->numsamples); + } + } + else + { + if((soundsystem->soundcursor + soundsystem->numsamples) > (soundsystem->buffersize >> 1)) + { + MixTikiStream((*streams_iter),&soundsystem->mixbuffer[soundsystem->soundcursor << 1],(soundsystem->buffersize >> 1) - soundsystem->soundcursor); + remain = soundsystem->numsamples - ((soundsystem->buffersize >> 1) - soundsystem->soundcursor); + MixTikiStream((*streams_iter),soundsystem->mixbuffer,remain); + } + else + { + MixTikiStream((*streams_iter),&soundsystem->mixbuffer[soundsystem->soundcursor << 1],soundsystem->numsamples); + } + } + } + REG_IME = 1; + SendCommandToArm7(MIXCOMPLETE_ONARM9); + break; + } + } +} + +void SendCommandToArm7(u32 command) +{ + while (REG_IPC_FIFO_CR & IPC_FIFO_SEND_FULL); + if (REG_IPC_FIFO_CR & IPC_FIFO_ERROR) + { + REG_IPC_FIFO_CR |= IPC_FIFO_SEND_CLEAR; + } + + REG_IPC_FIFO_TX = command; +} + bool Stream::initGlobal() { + irqSet(IRQ_FIFO_NOT_EMPTY,&TikiStreamFiFoHandler); + irqEnable(IRQ_FIFO_NOT_EMPTY); + + REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR | IPC_FIFO_RECV_IRQ; return true; } @@ -30,18 +112,31 @@ Stream::Stream() { // Default our members. - m_bufSize = 0x4000; + m_bufSize = 16384; m_chnCount = 2; m_freq = 44100; m_queueing = false; m_state = StateStopped; m_volume = 0.8f; + + streams.push_back(this); } Stream::~Stream() { + streams.remove(this); } bool Stream::create() { + soundsystem->rate = m_freq; + soundsystem->buffersize = m_bufSize * sizeof(short); + soundsystem->mixbuffer = (s8*)malloc(soundsystem->buffersize); + soundsystem->format = 16; + soundsystem->channel = 0; + soundsystem->prevtimer = 0; + soundsystem->soundcursor = 0; + soundsystem->numsamples = 0; + soundsystem->period = 0x1000000 / m_freq; + soundsystem->cmd = INIT | MIX; return true; } @@ -79,11 +174,12 @@ } void Stream::pause() { + stop(); m_state = StatePaused; } void Stream::resume() { - m_state = StatePlaying; + start(); } void Stream::setVolume(float vol) { Modified: tiki/nds/src/init_shutdown.cpp =================================================================== --- tiki/nds/src/init_shutdown.cpp 2007-07-18 23:45:51 UTC (rev 424) +++ tiki/nds/src/init_shutdown.cpp 2007-07-21 17:52:01 UTC (rev 425) @@ -19,9 +19,26 @@ namespace Tiki { bool init(int argc, char **argv) { - REG_POWERCNT = POWER_ALL; + // Turn on everything + powerON(POWER_ALL); + + // Setup the Main screen for 3D + videoSetMode(MODE_0_3D); + vramSetBankA(VRAM_A_TEXTURE); + lcdMainOnBottom(); + + // IRQ basic setup irqInit(); + + // initialize the geometry engine + glInit(); + + // initialize libfat fatInitDefault(); + + // initialize parallax + GL::Plxcompat::plx_mat3d_init(640, 480); + Audio::Stream::initGlobal(); return Hid::init(); } Modified: tiki/nds/src/platgl.cpp =================================================================== --- tiki/nds/src/platgl.cpp 2007-07-18 23:45:51 UTC (rev 424) +++ tiki/nds/src/platgl.cpp 2007-07-21 17:52:01 UTC (rev 425) @@ -36,6 +36,8 @@ } void tiki_scene_finish_hook() { + glFlush(0); + swiWaitForVBlank(); } void tiki_scene_begin_opaque_hook() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <at...@us...> - 2007-07-18 23:45:54
|
Revision: 424 http://svn.sourceforge.net/cadcdev/?rev=424&view=rev Author: atani Date: 2007-07-18 16:45:51 -0700 (Wed, 18 Jul 2007) Log Message: ----------- cleanups for dc-chain binutils-2.17 updates Modified Paths: -------------- dcload/dcload-ip/Makefile.cfg dcload/dcload-ip/host-src/tool/Makefile dcload/dcload-ip/host-src/tool/dc-tool.c dcload/dcload-serial/Makefile.cfg dcload/dcload-serial/host-src/tool/Makefile dcload/dcload-serial/host-src/tool/dc-tool.c Modified: dcload/dcload-ip/Makefile.cfg =================================================================== --- dcload/dcload-ip/Makefile.cfg 2007-07-18 23:03:43 UTC (rev 423) +++ dcload/dcload-ip/Makefile.cfg 2007-07-18 23:45:51 UTC (rev 424) @@ -18,7 +18,7 @@ # sh-elf-stuff TARGETCC = sh-elf-gcc -TARGETCFLAGS = -O2 -ml -m4 +TARGETCFLAGS = -O2 -ml -m4-single-only TARGETOBJCOPY = sh-elf-objcopy TARGETLD = sh-elf-ld @@ -34,7 +34,7 @@ #DREAMCAST_IP = 10.0.0.32 # dir to install dc-tool in -TOOLINSTALLDIR = /usr/local/dcdev/bin +TOOLINSTALLDIR = /usr/local/dc/bin #TOOLINSTALLDIR = /usr/local/dc/bin # uncomment this for cygwin Modified: dcload/dcload-ip/host-src/tool/Makefile =================================================================== --- dcload/dcload-ip/host-src/tool/Makefile 2007-07-18 23:03:43 UTC (rev 423) +++ dcload/dcload-ip/host-src/tool/Makefile 2007-07-18 23:45:51 UTC (rev 424) @@ -18,6 +18,7 @@ .PHONY : install install: $(DCTOOL) + -mkdir $(TOOLINSTALLDIR) cp $(DCTOOL) $(TOOLINSTALLDIR) .PHONY : clean Modified: dcload/dcload-ip/host-src/tool/dc-tool.c =================================================================== --- dcload/dcload-ip/host-src/tool/dc-tool.c 2007-07-18 23:03:43 UTC (rev 423) +++ dcload/dcload-ip/host-src/tool/dc-tool.c 2007-07-18 23:45:51 UTC (rev 424) @@ -24,8 +24,8 @@ #include <fcntl.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #ifdef _WIN32 -#include <string.h> #include <windows.h> #include <sys/time.h> #include <unistd.h> @@ -446,13 +446,13 @@ if ((section->flags & SEC_HAS_CONTENTS) && (section->flags & SEC_LOAD)) { printf("Section %s, ",section->name); printf("lma 0x%x, ",section->lma); - printf("size %d\n",section->_raw_size); - if (section->_raw_size) { - size += section->_raw_size; - inbuf = malloc(section->_raw_size); - bfd_get_section_contents(somebfd, section, inbuf, 0, section->_raw_size); + printf("size %d\n",bfd_section_size(somebfd, section)); + if (bfd_section_size(somebfd, section)) { + size += bfd_section_size(somebfd, section); + inbuf = malloc(bfd_section_size(somebfd, section)); + bfd_get_section_contents(somebfd, section, inbuf, 0, bfd_section_size(somebfd, section)); - send_data(inbuf, section->lma, section->_raw_size); + send_data(inbuf, section->lma, bfd_section_size(somebfd, section)); free(inbuf); } Modified: dcload/dcload-serial/Makefile.cfg =================================================================== --- dcload/dcload-serial/Makefile.cfg 2007-07-18 23:03:43 UTC (rev 423) +++ dcload/dcload-serial/Makefile.cfg 2007-07-18 23:45:51 UTC (rev 424) @@ -6,7 +6,7 @@ # dc compiler prefix -- this is usually what you used for --prefix when # building your compiler. -TARGETPREFIX = /usr/local/dcdev/sh-elf +TARGETPREFIX = /usr/local/dc/sh-elf # you may have to change the paths for BFDLIB and BFDINCLUDE to # the correct ones for your system @@ -50,7 +50,7 @@ #SERIALDEVICE = COM1 # dir to install dc-tool in -TOOLINSTALLDIR = /usr/local/dcdev/bin +TOOLINSTALLDIR = /usr/local/dc/bin # uncomment this for cygwin #EXECUTABLEEXTENSION = .exe Modified: dcload/dcload-serial/host-src/tool/Makefile =================================================================== --- dcload/dcload-serial/host-src/tool/Makefile 2007-07-18 23:03:43 UTC (rev 423) +++ dcload/dcload-serial/host-src/tool/Makefile 2007-07-18 23:45:51 UTC (rev 424) @@ -24,6 +24,7 @@ .PHONY : install install: $(DCTOOL) + -mkdir $(TOOLINSTALLDIR) cp $(DCTOOL) $(TOOLINSTALLDIR) .PHONY : clean Modified: dcload/dcload-serial/host-src/tool/dc-tool.c =================================================================== --- dcload/dcload-serial/host-src/tool/dc-tool.c 2007-07-18 23:03:43 UTC (rev 423) +++ dcload/dcload-serial/host-src/tool/dc-tool.c 2007-07-18 23:45:51 UTC (rev 424) @@ -25,8 +25,8 @@ #include <fcntl.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #ifdef _WIN32 -#include <string.h> #include <windows.h> #else #include <termios.h> @@ -337,7 +337,7 @@ ok = 'G'; serial_write(&ok, 1); total -= size; - (unsigned char *) data += size; + data += size; break; case 'C': // compressed if (verbose) { @@ -351,7 +351,7 @@ ok = 'G'; serial_write(&ok, 1); total -= newsize; - (unsigned char *) data += newsize; + data += newsize; } else { ok = 'B'; serial_write(&ok, 1); @@ -705,20 +705,20 @@ if ((section->flags & SEC_HAS_CONTENTS) && (section->flags & SEC_LOAD)) { printf("Section %s, ",section->name); printf("lma 0x%x, ",section->lma); - printf("size %d\n",section->_raw_size); - if (section->_raw_size) { - size += section->_raw_size; - inbuf = malloc(section->_raw_size); - bfd_get_section_contents(somebfd, section, inbuf, 0, section->_raw_size); + printf("size %d\n",bfd_section_size(somebfd, section)); + if (bfd_section_size(somebfd, section)) { + size += bfd_section_size(somebfd, section); + inbuf = malloc(bfd_section_size(somebfd, section)); + bfd_get_section_contents(somebfd, section, inbuf, 0, bfd_section_size(somebfd, section)); c = 'B'; serial_write(&c, 1); blread(&c, 1); send_uint(section->lma); - send_uint(section->_raw_size); + send_uint(bfd_section_size(somebfd, section)); - send_data(inbuf, section->_raw_size, 1); + send_data(inbuf, bfd_section_size(somebfd, section), 1); free(inbuf); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <at...@us...> - 2007-07-18 23:03:47
|
Revision: 423 http://svn.sourceforge.net/cadcdev/?rev=423&view=rev Author: atani Date: 2007-07-18 16:03:43 -0700 (Wed, 18 Jul 2007) Log Message: ----------- use dc-chain style naming as default Modified Paths: -------------- kos/doc/environ.sh.sample Modified: kos/doc/environ.sh.sample =================================================================== --- kos/doc/environ.sh.sample 2007-07-18 23:01:18 UTC (rev 422) +++ kos/doc/environ.sh.sample 2007-07-18 23:03:43 UTC (rev 423) @@ -36,10 +36,10 @@ #export KOS_GENROMFS="genromfs" # Compiler prefixes -export KOS_CC_BASE="/usr/local/dc/dc-elf" -export KOS_CC_PREFIX="dc" -#export KOS_CC_BASE="/usr/local/dc/sh-elf" # DC -#export KOS_CC_PREFIX="sh-elf" +#export KOS_CC_BASE="/usr/local/dc/dc-elf" +#export KOS_CC_PREFIX="dc" +export KOS_CC_BASE="/usr/local/dc/sh-elf" # DC +export KOS_CC_PREFIX="sh-elf" #export KOS_CC_BASE="${EE}" # PS2 #export KOS_CC_PREFIX="ee" #export KOS_CC_BASE="/usr/local/gba/arm-elf" # GBA This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <at...@us...> - 2007-07-18 23:01:21
|
Revision: 422 http://svn.sourceforge.net/cadcdev/?rev=422&view=rev Author: atani Date: 2007-07-18 16:01:18 -0700 (Wed, 18 Jul 2007) Log Message: ----------- binutils version bump to 2.17, this fixes compilation with native gcc 4x Modified Paths: -------------- kos/utils/dc-chain/Makefile kos/utils/dc-chain/download.sh kos/utils/dc-chain/unpack.sh Modified: kos/utils/dc-chain/Makefile =================================================================== --- kos/utils/dc-chain/Makefile 2007-07-18 18:16:53 UTC (rev 421) +++ kos/utils/dc-chain/Makefile 2007-07-18 23:01:18 UTC (rev 422) @@ -23,10 +23,10 @@ sh_prefix := /usr/local/dc/$(sh_target) arm_prefix := /usr/local/dc/$(arm_target) # kos_root: KOS subversion root (contains kos/ and kos-ports/) -kos_root=$(curdir)/../../.. +kos_root=$(CURDIR)/../../.. # kos_base: equivalent of KOS_BASE (contains include/ and kernel/) kos_base=$(kos_root)/kos -binutils_ver=2.15 +binutils_ver=2.17 gcc_ver=3.4.6 newlib_ver=1.12.0 thread_model=posix @@ -46,13 +46,15 @@ all: patch build # ---- patch {{{ +binutils_patches := $(wildcard $(patches)/binutils-$(binutils_ver)*.diff) gcc_patches := $(wildcard $(patches)/gcc-$(gcc_ver)*.diff) newlib_patches := $(wildcard $(patches)/newlib-$(newlib_ver)*.diff) kos_patches := $(wildcard $(patches)/kos-*.diff) -patch_targets=patch-gcc patch-newlib patch-kos +patch_targets=patch-binutils patch-gcc patch-newlib patch-kos patch: $(patch_targets) +patch-binutils: $(binutils_patches) patch-gcc: $(gcc_patches) patch-newlib: $(newlib_patches) patch-kos: $(kos_patches) @@ -60,6 +62,9 @@ $(newlib_patches): cd $(newlib_dir); patch -p1 < $@ +$(binutils_patches): + cd $(binutils_dir); patch -p1 < $@ + $(gcc_patches): cd $(gcc_dir); patch -p1 < $@ @@ -137,12 +142,18 @@ fixup-sh4-newlib: newlib_inc=$(sh_prefix)/$(sh_target)/include fixup-sh4-newlib: @echo "+++ Fixing up sh4 newlib includes..." - cp $(kos_base)/include/pthread.h $(newlib_inc) # KOS pthread.h is modified - cp $(kos_base)/include/sys/_pthread.h $(newlib_inc)/sys # to define _POSIX_THREADS - cp $(kos_base)/include/sys/sched.h $(newlib_inc)/sys # pthreads to kthreads mapping - ln -nsf $(kos_base)/include/kos $(newlib_inc) # so KOS includes are available as kos/file.h - ln -nsf $(kos_base)/kernel/arch/dreamcast/include/arch $(newlib_inc) # kos/thread.h requires arch/arch.h - ln -nsf $(kos_base)/kernel/arch/dreamcast/include/dc $(newlib_inc) # arch/arch.h requires dc/video.h +# KOS pthread.h is modified +# to define _POSIX_THREADS +# pthreads to kthreads mapping +# so KOS includes are available as kos/file.h +# kos/thread.h requires arch/arch.h +# arch/arch.h requires dc/video.h + cp $(kos_base)/include/pthread.h $(newlib_inc) + cp $(kos_base)/include/sys/_pthread.h $(newlib_inc)/sys + cp $(kos_base)/include/sys/sched.h $(newlib_inc)/sys + ln -nsf $(kos_base)/include/kos $(newlib_inc) + ln -nsf $(kos_base)/kernel/arch/dreamcast/include/arch $(newlib_inc) + ln -nsf $(kos_base)/kernel/arch/dreamcast/include/dc $(newlib_inc) $(build_gcc_pass2): log = $(logdir)/$(build)-pass2.log $(build_gcc_pass2): logdir @@ -194,7 +205,7 @@ # ---- phony targets {{{ .PHONY: $(patch_targets) -.PHONY: $(newlib_patches) $(gcc_patches) $(kos_patches) +.PHONY: $(newlib_patches) $(binutils_patches) $(gcc_patches) $(kos_patches) .PHONY: all build patch build-sh4 build-arm $(build_sh4_targets) $(build_arm_targets) clean .PHONY: build-binutils build-newlib build-gcc-pass1 build-gcc-pass2 fixup-sh4-newlib Modified: kos/utils/dc-chain/download.sh =================================================================== --- kos/utils/dc-chain/download.sh 2007-07-18 18:16:53 UTC (rev 421) +++ kos/utils/dc-chain/download.sh 2007-07-18 23:01:18 UTC (rev 422) @@ -1,5 +1,5 @@ #!/bin/sh -wget -c ftp://ftp.gnu.org/gnu/binutils/binutils-2.15.tar.bz2 || exit 1 +wget -c ftp://ftp.gnu.org/gnu/binutils/binutils-2.17.tar.bz2 || exit 1 wget -c ftp://ftp.gnu.org/gnu/gcc/gcc-3.4.6/gcc-3.4.6.tar.bz2 || exit 1 wget -c ftp://sources.redhat.com/pub/newlib/newlib-1.12.0.tar.gz || exit 1 Modified: kos/utils/dc-chain/unpack.sh =================================================================== --- kos/utils/dc-chain/unpack.sh 2007-07-18 18:16:53 UTC (rev 421) +++ kos/utils/dc-chain/unpack.sh 2007-07-18 23:01:18 UTC (rev 422) @@ -1,7 +1,7 @@ #!/bin/sh -rm -rf binutils-2.15 gcc-3.4.6 newlib-1.12.0 +rm -rf binutils-2.17 gcc-3.4.6 newlib-1.12.0 -tar jxf binutils-2.15.tar.bz2 || exit 1 +tar jxf binutils-2.17.tar.bz2 || exit 1 tar jxf gcc-3.4.6.tar.bz2 || exit 1 tar zxf newlib-1.12.0.tar.gz || exit 1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <at...@us...> - 2007-07-18 18:16:59
|
Revision: 421 http://svn.sourceforge.net/cadcdev/?rev=421&view=rev Author: atani Date: 2007-07-18 11:16:53 -0700 (Wed, 18 Jul 2007) Log Message: ----------- default paths update Modified Paths: -------------- kos/utils/dc-chain/Makefile Modified: kos/utils/dc-chain/Makefile =================================================================== --- kos/utils/dc-chain/Makefile 2007-07-18 18:15:56 UTC (rev 420) +++ kos/utils/dc-chain/Makefile 2007-07-18 18:16:53 UTC (rev 421) @@ -20,10 +20,10 @@ # User configuration sh_target=sh-elf arm_target=arm-elf -sh_prefix := /opt/dc/$(sh_target) -arm_prefix := /opt/dc/$(arm_target) +sh_prefix := /usr/local/dc/$(sh_target) +arm_prefix := /usr/local/dc/$(arm_target) # kos_root: KOS subversion root (contains kos/ and kos-ports/) -kos_root=~/prj/svn +kos_root=$(curdir)/../../.. # kos_base: equivalent of KOS_BASE (contains include/ and kernel/) kos_base=$(kos_root)/kos binutils_ver=2.15 @@ -108,6 +108,7 @@ > $(log) cd $(build); ../$(src_dir)/configure --target=$(target) --prefix=$(prefix) $(to_log) make -C $(build) all install $(to_log) + make -C $(build)/bfd install_libbfd $(to_log) $(clean_up) $(build_gcc_pass1) $(build_gcc_pass2): build = build-gcc-$(target)-$(gcc_ver) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <at...@us...> - 2007-07-18 18:15:59
|
Revision: 420 http://svn.sourceforge.net/cadcdev/?rev=420&view=rev Author: atani Date: 2007-07-18 11:15:56 -0700 (Wed, 18 Jul 2007) Log Message: ----------- glVertex2f patch Modified Paths: -------------- kos-ports/include/GL/gl.h kos-ports/libgl/gldraw.c Modified: kos-ports/include/GL/gl.h =================================================================== --- kos-ports/include/GL/gl.h 2007-07-17 23:29:11 UTC (rev 419) +++ kos-ports/include/GL/gl.h 2007-07-18 18:15:56 UTC (rev 420) @@ -355,6 +355,8 @@ void glEnd(void); +void glVertex2f(GLfloat x, GLfloat y); + void glVertex3f(GLfloat x, GLfloat y, GLfloat z); void glVertex3fv(GLfloat *v); Modified: kos-ports/libgl/gldraw.c =================================================================== --- kos-ports/libgl/gldraw.c 2007-07-17 23:29:11 UTC (rev 419) +++ kos-ports/libgl/gldraw.c 2007-07-18 18:15:56 UTC (rev 420) @@ -541,6 +541,10 @@ {0.0f, 1.0f} }; +void glVertex2f(GLfloat x, GLfloat y) { + glVertex3f(x, y, (GLfloat)0.0f); +} + void glVertex3f(GLfloat x, GLfloat y, GLfloat z) { gl_vbuf[gl_vbuf_top].flags = PVR_CMD_VERTEX; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <c99...@us...> - 2007-07-17 23:29:16
|
Revision: 419 http://svn.sourceforge.net/cadcdev/?rev=419&view=rev Author: c99koder Date: 2007-07-17 16:29:11 -0700 (Tue, 17 Jul 2007) Log Message: ----------- Tiki: SDL: Adjust makefile rules to use CC and CXX variables Modified Paths: -------------- tiki/sdl/Makefile.rules Modified: tiki/sdl/Makefile.rules =================================================================== --- tiki/sdl/Makefile.rules 2007-07-17 23:24:50 UTC (rev 418) +++ tiki/sdl/Makefile.rules 2007-07-17 23:29:11 UTC (rev 419) @@ -1,14 +1,14 @@ %.o: %.c @echo "Compiling $< to $@" - @gcc $(CFLAGS) -c $< -o $@ + @$(CC) $(CFLAGS) -c $< -o $@ %.o: %.cc @echo "Compiling $< to $@" - @g++ $(CFLAGS) $(CXXFLAGS) -c $< -o $@ + @$(CXX) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ %.o: %.cpp @echo "Compiling $< to $@" - @g++ $(CFLAGS) $(CXXFLAGS) -c $< -o $@ + @$(CXX) $(CFLAGS) $(CXXFLAGS) -c $< -o $@ subdirs: $(patsubst %, _dir_%, $(SUBDIRS)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <c99...@us...> - 2007-07-17 23:24:52
|
Revision: 418 http://svn.sourceforge.net/cadcdev/?rev=418&view=rev Author: c99koder Date: 2007-07-17 16:24:50 -0700 (Tue, 17 Jul 2007) Log Message: ----------- Tiki: Move the list of platforms into tiki.h Modified Paths: -------------- tiki/dc/include/Tiki/tikitypes.h tiki/gp2x/include/Tiki/tikitypes.h tiki/include/Tiki/tiki.h tiki/nds/include/Tiki/tikitypes.h tiki/osx/include/Tiki/tikitypes.h tiki/sdl/include/Tiki/tikitypes.h tiki/win32/include/Tiki/tikitypes.h Modified: tiki/dc/include/Tiki/tikitypes.h =================================================================== --- tiki/dc/include/Tiki/tikitypes.h 2007-07-17 23:06:07 UTC (rev 417) +++ tiki/dc/include/Tiki/tikitypes.h 2007-07-17 23:24:50 UTC (rev 418) @@ -16,11 +16,7 @@ #include <dc/sound/stream.h> #include <dc/sound/sfxmgr.h> -// This gets included in the main tiki.h, so it should suffice. -#define TIKI_OSX 0 -#define TIKI_WIN32 1 -#define TIKI_SDL 2 -#define TIKI_DC 3 +//Define our platform #define TIKI_PLAT TIKI_DC namespace Tiki { Modified: tiki/gp2x/include/Tiki/tikitypes.h =================================================================== --- tiki/gp2x/include/Tiki/tikitypes.h 2007-07-17 23:06:07 UTC (rev 417) +++ tiki/gp2x/include/Tiki/tikitypes.h 2007-07-17 23:24:50 UTC (rev 418) @@ -12,12 +12,7 @@ #include <stddef.h> -// This gets included in the main tiki.h, so it should suffice. -#define TIKI_OSX 0 -#define TIKI_WIN32 1 -#define TIKI_SDL 2 -#define TIKI_DC 3 -#define TIKI_GP2X 4 +// Define our platform #define TIKI_PLAT TIKI_GP2X namespace Tiki { Modified: tiki/include/Tiki/tiki.h =================================================================== --- tiki/include/Tiki/tiki.h 2007-07-17 23:06:07 UTC (rev 417) +++ tiki/include/Tiki/tiki.h 2007-07-17 23:24:50 UTC (rev 418) @@ -24,6 +24,14 @@ } } +// Define our supported platforms +#define TIKI_OSX 0 +#define TIKI_WIN32 1 +#define TIKI_SDL 2 +#define TIKI_DC 3 +#define TIKI_GP2X 4 +#define TIKI_NDS 5 + // Bring in our custom types. #include "Tiki/tikitypes.h" Modified: tiki/nds/include/Tiki/tikitypes.h =================================================================== --- tiki/nds/include/Tiki/tikitypes.h 2007-07-17 23:06:07 UTC (rev 417) +++ tiki/nds/include/Tiki/tikitypes.h 2007-07-17 23:24:50 UTC (rev 418) @@ -14,13 +14,7 @@ #include <sys/cdefs.h> #include <nds/jtypes.h> -// This gets included in the main tiki.h, so it should suffice. -#define TIKI_OSX 0 -#define TIKI_WIN32 1 -#define TIKI_SDL 2 -#define TIKI_DC 3 -#define TIKI_GP2X 4 -#define TIKI_NDS 5 +// Define our platform #define TIKI_PLAT TIKI_NDS namespace Tiki { Modified: tiki/osx/include/Tiki/tikitypes.h =================================================================== --- tiki/osx/include/Tiki/tikitypes.h 2007-07-17 23:06:07 UTC (rev 417) +++ tiki/osx/include/Tiki/tikitypes.h 2007-07-17 23:24:50 UTC (rev 418) @@ -12,13 +12,7 @@ #include <stddef.h> -// This gets included in the main tiki.h, so it should suffice. -#define TIKI_OSX 0 -#define TIKI_WIN32 1 -#define TIKI_SDL 2 -#define TIKI_DC 3 -#define TIKI_GP2X 4 -#define TIKI_NDS 5 +// Define our platform #define TIKI_PLAT TIKI_OSX namespace Tiki { Modified: tiki/sdl/include/Tiki/tikitypes.h =================================================================== --- tiki/sdl/include/Tiki/tikitypes.h 2007-07-17 23:06:07 UTC (rev 417) +++ tiki/sdl/include/Tiki/tikitypes.h 2007-07-17 23:24:50 UTC (rev 418) @@ -12,11 +12,7 @@ #include <stddef.h> -// This gets included in the main tiki.h, so it should suffice. -#define TIKI_OSX 0 -#define TIKI_WIN32 1 -#define TIKI_SDL 2 -#define TIKI_DC 3 +// Define our platform #define TIKI_PLAT TIKI_SDL namespace Tiki { Modified: tiki/win32/include/Tiki/tikitypes.h =================================================================== --- tiki/win32/include/Tiki/tikitypes.h 2007-07-17 23:06:07 UTC (rev 417) +++ tiki/win32/include/Tiki/tikitypes.h 2007-07-17 23:24:50 UTC (rev 418) @@ -12,13 +12,7 @@ #include <stddef.h> -// Figure out our platform. -#define TIKI_OSX 0 -#define TIKI_WIN32 1 -#define TIKI_SDL 2 -#define TIKI_DC 3 -#define TIKI_GP2X 4 -#define TIKI_NDS 5 +// Define our platform #define TIKI_PLAT TIKI_WIN32 namespace Tiki { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <c99...@us...> - 2007-07-17 23:06:59
|
Revision: 417 http://svn.sourceforge.net/cadcdev/?rev=417&view=rev Author: c99koder Date: 2007-07-17 16:06:07 -0700 (Tue, 17 Jul 2007) Log Message: ----------- NDS: Link with libfat, initialize libfat and the DS hardware, remove AutoLock calls from Stream class, and handle DS input events during VBlank interrupt Modified Paths: -------------- tiki/nds/Makefile.rules tiki/nds/src/audio/stream.cpp tiki/nds/src/init_shutdown.cpp tiki/nds/src/plathid.cpp tiki/nds/src/tikitime.cpp Modified: tiki/nds/Makefile.rules =================================================================== --- tiki/nds/Makefile.rules 2007-07-08 01:05:36 UTC (rev 416) +++ tiki/nds/Makefile.rules 2007-07-17 23:06:07 UTC (rev 417) @@ -12,7 +12,7 @@ $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitARM) endif -TIKI_BASE_LIBS=-ltiki -L$(DEVKITPRO)/libnds/lib -lnds9 +TIKI_BASE_LIBS=-ltiki -L$(DEVKITPRO)/libnds/lib -lfat -lnds9 CXXFLAGS=-I$(DEVKITPRO)/libnds/include Modified: tiki/nds/src/audio/stream.cpp =================================================================== --- tiki/nds/src/audio/stream.cpp 2007-07-08 01:05:36 UTC (rev 416) +++ tiki/nds/src/audio/stream.cpp 2007-07-17 23:06:07 UTC (rev 417) @@ -36,83 +36,61 @@ m_queueing = false; m_state = StateStopped; m_volume = 0.8f; - m_mutex = new Mutex(); } Stream::~Stream() { - destroy(); } bool Stream::create() { - AutoLock lock(m_mutex); return true; } void Stream::destroy() { - AutoLock lock(m_mutex); } // virtual void filter(int freq, int chncount, void * buffer, int smpcnt) { } void Stream::filterAdd(Filter * f) { - AutoLock lock(m_mutex); - m_filters.insertTail(f); } void Stream::filterRemove(Filter * f) { - AutoLock lock(m_mutex); - m_filters.del(f); } void Stream::setQueueing(bool isQueued) { - AutoLock lock(m_mutex); - m_queueing = isQueued; } void Stream::setFrequency(int freq) { - AutoLock lock(m_mutex); - m_freq = freq; } void Stream::setChannelCount(int chncount) { - AutoLock lock(m_mutex); - m_chnCount = chncount; } void Stream::start() { - AutoLock lock(m_mutex); m_state = StatePlaying; } void Stream::stop() { - AutoLock lock(m_mutex); m_state = StateStopped; } void Stream::pause() { - AutoLock lock(m_mutex); m_state = StatePaused; } void Stream::resume() { - AutoLock lock(m_mutex); m_state = StatePlaying; } void Stream::setVolume(float vol) { - AutoLock lock(m_mutex); - m_volume = vol; } bool Stream::isPlaying() { - AutoLock lock(m_mutex); - return m_state == StatePlaying; } Modified: tiki/nds/src/init_shutdown.cpp =================================================================== --- tiki/nds/src/init_shutdown.cpp 2007-07-08 01:05:36 UTC (rev 416) +++ tiki/nds/src/init_shutdown.cpp 2007-07-17 23:06:07 UTC (rev 417) @@ -13,9 +13,15 @@ #include "Tiki/plxcompat.h" #include "Tiki/hid.h" +#include <nds.h> +#include <fat.h> + namespace Tiki { bool init(int argc, char **argv) { + REG_POWERCNT = POWER_ALL; + irqInit(); + fatInitDefault(); return Hid::init(); } Modified: tiki/nds/src/plathid.cpp =================================================================== --- tiki/nds/src/plathid.cpp 2007-07-08 01:05:36 UTC (rev 416) +++ tiki/nds/src/plathid.cpp 2007-07-17 23:06:07 UTC (rev 417) @@ -4,7 +4,71 @@ namespace Tiki { namespace Hid { +#define CONTROLLER_BUTTON_MAP(OLDSTATE, NEWSTATE, BUTTON, EVENT) \ + if((NEWSTATE & BUTTON) && !(OLDSTATE & BUTTON)) { \ + Event evt(Event::EvtBtnPress); \ + evt.btn = EVENT; \ + evt.port = 1; \ + sendEvent(evt); \ + } \ + if(!(NEWSTATE & BUTTON) && (OLDSTATE & BUTTON)) { \ + Event evt(Event::EvtBtnRelease); \ + evt.btn = EVENT; \ + evt.port = 1; \ + sendEvent(evt); \ + } + +#define CONTROLLER_KEY_MAP(OLDSTATE, NEWSTATE, BUTTON, EVENT) \ + if((NEWSTATE & BUTTON) && !(OLDSTATE & BUTTON)) { \ + Event evtPress(Event::EvtKeypress); \ + evtPress.key = EVENT; \ + evtPress.port = 1; \ + sendEvent(evtPress); \ + \ + Event evt(Event::EvtKeyDown); \ + evt.key = EVENT; \ + evt.port = 1; \ + sendEvent(evt); \ + } \ + if(!(NEWSTATE & BUTTON) && (OLDSTATE & BUTTON)) { \ + Event evt(Event::EvtKeyUp); \ + evt.key = EVENT; \ + evt.port = 1; \ + sendEvent(evt); \ + } + +void TikiVBlank(void) +{ + static u32 oldkeys = 0; + scanKeys(); + u32 keys = keysHeld(); + + //Controller events + CONTROLLER_BUTTON_MAP(oldkeys, keys, KEY_UP, Event::BtnUp); + CONTROLLER_BUTTON_MAP(oldkeys, keys, KEY_DOWN, Event::BtnDown); + CONTROLLER_BUTTON_MAP(oldkeys, keys, KEY_LEFT, Event::BtnLeft); + CONTROLLER_BUTTON_MAP(oldkeys, keys, KEY_RIGHT, Event::BtnRight); + CONTROLLER_BUTTON_MAP(oldkeys, keys, KEY_A, Event::BtnA); + CONTROLLER_BUTTON_MAP(oldkeys, keys, KEY_B, Event::BtnB); + CONTROLLER_BUTTON_MAP(oldkeys, keys, KEY_X, Event::BtnX); + CONTROLLER_BUTTON_MAP(oldkeys, keys, KEY_Y, Event::BtnY); + CONTROLLER_BUTTON_MAP(oldkeys, keys, KEY_START, Event::BtnStart); + + //Keyboard emulation + CONTROLLER_KEY_MAP(oldkeys, keys, KEY_UP, Event::KeyUp); + CONTROLLER_KEY_MAP(oldkeys, keys, KEY_DOWN, Event::KeyDown); + CONTROLLER_KEY_MAP(oldkeys, keys, KEY_LEFT, Event::KeyLeft); + CONTROLLER_KEY_MAP(oldkeys, keys, KEY_RIGHT, Event::KeyRight); + CONTROLLER_KEY_MAP(oldkeys, keys, KEY_START, 13); + CONTROLLER_KEY_MAP(oldkeys, keys, KEY_A, 32); + CONTROLLER_KEY_MAP(oldkeys, keys, KEY_B, Event::KeyEsc); + + oldkeys = keys; +} + bool platInit() { + irqSet(IRQ_VBLANK,&TikiVBlank); + irqEnable(IRQ_VBLANK); return true; } Modified: tiki/nds/src/tikitime.cpp =================================================================== --- tiki/nds/src/tikitime.cpp 2007-07-08 01:05:36 UTC (rev 416) +++ tiki/nds/src/tikitime.cpp 2007-07-17 23:06:07 UTC (rev 417) @@ -11,6 +11,7 @@ #include <sys/time.h> #include <unistd.h> +#include <nds.h> namespace Tiki { namespace Time { @@ -25,17 +26,12 @@ } void sleep(uint64 us) { -// TODO: add this -} + float seconds = (float)us / 1000000.0f; + int blanks = (int)(seconds * 60.0f); + for(int i=0; i < blanks; i++) { + swiWaitForVBlank(); + } } } - - - - - - - - - +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <c99...@us...> - 2007-07-08 01:05:42
|
Revision: 416 http://svn.sourceforge.net/cadcdev/?rev=416&view=rev Author: c99koder Date: 2007-07-07 18:05:36 -0700 (Sat, 07 Jul 2007) Log Message: ----------- Tiki: win32: add missing TIKI_GP2X and TIKI_NDS definitions Modified Paths: -------------- tiki/win32/include/Tiki/tikitypes.h Modified: tiki/win32/include/Tiki/tikitypes.h =================================================================== --- tiki/win32/include/Tiki/tikitypes.h 2007-07-02 16:59:18 UTC (rev 415) +++ tiki/win32/include/Tiki/tikitypes.h 2007-07-08 01:05:36 UTC (rev 416) @@ -17,6 +17,8 @@ #define TIKI_WIN32 1 #define TIKI_SDL 2 #define TIKI_DC 3 +#define TIKI_GP2X 4 +#define TIKI_NDS 5 #define TIKI_PLAT TIKI_WIN32 namespace Tiki { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |