Previous 15994 Revisions Next

r14261 Sunday 29th January, 2012 at 18:25:58 UTC by Miodrag Milanović
Sync with MAME r15230 excluding diimage and softlist changes (no whatsnew)
[src]version.c
[src/emu]audit.c device.c device.h emutempl.h machine.c machine.h mconfig.c memory.c render.h romload.c screen.c tilemap.c tilemap.h validity.c validity.h
[src/emu/cpu/arm7]arm7ops.h
[src/emu/cpu/i386]i386.c i386op16.c i386op32.c i386priv.h i486ops.c x87ops.c
[src/emu/cpu/unsp]unspdasm.c
[src/emu/debug]dvmemory.c
[src/emu/imagedev]floppy.c
[src/emu/machine]6522via.c generic.c im6402.c im6402.h scsihd.c
[src/emu/sound]okim6295.c samples.c
[src/emu/video]pc_vga.c
[src/lib]lib.mak
[src/lib/formats]flopimg.c flopimg.h
[src/lib/libflac/include/flac]format.h metadata.h stream_decoder.h stream_encoder.h
[src/lib/libflac/include/flac++]decoder.h encoder.h metadata.h
[src/lib/libflac/include/private]fixed.h float.h lpc.h window.h
[src/lib/libflac/libflac]bitreader.c bitwriter.c cpu.c fixed.c float.c lpc.c md5.c metadata_iterators.c metadata_object.c stream_decoder.c stream_encoder.c stream_encoder_framing.c
[src/lib/libjpeg]jcapimin.c jcarith.c jccolor.c jcdctmgr.c jchuff.c jcmainct.c jcmarker.c jcmaster.c jcparam.c jctrans.c jdapimin.c jdarith.c jdcoefct.c jdcolor.c jdct.h jddctmgr.c jdhuff.c jdinput.c jdmarker.c jdmaster.c jdmerge.c jdsample.c jerror.c jidctflt.c jidctfst.c jidctint.c jmemmgr.c jpeglib.h jpegtran.c jquant1.c jquant2.c
[src/lib/util]cdrom.h chd.c tagmap.h
[src/mame]mame.lst
[src/mame/drivers]bnstars.c boogwing.c chihiro.c cntsteer.c cps3.c cybertnk.c dassault.c dreamwld.c eolithsp.c gberet.c konamigq.c konamigv.c multfish.c naomi.c nemesis.c neodrvr.c nexus3d.c pluto5.c pntnpuzl.c popobear.c rocnrope.c rohga.c segaorun.c sliver.c taitowlf.c triforce.c twincobr.c
[src/mame/includes]boogwing.h dassault.h metro.h rohga.h
[src/mame/machine]steppers.c
[src/mame/video]boogwing.c dassault.c deco16ic.c decospr.c decospr.h f1gp.c konicdev.c macrossp.c mermaid.c ms32.c namcona1.c namcos2.c ppu2c0x.c ppu2c0x.h psikyo.c punchout.c rohga.c simpl156.c skyraid.c
[src/osd/sdl]sdlmain.c
[src/tools]chdman.c

src/mame/mame.lst
r14260r14261
1125011250fcockt_10      // (c) 2003
1125111251fcockt_11      // (c) 2003
1125211252fcockt_12      // (c) 2003
11253fcockt2_3
11254fcockt2_4
11255fcockt2_4a
11256fcockt2_4b
11257fcockt2_4d
11258fcockt2_4f
11259fcockt2_5
1125311260
1125411261// Lucky Haunter
1125511262//lhaunt      // (c) 2003
r14260r14261
1682716834m1coro21n
1682816835m1coro21np
1682916836m1coro12n
16837m1coro12np
1683016838m1coro11n
1683116839m1coro11np
1683216840m1coro31
src/mame/machine/steppers.c
r14260r14261
6262   STARPOINT_48STEP_REEL,
6363   16,
6464   24,
65   0x09,//Starpoint tech specs say that the only coil pattern guaranteed to line up the opto is this one
65   0x09,//Starpoint tech specs say that the only coil pattern guaranteed to line up the opto is this one
6666   0
6767};
6868
r14260r14261
9090   step[which].index_patt   = intf->index_patt; /* hex value of coil pattern (0 if not needed)*/
9191   step[which].reverse     = intf->reverse;
9292
93   
93
9494   step[which].phase       = 0;
9595   step[which].pattern     = 0;
9696   step[which].old_pattern = 0;
r14260r14261
108108      //Dice reels are 48 step motors, but complete three full cycles between opto updates
109109      step[which].max_steps = ((48*3)*2);
110110      break;
111     
111
112112   }
113113
114114   state_save_register_item(machine, "stepper", NULL, which, step[which].index_start);
r14260r14261
209209   int changed = 0;
210210
211211   /* This code probably makes more sense if you visualise what is being emulated, namely
212   a spinning drum with two electromagnets inside. Essentially, the CPU
213   activates a pair of windings on these magnets leads as necessary to attract and repel the drum to pull it round and
214   display as appropriate. To attempt to visualise the rotation effect, take a look at the compass rose below, representing a side on view of the reel,
215   the numbers indicate the phase information as used
212    a spinning drum with two electromagnets inside. Essentially, the CPU
213    activates a pair of windings on these magnets leads as necessary to attract and repel the drum to pull it round and
214    display as appropriate. To attempt to visualise the rotation effect, take a look at the compass rose below, representing a side on view of the reel,
215    the numbers indicate the phase information as used
216216
217       7
218       N
219   1 W   E 5
220      S
221      3
217        7
218        N
219    1 W   E 5
220        S
221        3
222222
223   For sake of accuracy, we're representing all possible phases of the motor, effectively moving the motor one half step at a time, so a 48 step motor becomes
224   96 half steps. This is necessary because of some programs running the wiring in series with a distinct delay between the pair being completed. This causes
225   a small movement that may trigger the optic tab.
226   */
223    For sake of accuracy, we're representing all possible phases of the motor, effectively moving the motor one half step at a time, so a 48 step motor becomes
224    96 half steps. This is necessary because of some programs running the wiring in series with a distinct delay between the pair being completed. This causes
225    a small movement that may trigger the optic tab.
226    */
227227
228228   int pos,steps=0;
229229   step[which].pattern = pattern;
r14260r14261
288288         break;
289289      }
290290      break;
291                 
291
292292      case BARCREST_48STEP_REEL :
293293      //Standard drive table is 1,3,2,6,4,C,8,9
294294      //this runs through the stator patterns in such a way as to drive the reel forward (downwards from the player's view)
r14260r14261
321321         break;
322322
323323         // The below values should not be used by anything sane, as they effectively ignore one stator side entirely
324            //          Yellow   Black  Orange Brown
324          //          Yellow   Black  Orange Brown
325325         case 0x05://   0       1       0     1
326326         {
327327            if ((step[which].old_phase ==6)||(step[which].old_phase == 0)) // if the previous pattern had the drum in the northern quadrant, it will point north now
r14260r14261
334334            }
335335         }
336336         break;
337           
337
338338         case 0x0A://   1       0       1     0
339339         {
340340            if ((step[which].old_phase ==6)||(step[which].old_phase == 4)) // if the previous pattern had the drum in the eastern quadrant, it will point east now
r14260r14261
347347            }
348348         }
349349         break;
350      }   
350      }
351351      break;
352         
352
353353      case MPU3_48STEP_REEL :
354354      /* The MPU3 interface is actually the same as the MPU4 setup, but with two active lines instead of four
355         Inverters are used so if a pin is low, the higher bit of the pair is activated, and if high the lower bit is activated.
356         TODO:Check this, 2 and 1 could be switched over.
357       */
355           Inverters are used so if a pin is low, the higher bit of the pair is activated, and if high the lower bit is activated.
356           TODO:Check this, 2 and 1 could be switched over.
357         */
358358      switch (pattern)
359359      {
360360      //             Yellow(2)   Black(1)  Orange(!2) Brown(!1)
r14260r14261
375375   }
376376
377377   steps = step[which].old_phase - step[which].phase;
378     
378
379379   if (steps < -4)
380380   {
381381      steps = steps +8;
r14260r14261
384384   {
385385      steps = steps -8;
386386   }
387   
387
388388   step[which].old_phase = step[which].phase;
389389   step[which].old_pattern = step[which].pattern;
390390
src/mame/includes/metro.h
r14260r14261
5454   int         m_has_zoom;
5555   int         m_sprite_xoffs;
5656   int         m_sprite_yoffs;
57   
57
5858   UINT8 *      m_expanded_gfx1;
5959
6060   /* blitter */
src/mame/includes/rohga.h
r14260r14261
4545WRITE16_HANDLER( rohga_buffer_spriteram16_w );
4646
4747VIDEO_START( rohga );
48VIDEO_START( schmeisr );
49VIDEO_START( wizdfire );
4850
51
4952SCREEN_UPDATE_IND16( rohga );
50SCREEN_UPDATE_IND16( schmeisr );
5153SCREEN_UPDATE_RGB32( wizdfire );
5254SCREEN_UPDATE_RGB32( nitrobal );
55
56UINT16 rohga_pri_callback(UINT16 x);
57UINT16 schmeisr_col_callback(UINT16 x);
58UINT16 rohga_col_callback(UINT16 x);
src/mame/includes/dassault.h
r14260r14261
4242
4343/*----------- defined in video/dassault.c -----------*/
4444
45VIDEO_START(dassault);
4546SCREEN_UPDATE_RGB32( dassault );
src/mame/includes/boogwing.h
r14260r14261
4040
4141/*----------- defined in video/boogwing.c -----------*/
4242
43VIDEO_START( boogwing );
4344SCREEN_UPDATE_RGB32( boogwing );
4445
src/mame/video/simpl156.c
r14260r14261
1717   state->m_pf2_rowscroll = auto_alloc_array_clear(machine, UINT16, 0x800/2);
1818   state->m_spriteram = auto_alloc_array_clear(machine, UINT16, 0x2000/2);
1919   machine.generic.paletteram.u16 =  auto_alloc_array_clear(machine, UINT16, 0x1000/2);
20   
20
2121   memset(state->m_spriteram, 0xff, 0x2000);
2222
2323   /* and register the allocated ram so that save states still work */
src/mame/video/punchout.c
r14260r14261
240240
241241      state->m_spr1_tilemap->set_palette_offset(0x100 * palette);
242242
243      state->m_spr1_tilemap->draw_roz(bitmap, cliprect,
243      state->m_spr1_tilemap->draw_roz(bitmap, cliprect,
244244         startx,starty + 0x200*(2) * zoom,
245245         incxx,0,0,incyy,   /* zoom, no rotation */
246246         0,   /* no wraparound */
r14260r14261
288288
289289      _tilemap->set_palette_offset(0x100 * palette);
290290
291      _tilemap->draw_roz(bitmap, cliprect,
291      _tilemap->draw_roz(bitmap, cliprect,
292292         startx,starty + 0x200*(2) * zoom,
293293         incxx,0,0,incyy,   /* zoom, no rotation */
294294         0,   /* no wraparound */
r14260r14261
321321      incxx = 1;
322322
323323   // this tilemap doesn't actually zoom, but draw_roz is the only way to draw it without wraparound
324   state->m_spr2_tilemap->draw_roz(bitmap, cliprect,
324   state->m_spr2_tilemap->draw_roz(bitmap, cliprect,
325325      sx, sy, incxx << 16, 0, 0, 1 << 16,
326326      0, 0, 0);
327327}
src/mame/video/namcona1.c
r14260r14261
621621               int dy = -8; /* vertical adjust */
622622               UINT32 startx = (xoffset<<12)+incxx*dx+incyx*dy;
623623               UINT32 starty = (yoffset<<12)+incxy*dx+incyy*dy;
624               state->m_roz_tilemap->draw_roz(bitmap, clip,
624               state->m_roz_tilemap->draw_roz(bitmap, clip,
625625                  startx, starty, incxx, incxy, incyx, incyy, 0, 0, primask, 0);
626626            }
627627            else
src/mame/video/skyraid.c
r14260r14261
141141
142142   rectangle helper_clip = cliprect;
143143   helper_clip &= state->m_helper.cliprect();
144   
144
145145   draw_terrain(screen.machine(), state->m_helper, helper_clip);
146146   draw_sprites(screen.machine(), state->m_helper, helper_clip);
147147   draw_missiles(screen.machine(), state->m_helper, helper_clip);
src/mame/video/ms32.c
r14260r14261
315315         if (incxx & 0x10000) incxx |= ~0x1ffff;
316316         if (incxy & 0x10000) incxy |= ~0x1ffff;
317317
318         state->m_roz_tilemap->draw_roz(bitmap, my_clip,
318         state->m_roz_tilemap->draw_roz(bitmap, my_clip,
319319               (start2x+startx+offsx)<<16, (start2y+starty+offsy)<<16,
320320               incxx<<8, incxy<<8, 0, 0,
321321               1, // Wrap
r14260r14261
346346      if (incyy & 0x10000) incyy |= ~0x1ffff;
347347      if (incyx & 0x10000) incyx |= ~0x1ffff;
348348
349      state->m_roz_tilemap->draw_roz(bitmap, cliprect,
349      state->m_roz_tilemap->draw_roz(bitmap, cliprect,
350350            (startx+offsx)<<16, (starty+offsy)<<16,
351351            incxx<<8, incxy<<8, incyx<<8, incyy<<8,
352352            1, // Wrap
src/mame/video/mermaid.c
r14260r14261
501501         rect.max_y = sy + screen.machine().gfx[1]->height - 1;
502502
503503         rect &= visarea;
504         
504
505505         // check collision sprite - sprite
506506
507507         state->m_helper.fill(0, rect);
src/mame/video/decospr.c
r14260r14261
11/* Data East Sprite Chip
22   DECO 52
33
4   note, we have pri callbacks and checks to drop back to plain drawgfx because not all drivers are using pdrawgfx yet, they probably should be...
5   some games have different visible areas, but are confirmed as the same sprite chip.
4   This is a flexible implementation of the Data East Spite chip 52 emulation, used in a large number of drivers.
65
7   games with alpha aren't supported here yet, in most cases they need better mixing anyway, probably rendering to screen buffers and manual mixing.
8   see m_sprite_bitmap... (note, if using that you must also use BITMAP_FORMAT_RGB32 in the machine config)
6   Both list formats are supported (how is this selected on HW, external pin?)
97
8   Support for rendering to a raw indexed 16-bitmap is available allowing you to do complex mixing, which is required
9   if a game uses alpha blending at the mixing stage.
10
11   Basic callbacks priority and colour are supported for use with pdrawgfx if render-to-bitmap mode isn't being used.
12
13   There is also a very simply 'drawgfx' path for games where the sprites are only of one priority level.
14
15
1016   used by:
1117
1218   dblewing.c
r14260r14261
2430   cninja.c
2531   lemmings.c
2632   deco32.c
33   rohga.c
34   dassault.c
2735
28   partially converted:
29 
30   difficult to convert:
31   rohga.c - complex video mixing, 6bpp gfx..
32   dassault.c - complex video mixing
36   to convert:
37
3338   boogwing.c - complex video mixing
3439
3540   notes:
3641   does the chip natively support 5bpp (tattass / nslasher) in hw, or is it done with doubled up chips?
3742   the information in deco_tilegen1 lists 3x sprite chips on those games, but there are only 2 spritelists.
3843
44   likewise Rohga appears to have 2x DECO52 for 1 list of 6bpp gfx.
45
3946*/
4047
4148
r14260r14261
116123#include "emu.h"
117124#include "decospr.h"
118125
126UINT16 decospr_default_colour_callback(UINT16 col)
127{
128   return (col >> 9) & 0x1f;
129}
119130
120131void decospr_device::set_gfx_region(device_t &device, int gfxregion)
121132{
r14260r14261
128139{
129140   decospr_device &dev = downcast<decospr_device &>(device);
130141   dev.m_pricallback = callback;
131//  printf("decospr_device::set_pri_callback()\n");
132142}
133143
144void decospr_device::set_col_callback(device_t &device, decospr_colour_callback_func callback)
145{
146   decospr_device &dev = downcast<decospr_device &>(device);
147   dev.m_colcallback = callback;
148}
134149
150
135151const device_type DECO_SPRITE = &device_creator<decospr_device>;
136152
137153decospr_device::decospr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
138154   : device_t(mconfig, DECO_SPRITE, "decospr_device", tag, owner, clock),
139155     m_gfxregion(0),
140     m_pricallback(NULL)
156     m_pricallback(NULL),
157     m_colcallback(decospr_default_colour_callback)
141158{
142159}
143160
r14260r14261
173190   m_pricallback = callback;
174191}
175192
193void decospr_device::set_col_callback(decospr_priority_callback_func callback)
194{
195   m_colcallback = callback;
196}
176197
177198
178199template<class _BitmapClass>
r14260r14261
227248            x = spriteram[offs + 2];
228249
229250            if (!m_sprite_bitmap.valid())
230               colour = (x >> 9) & 0x1f;
251            {
252               colour = m_colcallback(x);
253            }
231254            else
232255            {
233256               colour = (x >> 9) & 0x7f;
src/mame/video/decospr.h
r14260r14261
11
22typedef UINT16 (*decospr_priority_callback_func)(UINT16 pri);
3typedef UINT16 (*decospr_colour_callback_func)(UINT16 col);
34
45class decospr_device : public device_t
56{
r14260r14261
78   decospr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
89   static void set_gfx_region(device_t &device, int gfxregion);
910   static void set_pri_callback(device_t &device, decospr_priority_callback_func callback);
11   static void set_col_callback(device_t &device, decospr_colour_callback_func callback);
1012   //void decospr_sprite_kludge(int x, int y);
1113   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16* spriteram, int sizewords, bool invert_flip = false );
1214   void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT16* spriteram, int sizewords, bool invert_flip = false );
1315   void set_pri_callback(decospr_priority_callback_func callback);
16   void set_col_callback(decospr_colour_callback_func callback);
1417   void set_gfxregion(int region) { m_gfxregion = region; };
1518   void set_alt_format(bool alt) { m_alt_format = alt; };
1619   void set_pix_mix_mask(UINT16 mask) { m_pixmask = mask; };
r14260r14261
2427   virtual void device_reset();
2528   UINT8                  m_gfxregion;
2629   decospr_priority_callback_func m_pricallback;
30   decospr_colour_callback_func m_colcallback;
2731   bitmap_ind16 m_sprite_bitmap;// optional sprite bitmap (should be INDEXED16)
2832   bool m_alt_format;
2933   UINT16 m_pixmask;
src/mame/video/psikyo.c
r14260r14261
637637            x0 = ((UINT16 *)state->m_vregs)[BYTE_XOR_BE(0x000/2 + i)];
638638      }
639639
640     
640
641641         tmptilemap0->set_scrollx(
642642         (i + layer0_scrolly) % tilemap_width(tm0size),
643643         layer0_scrollx + x0 );
r14260r14261
654654            x1 = ((UINT16 *)state->m_vregs)[BYTE_XOR_BE(0x200/2 + i)];
655655      }
656656
657     
657
658658         tmptilemap1->set_scrollx(
659659         (i + layer1_scrolly) % tilemap_width(tm1size),
660660         layer1_scrollx + x1 );
r14260r14261
811811            x0 = ((UINT16 *)state->m_vregs)[BYTE_XOR_BE(0x000/2 + i)];
812812      }
813813
814     
814
815815         tmptilemap0->set_scrollx(
816816         (i + layer0_scrolly) % tilemap_width(tm0size),
817817         layer0_scrollx + x0 );
r14260r14261
828828            x1 = ((UINT16 *)state->m_vregs)[BYTE_XOR_BE(0x200/2 + i)];
829829      }
830830
831     
831
832832         tmptilemap1->set_scrollx(
833833         (i + layer1_scrolly) % tilemap_width(tm1size),
834834         layer1_scrollx + x1 );
src/mame/video/rohga.c
r14260r14261
77#include "emu.h"
88#include "includes/rohga.h"
99#include "video/deco16ic.h"
10#include "video/decospr.h"
1011
11
1212WRITE16_HANDLER( rohga_buffer_spriteram16_w )
1313{
1414   // Spriteram seems to be triple buffered (no sprite lag on real pcb, but there
r14260r14261
2323   rohga_state *state = machine.driver_data<rohga_state>();
2424   state->m_spriteram = auto_alloc_array(machine, UINT16, 0x800/2);
2525   state->save_pointer(NAME(state->m_spriteram), 0x800/2);
26   machine.device<decospr_device>("spritegen1")->set_col_callback(rohga_col_callback);
27   machine.device<decospr_device>("spritegen1")->set_pri_callback(rohga_pri_callback);
2628}
2729
28/******************************************************************************/
29
30static void rohga_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, const UINT16 *spriteptr, int is_schmeisr )
30VIDEO_START( schmeisr )
3131{
32   int offs;
32   VIDEO_START_CALL( rohga );
33   // wire mods on pcb..
34   machine.device<decospr_device>("spritegen1")->set_col_callback(schmeisr_col_callback);
35}
3336
34   for (offs = 0x400 - 4; offs >= 0; offs -= 4)
35   {
36      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult, pri = 0;
37      sprite = spriteptr[offs + 1];
38      if (!sprite)
39         continue;
4037
41      x = spriteptr[offs + 2];
42
43      /* Sprite/playfield priority */
44      switch (x & 0x6000)
45      {
46      case 0x0000: pri = 0; break;
47      case 0x4000: pri = 0xf0; break;
48      case 0x6000: pri = 0xf0 | 0xcc; break;
49      case 0x2000: pri = 0;//0xf0|0xcc; break; /* Perhaps 0xf0|0xcc|0xaa (Sprite under bottom layer) */
50      }
51
52      y = spriteptr[offs];
53      flash = y & 0x1000;
54      if (flash && (machine.primary_screen->frame_number() & 1))
55         continue;
56
57      // Sprite colour is different between Rohga (6bpp) and Schmeisr (4bpp plus wire mods on pcb)
58      if (is_schmeisr)
59      {
60         colour = ((x >> 9) & 0xf) << 2;
61         if (x & 0x8000)
62            colour++;
63      }
64      else
65      {
66         colour = (x >> 9) & 0xf;
67      }
68
69      fx = y & 0x2000;
70      fy = y & 0x4000;
71      multi = (1 << ((y & 0x0600) >> 9)) - 1;   /* 1x, 2x, 4x, 8x height */
72
73      x = x & 0x01ff;
74      y = y & 0x01ff;
75      if (x >= 320) x -= 512;
76      if (y >= 256) y -= 512;
77
78      sprite &= ~multi;
79      if (fy)
80         inc = -1;
81      else
82      {
83         sprite += multi;
84         inc = 1;
85      }
86
87      if (flip_screen_get(machine))
88      {
89         x = 304 - x;
90         y = 240 - y;
91         if (fx) fx = 0; else fx = 1;
92         if (fy) fy = 0; else fy = 1;
93         mult = -16;
94      }
95      else
96         mult = +16;
97
98      while (multi >= 0)
99      {
100         pdrawgfx_transpen(bitmap,cliprect,machine.gfx[3],
101               sprite - multi * inc,
102               colour,
103               fx,fy,
104               x,y + mult * multi,
105               machine.priority_bitmap,pri,0);
106
107         multi--;
108      }
38UINT16 rohga_pri_callback(UINT16 x)
39{
40   switch (x & 0x6000)
41   {
42      case 0x0000: return 0;
43      case 0x4000: return 0xf0;
44      case 0x6000: return 0xf0 | 0xcc;
45      case 0x2000: return 0;//0xf0|0xcc; /* Perhaps 0xf0|0xcc|0xaa (Sprite under bottom layer) */
10946   }
47
48   return 0;
11049}
11150
112static void wizdfire_draw_sprites( running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT16 *spriteptr, int mode, int bank )
51UINT16 schmeisr_col_callback(UINT16 x)
11352{
114   int offs;
53   UINT16 colour = ((x >> 9) & 0xf) << 2;
54   if (x & 0x8000)
55      colour++;
11556
116   for (offs = 0; offs < 0x400; offs += 4)
117   {
118      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult;
119      int alpha = 0xff;
120
121      sprite = spriteptr[offs + 1];
122      if (!sprite)
123         continue;
124
125      x = spriteptr[offs + 2];
126
127      /*
128        Sprite/playfield priority - we can't use pdrawgfx because we need alpha'd sprites overlaid
129        over non-alpha'd sprites, plus sprites underneath and above an alpha'd background layer.
130
131        Hence, we rely on the hardware sorting everything correctly and not relying on any orthoganality
132        effects (it doesn't seem to), and instead draw separate passes for each sprite priority.  :(
133        */
134      switch (mode)
135      {
136      case 4:
137         if ((x & 0xc000) != 0xc000)
138            continue;
139         break;
140      case 3:
141         if ((x & 0xc000) != 0x8000)
142            continue;
143         break;
144      case 2:
145         if ((x & 0x8000) != 0x8000)
146            continue;
147         break;
148      case 1:
149      case 0:
150      default:
151         if ((x & 0x8000) != 0)
152            continue;
153         break;
154      }
155
156      y = spriteptr[offs];
157      flash = y & 0x1000;
158      if (flash && (machine.primary_screen->frame_number() & 1))
159         continue;
160      colour = (x >> 9) & 0x1f;
161
162      if (bank == 4 && colour & 0x10)
163      {
164         alpha = 0x80;
165         colour &= 0xf;
166      }
167
168      fx = y & 0x2000;
169      fy = y & 0x4000;
170      multi = (1 << ((y & 0x0600) >> 9)) - 1;   /* 1x, 2x, 4x, 8x height */
171
172      x = x & 0x01ff;
173      y = y & 0x01ff;
174      if (x >= 320) x -= 512;
175      if (y >= 256) y -= 512;
176
177      sprite &= ~multi;
178      if (fy)
179         inc = -1;
180      else
181      {
182         sprite += multi;
183         inc = 1;
184      }
185
186      if (flip_screen_get(machine))
187      {
188         x = 304 - x;
189         y = 240 - y;
190         if (fx) fx = 0; else fx = 1;
191         if (fy) fy = 0; else fy = 1;
192         mult = -16;
193      }
194      else
195         mult = +16;
196
197      if (fx) fx = 0; else fx = 1;
198      if (fy) fy = 0; else fy = 1;
199
200      while (multi >= 0)
201      {
202         drawgfx_alpha(bitmap,cliprect,machine.gfx[bank],
203               sprite - multi * inc,
204               colour,
205               fx,fy,
206               x,y + mult * multi,
207               0,alpha);
208
209         multi--;
210      }
211   }
57   return colour;
21258}
21359
214static void nitrobal_draw_sprites( running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, const UINT16 *spriteptr, int gfxbank )
60UINT16 rohga_col_callback(UINT16 x)
21561{
216   rohga_state *state = machine.driver_data<rohga_state>();
217   int offs, end, inc;
218   UINT16 priority = decocomn_priority_r(state->m_decocomn, 0, 0xffff);
62   return (x >> 9) & 0xf;
63}
21964
220   /*
221        Alternate format from most 16 bit games - same as Captain America and Mutant Fighter
22265
223        Word 0:
224            0x8000: Y flip
225            0x4000: X flip
226            0x2000: Flash (Sprite toggles on/off every frame)
227            0x1fff: Y value
228        Word 1:
229            0xffff: X value
230        Word 2:
231            0xf000: Block height
232            0x0f00: Block width
233            0x00e0: Unused?
23466
235sprites1:
236    bit 0x40 set for under PF2
237    bit 0x20 set on others...
238    bit 0x80 set in game pf3 (split)
239
240Sprites 2:
241    bit 0x10 set on alpha sprites..
242    bit 0x80 set is above pf2 else under pf2
243
244            0x001f: Colour
245        Word 3:
246            0xffff: Sprite value
247    */
248
249   offs = 0x3fc;
250   end = -4;
251   inc = -4;
252
253   while (offs != end)
254   {
255      int x, y, sprite, colour, fx, fy, w, h, sx, sy, x_mult, y_mult, tilemap_pri, sprite_pri;
256      int alpha = 0xff;
257
258      sprite = spriteptr[offs + 3];
259      if (!sprite)
260      {
261         offs += inc;
262         continue;
263      }
264
265      sx = spriteptr[offs + 1];
266
267      h = (spriteptr[offs + 2] & 0xf000) >> 12;
268      w = (spriteptr[offs + 2] & 0x0f00) >>  8;
269
270      sy = spriteptr[offs];
271      if ((sy & 0x2000) && (machine.primary_screen->frame_number() & 1))
272      {
273         offs += inc;
274         continue;
275      }
276
277      colour = (spriteptr[offs + 2] >> 0) & 0x1f;
278
279      // PRIORITIES - TODO
280      if (gfxbank == 3)
281      {
282         /* Sprite chip 1 */
283         switch (spriteptr[offs + 2] & 0xe0)
284         {
285//          case 0xc0: colour = rand()%0xff; tilemap_pri = 256; break; //todo
286         case 0xc0: tilemap_pri = 8; break; //? under other sprites
287         case 0x80: tilemap_pri = 32; break; //? under other sprites
288         case 0x20: tilemap_pri = 32; break; /* Over pf2 and under other sprite chip */
289         case 0x40: tilemap_pri = 8; break; /* Under pf2 and under other sprite chip */
290         case 0xa0: tilemap_pri = 32; break;
291         case 0:
292            tilemap_pri = 128; break;
293         default:
294            tilemap_pri = 128;
295            break;
296         }
297
298/*
299Intro:
300    0x40 is under pf2 and other sprites
301    0x20 is under pf2
302
303Level 1
304    0xa0 means under other sprites and pf2?
305
306Level 2 (tank scene)
307
308    Chip 1:
309
310  0x20 set means under pf2 else above??
311  0x80 set means under other sprites else above
312
313Level 3:
314    0xc0 means under other sprites and pf2      check??
315    0x40 means under pf2
316    0xa0 means under pf2..
317
318    always over other sprites..?
319
320
321PRI MODE 2:  (Level 4)
322sprite 1:
323    mode 0xa0 is under pf2 (sprites unknown)
324    mode 0x40 is under pf2 (sprites unknown)
325
326sprite 2:
327
328    mode 0x40 is under pf2
329    mode 0 is under pf2
330
331
332Level 5 (Space, pri mode 1)
333
334sprite 1:
335    mode 0x80 is over pf2 and over other sprites
336
337
338
339sprite 2:
340
341    mode 0 is over pf2
342
343  */
344
345         sprite_pri = 1;
346      }
347      else
348      {
349         /* Sprite chip 2 (with alpha blending) */
350
351         /* Sprite above playfield 2, but still below other sprite chip */
352//          if (spriteptr[offs + 2] & 0x80)
353            tilemap_pri = 64;
354//          else
355//              tilemap_pri = 8;
356
357         if (priority)
358            tilemap_pri = 8;
359         else
360            tilemap_pri = 64;
361
362         sprite_pri = 2;
363      }
364
365      if (gfxbank == 4 && colour & 0x10)
366      {
367         alpha = 0x80;
368         colour &= 0xf;
369      }
370
371      fx = (spriteptr[offs + 0] & 0x4000);
372      fy = (spriteptr[offs + 0] & 0x8000);
373
374      if (!flip_screen_get(machine))
375      { /* Inverted from Mutant Fighter! */
376         if (fx) fx = 0; else fx = 1;
377         if (fy) fy = 0; else fy = 1;
378
379         sx = sx & 0x01ff;
380         sy = sy & 0x01ff;
381         if (sx > 0x180) sx = -(0x200 - sx);
382         if (sy > 0x180) sy = -(0x200 - sy);
383
384         if (fx) { x_mult = -16; sx += 16 * w; } else { x_mult = 16; sx -= 16; }
385         if (fy) { y_mult = -16; sy += 16 * h; } else { y_mult = 16; sy -= 16; }
386      }
387      else
388      {
389         sx = sx & 0x01ff;
390         sy = sy & 0x01ff;
391         if (sx & 0x100) sx = -(0x100 - (sx & 0xff));
392         if (sy & 0x100) sy = -(0x100 - (sy & 0xff));
393         sx = 304 - sx;
394         sy = 240 - sy;
395         if (sx >= 432) sx -= 512;
396         if (sy >= 384) sy -= 512;
397         if (fx) { x_mult = -16; sx += 16; } else { x_mult = 16; sx -= 16 * w; }
398         if (fy) { y_mult = -16; sy += 16; } else { y_mult = 16; sy -= 16 * h; }
399      }
400
401      for (x = 0; x < w; x++)
402      {
403         for (y = 0; y < h; y++)
404         {
405            decocomn_pdrawgfx(
406                  state->m_decocomn,
407                  bitmap,cliprect,machine.gfx[gfxbank],
408                  sprite + y + h * x,
409                  colour,
410                  fx,fy,
411                  sx + x_mult * (w-x),sy + y_mult * (h-y),
412                  0,tilemap_pri,sprite_pri,1,alpha);
413         }
414      }
415
416      offs += inc;
417   }
418}
419
42067/******************************************************************************/
42168
422static void update_rohga( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int is_schmeisr )
69SCREEN_UPDATE_IND16( rohga )
42370{
42471   rohga_state *state = screen.machine().driver_data<rohga_state>();
42572   UINT16 flip = deco16ic_pf_control_r(state->m_deco_tilegen1, 0, 0xffff);
r14260r14261
462109      break;
463110   }
464111
465   rohga_draw_sprites(screen.machine(), bitmap, cliprect, state->m_spriteram, is_schmeisr);
112   screen.machine().device<decospr_device>("spritegen1")->draw_sprites(bitmap, cliprect, screen.machine().generic.buffered_spriteram.u16, 0x400, true);
466113   deco16ic_tilemap_1_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 0);
114
115   return 0;
467116}
468117
469SCREEN_UPDATE_IND16( rohga )
118
119
120VIDEO_START(wizdfire)
470121{
471   update_rohga(screen, bitmap, cliprect, 0);
472   return 0;
122   machine.device<decospr_device>("spritegen1")->alloc_sprite_bitmap();
123   machine.device<decospr_device>("spritegen2")->alloc_sprite_bitmap();
473124}
474125
475SCREEN_UPDATE_IND16( schmeisr )
126// not amazingly efficient, called multiple times to pull a layer out of the sprite bitmaps, but keeps correct sprite<->sprite priorities
127static void mixwizdfirelayer(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, int gfxregion, UINT16 pri, UINT16 primask)
476128{
477   // The Schmeisr pcb has wire mods which seem to remap sprite palette indices.
478   // Otherwise video update is the same as Rohga.
479   update_rohga(screen, bitmap, cliprect, 1);
480   return 0;
129   int y, x;
130   const pen_t *paldata = machine.pens;
131   bitmap_ind16* sprite_bitmap;
132   int penbase;
133
134   sprite_bitmap = &machine.device<decospr_device>("spritegen2")->get_sprite_temp_bitmap();
135   penbase = 0x600;
136
137   UINT16* srcline;
138   UINT32* dstline;
139
140
141   for (y=cliprect.min_y;y<=cliprect.max_y;y++)
142   {
143      srcline=&sprite_bitmap->pix16(y,0);
144      dstline=&bitmap.pix32(y,0);
145
146      for (x=cliprect.min_x;x<=cliprect.max_x;x++)
147      {
148         UINT16 pix = srcline[x];
149
150         if ((pix & primask) != pri)
151            continue;
152
153         if (pix&0xf)
154         {
155            UINT16 pen = pix&0x1ff;
156
157            if (pen&0x100)
158            {
159               UINT32 base = dstline[x];
160               pen &=0xff;
161               dstline[x] = alpha_blend_r32(base, paldata[pen+penbase], 0x80);
162            }
163            else
164            {
165               dstline[x] = paldata[pen+penbase];
166            }
167         }
168      }
169   }
481170}
482171
483172SCREEN_UPDATE_RGB32( wizdfire )
r14260r14261
486175   UINT16 flip = deco16ic_pf_control_r(state->m_deco_tilegen1, 0, 0xffff);
487176   UINT16 priority = decocomn_priority_r(state->m_decocomn, 0, 0xffff);
488177
178   /* draw sprite gfx to temp bitmaps */
179   screen.machine().device<decospr_device>("spritegen2")->draw_sprites(bitmap, cliprect, screen.machine().generic.buffered_spriteram2.u16, 0x400, true);
180   screen.machine().device<decospr_device>("spritegen1")->draw_sprites(bitmap, cliprect, screen.machine().generic.buffered_spriteram.u16, 0x400, true);
181
489182   /* Update playfields */
490183   flip_screen_set(screen.machine(), BIT(flip, 7));
491184   deco16ic_pf_update(state->m_deco_tilegen1, 0, 0);
r14260r14261
495188   bitmap.fill(screen.machine().pens[512], cliprect);
496189
497190   deco16ic_tilemap_2_draw(state->m_deco_tilegen2, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
498   wizdfire_draw_sprites(screen.machine(), bitmap, cliprect, screen.machine().generic.buffered_spriteram.u16, 4, 3);
191   screen.machine().device<decospr_device>("spritegen1")->inefficient_copy_sprite_bitmap(bitmap, cliprect, 0x0600, 0x0600, 0x400, 0x1ff);
499192   deco16ic_tilemap_2_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 0);
500   wizdfire_draw_sprites(screen.machine(), bitmap, cliprect, screen.machine().generic.buffered_spriteram.u16, 3, 3);
193   screen.machine().device<decospr_device>("spritegen1")->inefficient_copy_sprite_bitmap(bitmap, cliprect, 0x0400, 0x0600, 0x400, 0x1ff);
501194
502195   if ((priority & 0x1f) == 0x1f) /* Wizdfire has bit 0x40 always set, Dark Seal 2 doesn't?! */
503196      deco16ic_tilemap_1_draw(state->m_deco_tilegen2, bitmap, cliprect, TILEMAP_DRAW_ALPHA(0x80), 0);
504197   else
505198      deco16ic_tilemap_1_draw(state->m_deco_tilegen2, bitmap, cliprect, 0, 0);
506199
507   /* See notes in wizdfire_draw_sprites about this */
508   wizdfire_draw_sprites(screen.machine(), bitmap, cliprect, screen.machine().generic.buffered_spriteram.u16,  0, 3);
509   wizdfire_draw_sprites(screen.machine(), bitmap, cliprect, screen.machine().generic.buffered_spriteram2.u16, 2, 4);
510   wizdfire_draw_sprites(screen.machine(), bitmap, cliprect, screen.machine().generic.buffered_spriteram2.u16, 1, 4);
200   screen.machine().device<decospr_device>("spritegen1")->inefficient_copy_sprite_bitmap(bitmap, cliprect, 0x0000, 0x0400, 0x400, 0x1ff); // 0x000 and 0x200 of 0x600
511201
202   mixwizdfirelayer(screen.machine(), bitmap, cliprect, 4, 0x000, 0x000);
203
512204   deco16ic_tilemap_1_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 0);
513205   return 0;
514206}
r14260r14261
518210   rohga_state *state = screen.machine().driver_data<rohga_state>();
519211   UINT16 flip = deco16ic_pf_control_r(state->m_deco_tilegen1, 0, 0xffff);
520212
213   /* draw sprite gfx to temp bitmaps */
214   screen.machine().device<decospr_device>("spritegen1")->set_alt_format(true);
215   screen.machine().device<decospr_device>("spritegen2")->set_alt_format(true);
216   screen.machine().device<decospr_device>("spritegen2")->draw_sprites(bitmap, cliprect, screen.machine().generic.buffered_spriteram2.u16, 0x400, false);
217   screen.machine().device<decospr_device>("spritegen1")->draw_sprites(bitmap, cliprect, screen.machine().generic.buffered_spriteram.u16, 0x400, false);
218
521219   /* Update playfields */
522220   flip_screen_set(screen.machine(), BIT(flip, 7));
523221   deco16ic_pf_update(state->m_deco_tilegen1, state->m_pf1_rowscroll, state->m_pf2_rowscroll);
r14260r14261
532230   deco16ic_tilemap_12_combine_draw(state->m_deco_tilegen2, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
533231
534232   deco16ic_tilemap_2_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 16);
535   nitrobal_draw_sprites(screen.machine(), bitmap, cliprect, screen.machine().generic.buffered_spriteram.u16, 3);
536   nitrobal_draw_sprites(screen.machine(), bitmap, cliprect, screen.machine().generic.buffered_spriteram2.u16, 4);
537233
234   /* ToDo reimplement priorities + mixing / alpha, it was busted worse than this before anyway, so no big loss that we don't do it for now ;-) */
235   screen.machine().device<decospr_device>("spritegen2")->inefficient_copy_sprite_bitmap(bitmap, cliprect, 0x0000, 0x0000, 0x600, 0xff);
236   screen.machine().device<decospr_device>("spritegen1")->inefficient_copy_sprite_bitmap(bitmap, cliprect, 0x0000, 0x0000, 0x400, 0x1ff);
237
238
538239   deco16ic_tilemap_1_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 0);
539240   return 0;
540241}
src/mame/video/deco16ic.c
r14260r14261
345345         flags);
346346}
347347
348
348349/*****************************************************************************************/
349350
350351/*
src/mame/video/f1gp.c
r14260r14261
359359
360360   screen.machine().priority_bitmap.fill(0, cliprect);
361361
362   state->m_roz_tilemap->draw_roz(bitmap, cliprect,
362   state->m_roz_tilemap->draw_roz(bitmap, cliprect,
363363      startx << 13, starty << 13,
364364      incxx << 5, incxy << 5, incyx << 5, incyy << 5,
365365      1, 0, 0);
src/mame/video/namcos2.c
r14260r14261
236236   else
237237   {
238238      tmap->draw_roz(
239         bitmap, clip,
239         bitmap, clip,
240240         rozInfo->startx, rozInfo->starty,
241241         rozInfo->incxx, rozInfo->incxy,
242242         rozInfo->incyx, rozInfo->incyy,
src/mame/video/dassault.c
r14260r14261
22
33   Desert Assault Video emulation - Bryan McPhail, mish@tendril.co.uk
44
5  I'm not sure if one of the alpha blending effects is correct (mode 0x8000,
6  the usual mode 0x4000 should be correct).  It may be some kind of orthogonal
7  priority effect where it should cut a hole in other higher priority sprites
8  to reveal a non-alpha'd hole, or alpha against a further back tilemap.
9  (is this the helicopter shadow at the end of lv.1 ?)
10
11  Also, some priorities are still a little questionable.
12
13
514****************************************************************************/
615
716#include "emu.h"
817#include "video/deco16ic.h"
918#include "includes/dassault.h"
1019#include "video/decocomn.h"
20#include "video/decospr.h"
1121
1222/******************************************************************************/
1323
14static void draw_sprites( running_machine& machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, int pf_priority )
24VIDEO_START(dassault)
1525{
16   dassault_state *state = machine.driver_data<dassault_state>();
17   UINT16 *buffered_spriteram = machine.generic.buffered_spriteram.u16;
18   int x, y, sprite, colour, multi, fx, fy, inc, flash, mult;
19   int offs, bank, gfxbank;
20   const UINT16 *spritebase;
26   machine.device<decospr_device>("spritegen1")->alloc_sprite_bitmap();
27   machine.device<decospr_device>("spritegen2")->alloc_sprite_bitmap();
28}
2129
22   /* Have to loop over the two sprite sources */
23   for (bank = 0; bank < 2; bank++)
24   {
25      for (offs = 0x800 - 4; offs >= 0; offs -= 4)
26      {
27         int alpha = 0xff, pmask = 0;
30static void mixdassaultlayer(running_machine &machine, bitmap_rgb32 &bitmap, bitmap_ind16* sprite_bitmap, const rectangle &cliprect, UINT16 pri, UINT16 primask, UINT16 penbase, UINT8 alpha)
31{
32   int y, x;
33   const pen_t *paldata = machine.pens;
2834
29         /* Draw the main spritebank after the other one */
30         if (bank == 0)
31         {
32            spritebase = buffered_spriteram;
33            gfxbank = 3;
34         }
35         else
36         {
37            spritebase = machine.generic.buffered_spriteram2.u16;
38            gfxbank = 4;
39         }
35   UINT16* srcline;
36   UINT32* dstline;
4037
41         sprite = spritebase[offs + 1] & 0x7fff;
42         if (!sprite)
43            continue;
38   for (y=cliprect.min_y;y<=cliprect.max_y;y++)
39   {
40      srcline=&sprite_bitmap->pix16(y,0);
41      dstline=&bitmap.pix32(y,0);
4442
45         x = spritebase[offs + 2];
43      for (x=cliprect.min_x;x<=cliprect.max_x;x++)
44      {
45         UINT16 pix = srcline[x];
4646
47         /* Alpha on chip 2 only */
48         if (bank == 1 && x & 0xc000)
49            alpha = 0x80;
50
51         y = spritebase[offs];
52         flash = y & 0x1000;
53         if (flash && (machine.primary_screen->frame_number() & 1))
47         if ((pix & primask) != pri)
5448            continue;
55         colour = (x >> 9) & 0x1f;
56         if (y & 0x8000)
57            colour += 32;
5849
59         fx = y & 0x2000;
60         fy = y & 0x4000;
61         multi = (1 << ((y & 0x0600) >> 9)) - 1;   /* 1x, 2x, 4x, 8x height */
62
63         x = x & 0x01ff;
64         y = y & 0x01ff;
65         if (x >= 320) x -= 512;
66         if (y >= 256) y -= 512;
67         x = 304 - x;
68         y = 240 - y;
69
70         if (x > 320)
71            continue; /* Speedup */
72
73         sprite &= ~multi;
74         if (fy)
75            inc = -1;
76         else
50         if (pix&0xf)
7751         {
78            sprite += multi;
79            inc = 1;
80         }
52            UINT16 pen = pix&0x1ff;
53            if (pix & 0x800) pen += 0x200;
8154
82         if (flip_screen_get(machine))
83         {
84            y = 240 - y;
85            x = 304 - x;
86            if (fx) fx = 0; else fx = 1;
87            if (fy) fy = 0; else fy = 1;
88            mult = 16;
89         }
90         else mult = -16;
91
92         /* Priority */
93         switch (pf_priority & 3)
94         {
95         case 0:
96            if (bank == 0)
55            if (alpha!=0xff)
9756            {
98               switch (spritebase[offs+2]&0xc000)
57               if (pix&0x600)
9958               {
100               case 0xc000: pmask = 1; break;
101               case 0x8000: pmask = 8; break;
102               case 0x4000: pmask = 32; break;
103               case 0x0000: pmask = 128; break;
59                  UINT32 base = dstline[x];
60                  dstline[x] = alpha_blend_r32(base, paldata[pen+penbase], alpha);
10461               }
105            }
106            else
107            {
108               if (spritebase[offs + 2] & 0x8000)
109                  pmask = 64; /* Check */
11062               else
111                  pmask = 64;
112            }
113            break;
114
115         case 1:
116            if (bank == 0)
117            {
118               switch (spritebase[offs + 2] & 0xc000)
11963               {
120               case 0xc000: pmask = 1; break;
121               case 0x8000: pmask = 8; break;
122               case 0x4000: pmask = 32; break;
123               case 0x0000: pmask = 128; break;
64                  dstline[x] = paldata[pen+penbase];
12465               }
12566            }
12667            else
12768            {
128               if (spritebase[offs + 2] & 0x8000)
129                  pmask = 16; /* Check */
130               else
131                  pmask = 16;
69               dstline[x] = paldata[pen+penbase];
13270            }
133            break;
134
135         case 2: /* Unused */
136         case 3:
137            if (bank == 0)
138            {
139               switch (spritebase[offs + 2] & 0xc000)
140               {
141               case 0xc000: pmask = 1; break;
142               case 0x8000: pmask = 8; break;
143               case 0x4000: pmask = 32; break;
144               case 0x0000: pmask = 128; break;
145               }
146            }
147            else
148            {
149               if (spritebase[offs + 2] & 0x8000)
150                  pmask = 64; /* Check */
151               else
152                  pmask = 64;
153            }
154            break;
15571         }
156
157         while (multi >= 0)
158         {
159            decocomn_pdrawgfx(
160                  state->m_decocomn,
161                  bitmap,cliprect,machine.gfx[gfxbank],
162                  sprite - multi * inc,
163                  colour,
164                  fx, fy,
165                  x, y + mult * multi,
166                  0, pmask, 1 << bank, 1, alpha);
167
168            multi--;
169         }
17072      }
17173   }
17274}
17375
174/******************************************************************************/
175
76/* are the priorities 100% correct? they're the same as they were before conversion to DECO52 sprite device, but if (for example) you walk to the side of the crates in the first part of the game you appear over them... */
17677SCREEN_UPDATE_RGB32( dassault )
17778{
17879   dassault_state *state = screen.machine().driver_data<dassault_state>();
17980   UINT16 flip = deco16ic_pf_control_r(state->m_deco_tilegen1, 0, 0xffff);
18081   UINT16 priority = decocomn_priority_r(state->m_decocomn, 0, 0xffff);
18182
83   screen.machine().device<decospr_device>("spritegen2")->draw_sprites(bitmap, cliprect, screen.machine().generic.buffered_spriteram2.u16, 0x400, false);
84   screen.machine().device<decospr_device>("spritegen1")->draw_sprites(bitmap, cliprect, screen.machine().generic.buffered_spriteram.u16, 0x400, false);
85   bitmap_ind16* sprite_bitmap1 = &screen.machine().device<decospr_device>("spritegen1")->get_sprite_temp_bitmap();
86   bitmap_ind16* sprite_bitmap2 = &screen.machine().device<decospr_device>("spritegen2")->get_sprite_temp_bitmap();
87
18288   /* Update tilemaps */
18389   flip_screen_set(screen.machine(), BIT(flip, 7));
18490   deco16ic_pf_update(state->m_deco_tilegen1, 0, state->m_pf2_rowscroll);
18591   deco16ic_pf_update(state->m_deco_tilegen2, 0, state->m_pf4_rowscroll);
18692
18793   /* Draw playfields/update priority bitmap */
188   decocomn_clear_sprite_priority_bitmap(state->m_decocomn);
18994   screen.machine().priority_bitmap.fill(0, cliprect);
19095   bitmap.fill(screen.machine().pens[3072], cliprect);
19196   deco16ic_tilemap_2_draw(state->m_deco_tilegen2, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
r14260r14261
19398   /* The middle playfields can be swapped priority-wise */
19499   if ((priority & 3) == 0)
195100   {
196      deco16ic_tilemap_2_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 2);
197      deco16ic_tilemap_1_draw(state->m_deco_tilegen2, bitmap, cliprect, 0, 16);
101      mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect,  0x0600, 0x0600,  0x400, 0xff); // 1
102      deco16ic_tilemap_2_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 2); // 2
103      mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect,  0x0400, 0x0600,  0x400, 0xff); // 8
104      deco16ic_tilemap_1_draw(state->m_deco_tilegen2, bitmap, cliprect, 0, 16); // 16
105      mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect,  0x0200, 0x0600,  0x400, 0xff); // 32
106      mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap2, cliprect,  0x0000, 0x0000,  0x800, 0x80); // 64?
107      mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect,  0x0000, 0x0600,  0x400, 0xff); // 128
108
198109   }
199110   else if ((priority & 3) == 1)
200111   {
201      deco16ic_tilemap_1_draw(state->m_deco_tilegen2, bitmap, cliprect, 0, 2);
202      deco16ic_tilemap_2_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 64);
112      mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect,  0x0600, 0x0600,  0x400, 0xff); // 1
113      deco16ic_tilemap_1_draw(state->m_deco_tilegen2, bitmap, cliprect, 0, 2); // 2
114      mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect,  0x0400, 0x0600,  0x400, 0xff); // 8
115      mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap2, cliprect,  0x0000, 0x0000,  0x800, 0x80); // 16?
116      mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect,  0x0200, 0x0600,  0x400, 0xff); // 32
117      deco16ic_tilemap_2_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 64); // 64
118      mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect,  0x0000, 0x0600,  0x400, 0xff); // 128
203119   }
204120   else if ((priority & 3) == 3)
205121   {
206      deco16ic_tilemap_1_draw(state->m_deco_tilegen2, bitmap, cliprect, 0, 2);
207      deco16ic_tilemap_2_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 16);
122      mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect,  0x0600, 0x0600,  0x400, 0xff); // 1
123      deco16ic_tilemap_1_draw(state->m_deco_tilegen2, bitmap, cliprect, 0, 2); // 2
124      mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect,  0x0400, 0x0600,  0x400, 0xff); // 8
125      deco16ic_tilemap_2_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 16); // 16
126      mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect,  0x0200, 0x0600,  0x400, 0xff); // 32
127      mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap2, cliprect,  0x0000, 0x0000,  0x800, 0x80); // 64?
128      mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect,  0x0000, 0x0600,  0x400, 0xff); // 128
208129   }
209130   else
210131   {
211132      /* Unused */
212133   }
213134
214   /* Draw sprites - two sprite generators, with selectable priority */
215   draw_sprites(screen.machine(), bitmap, cliprect, priority);
216135   deco16ic_tilemap_1_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 0);
217136   return 0;
218137}
src/mame/video/boogwing.c
r14260r14261
22#include "includes/boogwing.h"
33#include "video/deco16ic.h"
44#include "video/decocomn.h"
5#include "video/decospr.h"
56
67static void draw_sprites( running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT16* spriteram_base, int gfx_region )
78{
r14260r14261
138139   }
139140}
140141
142VIDEO_START( boogwing )
143{
144   machine.device<decospr_device>("spritegen1")->alloc_sprite_bitmap();
145   machine.device<decospr_device>("spritegen2")->alloc_sprite_bitmap();
146}
147
141148SCREEN_UPDATE_RGB32( boogwing )
142149{
143150   boogwing_state *state = screen.machine().driver_data<boogwing_state>();
144151   UINT16 flip = deco16ic_pf_control_r(state->m_deco_tilegen1, 0, 0xffff);
145152   UINT16 priority = decocomn_priority_r(state->m_decocomn, 0, 0xffff);
146153
154   screen.machine().device<decospr_device>("spritegen2")->draw_sprites(bitmap, cliprect, screen.machine().generic.buffered_spriteram2.u16, 0x400, true);
155   screen.machine().device<decospr_device>("spritegen1")->draw_sprites(bitmap, cliprect, screen.machine().generic.buffered_spriteram.u16, 0x400, true);
156
147157   flip_screen_set(screen.machine(), BIT(flip, 7));
148158   deco16ic_pf_update(state->m_deco_tilegen1, state->m_pf1_rowscroll, state->m_pf2_rowscroll);
149159   deco16ic_pf_update(state->m_deco_tilegen2, state->m_pf3_rowscroll, state->m_pf4_rowscroll);
r14260r14261
184194
185195   draw_sprites(screen.machine(), bitmap, cliprect, screen.machine().generic.buffered_spriteram.u16, 3);
186196   draw_sprites(screen.machine(), bitmap, cliprect, screen.machine().generic.buffered_spriteram2.u16, 4);
197//  screen.machine().device<decospr_device>("spritegen1")->inefficient_copy_sprite_bitmap(bitmap, cliprect, 0x0000, 0x0000, 0x500, 0x1ff);
198//  screen.machine().device<decospr_device>("spritegen2")->inefficient_copy_sprite_bitmap(bitmap, cliprect, 0x0000, 0x0000, 0x700, 0xff);
187199
188200   deco16ic_tilemap_1_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 0);
189201   return 0;
src/mame/video/konicdev.c
r14260r14261
97389738
97399739      if ((k001604->reg[0x6c / 4] & (0x08 >> layer)) != 0)
97409740      {
9741         k001604->layer_roz[layer]->draw_roz(bitmap, cliprect,
9741         k001604->layer_roz[layer]->draw_roz(bitmap, cliprect,
97429742                      x << 5, y << 5, xx << 5, xy << 5, yx << 5, yy << 5, 1, 0, 0);
97439743      }
97449744   }
src/mame/video/ppu2c0x.c
r14260r14261
8787static ADDRESS_MAP_START( ppu2c0x, AS_0, 8, ppu2c0x_device )
8888   AM_RANGE(0x0000, 0x3eff) AM_RAM
8989   AM_RANGE(0x3f00, 0x3fff) AM_READWRITE(palette_read, palette_write)
90//   AM_RANGE(0x0000, 0x3fff) AM_RAM
90//  AM_RANGE(0x0000, 0x3fff) AM_RAM
9191ADDRESS_MAP_END
9292
9393//-------------------------------------------------
r14260r14261
109109{
110110   const ppu2c0x_interface *config = reinterpret_cast<const ppu2c0x_interface *>(static_config());
111111   assert(config);
112   
112
113113   /* reset the callbacks */
114114   m_latch = NULL;
115115   m_scanline_callback_proc = NULL;
r14260r14261
143143{
144144   for (int i = 0; i < PPU_MAX_REG; i++)
145145      m_regs[i] = 0;
146   
146
147147   memset(m_palette_ram, 0, ARRAY_LENGTH(m_palette_ram));
148   
148
149149   m_scanlines_per_frame = PPU_NTSC_SCANLINES_PER_FRAME;
150   
150
151151   /* usually, no security value... */
152152   m_security_value = 0;
153153}
r14260r14261
207207   m_cpu = machine().device<cpu_device>( m_cpu_tag );
208208
209209   assert(m_screen && m_cpu);
210   
210
211211   // allocate timers
212212   m_hblank_timer = timer_alloc(TIMER_HBLANK);
213213   m_nmi_timer = timer_alloc(TIMER_NMI);
214214   m_scanline_timer = timer_alloc(TIMER_SCANLINE);
215   
215
216216   /* initialize the scanline handling portion */
217217   m_scanline_timer->adjust(m_screen->time_until_pos(1));
218218   m_hblank_timer->adjust(m_cpu->cycles_to_attotime(86.67)); // ??? FIXME - hardcoding NTSC, need better calculation
r14260r14261
229229   {
230230      /* monochromatic table */
231231      m_colortable_mono[i] = default_colortable_mono[i] + m_color_base;
232     
232
233233      /* color table */
234234      m_colortable[i] = default_colortable[i] + m_color_base;
235235   }
r14260r14261
468468      case TIMER_HBLANK:
469469         blanked = (m_regs[PPU_CONTROL1] & (PPU_CONTROL1_BACKGROUND | PPU_CONTROL1_SPRITES)) == 0;
470470         vblank = ((m_scanline >= PPU_VBLANK_FIRST_SCANLINE - 1) && (m_scanline < m_scanlines_per_frame - 1)) ? 1 : 0;
471         
471
472472         //update_scanline();
473         
473
474474         if (m_hblank_callback_proc)
475475            (*m_hblank_callback_proc) (this, m_scanline, vblank, blanked);
476         
476
477477         m_hblank_timer->adjust(attotime::never);
478478         break;
479         
480      case TIMER_NMI:         
479
480      case TIMER_NMI:
481481         // Actually fire the VMI
482482         if (m_nmi_callback_proc)
483483            (*m_nmi_callback_proc) (this, regs);
484         
484
485485         m_nmi_timer->adjust(attotime::never);
486486         break;
487         
487
488488      case TIMER_SCANLINE:
489489         blanked = (m_regs[PPU_CONTROL1] & (PPU_CONTROL1_BACKGROUND | PPU_CONTROL1_SPRITES)) == 0;
490490         vblank = ((m_scanline >= PPU_VBLANK_FIRST_SCANLINE - 1) && (m_scanline < m_scanlines_per_frame - 1)) ? 1 : 0;
491491         int next_scanline;
492         
492
493493         /* if a callback is available, call it */
494494         if (m_scanline_callback_proc)
495495            (*m_scanline_callback_proc)(this, m_scanline, vblank, blanked);
496         
496
497497         /* update the scanline that just went by */
498498         update_scanline();
499         
499
500500         /* increment our scanline count */
501501         m_scanline++;
502         
502
503503         //  logerror("starting scanline %d (MAME %d, beam %d)\n", m_scanline, device->machine().primary_screen->vpos(), device->machine().primary_screen->hpos());
504         
504
505505         /* Note: this is called at the _end_ of each scanline */
506506         if (m_scanline == PPU_VBLANK_FIRST_SCANLINE)
507507         {
508508            // logerror("vblank starting\n");
509509            /* We just entered VBLANK */
510510            m_regs[PPU_STATUS] |= PPU_STATUS_VBLANK;
511           
511
512512            /* If NMI's are set to be triggered, go for it */
513513            if (m_regs[PPU_CONTROL0] & PPU_CONTROL0_NMI)
514514            {
r14260r14261
519519               m_nmi_timer->adjust(m_cpu->cycles_to_attotime(4));
520520            }
521521         }
522         
522
523523         if (m_scanline == m_scanlines_per_frame - 1)
524524         {
525525            // logerror("vblank ending\n");
526526            /* clear the vblank & sprite hit flag */
527527            m_regs[PPU_STATUS] &= ~(PPU_STATUS_VBLANK | PPU_STATUS_SPRITE0_HIT | PPU_STATUS_8SPRITES);
528528         }
529         
529
530530         /* see if we rolled */
531531         else if (m_scanline == m_scanlines_per_frame)
532532         {
533533            /* if background or sprites are enabled, copy the ppu address latch */
534534            if (!blanked)
535535               m_refresh_data = m_refresh_latch;
536           
536
537537            /* reset the scanline count */
538538            m_scanline = 0;
539539            //logerror("sprite 0 x: %d y: %d num: %d\n", m_spriteram[3], m_spriteram[0] + 1, m_spriteram[1]);
540540         }
541         
541
542542         next_scanline = m_scanline + 1;
543543         if (next_scanline == m_scanlines_per_frame)
544544            next_scanline = 0;
545         
545
546546         // Call us back when the hblank starts for this scanline
547547         m_hblank_timer->adjust(m_cpu->cycles_to_attotime(86.67)); // ??? FIXME - hardcoding NTSC, need better calculation
548         
548
549549         // trigger again at the start of the next scanline
550550         m_scanline_timer->adjust(m_screen->time_until_pos(next_scanline * m_scan_scale));
551551         break;
r14260r14261
10431043{
10441044   if (m_regs[PPU_CONTROL1] & PPU_CONTROL1_DISPLAY_MONO)
10451045      return (m_palette_ram[offset & 0x1f] & 0x30);
1046   
1046
10471047   else
10481048      return (m_palette_ram[offset & 0x1f]);
10491049}
src/mame/video/ppu2c0x.h
r14260r14261
144144public:
145145    // construction/destruction
146146   ppu2c0x_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
147   
147
148148   DECLARE_READ8_MEMBER( read );
149149   DECLARE_WRITE8_MEMBER( write );
150150   DECLARE_READ8_MEMBER( palette_read );
r14260r14261
157157   virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
158158   // address space configurations
159159   const address_space_config      m_space_config;
160   
161   
160
161
162162   /* routines */
163163   void init_palette( running_machine &machine, int first_entry );
164164   void init_palette_rgb( running_machine &machine, int first_entry );
165   
165
166166   void draw_background( UINT8 *line_priority );
167167   void draw_sprites( UINT8 *line_priority );
168168   void render_scanline();
r14260r14261
179179   void set_hblank_callback( ppu2c0x_scanline_cb cb ) { if (cb != NULL) m_hblank_callback_proc = cb; };
180180   void set_vidaccess_callback( ppu2c0x_vidaccess_cb cb ) { if (cb != NULL) m_vidaccess_callback_proc = cb; };
181181   void set_scanlines_per_frame( int scanlines ) { m_scanlines_per_frame = scanlines; };
182   
182
183183   //27/12/2002 (HACK!)
184184   void set_latch( void (*ppu_latch_t)( device_t *device, offs_t offset ) );
185   
186   //   void update_screen(bitmap_t &bitmap, const rectangle &cliprect);
187   
185
186   //  void update_screen(bitmap_t &bitmap, const rectangle &cliprect);
187
188188   cpu_device               *m_cpu;
189189   screen_device            *m_screen;
190   bitmap_ind16             *m_bitmap;         /* target bitmap */
190   bitmap_ind16            *m_bitmap;         /* target bitmap */
191191   UINT8                       *m_spriteram;         /* sprite ram */
192192   pen_t                       *m_colortable;         /* color table modified at run time */
193193   pen_t                       *m_colortable_mono;      /* monochromatic color table modified at run time */
r14260r14261
214214   int                         m_scanlines_per_frame;   /* number of scanlines per frame */
215215   int                         m_security_value;      /* 2C05 protection */
216216   void (*m_latch)( device_t *device, offs_t offset );
217   
217
218218   // timers
219219   emu_timer                   *m_hblank_timer;      /* hblank period at end of each scanline */
220220   emu_timer                   *m_nmi_timer;         /* NMI timer */
src/mame/video/macrossp.c
r14260r14261
358358      startx -= (368/2) * inc;
359359      starty -= (240/2) * inc;
360360
361      tm->draw_roz(bitmap, cliprect,
361      tm->draw_roz(bitmap, cliprect,
362362            startx,starty,inc,0,0,inc,
363363            1,   /* wraparound */
364364            0,0);
src/mame/drivers/cntsteer.c
r14260r14261
290290      x = -256 - (state->m_scrollx | state->m_scrollx_hi);
291291      y = 256 + (state->m_scrolly | state->m_scrolly_hi);
292292
293      state->m_bg_tilemap->draw_roz(bitmap, cliprect,
293      state->m_bg_tilemap->draw_roz(bitmap, cliprect,
294294                  (x << 16), (y << 16),
295295                  p1, p2,
296296                  p3, p4,
r14260r14261
339339      x = 256 + (state->m_scrollx | state->m_scrollx_hi);
340340      y = 256 - (state->m_scrolly | state->m_scrolly_hi);
341341
342      state->m_bg_tilemap->draw_roz(bitmap, cliprect,
342      state->m_bg_tilemap->draw_roz(bitmap, cliprect,
343343                  (x << 16), (y << 16),
344344                  p1, p2,
345345                  p3, p4,
src/mame/drivers/nexus3d.c
r14260r14261
127127
128128//static READ32_HANDLER( nexus3d_unk2_r )
129129//{
130//   return 0x00000000;//space->machine().rand() ^ (space->machine().rand() << 16);
130//  return 0x00000000;//space->machine().rand() ^ (space->machine().rand() << 16);
131131//}
132132//
133133//static READ32_HANDLER( nexus3d_unk3_r )
134134//{
135//   return 0x00000000;//space->machine().rand() ^ (space->machine().rand() << 16);
135//  return 0x00000000;//space->machine().rand() ^ (space->machine().rand() << 16);
136136//}
137137//
138138//static WRITE32_HANDLER( nexus3d_unk2_w )
r14260r14261
156156   AM_RANGE(0x9C000018, 0x9C00001b) AM_WRITE8( n3d_flash_addr_w, 0xffffffff)
157157
158158   // lots of accesses in this range
159//   AM_RANGE(0xC0000F44, 0xC0000F47) AM_READWRITE( nexus3d_unk2_r, nexus3d_unk2_w ) // often
160//   AM_RANGE(0xC0000F4C, 0xC0000F4f) AM_READWRITE( nexus3d_unk3_r, nexus3d_unk3_w ) // often
159//  AM_RANGE(0xC0000F44, 0xC0000F47) AM_READWRITE( nexus3d_unk2_r, nexus3d_unk2_w ) // often
160//  AM_RANGE(0xC0000F4C, 0xC0000F4f) AM_READWRITE( nexus3d_unk3_r, nexus3d_unk3_w ) // often
161161
162162   AM_RANGE(0xE0000014, 0xE0000017) AM_READ( nexus3d_unk_r ) // sits waiting for this
163163
src/mame/drivers/cybertnk.c
r14260r14261
851851   { 0 },
852852   1024*4,
853853   xoffsets
854};
854};
855855
856856static GFXDECODE_START( cybertnk )
857857   GFXDECODE_ENTRY( "gfx1", 0, tile_8x8x4,     0x1400, 16 ) /*Pal offset???*/
src/mame/drivers/konamigq.c
r14260r14261
319319{
320320   1, /* 1 SCSI device */
321321   {
322      { SCSI_ID_0, "disk", SCSI_DEVICE_HARDDISK } /* SCSI ID 0, using CHD 0, and it's a HDD */
322      { SCSI_ID_0, ":disk", SCSI_DEVICE_HARDDISK } /* SCSI ID 0, using CHD 0, and it's a HDD */
323323   }
324324};
325325
src/mame/drivers/chihiro.c
r14260r14261
11451145MACHINE_CONFIG_END
11461146
11471147static MACHINE_CONFIG_DERIVED( chihirogd, chihiro_base )
1148   MCFG_NAOMI_GDROM_BOARD_ADD("rom_board", "gdrom", "pic", NULL, "maincpu", NULL)
1148   MCFG_NAOMI_GDROM_BOARD_ADD("rom_board", ":gdrom", "pic", NULL, "maincpu", NULL)
11491149MACHINE_CONFIG_END
11501150
11511151#define ROM_LOAD16_WORD_SWAP_BIOS(bios,name,offset,length,hash) \
src/mame/drivers/naomi.c
r14260r14261
25602560 */
25612561
25622562static MACHINE_CONFIG_DERIVED( naomigd, naomi_base )
2563   MCFG_NAOMI_GDROM_BOARD_ADD("rom_board", "gdrom", "pic", "naomibd_eeprom", "maincpu", naomi_g1_irq)
2563   MCFG_NAOMI_GDROM_BOARD_ADD("rom_board", ":gdrom", "pic", "naomibd_eeprom", "maincpu", naomi_g1_irq)
25642564MACHINE_CONFIG_END
25652565
25662566/*
r14260r14261
39543954   NAOMI_DEFAULT_EEPROM
39553955
39563956    ROM_REGION( 0x4000000, "rom_board", ROMREGION_ERASEFF)
3957    ROM_LOAD( "epr-24217.ic11",         0x0000000, 0x0400000, CRC(5ecf807b) SHA1(f91d03a68a44d02970e360789b746bec9289275f) )
3958    ROM_LOAD32_WORD( "mpr-24218.ic17s", 0x1000000, 0x0800000, CRC(e8c51e1d) SHA1(e81f0580e144aa7a7e8c9399ffa09227b6e93675) )
3959    ROM_LOAD32_WORD( "mpr-24219.ic18",  0x1000002, 0x0800000, CRC(b0a5709f) SHA1(993f7a99d59a924641c37a549208723342007e5a) )
3960    ROM_LOAD32_WORD( "mpr-24220.ic19s", 0x2000000, 0x0800000, CRC(9f6cefe2) SHA1(499e17d2c284b340db6b124b63a23c7fa5045d0f) )
3961    ROM_LOAD32_WORD( "mpr-24221.ic20",  0x2000002, 0x0800000, CRC(73bf9cc6) SHA1(ab187cc0babd1435f5e8636331818d81de23636f) )
3962    ROM_LOAD32_WORD( "mpr-24222.ic21s", 0x3000000, 0x0800000, CRC(7098e728) SHA1(82f4f57efcee3063467c24758cefd406dccb1ea4) )
3963    ROM_LOAD32_WORD( "mpr-24223.ic22",  0x3000002, 0x0800000, CRC(eca13c90) SHA1(26a66906bf4ebda8697140d89eb5e493e941e8b2) )
3957    ROM_LOAD( "epr-24217.ic11",         0x0000000, 0x0400000, CRC(5ecf807b) SHA1(f91d03a68a44d02970e360789b746bec9289275f) )
3958    ROM_LOAD32_WORD( "mpr-24218.ic17s", 0x1000000, 0x0800000, CRC(e8c51e1d) SHA1(e81f0580e144aa7a7e8c9399ffa09227b6e93675) )
3959    ROM_LOAD32_WORD( "mpr-24219.ic18",  0x1000002, 0x0800000, CRC(b0a5709f) SHA1(993f7a99d59a924641c37a549208723342007e5a) )
3960    ROM_LOAD32_WORD( "mpr-24220.ic19s", 0x2000000, 0x0800000, CRC(9f6cefe2) SHA1(499e17d2c284b340db6b124b63a23c7fa5045d0f) )
3961    ROM_LOAD32_WORD( "mpr-24221.ic20",  0x2000002, 0x0800000, CRC(73bf9cc6) SHA1(ab187cc0babd1435f5e8636331818d81de23636f) )
3962    ROM_LOAD32_WORD( "mpr-24222.ic21s", 0x3000000, 0x0800000, CRC(7098e728) SHA1(82f4f57efcee3063467c24758cefd406dccb1ea4) )
3963    ROM_LOAD32_WORD( "mpr-24223.ic22",  0x3000002, 0x0800000, CRC(eca13c90) SHA1(26a66906bf4ebda8697140d89eb5e493e941e8b2) )
39643964
39653965    ROM_REGION( 4, "rom_key", 0 )
3966    ROM_LOAD( "mtkob2-key.bin", 0x000000, 0x000004, CRC(db088208) SHA1(14d65ad2555183a445abcd93907c85df4032b41d) )
3966    ROM_LOAD( "mtkob2-key.bin", 0x000000, 0x000004, CRC(db088208) SHA1(14d65ad2555183a445abcd93907c85df4032b41d) )
39673967ROM_END
39683968
39693969ROM_START( crackndj )
r14260r14261
51355135   NAOMI_DEFAULT_EEPROM
51365136
51375137   ROM_REGION( 0xb000000, "rom_board", ROMREGION_ERASEFF)
5138    ROM_LOAD("vnbaearly.ic22",0x0000000, 0x0400000, CRC(5bbf7a45) SHA1(ad71ae8e9e08d7e0a9a60d1ba51bc5dcfeb0f50c) )
5138    ROM_LOAD("vnbaearly.ic22",0x0000000, 0x0400000, CRC(5bbf7a45) SHA1(ad71ae8e9e08d7e0a9a60d1ba51bc5dcfeb0f50c) )
51395139   ROM_LOAD("mpr-22928.ic1", 0x0800000, 0x0800000, CRC(63245c98) SHA1(a5a542244f07c6c8b66961a231fb56c89d2cf20c) )
51405140   ROM_LOAD("mpr-22929.ic2", 0x1000000, 0x0800000, CRC(eea89d21) SHA1(5fe184267e637f155d767f8d931462d9593eff5a) )
51415141   ROM_LOAD("mpr-22930.ic3", 0x1800000, 0x0800000, CRC(2fbefa9a) SHA1(a6df46cb8742022e436cdc6a9a50490c7a551421) )
r14260r14261
77937793/* 0126 */ GAME( 2003, oinori,   naomi,    naomi,   naomi,    naomi,    ROT0, "Sega", "Oinori-daimyoujin Matsuri", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
77947794/* 0128 */ GAME( 2002, shootpl,  naomi,    naomim1, naomi,    naomi,    ROT0, "Sega", "Shootout Pool (JPN, USA, KOR, AUS) / Shootout Pool Prize (EXP)", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
77957795/* 0140 */ GAME( 2004, kick4csh, naomi,    naomim1, naomi,    kick4csh, ROT0, "Sega", "Kick '4' Cash", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
7796/* 0150 */ GAME( 2003, mtkob2,   naomi,    naomim1, naomi,    naomi,    ROT0, "Sega", "Mushiking The King Of Beetle 2K3 2nd", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
7796/* 0150 */ GAME( 2003, mtkob2,   naomi,    naomim1, naomi,    naomi,    ROT0, "Sega", "Mushiking The King Of Beetle 2K3 2nd", GAME_UNEMULATED_PROTECTION|GAME_FLAGS )
77977797// 0164 MushiKing The King Of Beetle II ENG
77987798// 0166 Touch De Zunou (Japan)
77997799// 0166 Touch De Zunou (Japan) (Rev A)
src/mame/drivers/bnstars.c
r14260r14261
245245            if (incxx & 0x10000) incxx |= ~0x1ffff;
246246            if (incxy & 0x10000) incxy |= ~0x1ffff;
247247
248            state->m_ms32_roz_tilemap->draw_roz(bitmap, &my_clip,
248            state->m_ms32_roz_tilemap->draw_roz(bitmap, &my_clip,
249249                    (start2x+startx+offsx)<<16, (start2y+starty+offsy)<<16,
250250                    incxx<<8, incxy<<8, 0, 0,
251251                    1, // Wrap
r14260r14261
277277      if (incyy & 0x10000) incyy |= ~0x1ffff;
278278      if (incyx & 0x10000) incyx |= ~0x1ffff;
279279
280      state->m_ms32_roz_tilemap[chip]->draw_roz(bitmap, cliprect,
280      state->m_ms32_roz_tilemap[chip]->draw_roz(bitmap, cliprect,
281281            (startx+offsx)<<16, (starty+offsy)<<16,
282282            incxx<<8, incxy<<8, incyx<<8, incyy<<8,
283283            1, // Wrap
src/mame/drivers/dassault.c
r14260r14261
44  Desert Assault     (c) 1991 Data East Corporation (USA 4 players)
55  Desert Assault     (c) 1991 Data East Corporation (USA 2 players)
66
7  I'm not sure if one of the alpha blending effects is correct (mode 0x8000,
8  the usual mode 0x4000 should be correct).  It may be some kind of orthogonal
9  priority effect where it should cut a hole in other higher priority sprites
10  to reveal a non-alpha'd hole, or alpha against a further back tilemap.
11
127  Emulation by Bryan McPhail, mish@tendril.co.uk
138
149
r14260r14261
130125#include "sound/okim6295.h"
131126#include "video/deco16ic.h"
132127#include "video/decocomn.h"
128#include "video/decospr.h"
133129
134130/**********************************************************************************/
135131
r14260r14261
505501   GFXDECODE_ENTRY( "gfx2", 0, charlayout,     0,  32 )   /* Characters 8x8 */
506502   GFXDECODE_ENTRY( "gfx2", 0, tilelayout,     0,  32 )   /* Tiles 16x16 */
507503   GFXDECODE_ENTRY( "gfx3", 0, tilelayout,   512,  32 )   /* Tiles 16x16 */
508   GFXDECODE_ENTRY( "gfx4", 0, tilelayout,  1024,  64 )   /* Sprites 16x16 */
509   GFXDECODE_ENTRY( "gfx5", 0, tilelayout,  2048,  64 )   /* Sprites 16x16 */
504   GFXDECODE_ENTRY( "gfx4", 0, tilelayout,  0/*1024*/,  64 )   /* Sprites 16x16 */
505   GFXDECODE_ENTRY( "gfx5", 0, tilelayout,  0/*2048*/,  64 )   /* Sprites 16x16 */
510506GFXDECODE_END
511507
512508/**********************************************************************************/
r14260r14261
582578   MCFG_CPU_ADD("audiocpu", H6280,32220000/8)   /* Accurate */
583579   MCFG_CPU_PROGRAM_MAP(sound_map)
584580
585   MCFG_QUANTUM_TIME(attotime::from_hz(8400)) /* 140 CPU slices per frame */
581//  MCFG_QUANTUM_TIME(attotime::from_hz(8400)) /* 140 CPU slices per frame */
582   MCFG_QUANTUM_PERFECT_CPU("maincpu") // I was seeing random lockups.. let's see if this helps
586583
587584   /* video hardware */
588585   MCFG_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)
r14260r14261
594591   MCFG_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 1*8, 31*8-1)
595592   MCFG_SCREEN_UPDATE_STATIC(dassault)
596593
594   MCFG_VIDEO_START(dassault)
595
597596   MCFG_GFXDECODE(dassault)
598597   MCFG_PALETTE_LENGTH(4096)
599598
r14260r14261
602601   MCFG_DECO16IC_ADD("tilegen1", dassault_deco16ic_tilegen1_intf)
603602   MCFG_DECO16IC_ADD("tilegen2", dassault_deco16ic_tilegen2_intf)
604603
604   MCFG_DEVICE_ADD("spritegen1", DECO_SPRITE, 0)
605   decospr_device::set_gfx_region(*device, 3);
606
607   MCFG_DEVICE_ADD("spritegen2", DECO_SPRITE, 0)
608   decospr_device::set_gfx_region(*device, 4);
609
610
605611   /* sound hardware */
606612   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
607613
r14260r14261
825831
826832/**********************************************************************************/
827833
828static READ16_HANDLER( dassault_main_skip )
829{
830   dassault_state *state = space->machine().driver_data<dassault_state>();
831   int ret = state->m_ram[0];
832834
833   if (cpu_get_previouspc(&space->device()) == 0x1170 && ret & 0x8000)
834      device_spin_until_interrupt(&space->device());
835
836   return ret;
837}
838
839static READ16_HANDLER( thndzone_main_skip )
840{
841   dassault_state *state = space->machine().driver_data<dassault_state>();
842   int ret = state->m_ram[0];
843
844   if (cpu_get_pc(&space->device()) == 0x114c && ret & 0x8000)
845      device_spin_until_interrupt(&space->device());
846
847   return ret;
848}
849
850835static DRIVER_INIT( dassault )
851836{
852837   const UINT8 *src = machine.region("gfx1")->base();
r14260r14261
862847   memcpy(dst + 0x110000, src + 0x10000, 0x10000);
863848
864849   auto_free(machine, tmp);
865
866   /* Save time waiting on vblank bit */
867   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x3f8000, 0x3f8001, FUNC(dassault_main_skip));
868850}
869851
870852static DRIVER_INIT( thndzone )
r14260r14261
882864   memcpy(dst + 0x110000, src + 0x10000, 0x10000);
883865
884866   auto_free(machine, tmp);
885
886   /* Save time waiting on vblank bit */
887   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x3f8000, 0x3f8001, FUNC(thndzone_main_skip));
888867}
889868
890869/**********************************************************************************/
src/mame/drivers/boogwing.c
r14260r14261
8888#include "sound/okim6295.h"
8989#include "video/deco16ic.h"
9090#include "video/decocomn.h"
91#include "video/decospr.h"
9192
9293static ADDRESS_MAP_START( boogwing_map, AS_PROGRAM, 16 )
9394   AM_RANGE(0x000000, 0x0fffff) AM_ROM
r14260r14261
361362   MCFG_PALETTE_LENGTH(2048)
362363   MCFG_GFXDECODE(boogwing)
363364
365   MCFG_VIDEO_START(boogwing)
366
364367   MCFG_DECOCOMN_ADD("deco_common", boogwing_decocomn_intf)
365368
366369   MCFG_DECO16IC_ADD("tilegen1", boogwing_deco16ic_tilegen1_intf)
367370   MCFG_DECO16IC_ADD("tilegen2", boogwing_deco16ic_tilegen2_intf)
368371
372   MCFG_DEVICE_ADD("spritegen1", DECO_SPRITE, 0)
373   decospr_device::set_gfx_region(*device, 3);
374
375   MCFG_DEVICE_ADD("spritegen2", DECO_SPRITE, 0)
376   decospr_device::set_gfx_region(*device, 4);
377
369378   /* sound hardware */
370379   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
371380
src/mame/drivers/neodrvr.c
r14260r14261
88828882   ROM_IGNORE(0x20000)
88838883
88848884   ROM_REGION( 0x20000, "fixedbios", 0 )
8885   ROM_LOAD( "sfix.sfix", 0x000000, 0x20000, CRC(c2ea0cfd) SHA1(fd4a618cdcdbf849374f0a50dd8efe9dbab706c3) )                                                                                   
8885   ROM_LOAD( "sfix.sfix", 0x000000, 0x20000, CRC(c2ea0cfd) SHA1(fd4a618cdcdbf849374f0a50dd8efe9dbab706c3) )
88868886   ROM_Y_ZOOM
88878887
88888888   NEO_BIOS_AUDIO_512K( "1b.bin", CRC(7b1f86f7) SHA1(15b6af7f9fbd0f1f6a1ecd912200ca8d0af2da2a) )
src/mame/drivers/eolithsp.c
r14260r14261
101101CUSTOM_INPUT( eolith_speedup_getvblank )
102102{
103103
104//   printf("%s:eolith speedup_read data %02x\n",field.machine().describe_context(), eolith_vblank);
105   
104//  printf("%s:eolith speedup_read data %02x\n",field.machine().describe_context(), eolith_vblank);
106105
106
107107   return (field.machine().primary_screen->vpos() >= 240);
108108}
109109
110// StealSee doesn't use interrupts, just the vblank
110// StealSee doesn't use interrupts, just the vblank
111111CUSTOM_INPUT( stealsee_speedup_getvblank )
112112{
113113   eolith_state *state = field.machine().driver_data<eolith_state>();
114114
115115   int pc = cpu_get_pc(state->m_maincpu);
116   
116
117117   if (pc==0x400081ec)
118118      if(!eolith_vblank)
119119         device_eat_cycles(state->m_maincpu, 500);
120   
120
121121   return (field.machine().primary_screen->vpos() >= 240);
122122}
src/mame/drivers/rocnrope.c
r14260r14261
121121
122122   PORT_START("DSW3")
123123   PORT_DIPNAME( 0x07, 0x06, "First Bonus" )         PORT_DIPLOCATION("SW3:1,2,3")
124//   PORT_DIPSETTING(    0x07, "20000" ) // unused
124//  PORT_DIPSETTING(    0x07, "20000" ) // unused
125125   PORT_DIPSETTING(    0x06, "20000" )
126126   PORT_DIPSETTING(    0x05, "30000" )
127127   PORT_DIPSETTING(    0x04, "40000" )
src/mame/drivers/twincobr.c
r14260r14261
66        Flying Shark details: Carl-Henrik Skarstedt  &  Magnus Danielsson
77        Flying Shark bootleg info: Ruben Panossian
88
9      Both bootlegs, while sharing a lot of code with the original sets
10      are probably based off undumped versions.
9        Both bootlegs, while sharing a lot of code with the original sets
10        are probably based off undumped versions.
1111
1212
1313Supported games:
src/mame/drivers/multfish.c
r14260r14261
9494  Revision information comes from Igrosoft's website, not all of them can be
9595  tested because some program rom revisions don't seem to be dumped.
9696
97  For sets where the program rom hasn't been verified, the MD5 hash is given
97  For sets where the program rom hasn't been verified, the SHA1 hash is given
9898  but not the CRC32 hash.
9999
100100Banking addresses are likely controlled via a GAL/PAL and was added at some
r14260r14261
14511451   ROM_LOAD( "crazymonkey_m.008", 0x380000, 0x80000, CRC(6fdb6fd5) SHA1(f40916112365de258956ec033aff79aae1f58690) )
14521452ROM_END
14531453
1454ROM_START( crzmon_10 ) // 081027 lottery
1455   ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked
1456   ROM_LOAD( "cm_l_081027.rom", 0x00000, 0x40000, SHA1(11a1523bc0ce5cf43534b34201f59784283693f0) )
14541457
1458   ROM_REGION( 0x400000, "gfx", 0 )
1459   ROM_LOAD( "crazymonkey_loto.001", 0x000000, 0x80000, SHA1(bf953dc53ec85f4841fe7ada7e480520b3bce1d7) )
1460   ROM_LOAD( "crazymonkey_loto.002", 0x100000, 0x80000, SHA1(57db2212b690a8a92034ba4993526c34cbf48c09) )
1461   ROM_LOAD( "crazymonkey_loto.003", 0x200000, 0x80000, SHA1(4551494b883f8076931bb22fd0541b193039dfdc) )
1462   ROM_LOAD( "crazymonkey_loto.004", 0x300000, 0x80000, SHA1(b33d5007b649661a3d811139c2b40d036863343d) )
1463   ROM_LOAD( "crazymonkey_m.005",    0x080000, 0x80000, CRC(9d4d2a94) SHA1(c714e110de628b343dfc7fff23befaa1276056a9) )
1464   ROM_LOAD( "crazymonkey_m.006",    0x180000, 0x80000, CRC(a15f0fee) SHA1(3f06d5a1a41e1335bcc7586a5ea95b9b734155c0) )
1465   ROM_LOAD( "crazymonkey_m.007",    0x280000, 0x80000, CRC(715a2528) SHA1(6c4c72592568ecbaa9518fb7271d2714dd22dbbb) )
1466   ROM_LOAD( "crazymonkey_m.008",    0x380000, 0x80000, CRC(6fdb6fd5) SHA1(f40916112365de258956ec033aff79aae1f58690) )
1467ROM_END
1468
1469ROM_START( crzmon_11 ) // 081113 lottery
1470   ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked
1471   ROM_LOAD( "cm_l_081113.rom", 0x00000, 0x40000, SHA1(7196c301691b47a572cefc090888db550f10998c) )
1472
1473   ROM_REGION( 0x400000, "gfx", 0 )
1474   ROM_LOAD( "crazymonkey_loto.001", 0x000000, 0x80000, SHA1(bf953dc53ec85f4841fe7ada7e480520b3bce1d7) )
1475   ROM_LOAD( "crazymonkey_loto.002", 0x100000, 0x80000, SHA1(57db2212b690a8a92034ba4993526c34cbf48c09) )
1476   ROM_LOAD( "crazymonkey_loto.003", 0x200000, 0x80000, SHA1(4551494b883f8076931bb22fd0541b193039dfdc) )
1477   ROM_LOAD( "crazymonkey_loto.004", 0x300000, 0x80000, SHA1(b33d5007b649661a3d811139c2b40d036863343d) )
1478   ROM_LOAD( "crazymonkey_m.005",    0x080000, 0x80000, CRC(9d4d2a94) SHA1(c714e110de628b343dfc7fff23befaa1276056a9) )
1479   ROM_LOAD( "crazymonkey_m.006",    0x180000, 0x80000, CRC(a15f0fee) SHA1(3f06d5a1a41e1335bcc7586a5ea95b9b734155c0) )
1480   ROM_LOAD( "crazymonkey_m.007",    0x280000, 0x80000, CRC(715a2528) SHA1(6c4c72592568ecbaa9518fb7271d2714dd22dbbb) )
1481   ROM_LOAD( "crazymonkey_m.008",    0x380000, 0x80000, CRC(6fdb6fd5) SHA1(f40916112365de258956ec033aff79aae1f58690) )
1482ROM_END
1483
14551484/*********************************************************
14561485   Fruit Cocktail
14571486
r14260r14261
16401669   ROM_LOAD( "fruitcocktail.008",   0x380000, 0x80000, CRC(8384e4d4) SHA1(83d0bbbd7cca7328a66a69cf802632fd8d22d5b8) )
16411670ROM_END
16421671
1672ROM_START( fcockt_13 ) // 081124 lottery
1673   ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked
1674   ROM_LOAD( "fc_l_081124.rom", 0x00000, 0x40000, SHA1(896252194f32842f784463668e6416cbfe9687a0) )
16431675
1676   ROM_REGION( 0x400000, "gfx", 0 )
1677   ROM_LOAD( "fruitcocktail_loto.001", 0x000000, 0x80000, SHA1(bb2b518dc166836f7cedd4ec443b50687e8927e1) ) /* Only this set is listed as official hashes */
1678   ROM_LOAD( "fruitcocktail_loto.002", 0x100000, 0x80000, SHA1(2621e2644ebec3959c49905c54eb20a83d5a7bd6) )
1679   ROM_LOAD( "fruitcocktail_loto.003", 0x200000, 0x80000, SHA1(ffe11deef6b3b86b4b78e2e4d96c30f820e77971) )
1680   ROM_LOAD( "fruitcocktail_loto.004", 0x300000, 0x80000, SHA1(fa88d113721ce7c0b3418614cd6bb974c20df644) )
1681   ROM_LOAD( "fruitcocktail_m.005",    0x080000, 0x80000, CRC(f0176b60) SHA1(f764aea00ed306a28cacc62f8d2db9cc42895db8) )
1682   ROM_LOAD( "fruitcocktail_m.006",    0x180000, 0x80000, CRC(ef24f255) SHA1(6ff924627c179868a25f180f79cd57182b72d9d4) )
1683   ROM_LOAD( "fruitcocktail_m.007",    0x280000, 0x80000, CRC(20f87a15) SHA1(cb60866a3543668f3592c270b445dee881d78128) )
1684   ROM_LOAD( "fruitcocktail_m.008",    0x380000, 0x80000, CRC(d282e42e) SHA1(eac9c3eaef39b1805f863ade5da47d6274d20a55) )
1685ROM_END
1686
16441687/*********************************************************
16451688   Lucky Haunter
16461689
r14260r14261
17691812   ROM_LOAD( "luckyhaunter_m.008", 0x380000, 0x80000, CRC(1bdf6252) SHA1(7b5ae82a95a744b236e109024d47b526dccf9c14) )
17701813ROM_END
17711814
1815ROM_START( lhaunt_9 ) // 081208 lottery
1816   ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked
1817   ROM_LOAD( "lh_l_081208.rom", 0x00000, 0x40000, SHA1(4962bfc9c3aadd45fdb30bb159aaaed463e4d06b) )
17721818
1819   ROM_REGION( 0x400000, "gfx", 0 )
1820   ROM_LOAD( "luckyhaunter_loto.001",   0x000000, 0x80000, SHA1(961f832654f2cdb844e36a1a9034b87b5e3750f5) )
1821   ROM_LOAD( "luckyhaunter_loto.002",   0x100000, 0x80000, SHA1(20ac980f4f8b502773845d2e1350b960ea707d83) )
1822   ROM_LOAD( "luckyhaunter_loto.003",   0x200000, 0x80000, SHA1(e4cf08104e7717d9706105ad52ade6bf9a782d76) )
1823   ROM_LOAD( "luckyhaunter_loto.004",   0x300000, 0x80000, SHA1(ceb4a5e9912f5d98483cb75e871c925dffbb8e72) )
1824   ROM_LOAD( "luckyhaunter_m.005",      0x080000, 0x80000, CRC(b50c90a3) SHA1(74749f4ffb5b0630631b511fc3230c6e7b50dc3b) )
1825   ROM_LOAD( "luckyhaunter_m.006",      0x180000, 0x80000, CRC(4eaaab64) SHA1(9fed16f8e0308200fd16c4b1e511e1bf6c22ae66) )
1826   ROM_LOAD( "luckyhaunter_m.007",      0x280000, 0x80000, CRC(64d16ba9) SHA1(3b897183d6e0f1256be7657441f234fc72077682) )
1827   ROM_LOAD( "luckyhaunter_m.008",      0x380000, 0x80000, CRC(1bdf6252) SHA1(7b5ae82a95a744b236e109024d47b526dccf9c14) )
1828ROM_END
1829
17731830/*********************************************************
17741831   Garage
17751832
r14260r14261
18831940   ROM_LOAD( "garage_m.008", 0x380000, 0x80000, CRC(90c5416b) SHA1(583bfb517bc2e30d7b7903aa19fc3b4b5188d7d2) )
18841941ROM_END
18851942
1943ROM_START( garage_8 ) // 081229 lottery
1944   ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked
1945   ROM_LOAD( "gg_l_081229.rom", 0x00000, 0x40000, SHA1(6bc22aeb6d8d5ffbc556d9056a25e6506bb8f118) )
18861946
1947   ROM_REGION( 0x400000, "gfx", 0 )
1948   ROM_LOAD( "garage_loto.001", 0x000000, 0x80000, SHA1(50de46c4ae28f70c96da03391446cca0cb91f43b) )
1949   ROM_LOAD( "garage_loto.002", 0x100000, 0x80000, SHA1(df5c1684f1a29f77a3fa79b35a9a0b9371c1b8a3) )
1950   ROM_LOAD( "garage_loto.003", 0x200000, 0x80000, SHA1(47e81aa034c1ac717b1715c521cbaa8ff4d336c5) )
1951   ROM_LOAD( "garage_loto.004", 0x300000, 0x80000, SHA1(71dbcd71ee5bddeda77a012c243981e0960e0c9e) )
1952   ROM_LOAD( "garage_m.005",    0x080000, 0x80000, CRC(5bf85bc5) SHA1(ff9d2b9cbcd2af6f5fda972e387820d830c196a9) )
1953   ROM_LOAD( "garage_m.006",    0x180000, 0x80000, CRC(e5082b26) SHA1(6547409d39dd51498ce8e3f82ff813a8ac3c6522) )
1954   ROM_LOAD( "garage_m.007",    0x280000, 0x80000, CRC(dfa2ceb1) SHA1(ec7de8a8f6e7785a563df973841cc1f1603f79fc) )
1955   ROM_LOAD( "garage_m.008",    0x380000, 0x80000, CRC(90c5416b) SHA1(583bfb517bc2e30d7b7903aa19fc3b4b5188d7d2) )
1956ROM_END
18871957
18881958/*********************************************************
18891959   Rock Climber
r14260r14261
24992569   ROM_LOAD( "fruitcocktail2_old.008", 0x380000, 0x80000, CRC(a27c49a2) SHA1(7c9ee0e01f76ca3ab6716579f5dde7036050970b) )
25002570ROM_END
25012571
2572ROM_START( fcockt2_2 ) // 080904
2573   ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked
2574   ROM_LOAD( "fc2_080904.rom", 0x00000, 0x40000, SHA1(d8f1034753274aed874ee552ab78e660ddaba939) )
25022575
2576   ROM_REGION( 0x400000, "gfx", 0 )
2577   ROM_LOAD( "fruitcocktail2.001",  0x000000, 0x80000, CRC(d1b9416d) SHA1(4d3cb0a6dbcf02bbd20d5c43df358882b2ad794d) )
2578   ROM_LOAD( "fruitcocktail2.002",  0x100000, 0x80000, CRC(69236be1) SHA1(9a2e6c8f279714f79a606c0b118b6bf1d8442cda) )
2579   ROM_LOAD( "fruitcocktail2.003",  0x200000, 0x80000, CRC(29aade8c) SHA1(bef42f8a25c90e3a1cccd13872a10eb8b2b2e276) )
2580   ROM_LOAD( "fruitcocktail2.004",  0x300000, 0x80000, CRC(4b9646e7) SHA1(26548a018401f4e07383eb145f8f0847677f3272) )
2581   ROM_LOAD( "fruitcocktail2_old.005", 0x080000, 0x80000, CRC(6b9e6b43) SHA1(c7fb17e91ec62b22da42f110d68b4f37e39de3ce) )
2582   ROM_LOAD( "fruitcocktail2_old.006", 0x180000, 0x80000, CRC(2c9f712e) SHA1(c3118154eafca74b66b3325a2e07c85f86f3544d) )
2583   ROM_LOAD( "fruitcocktail2_old.007", 0x280000, 0x80000, CRC(85ba9a86) SHA1(aa9b6170135e9e420509e8f7c1702c9896bc5d8e) )
2584   ROM_LOAD( "fruitcocktail2_old.008", 0x380000, 0x80000, CRC(a27c49a2) SHA1(7c9ee0e01f76ca3ab6716579f5dde7036050970b) )
2585ROM_END
2586
2587ROM_START( fcockt2_3 ) // 080909
2588   ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked
2589   ROM_LOAD( "fc2_m_080909.rom", 0x00000, 0x40000, CRC(6de0353c) SHA1(7a827a172cdd593f8b37a7737304a5a2e145d52d) )
2590
2591   ROM_REGION( 0x400000, "gfx", 0 )
2592   ROM_LOAD( "fruitcocktail2.001",  0x000000, 0x80000, CRC(d1b9416d) SHA1(4d3cb0a6dbcf02bbd20d5c43df358882b2ad794d) )
2593   ROM_LOAD( "fruitcocktail2.002",  0x100000, 0x80000, CRC(69236be1) SHA1(9a2e6c8f279714f79a606c0b118b6bf1d8442cda) )
2594   ROM_LOAD( "fruitcocktail2.003",  0x200000, 0x80000, CRC(29aade8c) SHA1(bef42f8a25c90e3a1cccd13872a10eb8b2b2e276) )
2595   ROM_LOAD( "fruitcocktail2.004",  0x300000, 0x80000, CRC(4b9646e7) SHA1(26548a018401f4e07383eb145f8f0847677f3272) )
2596   ROM_LOAD( "fruitcocktail2_old.005", 0x080000, 0x80000, CRC(6b9e6b43) SHA1(c7fb17e91ec62b22da42f110d68b4f37e39de3ce) )
2597   ROM_LOAD( "fruitcocktail2_old.006", 0x180000, 0x80000, CRC(2c9f712e) SHA1(c3118154eafca74b66b3325a2e07c85f86f3544d) )
2598   ROM_LOAD( "fruitcocktail2_old.007", 0x280000, 0x80000, CRC(85ba9a86) SHA1(aa9b6170135e9e420509e8f7c1702c9896bc5d8e) )
2599   ROM_LOAD( "fruitcocktail2_old.008", 0x380000, 0x80000, CRC(a27c49a2) SHA1(7c9ee0e01f76ca3ab6716579f5dde7036050970b) )
2600ROM_END
2601
2602ROM_START( fcockt2_4 ) // 081105
2603   ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked
2604   ROM_LOAD( "fc2_m_081105.rom", 0x00000, 0x40000,  CRC(2cc5313d) SHA1(b5e55acbb5936f49130758947ae22d1847800333) )
2605
2606   ROM_REGION( 0x400000, "gfx", 0 )
2607   ROM_LOAD( "fruitcocktail2.001", 0x000000, 0x80000, CRC(d1b9416d) SHA1(4d3cb0a6dbcf02bbd20d5c43df358882b2ad794d) )
2608   ROM_LOAD( "fruitcocktail2.002", 0x100000, 0x80000, CRC(69236be1) SHA1(9a2e6c8f279714f79a606c0b118b6bf1d8442cda) )
2609   ROM_LOAD( "fruitcocktail2.003", 0x200000, 0x80000, CRC(29aade8c) SHA1(bef42f8a25c90e3a1cccd13872a10eb8b2b2e276) )
2610   ROM_LOAD( "fruitcocktail2.004", 0x300000, 0x80000, CRC(4b9646e7) SHA1(26548a018401f4e07383eb145f8f0847677f3272) )
2611   ROM_LOAD( "fruitcocktail2.005", 0x080000, 0x80000, CRC(3fc13d72) SHA1(ba0727138ef03d576d190cbce04b9eb0bba88a9a) )
2612   ROM_LOAD( "fruitcocktail2.006", 0x180000, 0x80000, CRC(8fc75fd7) SHA1(3b7cd8a3e04ca9d4494b37c801e21d1293f094e8) )
2613   ROM_LOAD( "fruitcocktail2.007", 0x280000, 0x80000, CRC(d37fcc0f) SHA1(57c2ea5dc747f16e2233305f2c73cb4b632aae2c) )
2614   ROM_LOAD( "fruitcocktail2.008", 0x380000, 0x80000, CRC(e3a9442c) SHA1(cbaba182e858b0f158756118e5da873e3ddfc0b9) )
2615ROM_END
2616
2617ROM_START( fcockt2_5 ) // 081106
2618   ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked
2619   ROM_LOAD( "fc2_081106.rom", 0x00000, 0x40000, CRC(d23347b3) SHA1(2d7d00af182c61fa166a8f3fd6fd830cf5eb78c6) )
2620
2621   ROM_REGION( 0x400000, "gfx", 0 )
2622   ROM_LOAD( "fruitcocktail2.001", 0x000000, 0x80000, CRC(d1b9416d) SHA1(4d3cb0a6dbcf02bbd20d5c43df358882b2ad794d) )
2623   ROM_LOAD( "fruitcocktail2.002", 0x100000, 0x80000, CRC(69236be1) SHA1(9a2e6c8f279714f79a606c0b118b6bf1d8442cda) )
2624   ROM_LOAD( "fruitcocktail2.003", 0x200000, 0x80000, CRC(29aade8c) SHA1(bef42f8a25c90e3a1cccd13872a10eb8b2b2e276) )
2625   ROM_LOAD( "fruitcocktail2.004", 0x300000, 0x80000, CRC(4b9646e7) SHA1(26548a018401f4e07383eb145f8f0847677f3272) )
2626   ROM_LOAD( "fruitcocktail2.005", 0x080000, 0x80000, CRC(3fc13d72) SHA1(ba0727138ef03d576d190cbce04b9eb0bba88a9a) )
2627   ROM_LOAD( "fruitcocktail2.006", 0x180000, 0x80000, CRC(8fc75fd7) SHA1(3b7cd8a3e04ca9d4494b37c801e21d1293f094e8) )
2628   ROM_LOAD( "fruitcocktail2.007", 0x280000, 0x80000, CRC(d37fcc0f) SHA1(57c2ea5dc747f16e2233305f2c73cb4b632aae2c) )
2629   ROM_LOAD( "fruitcocktail2.008", 0x380000, 0x80000, CRC(e3a9442c) SHA1(cbaba182e858b0f158756118e5da873e3ddfc0b9) )
2630ROM_END
2631
25032632/*********************************************************
25042633   Crazy Monkey 2
25052634**********************************************************/
r14260r14261
25612690*/
25622691
25632692
2564#define mfish_parent mfish_3
2693#define mfish_parent mfish_13
25652694  GAME( 2002, goldfish,    mfish_parent,    multfish, multfish,  0,        ROT0, "Igrosoft", "Gold Fish (020903, prototype)", GAME_SUPPORTS_SAVE ) /* World */
25662695//GAME( 2002, mfish,       mfish_parent,    multfish, multfish,  0,        ROT0, "Igrosoft", "Multi Fish (021120)", GAME_SUPPORTS_SAVE ) /* World */
25672696//GAME( 2002, mfish_2,     mfish_parent,    multfish, multfish,  0,        ROT0, "Igrosoft", "Multi Fish (021121)", GAME_SUPPORTS_SAVE ) /* World */
2568  GAME( 2002, mfish_3,     0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Multi Fish (021124)", GAME_SUPPORTS_SAVE ) /* World */
2697  GAME( 2002, mfish_3,     mfish_parent,    multfish, multfish,  0,        ROT0, "Igrosoft", "Multi Fish (021124)", GAME_SUPPORTS_SAVE ) /* World */
25692698//GAME( 2002, mfish_4,     mfish_parent,    multfish, multfish,  0,        ROT0, "Igrosoft", "Multi Fish (021219)", GAME_SUPPORTS_SAVE ) /* World */
25702699//GAME( 2002, mfish_5,     mfish_parent,    multfish, multfish,  0,        ROT0, "Igrosoft", "Multi Fish (021227)", GAME_SUPPORTS_SAVE ) /* World */
25712700  GAME( 2002, mfish_6,     mfish_parent,    multfish, multfish,  0,        ROT0, "Igrosoft", "Multi Fish (030124)", GAME_SUPPORTS_SAVE ) /* World */
r14260r14261
25752704//GAME( 2002, mfish_10,    mfish_parent,    multfish, multfish,  0,        ROT0, "Igrosoft", "Multi Fish (031117)", GAME_SUPPORTS_SAVE ) /* World */
25762705  GAME( 2002, mfish_11,    mfish_parent,    multfish, multfish,  0,        ROT0, "Igrosoft", "Multi Fish (031124)", GAME_SUPPORTS_SAVE ) /* World */
25772706  GAME( 2002, mfish_12,    mfish_parent,    multfish, multfish,  0,        ROT0, "Igrosoft", "Multi Fish (040308)", GAME_SUPPORTS_SAVE ) /* World */
2578  GAME( 2002, mfish_13,    mfish_parent,    multfish, multfish,  0,        ROT0, "Igrosoft", "Multi Fish (040316)", GAME_SUPPORTS_SAVE ) /* World */
2707  GAME( 2002, mfish_13,    0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Multi Fish (040316)", GAME_SUPPORTS_SAVE ) /* World */
25792708
2580#define crzmon_parent crzmon_5
2709#define crzmon_parent crzmon_8
25812710//GAME( 2003, crzmon,      crzmon_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Crazy Monkey (030217 World)", GAME_SUPPORTS_SAVE ) /* World */
25822711//GAME( 2003, crzmon_2,    crzmon_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Crazy Monkey (030225 World)", GAME_SUPPORTS_SAVE ) /* World */
25832712//GAME( 2003, crzmon_3,    crzmon_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Crazy Monkey (030227 World)", GAME_SUPPORTS_SAVE ) /* World */
25842713//GAME( 2003, crzmon_4,    crzmon_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Crazy Monkey (030404 World)", GAME_SUPPORTS_SAVE ) /* World */
2585  GAME( 2003, crzmon_5,    0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Crazy Monkey (030421 World)", GAME_SUPPORTS_SAVE ) /* World */
2714  GAME( 2003, crzmon_5,    crzmon_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Crazy Monkey (030421 World)", GAME_SUPPORTS_SAVE ) /* World */
25862715//GAME( 2003, crzmon_6,    crzmon_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Crazy Monkey (031016 World)", GAME_SUPPORTS_SAVE ) /* World */
25872716  GAME( 2003, crzmon_7,    crzmon_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Crazy Monkey (031110 World)", GAME_SUPPORTS_SAVE ) /* World */
2588  GAME( 2003, crzmon_8,    crzmon_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Crazy Monkey (050120 World)", GAME_SUPPORTS_SAVE ) /* World */
2717  GAME( 2003, crzmon_8,    0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Crazy Monkey (050120 World)", GAME_SUPPORTS_SAVE ) /* World */
25892718  GAME( 2003, crzmon_9,    crzmon_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Crazy Monkey (070315 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
2719//GAME( 2003, crzmon_10,   crzmon_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Crazy Monkey (081027 Lottery)", GAME_SUPPORTS_SAVE ) /* Lottery */
2720//GAME( 2003, crzmon_11,   crzmon_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Crazy Monkey (081113 Lottery)", GAME_SUPPORTS_SAVE ) /* Lottery */
25902721
25912722
2592#define fcockt_parent fcockt_3
2723#define fcockt_parent fcockt_8
25932724//GAME( 2003, fcockt,      fcockt_parent    multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail (030505 World)", GAME_SUPPORTS_SAVE ) /* World */
25942725//GAME( 2003, fcockt_2,    fcockt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail (030512 World)", GAME_SUPPORTS_SAVE ) /* World */
2595  GAME( 2003, fcockt_3,    0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail (030623 World)", GAME_SUPPORTS_SAVE ) /* World */
2726  GAME( 2003, fcockt_3,    fcockt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail (030623 World)", GAME_SUPPORTS_SAVE ) /* World */
25962727//GAME( 2003, fcockt_4,    fcockt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail (031028 World)", GAME_SUPPORTS_SAVE ) /* World */
25972728  GAME( 2003, fcockt_5,    fcockt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail (031111 World)", GAME_SUPPORTS_SAVE ) /* World */
25982729  GAME( 2003, fcockt_6,    fcockt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail (040216 World)", GAME_SUPPORTS_SAVE ) /* World */
25992730  GAME( 2003, fcockt_7,    fcockt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail (050118 World)", GAME_SUPPORTS_SAVE ) /* World */
2600  GAME( 2003, fcockt_8,    fcockt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail (060111 World)", GAME_SUPPORTS_SAVE ) /* World */
2731  GAME( 2003, fcockt_8,    0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail (060111 World)", GAME_SUPPORTS_SAVE ) /* World */
26012732  GAME( 2003, fcockt_9,    fcockt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail (070305 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
26022733  GAME( 2003, fcockt_10,   fcockt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail (070517 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
26032734  GAME( 2003, fcockt_11,   fcockt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail (070822 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
26042735  GAME( 2003, fcockt_12,   fcockt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail (070911 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
2736//GAME( 2003, fcockt_13,   fcockt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail (081124 Lottery)", GAME_SUPPORTS_SAVE ) /* Lottery */
26052737
2606#define lhaunt_parent lhaunt_2
2738#define lhaunt_parent lhaunt_6
26072739//GAME( 2003, lhaunt,      lhaunt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Lucky Haunter (030707 World)", GAME_SUPPORTS_SAVE ) /* World */
2608  GAME( 2003, lhaunt_2,    0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Lucky Haunter (030804 World)", GAME_SUPPORTS_SAVE ) /* World */
2740  GAME( 2003, lhaunt_2,    lhaunt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Lucky Haunter (030804 World)", GAME_SUPPORTS_SAVE ) /* World */
26092741//GAME( 2003, lhaunt_3,    lhaunt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Lucky Haunter (031027 World)", GAME_SUPPORTS_SAVE ) /* World */
26102742  GAME( 2003, lhaunt_4,    lhaunt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Lucky Haunter (031111 World)", GAME_SUPPORTS_SAVE ) /* World */
26112743  GAME( 2003, lhaunt_5,    lhaunt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Lucky Haunter (040216 World)", GAME_SUPPORTS_SAVE ) /* World */
2612  GAME( 2003, lhaunt_6,    lhaunt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Lucky Haunter (040825 World)", GAME_SUPPORTS_SAVE ) /* World */
2744  GAME( 2003, lhaunt_6,    0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Lucky Haunter (040825 World)", GAME_SUPPORTS_SAVE ) /* World */
26132745  GAME( 2003, lhaunt_7,    lhaunt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Lucky Haunter (070402 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
26142746  GAME( 2003, lhaunt_8,    lhaunt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Lucky Haunter (070604 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
2747//GAME( 2003, lhaunt_9,    lhaunt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Lucky Haunter (081208 Lottery)", GAME_SUPPORTS_SAVE ) /* Lottery */
26152748
26162749
2617#define rollfr_parent rollfr_2
2750#define rollfr_parent rollfr_4
26182751//GAME( 2003, rollfr,      rollfr_parent,   rollfr,   rollfr,    0,        ROT0, "Igrosoft", "Roll Fruit (030821)", GAME_SUPPORTS_SAVE ) /* World */
2619  GAME( 2003, rollfr_2,    0,               rollfr,   rollfr,    0,        ROT0, "Igrosoft", "Roll Fruit (040318)", GAME_SUPPORTS_SAVE ) /* World */
2752  GAME( 2003, rollfr_2,    rollfr_parent,   rollfr,   rollfr,    0,        ROT0, "Igrosoft", "Roll Fruit (040318)", GAME_SUPPORTS_SAVE ) /* World */
26202753  GAME( 2003, rollfr_3,    rollfr_parent,   rollfr,   rollfr,    0,        ROT0, "Igrosoft", "Roll Fruit (080327)", GAME_SUPPORTS_SAVE ) /* World */
2621  GAME( 2003, rollfr_4,    rollfr_parent,   rollfr,   rollfr,    0,        ROT0, "Igrosoft", "Roll Fruit (080331)", GAME_SUPPORTS_SAVE ) /* World */
2754  GAME( 2003, rollfr_4,    0,               rollfr,   rollfr,    0,        ROT0, "Igrosoft", "Roll Fruit (080331)", GAME_SUPPORTS_SAVE ) /* World */
26222755
2623#define garage_parent garage_4
2756#define garage_parent garage_5
26242757//GAME( 2004, garage,      garage_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Garage (040122 World)", GAME_SUPPORTS_SAVE ) /* World */
26252758//GAME( 2004, garage_2,    garage_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Garage (040123 World)", GAME_SUPPORTS_SAVE ) /* World */
26262759//GAME( 2004, garage_3,    garage_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Garage (040216 World)", GAME_SUPPORTS_SAVE ) /* World */
2627  GAME( 2004, garage_4,    0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Garage (040219 World)", GAME_SUPPORTS_SAVE ) /* World */
2628  GAME( 2004, garage_5,    garage_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Garage (050311 World)", GAME_SUPPORTS_SAVE ) /* World */
2760  GAME( 2004, garage_4,    garage_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Garage (040219 World)", GAME_SUPPORTS_SAVE ) /* World */
2761  GAME( 2004, garage_5,    0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Garage (050311 World)", GAME_SUPPORTS_SAVE ) /* World */
26292762  GAME( 2004, garage_6,    garage_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Garage (070213 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
26302763  GAME( 2004, garage_7,    garage_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Garage (070329 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
2764//GAME( 2004, garage_8,    garage_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Garage (081229 Lottery)", GAME_SUPPORTS_SAVE ) /* Lottery */
26312765
26322766
2633#define rclimb_parent rclimb
2634  GAME( 2004, rclimb,      0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Rock Climber (040815 World)", GAME_SUPPORTS_SAVE ) /* World */
2767#define rclimb_parent rclimb_3
2768  GAME( 2004, rclimb,      rclimb_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Rock Climber (040815 World)", GAME_SUPPORTS_SAVE ) /* World */
26352769//GAME( 2004, rclimb_2,    rclimb_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Rock Climber (040823 World)", GAME_SUPPORTS_SAVE ) /* World */
2636  GAME( 2004, rclimb_3,    rclimb_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Rock Climber (040827 World)", GAME_SUPPORTS_SAVE ) /* World */
2770  GAME( 2004, rclimb_3,    0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Rock Climber (040827 World)", GAME_SUPPORTS_SAVE ) /* World */
26372771  GAME( 2004, rclimb_4,    rclimb_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Rock Climber (070322 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
26382772  GAME( 2004, rclimb_5,    rclimb_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Rock Climber (070621 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
26392773
r14260r14261
26422776  GAME( 2004, sweetl,      0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Sweet Life (041220 World)", GAME_SUPPORTS_SAVE ) /* World */
26432777  GAME( 2004, sweetl_2,    sweetl_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Sweet Life (070412 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
26442778
2645#define resdnt_parent resdnt
2646  GAME( 2004, resdnt,      0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Resident (040415 World)", GAME_SUPPORTS_SAVE ) /* World */
2647  GAME( 2004, resdnt_2,    resdnt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Resident (040513 World)", GAME_SUPPORTS_SAVE ) /* World */
2779#define resdnt_parent resdnt_2
2780  GAME( 2004, resdnt,      resdnt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Resident (040415 World)", GAME_SUPPORTS_SAVE ) /* World */
2781  GAME( 2004, resdnt_2,    0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Resident (040513 World)", GAME_SUPPORTS_SAVE ) /* World */
26482782  GAME( 2004, resdnt_3,    resdnt_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Resident (070222 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
26492783
26502784
r14260r14261
26522786  GAME( 2005, island,      0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Island (050713 World)", GAME_SUPPORTS_SAVE ) /* World */
26532787  GAME( 2005, island_2,    island_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Island (070409 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
26542788
2655#define pirate_parent pirate_2
2789#define pirate_parent pirate_3
26562790//GAME( 2005, pirate,      pirate_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Pirate (051229 World)", GAME_SUPPORTS_SAVE ) /* World */
2657  GAME( 2005, pirate_2,    0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Pirate (060210 World)", GAME_SUPPORTS_SAVE ) /* World */
2658  GAME( 2005, pirate_3,    pirate_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Pirate (060803 World)", GAME_SUPPORTS_SAVE ) /* World */
2791  GAME( 2005, pirate_2,    pirate_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Pirate (060210 World)", GAME_SUPPORTS_SAVE ) /* World */
2792  GAME( 2005, pirate_3,    0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Pirate (060803 World)", GAME_SUPPORTS_SAVE ) /* World */
26592793  GAME( 2005, pirate_4,    pirate_parent,   multfish, multfish,  0,        ROT0, "Igrosoft", "Pirate (070412 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
26602794
26612795#define island2_parent island2
r14260r14261
26702804  GAME( 2006, pirate2_2,   pirate2_parent,  multfish, multfish,  0,        ROT0, "Igrosoft", "Pirate 2 (070126 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
26712805
26722806
2673#define keks_parent keks
2674  GAME( 2006, keks,        0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Keks (060328 World)", GAME_SUPPORTS_SAVE ) /* World */
2675  GAME( 2006, keks_2,      keks_parent,     multfish, multfish,  0,        ROT0, "Igrosoft", "Keks (060403 World)", GAME_SUPPORTS_SAVE ) /* World */
2807#define keks_parent keks_2
2808  GAME( 2006, keks,        keks_parent,     multfish, multfish,  0,        ROT0, "Igrosoft", "Keks (060328 World)", GAME_SUPPORTS_SAVE ) /* World */
2809  GAME( 2006, keks_2,      0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Keks (060403 World)", GAME_SUPPORTS_SAVE ) /* World */
26762810  GAME( 2006, keks_3,      keks_parent,     multfish, multfish,  0,        ROT0, "Igrosoft", "Keks (070119 Russia)", GAME_SUPPORTS_SAVE )  /* Russia */
26772811
26782812
2679#define gnome_parent gnome
2680  GAME( 2007, gnome,       0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Gnome (070906 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
2813#define gnome_parent gnome_3
2814  GAME( 2007, gnome,       gnome_parent,    multfish, multfish,  0,        ROT0, "Igrosoft", "Gnome (070906 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
26812815  GAME( 2007, gnome_2,     gnome_parent,    multfish, multfish,  0,        ROT0, "Igrosoft", "Gnome (071115 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
2682  GAME( 2007, gnome_3,     gnome_parent,    multfish, multfish,  0,        ROT0, "Igrosoft", "Gnome (080303 World)", GAME_SUPPORTS_SAVE ) /* World */
2816  GAME( 2007, gnome_3,     0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Gnome (080303 World)", GAME_SUPPORTS_SAVE ) /* World */
26832817
26842818
26852819#define sweetl2_parent sweetl2
r14260r14261
26882822
26892823#define fcockt2_parent fcockt2
26902824  GAME( 2008, fcockt2,     0,               multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail 2 (080707 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
2825//GAME( 2008, fcockt2_2,   fcockt2_parent,  multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail 2 (080904 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
2826  GAME( 2008, fcockt2_3,   fcockt2_parent,  multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail 2 (080909 World)", GAME_SUPPORTS_SAVE ) /* World */
2827  GAME( 2008, fcockt2_4,   fcockt2_parent,  multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail 2 (081105 World)", GAME_SUPPORTS_SAVE ) /* World */
2828  GAME( 2008, fcockt2_5,   fcockt2_parent,  multfish, multfish,  0,        ROT0, "Igrosoft", "Fruit Cocktail 2 (081106 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */
26912829
26922830
26932831
r14260r14261
42334371   ROM_LOAD( "fruitcocktail2_old.008", 0x380000, 0x80000, CRC(a27c49a2) SHA1(7c9ee0e01f76ca3ab6716579f5dde7036050970b) )
42344372ROM_END
42354373
4374ROM_START( fcockt2_4a ) // 081105 bank F9
4375   ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked
4376   ROM_LOAD( "bootleg_fc2_m_081105a.rom", 0x00000, 0x40000,  CRC(411ad706) SHA1(4d29a6b1927241efdcdb3224b9ebe0eb6af92533) ) /* Not officially listed on Igrosoft's web site hash page */
42364377
4378   ROM_REGION( 0x400000, "gfx", 0 )
4379   ROM_LOAD( "fruitcocktail2.001", 0x000000, 0x80000, CRC(d1b9416d) SHA1(4d3cb0a6dbcf02bbd20d5c43df358882b2ad794d) )
4380   ROM_LOAD( "fruitcocktail2.002", 0x100000, 0x80000, CRC(69236be1) SHA1(9a2e6c8f279714f79a606c0b118b6bf1d8442cda) )
4381   ROM_LOAD( "fruitcocktail2.003", 0x200000, 0x80000, CRC(29aade8c) SHA1(bef42f8a25c90e3a1cccd13872a10eb8b2b2e276) )
4382   ROM_LOAD( "fruitcocktail2.004", 0x300000, 0x80000, CRC(4b9646e7) SHA1(26548a018401f4e07383eb145f8f0847677f3272) )
4383   ROM_LOAD( "fruitcocktail2.005", 0x080000, 0x80000, CRC(3fc13d72) SHA1(ba0727138ef03d576d190cbce04b9eb0bba88a9a) )
4384   ROM_LOAD( "fruitcocktail2.006", 0x180000, 0x80000, CRC(8fc75fd7) SHA1(3b7cd8a3e04ca9d4494b37c801e21d1293f094e8) )
4385   ROM_LOAD( "fruitcocktail2.007", 0x280000, 0x80000, CRC(d37fcc0f) SHA1(57c2ea5dc747f16e2233305f2c73cb4b632aae2c) )
4386   ROM_LOAD( "fruitcocktail2.008", 0x380000, 0x80000, CRC(e3a9442c) SHA1(cbaba182e858b0f158756118e5da873e3ddfc0b9) )
4387ROM_END
4388
4389ROM_START( fcockt2_4b ) // 081105 bank F9, no credit limit, "MaxVin" signature
4390   ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked
4391   ROM_LOAD( "bootleg_fc2_m_081105_cm.rom", 0x00000, 0x40000,  CRC(f0c702b9) SHA1(89121ddd325aac567ebd443eb443c4db0549236c) ) /* Not officially listed on Igrosoft's web site hash page */
4392
4393   ROM_REGION( 0x400000, "gfx", 0 )
4394   ROM_LOAD( "fruitcocktail2.001", 0x000000, 0x80000, CRC(d1b9416d) SHA1(4d3cb0a6dbcf02bbd20d5c43df358882b2ad794d) )
4395   ROM_LOAD( "fruitcocktail2.002", 0x100000, 0x80000, CRC(69236be1) SHA1(9a2e6c8f279714f79a606c0b118b6bf1d8442cda) )
4396   ROM_LOAD( "fruitcocktail2.003", 0x200000, 0x80000, CRC(29aade8c) SHA1(bef42f8a25c90e3a1cccd13872a10eb8b2b2e276) )
4397   ROM_LOAD( "fruitcocktail2.004", 0x300000, 0x80000, CRC(4b9646e7) SHA1(26548a018401f4e07383eb145f8f0847677f3272) )
4398   ROM_LOAD( "fruitcocktail2.005", 0x080000, 0x80000, CRC(3fc13d72) SHA1(ba0727138ef03d576d190cbce04b9eb0bba88a9a) )
4399   ROM_LOAD( "fruitcocktail2.006", 0x180000, 0x80000, CRC(8fc75fd7) SHA1(3b7cd8a3e04ca9d4494b37c801e21d1293f094e8) )
4400   ROM_LOAD( "fruitcocktail2.007", 0x280000, 0x80000, CRC(d37fcc0f) SHA1(57c2ea5dc747f16e2233305f2c73cb4b632aae2c) )
4401   ROM_LOAD( "fruitcocktail2.008", 0x380000, 0x80000, CRC(e3a9442c) SHA1(cbaba182e858b0f158756118e5da873e3ddfc0b9) )
4402ROM_END
4403
4404ROM_START( fcockt2_4c ) // 081105 custom alteras, modified graphics, bank F9, many texts changed, changed version text to "VIDEO GAME-1 FR02"
4405   ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked
4406   ROM_LOAD( "bootleg_fc2_m_081105b.rom", 0x00000, 0x40000,  CRC(b627f7d6) SHA1(0bcdb1cd808055d0a9e965f2c6ff522ac3fe6949) ) /* Not officially listed on Igrosoft's web site hash page */
4407
4408   ROM_REGION( 0x400000, "gfx", 0 )
4409   ROM_LOAD( "bootleg_1b", 0x000000, 0x80000, CRC(68b62355) SHA1(387da330fddaa685cb7aca32bf861e44d5cdbe58) )
4410   ROM_LOAD( "bootleg_2b", 0x100000, 0x80000, CRC(d36e8704) SHA1(80a84a24b3a43a0110a00ed3b01c7156218ccbf3) )
4411   ROM_LOAD( "bootleg_3b", 0x200000, 0x80000, CRC(57d87c5b) SHA1(6bc28e5c34a7e76d0e601b970ab922e5ad28ae85) )
4412   ROM_LOAD( "bootleg_4b", 0x300000, 0x80000, CRC(3de30bab) SHA1(c4c4c549ad980f562238054cd0e3ef6b0977f7b7) )
4413   ROM_LOAD( "bootleg_5b", 0x080000, 0x80000, CRC(b47d65aa) SHA1(71c642ea7887ea35c6d7d985502082d2424c035a) )
4414   ROM_LOAD( "bootleg_6b", 0x180000, 0x80000, CRC(aa982f4e) SHA1(edf75d4ddd60532ac0ca2e17e3fd9004aa768973) )
4415   ROM_LOAD( "bootleg_7b", 0x280000, 0x80000, CRC(b9b1ead7) SHA1(111e505fce8fe75043ff7cc5dc68e81ce4f98d06) )
4416   ROM_LOAD( "bootleg_8b", 0x380000, 0x80000, CRC(8e49d1c1) SHA1(4735503335cf499895d1b2d9a405be50f21a2d68) )
4417ROM_END
4418
4419ROM_START( fcockt2_4d ) // 081105 bank F9, no credit limit, "MaxVin" signature, payout percentage 70%
4420   ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked
4421   ROM_LOAD( "bootleg_fc2_m_081105c.rom", 0x00000, 0x40000,  CRC(b6d88fcc) SHA1(337a59accfbc229be05aff84ba70fc135fde09de) ) /* Not officially listed on Igrosoft's web site hash page */
4422
4423   ROM_REGION( 0x400000, "gfx", 0 )
4424   ROM_LOAD( "fruitcocktail2.001", 0x000000, 0x80000, CRC(d1b9416d) SHA1(4d3cb0a6dbcf02bbd20d5c43df358882b2ad794d) )
4425   ROM_LOAD( "fruitcocktail2.002", 0x100000, 0x80000, CRC(69236be1) SHA1(9a2e6c8f279714f79a606c0b118b6bf1d8442cda) )
4426   ROM_LOAD( "fruitcocktail2.003", 0x200000, 0x80000, CRC(29aade8c) SHA1(bef42f8a25c90e3a1cccd13872a10eb8b2b2e276) )
4427   ROM_LOAD( "fruitcocktail2.004", 0x300000, 0x80000, CRC(4b9646e7) SHA1(26548a018401f4e07383eb145f8f0847677f3272) )
4428   ROM_LOAD( "fruitcocktail2.005", 0x080000, 0x80000, CRC(3fc13d72) SHA1(ba0727138ef03d576d190cbce04b9eb0bba88a9a) )
4429   ROM_LOAD( "fruitcocktail2.006", 0x180000, 0x80000, CRC(8fc75fd7) SHA1(3b7cd8a3e04ca9d4494b37c801e21d1293f094e8) )
4430   ROM_LOAD( "fruitcocktail2.007", 0x280000, 0x80000, CRC(d37fcc0f) SHA1(57c2ea5dc747f16e2233305f2c73cb4b632aae2c) )
4431   ROM_LOAD( "fruitcocktail2.008", 0x380000, 0x80000, CRC(e3a9442c) SHA1(cbaba182e858b0f158756118e5da873e3ddfc0b9) )
4432ROM_END
4433
4434ROM_START( fcockt2_4e ) // 081105 bank F9, modified graphics, changed version text to "MDS_is_the_best_ LOTTOGAME (I)"
4435   ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked
4436   ROM_LOAD( "bootleg_fc2_m_081105d.rom", 0x00000, 0x40000,  CRC(37b1a159) SHA1(52c8e825ebb85a59803a6d14c766892e56a72c9e) ) /* Not officially listed on Igrosoft's web site hash page */
4437
4438   ROM_REGION( 0x400000, "gfx", 0 )
4439   ROM_LOAD( "bootleg_1c", 0x000000, 0x80000, CRC(9fe02e19) SHA1(dec48a0990d2341ae86a3a4acd5972844b93fccb) )
4440   ROM_LOAD( "bootleg_2c", 0x100000, 0x80000, CRC(734bd656) SHA1(e44124fd60675cfc8319bca5bbd90f99d73f4896) )
4441   ROM_LOAD( "bootleg_3c", 0x200000, 0x80000, CRC(36ff74dc) SHA1(7df93e4fa1c240adf33ef910efb8397abfa1a106) )
4442   ROM_LOAD( "bootleg_4c", 0x300000, 0x80000, CRC(b88356c9) SHA1(fbdcfc0d30f2a9b1364863d7a06b32f94113e865) )
4443   ROM_LOAD( "bootleg_5c", 0x080000, 0x80000, CRC(14053302) SHA1(adf0a1493074d16797e8d19dc98f2d5d2cb26e43) )
4444   ROM_LOAD( "bootleg_6c", 0x180000, 0x80000, CRC(21a91970) SHA1(6f4832c743469171cd0efe4554f243c4bed21e88) )
4445   ROM_LOAD( "bootleg_7c", 0x280000, 0x80000, CRC(3a8a7340) SHA1(9408791686926dd13216352ffcb04ad9f8954b3e) )
4446   ROM_LOAD( "bootleg_8c", 0x380000, 0x80000, CRC(fbf48ebd) SHA1(04917e613d9a3f0caeab71c78b9f77c4b5b84988) )
4447ROM_END
4448
4449ROM_START( fcockt2_4f ) // 081105 custom alteras, modified graphics, bank F9, many texts changed, changed version text to "LOTOS FR02"
4450   ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked
4451   ROM_LOAD( "bootleg_fc2_m_081105f.rom", 0x00000, 0x40000,  CRC(b4fa0663) SHA1(aee3cb980fc7d9fbba1a4e9fe80e6be8df58bb3b) ) /* Not officially listed on Igrosoft's web site hash page */
4452
4453   ROM_REGION( 0x400000, "gfx", 0 )
4454   ROM_LOAD( "bootleg_1e", 0x000000, 0x80000, CRC(3c72a5e2) SHA1(15e07d64a0d633ccdadea9eb55556e6aa239c0e5) )
4455   ROM_LOAD( "bootleg_2e", 0x100000, 0x80000, CRC(017a61f7) SHA1(023cec2be1cfe885c562415d18fc32edf3c61346) )
4456   ROM_LOAD( "bootleg_3e", 0x200000, 0x80000, CRC(8ea5532f) SHA1(498991cfb7a92c3a6342e824a310c7edc5577cff) )
4457   ROM_LOAD( "bootleg_4e", 0x300000, 0x80000, CRC(c879025f) SHA1(93f77787ded2a4353320dcb9d4d1b1f5dd7a3b13) )
4458   ROM_LOAD( "bootleg_5b", 0x080000, 0x80000, CRC(b47d65aa) SHA1(71c642ea7887ea35c6d7d985502082d2424c035a) )
4459   ROM_LOAD( "bootleg_6b", 0x180000, 0x80000, CRC(aa982f4e) SHA1(edf75d4ddd60532ac0ca2e17e3fd9004aa768973) )
4460   ROM_LOAD( "bootleg_7b", 0x280000, 0x80000, CRC(b9b1ead7) SHA1(111e505fce8fe75043ff7cc5dc68e81ce4f98d06) )
4461   ROM_LOAD( "bootleg_8b", 0x380000, 0x80000, CRC(8e49d1c1) SHA1(4735503335cf499895d1b2d9a405be50f21a2d68) )
4462ROM_END
4463
4464
42374465GAME( 2002, mfish_3a,    mfish_parent,    multfish, multfish,  0,             ROT0,  "bootleg", "Multi Fish (bootleg, 021124, banking address hack)", GAME_SUPPORTS_SAVE ) // bank F9
42384466GAME( 2002, mfish_12a,   mfish_parent,    multfish, multfish,  0,             ROT0,  "bootleg", "Multi Fish (bootleg, 040308, banking address hack)", GAME_SUPPORTS_SAVE ) // bank F9
42394467
r14260r14261
43484576GAME( 2007, sweetl2_2d,  sweetl2_parent,  multfish, multfish,  0,             ROT0,  "bootleg", "Sweet Life 2 (bootleg, 080320, LOTTOGAME (I))", GAME_SUPPORTS_SAVE ) // bank F9, modified graphics, changed version text to "MDS_is_the_best_ LOTTOGAME (I)"
43494577
43504578GAME( 2008, fcockt2a,    fcockt2_parent,  multfish, multfish,  0,             ROT0,  "bootleg", "Fruit Cocktail 2 (bootleg, 080707, banking address hack)", GAME_SUPPORTS_SAVE ) // bank F9
4579GAME( 2008, fcockt2_4a,  fcockt2_parent,  multfish, multfish,  0,             ROT0,  "bootleg", "Fruit Cocktail 2 (bootleg, 081105, banking address hack)", GAME_SUPPORTS_SAVE ) // bank F9
4580GAME( 2008, fcockt2_4b,  fcockt2_parent,  multfish, multfish,  0,             ROT0,  "bootleg", "Fruit Cocktail 2 (bootleg, 081105, banking address hack, no credit limit)", GAME_SUPPORTS_SAVE ) // bank F9, no credit limit, "MaxVin" signature
4581GAME( 2008, fcockt2_4c,  fcockt2_parent,  multfish, multfish,  customl,       ROT0,  "bootleg", "Fruit Cocktail 2 (bootleg, 081105, VIDEO GAME-1 FR02)", GAME_SUPPORTS_SAVE ) // custom alteras, modified graphics, bank F9, many texts changed, changed version text to "VIDEO GAME-1 FR02"
4582GAME( 2008, fcockt2_4d,  fcockt2_parent,  multfish, multfish,  0,             ROT0,  "bootleg", "Fruit Cocktail 2 (bootleg, 081105, banking address hack, payout percentage 70)", GAME_SUPPORTS_SAVE ) // bank F9, no credit limit, "MaxVin" signature, payout percentage 70%
4583GAME( 2008, fcockt2_4e,  fcockt2_parent,  multfish, multfish,  0,             ROT0,  "bootleg", "Fruit Cocktail 2 (bootleg, 081105, LOTTOGAME (I))", GAME_SUPPORTS_SAVE ) // bank F9, modified graphics, changed version text to "MDS_is_the_best_ LOTTOGAME (I)"
4584GAME( 2008, fcockt2_4f,  fcockt2_parent,  multfish, multfish,  customl,       ROT0,  "bootleg", "Fruit Cocktail 2 (bootleg, 081105, LOTOS FR02)", GAME_SUPPORTS_SAVE ) // custom alteras, modified graphics, bank F9, many texts changed, changed version text to "LOTOS FR02"
43514585
43524586
43534587/* 0x000000 - 0x03ffff Crazy Monkey V03-1110
src/mame/drivers/popobear.c
r14260r14261
22(c) 2000 - Bao Ma Technology Co., LTD
33
44|-----------------------------------------|
5| DIP2 DIP4  UM3567(YM2413)               |J 
6| DIP1 DIP3                               |A
5| DIP2 DIP4  UM3567(YM2413)               |J
6| DIP1 DIP3                               |A
77|           TA-A-901                      |M
8| EN-A-701  EN-A-801  U6295(OKI)          |M
8| EN-A-701  EN-A-801  U6295(OKI)          |M
99| EN-A-501  EN-A-601                      |A
1010| EN-A-301  EN-A-401                      |
1111|                                         |C
1212|                   AIA90610              |O
1313|                   BMC-68pin  AIA90423   |N
14|                   plcc (68k) BMC-160pin |N
15|                                         |E
14|                   plcc (68k) BMC-160pin |N
15|                                         |E
1616|                                    OSC  |C
17|                                 42.000  |T
17|                                 42.000  |T
1818|-----------------------------------------|
1919
20201 - BMC AIA90423 - 160-Pin ASIC, FGPA, Video?
r14260r14261
111111static ADDRESS_MAP_START( popobear_mem, AS_PROGRAM, 16 )
112112   AM_RANGE(0x000000, 0x03ffff) AM_ROM
113113   AM_RANGE(0x210000, 0x21ffff) AM_RAM
114   AM_RANGE(0x3E0000, 0x3EFFFF) AM_RAM  AM_BASE_MEMBER(popobear_state, popobear_vram)
114   AM_RANGE(0x3E0000, 0x3EFFFF) AM_RAM  AM_BASE_MEMBER(popobear_state, popobear_vram)
115115
116116   /* Blitter stuff? */
117117   AM_RANGE(0x480000, 0x480001) AM_READ(popo_480001_r) AM_WRITE(popo_480001_w)
r14260r14261
125125   AM_RANGE(0x48003a, 0x48003b) AM_READ(popo_48003a_r) AM_WRITE(popo_48003a_w)
126126
127127   AM_RANGE(0x480400, 0x48041f) AM_RAM AM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram) // looks palette like at least
128   
128
129129   /* I/O maybe? */
130130   AM_RANGE(0x500000, 0x500001) AM_READ(popo_500000_r)
131131   AM_RANGE(0x520000, 0x520001) AM_READ(popo_520000_r)
r14260r14261
315315
316316static MACHINE_CONFIG_START( popobear, popobear_state )
317317   MCFG_CPU_ADD("maincpu", M68000, XTAL_42MHz/4)  // XTAL CORRECT, DIVISOR GUESSED
318   MCFG_CPU_PROGRAM_MAP(popobear_mem)
318   MCFG_CPU_PROGRAM_MAP(popobear_mem)
319319   // levels 2,3,5 look interesting
320320   //MCFG_CPU_VBLANK_INT("screen",irq3_line_hold)
321321   MCFG_TIMER_ADD_SCANLINE("scantimer", popobear_irq, "screen", 0, 1)
src/mame/drivers/segaorun.c
r14260r14261
15961596
15971597/**************************************************************************************************************************
15981598    Turbo Outrun (Upright version?? According to service mode dipswitch screen it's a Cockpit)
1599    CPU: FD1094 (317-????)
1600    GAME BD   834-6919
1599    CPU: FD1094 (317-0107)
1600    GAME BD   834-6919-02
16011601     CPU BD   837-6905
16021602     VIDEO BD 837-6906
16031603
r14260r14261
16141614   ROM_LOAD16_BYTE( "epr-12292.116", 0x040001, 0x10000, CRC(51d98af0) SHA1(6e7115706bfafb687faa23d55d4a8c8e498a4df2) )
16151615
16161616   ROM_REGION( 0x2000, "user1", 0 )   /* decryption key */
1617   ROM_LOAD( "317-unknown.key", 0x0000, 0x2000, CRC(33e632ae) SHA1(9fd8bd11d0a87ec4dfc4dc386012ab7992cb2bd7) )
1617   ROM_LOAD( "317-0107.key", 0x0000, 0x2000, CRC(33e632ae) SHA1(9fd8bd11d0a87ec4dfc4dc386012ab7992cb2bd7) )
16181618
16191619   ROM_REGION( 0x60000, "sub", 0 ) /* second 68000 CPU */
16201620   ROM_LOAD16_BYTE( "opr-12295.76", 0x000000, 0x10000, CRC(d43a3a84) SHA1(362c98f62c205b6b40b7e8a4ba107745b547b984) )
r14260r14261
16811681   ROM_LOAD16_BYTE( "epr-12292.116", 0x040001, 0x10000, CRC(51d98af0) SHA1(6e7115706bfafb687faa23d55d4a8c8e498a4df2) )
16821682
16831683   ROM_REGION( 0x2000, "user1", 0 )   /* decryption key */
1684   ROM_LOAD( "317-unknown-toutrun1.key", 0x0000, 0x2000, NO_DUMP )   /* FD1094 number unknown and not dumped */
1684   ROM_LOAD( "317-unknown-toutrun2.key", 0x0000, 0x2000, NO_DUMP )   /* FD1094 number unknown and not dumped */
16851685
16861686   ROM_REGION( 0x60000, "sub", 0 ) /* second 68000 CPU */
16871687   ROM_LOAD16_BYTE( "opr-12295.76", 0x000000, 0x10000, CRC(d43a3a84) SHA1(362c98f62c205b6b40b7e8a4ba107745b547b984) )
r14260r14261
17951795 **************************************************************************************************************************
17961796    Super Hangon
17971797    CPU: 68000 (317-????)
1798     GAME BD SUPER HANG-ON  834-6277-07
17981799     CPU BD SUPER HANG-ON   837-6278-01 (or 837-6278-03)
17991800     VIDEO BD SUPER HANG-ON 837-6279-01
18001801*/
r14260r14261
18481849/**************************************************************************************************************************
18491850    Super Hangon
18501851    CPU: FD1089B (317-0034)
1852     GAME BD SUPER HANG-ON  834-6277-02
18511853     CPU BD SUPER HANG-ON   837-6278-01 (or 837-6278-03)
18521854     VIDEO BD SUPER HANG-ON 837-6279 (or 837-6279-02, roms would be "OPR")
1855
1856Manual states for this set:
1857  834-6277-01 (Object data (sprits) EPR type AKA EP-ROM type)
1858  834-6277-03 (Object data (sprits) MPR type AKA Mask-ROM type)
1859  834-6277-05 (Object data (sprits) OPR type AKA One Time ROM type)
1860
18531861*/
18541862ROM_START( shangon3 )
18551863   ROM_REGION( 0x60000, "maincpu", 0 ) /* 68000 code - protected */
r14260r14261
21882196GAME( 1987, shangon1, shangon, shangon,  shangon,  shangon3, ROT0,   "Sega", "Super Hang-On (mini ride-on?, FD1089B 317-0034)", GAME_NOT_WORKING ) /* bad program rom */
21892197GAME( 1991, shangonle,shangon, shangon,  shangon,  shangon,  ROT0,   "Sega", "Limited Edition Hang-On", 0 )
21902198GAMEL(1989, toutrun,  0,       outrun,   toutrun,  outrun,   ROT0,   "Sega", "Turbo Out Run (Out Run upgrade, FD1094 317-0118)", 0,           layout_outrun ) /* Cabinet determined by dipswitch settings */
2191GAMEL(1989, toutrun3, toutrun, outrun,   toutrunc, outrun,   ROT0,   "Sega", "Turbo Out Run (upright, FD1094 317-unknown)", 0,                layout_outrun )
2199GAMEL(1989, toutrun3, toutrun, outrun,   toutrunc, outrun,   ROT0,   "Sega", "Turbo Out Run (upright, FD1094 317-0107)", 0,                   layout_outrun )
21922200GAMEL(1989, toutrun2, toutrun, outrun,   toutrun,  outrun,   ROT0,   "Sega", "Turbo Out Run (cockpit, FD1094 317-unknown)", GAME_NOT_WORKING, layout_outrun ) /* FD1094 CPU not decrypted */
21932201GAMEL(1989, toutrun1, toutrun, outrun,   toutrunm, outrun,   ROT0,   "Sega", "Turbo Out Run (deluxe cockpit, FD1094 317-0109)", 0,            layout_outrun )
src/mame/drivers/sliver.c
r14260r14261
107107
108108static void plot_pixel_rgb(sliver_state *state, int x, int y, UINT32 r, UINT32 g, UINT32 b)
109109{
110//   printf("plot %d %d %d\n", r,g,b);
110//  printf("plot %d %d %d\n", r,g,b);
111111
112112   if (y < 0 || x < 0 || x > 383 || y > 255)
113113      return;
r14260r14261
228228
229229      struct jpeg_decompress_struct cinfo;
230230      struct jpeg_error_mgr jerr;
231      JSAMPARRAY buffer;   
231      JSAMPARRAY buffer;
232232
233233      cinfo.err = jpeg_std_error(&jerr);
234234      jpeg_create_decompress(&cinfo);
r14260r14261
239239      jpeg_start_decompress(&cinfo);
240240
241241      int row_stride = cinfo.output_width * cinfo.output_components;
242
242
243243      buffer = (*cinfo.mem->alloc_sarray)((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
244244
245245      while (cinfo.output_scanline < cinfo.output_height)
r14260r14261
253253            UINT8 g = buffer[0][(x*3)+1];
254254            UINT8 r = buffer[0][(x*3)+2];
255255            plot_pixel_rgb(state, x - x_offset + state->m_jpeg_x, y - y_offset - state->m_jpeg_y, r, g, b);
256         
256
257257         }
258258
259259      }
src/mame/drivers/cps3.c
r14260r14261
23172317static const SCSIConfigTable dev_table =
23182318{
23192319   1,                                      /* 1 SCSI device */
2320   { { SCSI_ID_1, "cdrom", SCSI_DEVICE_CDROM } } /* SCSI ID 2, using CD 0, and it's a CD-ROM */
2320   { { SCSI_ID_1, ":cdrom", SCSI_DEVICE_CDROM } } /* SCSI ID 2, using CD 0, and it's a CD-ROM */
23212321};
23222322
23232323static const struct WD33C93interface scsi_intf =
src/mame/drivers/pluto5.c
r14260r14261
2727
2828  ---------------------------------------------------------------------
2929
30  Pluto 5 Technical Notes....
30  Pluto 5 Technical Notes....
3131
3232
3333  * Clocks...
src/mame/drivers/rohga.c
r14260r14261
113113#include "sound/2151intf.h"
114114#include "sound/okim6295.h"
115115#include "video/decocomn.h"
116#include "video/decospr.h"
116117
117118static READ16_HANDLER( rohga_irq_ack_r )
118119{
r14260r14261
663664   4096*8,
664665   6,
665666   { 0x400000*8+8, 0x400000*8, 0x200000*8+8, 0x200000*8, 8, 0 },
666   { 7,6,5,4,3,2,1,0,
667   32*8+7, 32*8+6, 32*8+5, 32*8+4, 32*8+3, 32*8+2, 32*8+1, 32*8+0 },
668   { 15*16, 14*16, 13*16, 12*16, 11*16, 10*16, 9*16, 8*16,
669         7*16, 6*16, 5*16, 4*16, 3*16, 2*16, 1*16, 0*16 },
667   { 32*8+0, 32*8+1, 32*8+2, 32*8+3, 32*8+4, 32*8+5, 32*8+6, 32*8+7, 0,1,2,3,4,5,6,7 },
668   { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
669         8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 },
670670   64*8
671671};
672672
r14260r14261
676676   4096*8,
677677   4,
678678   { 0x200000*8+8, 0x200000*8, 8, 0 },
679   { 7,6,5,4,3,2,1,0,
680   32*8+7, 32*8+6, 32*8+5, 32*8+4, 32*8+3, 32*8+2, 32*8+1, 32*8+0 },
681   { 15*16, 14*16, 13*16, 12*16, 11*16, 10*16, 9*16, 8*16,
682         7*16, 6*16, 5*16, 4*16, 3*16, 2*16, 1*16, 0*16 },
679   { 32*8+0, 32*8+1, 32*8+2, 32*8+3, 32*8+4, 32*8+5, 32*8+6, 32*8+7, 0,1,2,3,4,5,6,7 },
680   { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
681         8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 },
683682   64*8
684683};
685684
r14260r14261
707706   GFXDECODE_ENTRY( "gfx1", 0, charlayout,        0, 32 )   /* Gfx chip 1 as 8x8 */
708707   GFXDECODE_ENTRY( "gfx2", 0, tilelayout,        0, 32 )   /* Gfx chip 1 as 16x16 */
709708   GFXDECODE_ENTRY( "gfx3", 0, tilelayout,      512, 32 )  /* Gfx chip 2 as 16x16 */
710   GFXDECODE_ENTRY( "gfx4", 0, spritelayout,   1024, 32 ) /* Sprites 16x16 */
711   GFXDECODE_ENTRY( "gfx5", 0, spritelayout,   1536, 32 )
709   GFXDECODE_ENTRY( "gfx4", 0, spritelayout,   0, 32 ) /* Sprites 16x16 */
710   GFXDECODE_ENTRY( "gfx5", 0, spritelayout,   0, 32 )
712711GFXDECODE_END
713712
714713static GFXDECODE_START( schmeisr )
r14260r14261
829828   MCFG_DECO16IC_ADD("tilegen1", rohga_deco16ic_tilegen1_intf)
830829   MCFG_DECO16IC_ADD("tilegen2", rohga_deco16ic_tilegen2_intf)
831830
831   MCFG_DEVICE_ADD("spritegen1", DECO_SPRITE, 0)
832   decospr_device::set_gfx_region(*device, 3);
833
832834   /* sound hardware */
833835   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
834836
r14260r14261
874876   MCFG_DECO16IC_ADD("tilegen1", rohga_deco16ic_tilegen1_intf)
875877   MCFG_DECO16IC_ADD("tilegen2", rohga_deco16ic_tilegen2_intf)
876878
879   MCFG_DEVICE_ADD("spritegen1", DECO_SPRITE, 0)
880   decospr_device::set_gfx_region(*device, 3);
881
882   MCFG_DEVICE_ADD("spritegen2", DECO_SPRITE, 0)
883   decospr_device::set_gfx_region(*device, 4);
884
885   MCFG_VIDEO_START(wizdfire)
886
877887   /* sound hardware */
878888   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
879889
r14260r14261
919929   MCFG_DECO16IC_ADD("tilegen1", nitrobal_deco16ic_tilegen1_intf)
920930   MCFG_DECO16IC_ADD("tilegen2", nitrobal_deco16ic_tilegen2_intf)
921931
932   MCFG_DEVICE_ADD("spritegen1", DECO_SPRITE, 0)
933   decospr_device::set_gfx_region(*device, 3);
934
935   MCFG_DEVICE_ADD("spritegen2", DECO_SPRITE, 0)
936   decospr_device::set_gfx_region(*device, 4);
937
938   MCFG_VIDEO_START(wizdfire)
939
922940   /* sound hardware */
923941   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
924942
r14260r14261
954972   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
955973   MCFG_SCREEN_SIZE(40*8, 32*8)
956974   MCFG_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 1*8, 31*8-1)
957   MCFG_SCREEN_UPDATE_STATIC(schmeisr)
975   MCFG_SCREEN_UPDATE_STATIC(rohga)
958976
959977   MCFG_GFXDECODE(schmeisr)
960978   MCFG_PALETTE_LENGTH(2048)
961979
962   MCFG_VIDEO_START(rohga)
980   MCFG_VIDEO_START(schmeisr)
963981
964982   MCFG_DECOCOMN_ADD("deco_common", rohga_decocomn_intf)
965983
966984   MCFG_DECO16IC_ADD("tilegen1", rohga_deco16ic_tilegen1_intf)
967985   MCFG_DECO16IC_ADD("tilegen2", rohga_deco16ic_tilegen2_intf)
968986
987   MCFG_DEVICE_ADD("spritegen1", DECO_SPRITE, 0)
988   decospr_device::set_gfx_region(*device, 3);
989
990
969991   /* sound hardware */
970992   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
971993
src/mame/drivers/nemesis.c
r14260r14261
814814
815815   PORT_START("DSW1")
816816   PORT_BIT( 0x4f, IP_ACTIVE_LOW, IPT_UNUSED )
817   
817
818818   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Difficulty ) )   PORT_DIPLOCATION("SW2:5,6")
819819   PORT_DIPSETTING(    0x30, DEF_STR( Easy ) )
820820   PORT_DIPSETTING(    0x20, DEF_STR( Medium ) )
r14260r14261
12161216
12171217   PORT_START("DSW1")
12181218   PORT_DIPUNUSED_DIPLOC( 0x01, IP_ACTIVE_LOW, "SW2:1" )
1219   PORT_DIPUNUSED_DIPLOC( 0x02, IP_ACTIVE_LOW, "SW2:2" )
1219   PORT_DIPUNUSED_DIPLOC( 0x02, IP_ACTIVE_LOW, "SW2:2" )
12201220   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Cabinet ) )      PORT_DIPLOCATION("SW2:3")
12211221   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
12221222   PORT_DIPSETTING(    0x04, DEF_STR( Cocktail ) )
src/mame/drivers/dreamwld.c
r14260r14261
340340            x0 = ((UINT16 *)state->m_vregs)[BYTE_XOR_BE(0x000/2 + ((i + layer0_scrolly)&0xff))]; // different handling to psikyo.c? ( + scrolly )
341341      }
342342
343     
343
344344         tmptilemap0->set_scrollx(
345345         (i + layer0_scrolly) % 256 /*tilemap_width(tm0size) */,
346346         layer0_scrollx + x0 );
r14260r14261
357357            x1 = ((UINT16 *)state->m_vregs)[BYTE_XOR_BE(0x200/2 + ((i + layer1_scrolly)&0xff))];  // different handling to psikyo.c? ( + scrolly )
358358      }
359359
360     
360
361361         tmptilemap1->set_scrollx(
362362         (i + layer1_scrolly) % 256 /* tilemap_width(tm1size) */,
363363         layer1_scrollx + x1 );
src/mame/drivers/konamigv.c
r14260r14261
274274{
275275   1, /* 1 SCSI device */
276276   {
277      { SCSI_ID_4, "cdrom", SCSI_DEVICE_CDROM } /* SCSI ID 4, using CHD 0, and it's a CD-ROM */
277      { SCSI_ID_4, ":cdrom", SCSI_DEVICE_CDROM } /* SCSI ID 4, using CHD 0, and it's a CD-ROM */
278278   }
279279};
280280
src/mame/drivers/taitowlf.c
r14260r14261
713713   kbdc8042_init(machine, &at8042);
714714   #if ENABLE_VGA
715715   pc_vga_init(machine, vga_setting, NULL);
716   pc_vga_io_init(machine, machine.device("maincpu")->memory().space(AS_PROGRAM), 0xa0000, machine.device("maincpu")->memory().space(AS_IO), 0x0000);   
716   pc_vga_io_init(machine, machine.device("maincpu")->memory().space(AS_PROGRAM), 0xa0000, machine.device("maincpu")->memory().space(AS_IO), 0x0000);
717717   #endif
718718}
719719
src/mame/drivers/pntnpuzl.c
r14260r14261
381381//  rom[0x2696/2] = 0x4e71;
382382//  rom[0x26a0/2] = 0x4e71;
383383   pc_vga_init(machine, vga_setting, NULL);
384   pc_vga_io_init(machine, machine.device("maincpu")->memory().space(AS_PROGRAM), 0x3a0000, machine.device("maincpu")->memory().space(AS_PROGRAM), 0x3c0000);   
385   
384   pc_vga_io_init(machine, machine.device("maincpu")->memory().space(AS_PROGRAM), 0x3a0000, machine.device("maincpu")->memory().space(AS_PROGRAM), 0x3c0000);
385
386386}
387387
388388GAME( 199?, pntnpuzl,    0, pntnpuzl,    pntnpuzl,    pip, ROT90,  "Century?", "Paint & Puzzle",GAME_NO_SOUND|GAME_NOT_WORKING )
src/mame/drivers/triforce.c
r14260r14261
447447MACHINE_CONFIG_END
448448
449449static MACHINE_CONFIG_DERIVED( triforcegd, triforce_base )
450   MCFG_NAOMI_GDROM_BOARD_ADD("rom_board", "gdrom", "picreturn", NULL, "maincpu", NULL)
450   MCFG_NAOMI_GDROM_BOARD_ADD("rom_board", ":gdrom", "picreturn", NULL, "maincpu", NULL)
451451MACHINE_CONFIG_END
452452
453453#define ROM_LOAD16_WORD_SWAP_BIOS(bios,name,offset,length,hash) \
src/mame/drivers/gberet.c
r14260r14261
9191   // NMI on d0
9292   if (ticks_mask & state->m_interrupt_mask & 1)
9393      cputag_set_input_line(timer.machine(), "maincpu", INPUT_LINE_NMI, ASSERT_LINE);
94   
94
9595   // IRQ on d3 (used by mrgoemon)
9696   if (ticks_mask & state->m_interrupt_mask<<2 & 8)
9797      cputag_set_input_line(timer.machine(), "maincpu", 0, ASSERT_LINE);
src/tools/chdman.c
r14260r14261
34103410      { "-createuncomphd",   do_createhd_uncomp, 0 },
34113411      { "-createraw",      do_createraw, 0 },
34123412      { "-createcd",      do_createcd, 0 },
3413//      { "-createcdflac",   do_createcd, 1 },
3413//      { "-createcdflac",  do_createcd, 1 },
34143414      { "-createblankhd",   do_createblankhd, 0 },
34153415      { "-createav",      do_createav, 0 },
34163416      { "-copydata",      do_copydata, 0 },
src/osd/sdl/sdlmain.c
r14260r14261
851851   return TTF_OpenFont(name.cstr(), POINT_SIZE);
852852}
853853
854static bool BDF_Check_Magic(astring name)
855{
856    emu_file file(OPEN_FLAG_READ);
857    if (file.open(name) == FILERR_NONE)
858    {
859      unsigned char buffer[9];
860      unsigned char magic[9] = { 'S', 'T', 'A', 'R', 'T', 'F', 'O', 'N', 'T' };
861      file.read(buffer, 9);
862        file.close();
863      if (!memcmp(buffer, magic, 9))
864         return true;
865    }
866
867    return false;
868}
869
854870static TTF_Font *search_font_config(astring name, bool bold, bool italic, bool underline, bool &bakedstyles)
855871{
856872   TTF_Font *font = (TTF_Font *)NULL;
r14260r14261
10091025
10101026   if (!font)
10111027   {
1012      printf("WARNING: Couldn't find/open TrueType font %s, using MAME default\n", name.cstr());
1028        if (!BDF_Check_Magic(name))
1029        {
1030            printf("WARNING: font %s, is not TrueType or BDF, using MAME default\n", name.cstr());
1031        }
10131032      return NULL;
10141033   }
10151034
src/emu/debug/dvmemory.c
r14260r14261
182182         break;
183183
184184      // if this is a single-entry global, add it
185      if (valcount > 1 && strstr(itemname, "globals/"))
185    if (strstr(itemname, "state->"))
186186      {
187187         name.cpy(strrchr(itemname, '/') + 1);
188188         m_source_list.append(*auto_alloc(machine(), debug_view_memory_source(name, base, valsize, valcount)));
src/emu/cpu/unsp/unspdasm.c
r14260r14261
207207
208208      // Far Jump
209209      case 0x2f: case 0x3f: case 0x6f: case 0x7f:
210         if (OPA == 7 && OPA == 2)
210         if (OPA == 7 && OP1 == 2)
211211         {
212212            print("goto %06x", ((OPIMM << 16) | imm16) << 1);
213213         }
src/emu/cpu/i386/i386op16.c
r14260r14261
32773277      case 2:         /* LGDT */
32783278         {
32793279            if(PROTECTED_MODE && cpustate->CPL)
3280               FAULT(FAULT_GP,0)
3280               FAULT(FAULT_GP,0)
32813281            if( modrm >= 0xc0 ) {
32823282               address = LOAD_RM16(modrm);
32833283               ea = i386_translate(cpustate, CS, address, 0 );
r14260r14261
32923292      case 3:         /* LIDT */
32933293         {
32943294            if(PROTECTED_MODE && cpustate->CPL)
3295               FAULT(FAULT_GP,0)
3295               FAULT(FAULT_GP,0)
32963296            if( modrm >= 0xc0 ) {
32973297               address = LOAD_RM16(modrm);
32983298               ea = i386_translate(cpustate, CS, address, 0 );
src/emu/cpu/i386/i386priv.h
r14260r14261
458458               if(!(page_dir & 0x40) && (rwn == 1))
459459                  cpustate->program->write_dword(pdbr + directory * 4, page_dir | 0x60);
460460               else if(!(page_dir & 0x20) && (rwn != -1))
461                  cpustate->program->write_dword(pdbr + directory * 4, page_dir | 0x20);                 
461                  cpustate->program->write_dword(pdbr + directory * 4, page_dir | 0x20);
462462               *address = (page_dir & 0xffc00000) | (a & 0x003fffff);
463463            }
464464         }
src/emu/cpu/i386/x87ops.c
r14260r14261
22
33    x87 FPU emulation
44
5   TODO:
6    - 80-bit precision for F2XM1, FYL2X, FPATAN
7    - Figure out why SoftFloat trig extensions produce bad values
8    - Cycle counts for all processors (currently using 486 counts)
9    - Precision-dependent cycle counts for divide instructions
10    - Last instruction, operand pointers etc.
11    - Fix FLDENV, FSTENV, FSAVE, FRSTOR and FPREM
12    - Status word C2 updates to reflect round up/down
13    - Handling of invalid and denormal numbers
14    - Remove redundant operand checks
15    - Exceptions
5    TODO:
6     - 80-bit precision for F2XM1, FYL2X, FPATAN
7     - Figure out why SoftFloat trig extensions produce bad values
8     - Cycle counts for all processors (currently using 486 counts)
9     - Precision-dependent cycle counts for divide instructions
10     - Last instruction, operand pointers etc.
11     - Fix FLDENV, FSTENV, FSAVE, FRSTOR and FPREM
12     - Status word C2 updates to reflect round up/down
13     - Handling of invalid and denormal numbers
14     - Remove redundant operand checks
15     - Exceptions
1616
1717***************************************************************************/
1818
r14260r14261
21672167      double x = fx80_to_double(result1);
21682168      x = tan(x);
21692169      result1 = double_to_fx80(x);
2170     
2170
21712171      cpustate->x87_sw &= ~X87_SW_C2;
21722172#endif
21732173   }
r14260r14261
22292229      double x = fx80_to_double(result);
22302230      x = sin(x);
22312231      result = double_to_fx80(x);
2232     
2232
22332233      cpustate->x87_sw &= ~X87_SW_C2;
22342234#endif
22352235   }
r14260r14261
22622262      double x = fx80_to_double(result);
22632263      x = cos(x);
22642264      result = double_to_fx80(x);
2265     
2265
22662266      cpustate->x87_sw &= ~X87_SW_C2;
22672267#endif
22682268   }
r14260r14261
23002300         cpustate->x87_sw |= X87_SW_C2;
23012301#else
23022302      double s = fx80_to_double(s_result);
2303      double c = fx80_to_double(c_result);     
2303      double c = fx80_to_double(c_result);
23042304      s = sin(s);
23052305      c = cos(c);
2306     
2306
23072307      s_result = double_to_fx80(s);
23082308      c_result = double_to_fx80(c);
2309     
2309
23102310      cpustate->x87_sw &= ~X87_SW_C2;
23112311#endif
23122312   }
r14260r14261
40234023         WRITE16(cpustate, ea + 0, cpustate->x87_cw);
40244024         WRITE16(cpustate, ea + 2, cpustate->x87_sw);
40254025         WRITE16(cpustate, ea + 4, cpustate->x87_tw);
4026//         WRITE16(cpustate, ea + 6, cpustate->fpu_inst_ptr & 0xffff);
4027//         WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4028//         WRITE16(cpustate, ea + 10, cpustate->fpu_data_ptr & 0xffff);
4029//         WRITE16(cpustate, ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4);
4026//          WRITE16(cpustate, ea + 6, cpustate->fpu_inst_ptr & 0xffff);
4027//          WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4028//          WRITE16(cpustate, ea + 10, cpustate->fpu_data_ptr & 0xffff);
4029//          WRITE16(cpustate, ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4);
40304030         break;
40314031      case 1: // 16-bit protected mode
40324032         WRITE16(cpustate,ea + 0, cpustate->x87_cw);
40334033         WRITE16(cpustate,ea + 2, cpustate->x87_sw);
40344034         WRITE16(cpustate,ea + 4, cpustate->x87_tw);
4035//         WRITE16(cpustate,ea + 6, cpustate->fpu_inst_ptr & 0xffff);
4036//         WRITE16(cpustate,ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4037//         WRITE16(cpustate,ea + 10, cpustate->fpu_data_ptr & 0xffff);
4038//         WRITE16(cpustate,ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4);
4035//          WRITE16(cpustate,ea + 6, cpustate->fpu_inst_ptr & 0xffff);
4036//          WRITE16(cpustate,ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4037//          WRITE16(cpustate,ea + 10, cpustate->fpu_data_ptr & 0xffff);
4038//          WRITE16(cpustate,ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4);
40394039         break;
40404040      case 2: // 32-bit real mode
40414041         WRITE16(cpustate, ea + 0, cpustate->x87_cw);
40424042         WRITE16(cpustate, ea + 4, cpustate->x87_sw);
40434043         WRITE16(cpustate, ea + 8, cpustate->x87_tw);
4044//         WRITE16(cpustate, ea + 12, cpustate->fpu_inst_ptr & 0xffff);
4045//         WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4046//         WRITE16(cpustate, ea + 20, cpustate->fpu_data_ptr & 0xffff);
4047//         WRITE16(cpustate, ea + 12, ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4048//         WRITE32(cpustate, ea + 24, (cpustate->fpu_data_ptr >> 16) << 12);
4044//          WRITE16(cpustate, ea + 12, cpustate->fpu_inst_ptr & 0xffff);
4045//          WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4046//          WRITE16(cpustate, ea + 20, cpustate->fpu_data_ptr & 0xffff);
4047//          WRITE16(cpustate, ea + 12, ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4048//          WRITE32(cpustate, ea + 24, (cpustate->fpu_data_ptr >> 16) << 12);
40494049         break;
40504050      case 3: // 32-bit protected mode
40514051         WRITE16(cpustate, ea + 0,  cpustate->x87_cw);
40524052         WRITE16(cpustate, ea + 4,  cpustate->x87_sw);
40534053         WRITE16(cpustate, ea + 8,  cpustate->x87_tw);
4054//         WRITE32(cpustate, ea + 12, cpustate->fpu_inst_ptr);
4055//         WRITE32(cpustate, ea + 16, cpustate->fpu_opcode);
4056//         WRITE32(cpustate, ea + 20, cpustate->fpu_data_ptr);
4057//         WRITE32(cpustate, ea + 24, cpustate->fpu_inst_ptr);
4054//          WRITE32(cpustate, ea + 12, cpustate->fpu_inst_ptr);
4055//          WRITE32(cpustate, ea + 16, cpustate->fpu_opcode);
4056//          WRITE32(cpustate, ea + 20, cpustate->fpu_data_ptr);
4057//          WRITE32(cpustate, ea + 24, cpustate->fpu_inst_ptr);
40584058         break;
40594059   }
40604060
r14260r14261
40724072         WRITE16(cpustate, ea + 0, cpustate->x87_cw);
40734073         WRITE16(cpustate, ea + 2, cpustate->x87_sw);
40744074         WRITE16(cpustate, ea + 4, cpustate->x87_tw);
4075//         WRITE16(cpustate, ea + 6, cpustate->fpu_inst_ptr & 0xffff);
4076//         WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4077//         WRITE16(cpustate, ea + 10, cpustate->fpu_data_ptr & 0xffff);
4078//         WRITE16(cpustate, ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4);
4075//          WRITE16(cpustate, ea + 6, cpustate->fpu_inst_ptr & 0xffff);
4076//          WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4077//          WRITE16(cpustate, ea + 10, cpustate->fpu_data_ptr & 0xffff);
4078//          WRITE16(cpustate, ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4);
40794079         ea += 14;
40804080         break;
40814081      case 1: // 16-bit protected mode
40824082         WRITE16(cpustate,ea + 0, cpustate->x87_cw);
40834083         WRITE16(cpustate,ea + 2, cpustate->x87_sw);
40844084         WRITE16(cpustate,ea + 4, cpustate->x87_tw);
4085//         WRITE16(cpustate,ea + 6, cpustate->fpu_inst_ptr & 0xffff);
4086//         WRITE16(cpustate,ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4087//         WRITE16(cpustate,ea + 10, cpustate->fpu_data_ptr & 0xffff);
4088//         WRITE16(cpustate,ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4);
4085//          WRITE16(cpustate,ea + 6, cpustate->fpu_inst_ptr & 0xffff);
4086//          WRITE16(cpustate,ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4087//          WRITE16(cpustate,ea + 10, cpustate->fpu_data_ptr & 0xffff);
4088//          WRITE16(cpustate,ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4);
40894089         ea += 14;
40904090         break;
40914091      case 2: // 32-bit real mode
40924092         WRITE16(cpustate, ea + 0, cpustate->x87_cw);
40934093         WRITE16(cpustate, ea + 4, cpustate->x87_sw);
40944094         WRITE16(cpustate, ea + 8, cpustate->x87_tw);
4095//         WRITE16(cpustate, ea + 12, cpustate->fpu_inst_ptr & 0xffff);
4096//         WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4097//         WRITE16(cpustate, ea + 20, cpustate->fpu_data_ptr & 0xffff);
4098//         WRITE16(cpustate, ea + 12, ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4099//         WRITE32(cpustate, ea + 24, (cpustate->fpu_data_ptr >> 16) << 12);
4095//          WRITE16(cpustate, ea + 12, cpustate->fpu_inst_ptr & 0xffff);
4096//          WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4097//          WRITE16(cpustate, ea + 20, cpustate->fpu_data_ptr & 0xffff);
4098//          WRITE16(cpustate, ea + 12, ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4099//          WRITE32(cpustate, ea + 24, (cpustate->fpu_data_ptr >> 16) << 12);
41004100         ea += 28;
41014101         break;
41024102      case 3: // 32-bit protected mode
41034103         WRITE16(cpustate, ea + 0,  cpustate->x87_cw);
41044104         WRITE16(cpustate, ea + 4,  cpustate->x87_sw);
41054105         WRITE16(cpustate, ea + 8,  cpustate->x87_tw);
4106//         WRITE32(cpustate, ea + 12, cpustate->fpu_inst_ptr);
4107//         WRITE32(cpustate, ea + 16, cpustate->fpu_opcode);
4108//         WRITE32(cpustate, ea + 20, cpustate->fpu_data_ptr);
4109//         WRITE32(cpustate, ea + 24, cpustate->fpu_inst_ptr);
4106//          WRITE32(cpustate, ea + 12, cpustate->fpu_inst_ptr);
4107//          WRITE32(cpustate, ea + 16, cpustate->fpu_opcode);
4108//          WRITE32(cpustate, ea + 20, cpustate->fpu_data_ptr);
4109//          WRITE32(cpustate, ea + 24, cpustate->fpu_inst_ptr);
41104110         ea += 28;
41114111         break;
41124112   }
r14260r14261
41284128         x87_write_cw(cpustate, READ16(cpustate, ea));
41294129         cpustate->x87_sw = READ16(cpustate, ea + 2);
41304130         cpustate->x87_tw = READ16(cpustate, ea + 4);
4131//         WRITE16(cpustate, ea + 6, cpustate->fpu_inst_ptr & 0xffff);
4132//         WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4133//         WRITE16(cpustate, ea + 10, cpustate->fpu_data_ptr & 0xffff);
4134//         WRITE16(cpustate, ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4);
4131//          WRITE16(cpustate, ea + 6, cpustate->fpu_inst_ptr & 0xffff);
4132//          WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4133//          WRITE16(cpustate, ea + 10, cpustate->fpu_data_ptr & 0xffff);
4134//          WRITE16(cpustate, ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4);
41354135         ea += 14;
41364136         break;
41374137      case 1: // 16-bit protected mode
41384138         x87_write_cw(cpustate, READ16(cpustate, ea));
41394139         cpustate->x87_sw = READ16(cpustate, ea + 2);
41404140         cpustate->x87_tw = READ16(cpustate, ea + 4);
4141//         WRITE16(cpustate,ea + 6, cpustate->fpu_inst_ptr & 0xffff);
4142//         WRITE16(cpustate,ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4143//         WRITE16(cpustate,ea + 10, cpustate->fpu_data_ptr & 0xffff);
4144//         WRITE16(cpustate,ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4);
4141//          WRITE16(cpustate,ea + 6, cpustate->fpu_inst_ptr & 0xffff);
4142//          WRITE16(cpustate,ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4143//          WRITE16(cpustate,ea + 10, cpustate->fpu_data_ptr & 0xffff);
4144//          WRITE16(cpustate,ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4);
41454145         ea += 14;
41464146         break;
41474147      case 2: // 32-bit real mode
41484148         x87_write_cw(cpustate, READ16(cpustate, ea));
41494149         cpustate->x87_sw = READ16(cpustate, ea + 4);
41504150         cpustate->x87_tw = READ16(cpustate, ea + 8);
4151//         WRITE16(cpustate, ea + 12, cpustate->fpu_inst_ptr & 0xffff);
4152//         WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4153//         WRITE16(cpustate, ea + 20, cpustate->fpu_data_ptr & 0xffff);
4154//         WRITE16(cpustate, ea + 12, ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4155//         WRITE32(cpustate, ea + 24, (cpustate->fpu_data_ptr >> 16) << 12);
4151//          WRITE16(cpustate, ea + 12, cpustate->fpu_inst_ptr & 0xffff);
4152//          WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4153//          WRITE16(cpustate, ea + 20, cpustate->fpu_data_ptr & 0xffff);
4154//          WRITE16(cpustate, ea + 12, ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4));
4155//          WRITE32(cpustate, ea + 24, (cpustate->fpu_data_ptr >> 16) << 12);
41564156         ea += 28;
41574157         break;
41584158      case 3: // 32-bit protected mode
41594159         x87_write_cw(cpustate, READ16(cpustate, ea));
41604160         cpustate->x87_sw = READ16(cpustate, ea + 4);
41614161         cpustate->x87_tw = READ16(cpustate, ea + 8);
4162//         WRITE32(cpustate, ea + 12, cpustate->fpu_inst_ptr);
4163//         WRITE32(cpustate, ea + 16, cpustate->fpu_opcode);
4164//         WRITE32(cpustate, ea + 20, cpustate->fpu_data_ptr);
4165//         WRITE32(cpustate, ea + 24, cpustate->fpu_inst_ptr);
4162//          WRITE32(cpustate, ea + 12, cpustate->fpu_inst_ptr);
4163//          WRITE32(cpustate, ea + 16, cpustate->fpu_opcode);
4164//          WRITE32(cpustate, ea + 20, cpustate->fpu_data_ptr);
4165//          WRITE32(cpustate, ea + 24, cpustate->fpu_inst_ptr);
41664166         ea += 28;
41674167         break;
41684168   }
src/emu/cpu/i386/i386.c
r14260r14261
10621062   CHANGE_PC(cpustate,cpustate->eip);
10631063
10641064   cpustate->CPL = cpustate->sreg[CS].selector & 0x03;
1065//   printf("286 Task Switch from selector %04x to %04x\n",old_task,selector);
1065//  printf("286 Task Switch from selector %04x to %04x\n",old_task,selector);
10661066}
10671067
10681068static void i386_task_switch(i386_state *cpustate, UINT16 selector, UINT8 nested)
r14260r14261
11771177   CHANGE_PC(cpustate,cpustate->eip);
11781178
11791179   cpustate->CPL = cpustate->sreg[CS].selector & 0x03;
1180//   printf("386 Task Switch from selector %04x to %04x\n",old_task,selector);
1180//  printf("386 Task Switch from selector %04x to %04x\n",old_task,selector);
11811181}
11821182
11831183static void i386_check_irq_line(i386_state *cpustate)
src/emu/cpu/i386/i486ops.c
r14260r14261
241241      case 2:         /* LGDT */
242242         {
243243            if(PROTECTED_MODE && cpustate->CPL)
244               FAULT(FAULT_GP,0)
244               FAULT(FAULT_GP,0)
245245            if( modrm >= 0xc0 ) {
246246               address = LOAD_RM16(modrm);
247247               ea = i386_translate( cpustate, CS, address, 0 );
r14260r14261
256256      case 3:         /* LIDT */
257257         {
258258            if(PROTECTED_MODE && cpustate->CPL)
259               FAULT(FAULT_GP,0)
259               FAULT(FAULT_GP,0)
260260            if( modrm >= 0xc0 ) {
261261               address = LOAD_RM16(modrm);
262262               ea = i386_translate( cpustate, CS, address, 0 );
src/emu/cpu/i386/i386op32.c
r14260r14261
31233123      case 2:         /* LGDT */
31243124         {
31253125            if(PROTECTED_MODE && cpustate->CPL)
3126               FAULT(FAULT_GP,0)
3126               FAULT(FAULT_GP,0)
31273127            if( modrm >= 0xc0 ) {
31283128               address = LOAD_RM32(modrm);
31293129               ea = i386_translate(cpustate, CS, address, 0 );
r14260r14261
31383138      case 3:         /* LIDT */
31393139         {
31403140            if(PROTECTED_MODE && cpustate->CPL)
3141               FAULT(FAULT_GP,0)
3141               FAULT(FAULT_GP,0)
31423142            if( modrm >= 0xc0 ) {
31433143               address = LOAD_RM32(modrm);
31443144               ea = i386_translate(cpustate, CS, address, 0 );
src/emu/cpu/arm7/arm7ops.h
r14260r14261
55const void arm7ops_ab(arm_state *cpustate, UINT32 insn);
66const void arm7ops_cd(arm_state *cpustate, UINT32 insn);
77const void arm7ops_e(arm_state *cpustate, UINT32 insn);
8const void arm7ops_f(arm_state *cpustate, UINT32 insn);
8const void arm7ops_f(arm_state *cpustate, UINT32 insn);
src/emu/video/pc_vga.c
r14260r14261
2020    - modernize
2121    - add emulated mc6845 hook-up
2222    - fix video update.
23   - rewrite video drawing functions (they are horrible)
24   - add VESA etc.
25   - "System Information" UI currently crashes the emulation
23    - rewrite video drawing functions (they are horrible)
24    - add VESA etc.
25    - "System Information" UI currently crashes the emulation
2626    - (and many more ...)
2727
28   per-game issues:
29   - The Incredible Machine: fix partial updates
30   - MAME 0.01: fix 92 Hz refresh rate bug (uses VESA register?).
31   - Bio Menace: jerky H scrolling (uses EGA mode)
28    per-game issues:
29    - The Incredible Machine: fix partial updates
30    - MAME 0.01: fix 92 Hz refresh rate bug (uses VESA register?).
31    - Bio Menace: jerky H scrolling (uses EGA mode)
3232    - Virtual Pool: ET4k unrecognized;
3333    - California Chase (calchase): init bug causes messed up chars at POST
3434      (gfxs works if you soft reset).
r14260r14261
728728
729729   /* TODO: 10b and 11b settings aren't known */
730730   pixel_clock  = (vga.miscellaneous_output & 0xc) ? XTAL_28_63636MHz : XTAL_25_1748MHz;
731   pixel_clock /=    (((vga.sequencer.data[1]&8) >> 3) + 1);
731   pixel_clock /=   (((vga.sequencer.data[1]&8) >> 3) + 1);
732732
733733   refresh  = HZ_TO_ATTOSECONDS(pixel_clock) * (hblank_period) * vblank_period;
734734
735735   machine.primary_screen->configure((hblank_period), (vblank_period), visarea, refresh );
736//   popmessage("%d %d\n",vga.crtc.horz_total * 8,vga.crtc.vert_total);
736//  popmessage("%d %d\n",vga.crtc.horz_total * 8,vga.crtc.vert_total);
737737}
738738
739739static void crtc_reg_write(running_machine &machine, UINT8 index, UINT8 data)
740740{
741741   /* Doom does this */
742//   if(vga.crtc.protect_enable && index <= 0x07)
743//      printf("write to protected address %02x\n",index);
742//  if(vga.crtc.protect_enable && index <= 0x07)
743//      printf("write to protected address %02x\n",index);
744744
745745   switch(index)
746746   {
r14260r14261
878878         break;
879879      case 0x03:
880880         /* --2- 84-- character select A
881            ---2 --84 character select B */
881               ---2 --84 character select B */
882882         vga.sequencer.char_sel.A = (((data & 0xc) >> 2)<<1) | ((data & 0x20) >> 5);
883883         vga.sequencer.char_sel.B = (((data & 0x3) >> 0)<<1) | ((data & 0x10) >> 4);
884884         if(data)
r14260r14261
12661266
12671267READ8_HANDLER(vga_mem_r)
12681268{
1269   #if 0
12691270   switch((vga.gc.data[6] >> 2) & 0x03)
12701271   {
12711272      case 0: break;
r14260r14261
12731274      case 2: offset -= 0x10000; offset &= 0x07fff; break;
12741275      case 3: offset -= 0x18000; offset &= 0x07fff; break;
12751276   }
1277   #endif
12761278
12771279   if(vga.sequencer.data[4] & 4)
12781280   {
r14260r14261
13191321
13201322WRITE8_HANDLER(vga_mem_w)
13211323{
1324   //Inside each case must prevent writes to non-mapped VGA memory regions, not only mask  the offset.
13221325   switch((vga.gc.data[6] >> 2) & 0x03)
13231326   {
13241327      case 0: break;
1325      case 1: offset &= 0x0ffff; break;
1326      case 2: offset -= 0x10000; offset &= 0x07fff; break;
1327      case 3: offset -= 0x18000; offset &= 0x07fff; break;
1328      case 1:
1329         if(offset & 0x10000)
1330            return;
1331
1332         offset &= 0x0ffff;
1333         break;
1334      case 2:
1335         if((offset & 0x18000) != 0x10000)
1336            return;
1337
1338         offset &= 0x07fff;
1339         break;
1340      case 3:
1341         if((offset & 0x18000) != 0x18000)
1342            return;
1343
1344         offset &= 0x07fff;
1345         break;
13281346   }
13291347
13301348   {
src/emu/tilemap.c
r14260r14261
446446
447447
448448//-------------------------------------------------
449//  mark_tile_dirty - mark a single tile dirty
449//  mark_tile_dirty - mark a single tile dirty
450450//  based on its memory index
451451//-------------------------------------------------
452452
r14260r14261
467467
468468
469469//-------------------------------------------------
470//  map_pens_to_layer - specify the mapping of one
471//  or more pens (where (<pen> & mask) == pen) to
470//  map_pens_to_layer - specify the mapping of one
471//  or more pens (where (<pen> & mask) == pen) to
472472//  a layer
473473//-------------------------------------------------
474474
r14260r14261
503503
504504
505505//-------------------------------------------------
506//  set_transparent_pen - set a single transparent
507//  pen into the tilemap, mapping all other pens
506//  set_transparent_pen - set a single transparent
507//  pen into the tilemap, mapping all other pens
508508//  to layer 0
509509//-------------------------------------------------
510510
r14260r14261
519519
520520
521521//-------------------------------------------------
522//  set_transmask - set up the first 32 pens using
523//  a foreground mask (mapping to layer 0) and a
522//  set_transmask - set up the first 32 pens using
523//  a foreground mask (mapping to layer 0) and a
524524//  background mask (mapping to layer 1)
525525//-------------------------------------------------
526526
r14260r14261
601601
602602
603603//-------------------------------------------------
604//  postload - after loading a save state
604//  postload - after loading a save state
605605//  invalidate everything
606606//-------------------------------------------------
607607
r14260r14261
918918
919919
920920//-------------------------------------------------
921//  draw_common - draw a tilemap to the
921//  draw_common - draw a tilemap to the
922922//  destination with clipping; pixels apply
923923//  priority/priority_mask to the priority bitmap
924924//-------------------------------------------------
r14260r14261
10371037
10381038
10391039//-------------------------------------------------
1040//  draw_roz - draw a tilemap to the destination
1041//  with clipping and arbitrary rotate/zoom; pixels
1042//  apply priority/priority_mask to the priority
1040//  draw_roz - draw a tilemap to the destination
1041//  with clipping and arbitrary rotate/zoom; pixels
1042//  apply priority/priority_mask to the priority
10431043//  bitmap
10441044//-------------------------------------------------
10451045
r14260r14261
10901090
10911091
10921092//-------------------------------------------------
1093//  draw_instance - draw a single instance of the
1094//  tilemap to the internal pixmap at the given
1093//  draw_instance - draw a single instance of the
1094//  tilemap to the internal pixmap at the given
10951095//  xpos,ypos
10961096//-------------------------------------------------
10971097
r14260r14261
14811481
14821482
14831483//-------------------------------------------------
1484//  set_flip_all - set a global flip for all the
1484//  set_flip_all - set a global flip for all the
14851485//  tilemaps
14861486//-------------------------------------------------
14871487
r14260r14261
14971497
14981498
14991499//-------------------------------------------------
1500//  set_flip_all - set a global flip for all the
1500//  set_flip_all - set a global flip for all the
15011501//  tilemaps
15021502//-------------------------------------------------
15031503
r14260r14261
15091509
15101510
15111511//-------------------------------------------------
1512//  mark_all_dirty - mark all the tiles in all the
1512//  mark_all_dirty - mark all the tiles in all the
15131513//  tilemaps dirty
15141514//-------------------------------------------------
15151515
src/emu/tilemap.h
r14260r14261
419419class tilemap_t
420420{
421421   DISABLE_COPYING(tilemap_t);
422   
422
423423   friend class tilemap_manager;
424424   friend class simple_list<tilemap_t>;
425425    friend resource_pool_object<tilemap_t>::~resource_pool_object();
r14260r14261
455455   bitmap_ind8 &flagsmap() { pixmap_update(); return m_flagsmap; }
456456   UINT8 *tile_flags() { pixmap_update(); return m_tileflags; }
457457   tilemap_memory_index memory_index(UINT32 col, UINT32 row) { return m_mapper(col, row, m_cols, m_rows); }
458   
458
459459   // setters
460460   void enable(bool enable = true) { m_enable = enable; }
461461   void set_user_data(void *user_data) { m_user_data = user_data; }
r14260r14261
505505      UINT8            value;
506506      UINT8            alpha;
507507   };
508   
508
509509   // inline helpers
510510   INT32 effective_rowscroll(int index, UINT32 screen_width);
511511   INT32 effective_colscroll(int index, UINT32 screen_height);
512512   bool gfx_elements_changed();
513   
513
514514   // inline scanline rasterizers
515515   void scanline_draw_opaque_null(int count, UINT8 *pri, UINT32 pcode);
516516   void scanline_draw_masked_null(const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode);
r14260r14261
600600public:
601601   // construction/destuction
602602   tilemap_manager(running_machine &machine);
603   
603
604604   // getters
605605   running_machine &machine() const { return m_machine; }
606   
606
607607   // tilemap creation
608608   tilemap_t &create(tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, int tilewidth, int tileheight, int cols, int rows);
609609   tilemap_t &create(tile_get_info_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows);
r14260r14261
622622
623623   // internal state
624624   running_machine &      m_machine;
625   simple_list<tilemap_t>    m_tilemap_list;
625   simple_list<tilemap_t>   m_tilemap_list;
626626   int                  m_instance;
627627};
628628
r14260r14261
643643// function definition for a logical-to-memory mapper
644644#define TILEMAP_MAPPER(_name)         tilemap_memory_index _name(running_machine &machine, UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows)
645645
646// useful macro inside of a TILE_GET_INFO callback to set tile information
646// useful macro inside of a TILE_GET_INFO callback to set tile information
647647#define SET_TILE_INFO(GFX,CODE,COLOR,FLAGS)         tileinfo.set(machine, GFX, CODE, COLOR, FLAGS)
648648#define SET_TILE_INFO_DEVICE(GFX,CODE,COLOR,FLAGS)  tileinfo.set(device->machine(), GFX, CODE, COLOR, FLAGS)
649649
src/emu/machine.c
r14260r14261
915915               failed_starts++;
916916            }
917917         }
918     
918
919919      // each iteration should reduce the number of failed starts; error if
920920      // this doesn't happen
921921      if (failed_starts == last_failed_starts)
r14260r14261
954954      device->stop();
955955
956956   // then nuke the device tree
957//   global_free(m_root_device);
957//  global_free(m_root_device);
958958}
959959
960960
961961//-------------------------------------------------
962//  presave_all_devices - tell all the devices we
962//  presave_all_devices - tell all the devices we
963963//  are about to save
964964//-------------------------------------------------
965965
r14260r14261
972972
973973
974974//-------------------------------------------------
975//  postload_all_devices - tell all the devices we
975//  postload_all_devices - tell all the devices we
976976//  just completed a load
977977//-------------------------------------------------
978978
r14260r14261
12661266
12671267
12681268//-------------------------------------------------
1269//  device_reset_after_children - device override
1269//  device_reset_after_children - device override
12701270//  which calls the various helpers; must happen
12711271//  after all child devices are reset
12721272//-------------------------------------------------
src/emu/sound/samples.c
r14260r14261
124124
125125}
126126
127FLAC__StreamDecoderWriteStatus my_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *const buffer[], void *client_data)
127FLAC__StreamDecoderWriteStatus my_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *const buffer[], void *client_data)
128128{
129129   //printf("my_write_callback\n");
130130   //printf("array size %d\n",frame->header.blocksize);
r14260r14261
140140   }
141141
142142   flacrd->write_position +=  frame->header.blocksize;
143   
143
144144   return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
145145}
146146
r14260r14261
328328         return 0;
329329
330330      int size = flacread.total_samples * (flacread.bits_per_sample/8);
331   
331
332332      sample->data = auto_alloc_array(machine, INT16, size);
333333      flacread.write_position = 0;
334334      flacread.write_data = sample->data;
r14260r14261
342342      FLAC__stream_decoder_delete(decoder);
343343
344344      /* fill in the sample data */
345     
345
346346      sample->frequency = flacread.sample_rate;
347347      sample->length = size;
348348
src/emu/sound/okim6295.c
r14260r14261
130130   m_stream = machine().sound().stream_alloc(*this, 0, 1, clock() / divisor);
131131
132132   save_item(NAME(m_command));
133   save_item(NAME(m_bank_installed));
134133   save_item(NAME(m_bank_offs));
135134   save_item(NAME(m_pin7_state));
136135
src/emu/machine.h
r14260r14261
444444   void fill_systime(system_time &systime, time_t t);
445445   void handle_saveload();
446446   void soft_reset(void *ptr = NULL, INT32 param = 0);
447   
447
448448   // internal callbacks
449449   static void logfile_callback(running_machine &machine, const char *buffer);
450450
src/emu/emutempl.h
r14260r14261
5959
6060public:
6161   // construction/destruction
62   simple_list(resource_pool &pool = global_resource_pool())
62   simple_list(resource_pool &pool = global_resource_pool())
6363      : m_head(NULL),
6464        m_tail(NULL),
6565        m_pool(pool),
src/emu/render.h
r14260r14261
190190   float            y0;               // topmost Y coordinate
191191   float            x1;               // rightmost X coordinate
192192   float            y1;               // bottommost Y coordinate
193   
193
194194   float width() const { return x1 - x0; }
195195   float height() const { return y1 - y0; }
196196};
src/emu/validity.c
r14260r14261
7272//**************************************************************************
7373
7474//-------------------------------------------------
75//  ioport_string_from_index - return an indexed
75//  ioport_string_from_index - return an indexed
7676//  string from the I/O port system
7777//-------------------------------------------------
7878
r14260r14261
200200{
201201   // initialize
202202   validate_begin();
203   
203
204204   // then iterate over all drivers and check the ones that share the same source file
205205   m_drivlist.reset();
206206   while (m_drivlist.next())
207207      if (strcmp(driver.source_file, m_drivlist.driver().source_file) == 0)
208208         validate_one(m_drivlist.driver());
209   
209
210210   // cleanup
211211   validate_end();
212212}
r14260r14261
222222   validate_begin();
223223   validate_core();
224224   validate_inlines();
225   
225
226226   // then iterate over all drivers and check them
227227   m_drivlist.reset();
228228   while (m_drivlist.next())
229229      validate_one(m_drivlist.driver());
230   
230
231231   // cleanup
232232   validate_end();
233233}
234234
235235
236236//-------------------------------------------------
237//  validate_begin - prepare for validation by
238//  taking over the output callbacks and resetting
237//  validate_begin - prepare for validation by
238//  taking over the output callbacks and resetting
239239//  our internal state
240240//-------------------------------------------------
241241
r14260r14261
244244   // take over error and warning outputs
245245   m_saved_error_output = mame_set_output_channel(OUTPUT_CHANNEL_ERROR, output_delegate(FUNC(validity_checker::error_output), this));
246246   m_saved_warning_output = mame_set_output_channel(OUTPUT_CHANNEL_WARNING, output_delegate(FUNC(validity_checker::warning_output), this));
247   
247
248248   // reset all our maps
249249   m_names_map.reset();
250250   m_descriptions_map.reset();
251251   m_roms_map.reset();
252252   m_defstr_map.reset();
253253   m_region_map.reset();
254   
254
255255   // reset internal state
256256   m_errors = 0;
257257   m_warnings = 0;
258   
258
259259   // reset some special case state
260260   software_list_device::reset_checked_lists();
261261}
262262
263263
264264//-------------------------------------------------
265//  validate_end - restore output callbacks and
265//  validate_end - restore output callbacks and
266266//  clean up
267267//-------------------------------------------------
268268
r14260r14261
286286   m_current_device = NULL;
287287   m_current_ioport = NULL;
288288   m_region_map.reset();
289   
289
290290   // reset error/warning state
291291   int start_errors = m_errors;
292292   int start_warnings = m_warnings;
r14260r14261
314314      mame_printf_error("Fatal error %s", err.string());
315315   }
316316   m_current_config = NULL;
317   
317
318318   // if we had warnings or errors, output
319319   if (m_errors > start_errors || m_warnings > start_warnings)
320320   {
r14260r14261
625625   {
626626      // for non-root devices, track the current device
627627      m_current_device = (source == &m_current_config->root_device()) ? NULL : source;
628   
628
629629      // scan the ROM entries for this device
630630      const char *last_region_name = "???";
631631      const char *last_name = "???";
r14260r14261
660660            // generate the full tag
661661            astring fulltag;
662662            rom_region_name(fulltag, m_current_driver, source, romp);
663           
663
664664            // attempt to add it to the map, reporting duplicates as errors
665665            current_length = ROMREGION_GETLENGTH(romp);
666666            if (m_region_map.add(fulltag, current_length, false) == TMERR_DUPLICATE)
r14260r14261
807807
808808      int xscale = (m_current_config->m_gfxdecodeinfo[gfxnum].xscale == 0) ? 1 : m_current_config->m_gfxdecodeinfo[gfxnum].xscale;
809809      int yscale = (m_current_config->m_gfxdecodeinfo[gfxnum].yscale == 0) ? 1 : m_current_config->m_gfxdecodeinfo[gfxnum].yscale;
810     
810
811811      // verify raw decode, which can only be full-region and have no scaling
812812      if (layout.planeoffset[0] == GFX_RAW)
813813      {
r14260r14261
816816         if (xscale != 1 || yscale != 1)
817817            mame_printf_error("gfx[%d] with unsupported xscale/yscale\n", gfxnum);
818818      }
819     
819
820820      // verify traditional decode doesn't have too many planes or is not too large
821821      else
822822      {
r14260r14261
989989   // resolve the tag
990990   astring porttag;
991991   device.subtag(porttag, condition.tag);
992   
992
993993   // then find a matching port
994994   if (port_map.find(porttag) == 0)
995995      mame_printf_error("Condition referencing non-existent ioport tag '%s'\n", condition.tag);
r14260r14261
10191019      ioport_list portlist;
10201020      astring errorbuf;
10211021      input_port_list_init(*device, portlist, errorbuf);
1022     
1022
10231023      // report any errors during construction
10241024      if (errorbuf)
10251025         mame_printf_error("I/O port error during construction:\n%s\n", errorbuf.cstr());
r14260r14261
10841084               if (setting->condition.tag != NULL)
10851085                  validate_condition(setting->condition, *device, port_map);
10861086         }
1087   
1087
10881088         // done with this port
10891089         m_current_ioport = NULL;
10901090      }
r14260r14261
11491149         // instantiate the device
11501150         device_t *dev = (*intf[j].devtype)(*m_current_config, "dummy", &m_current_config->root_device(), 0);
11511151         dev->config_complete();
1152         
1152
11531153         // if a ROM region is present
11541154         if (dev->rom_region() != NULL)
11551155         {
r14260r14261
11611161                  break;
11621162               }
11631163
1164            if (has_romfiles)
1164            if (has_romfiles)
11651165            {
11661166               // scan the list of devices for this device type
11671167               bool found = false;
r14260r14261
11841184
11851185
11861186//-------------------------------------------------
1187//  build_output_prefix - create a prefix
1187//  build_output_prefix - create a prefix
11881188//  indicating the current source file, driver,
11891189//  and device
11901190//-------------------------------------------------
r14260r14261
11931193{
11941194   // start empty
11951195   string.reset();
1196     
1196
11971197   // if we have a current device, indicate that
11981198   if (m_current_device != NULL)
11991199      string.cat(m_current_device->name()).cat(" device '").cat(m_current_device->tag()).cat("': ");
1200   
1200
12011201   // if we have a current port, indicate that as well
12021202   if (m_current_ioport != NULL)
12031203      string.cat("ioport '").cat(m_current_ioport).cat("': ");
r14260r14261
12121212{
12131213   // count the error
12141214   m_errors++;
1215   
1215
12161216   // output the source(driver) device 'tag'
12171217   astring output;
12181218   build_output_prefix(output);
r14260r14261
12241224
12251225
12261226//-------------------------------------------------
1227//  warning_output - warning message output
1227//  warning_output - warning message output
12281228//  override
12291229//-------------------------------------------------
12301230
r14260r14261
12321232{
12331233   // count the error
12341234   m_warnings++;
1235   
1235
12361236   // output the source(driver) device 'tag'
12371237   astring output;
12381238   build_output_prefix(output);
src/emu/validity.h
r14260r14261
6363public:
6464   validity_checker(emu_options &options);
6565
66   // getters   
66   // getters
6767   int errors() const { return m_errors; }
6868   int warnings() const { return m_warnings; }
6969
70   // operations   
70   // operations
7171   void check_driver(const game_driver &driver);
7272   void check_shared_source(const game_driver &driver);
7373   void check_all();
7474
7575   // helpers for devices
7676   void validate_tag(const char *tag);
77   
77
7878private:
7979   // internal helpers
8080   const char *ioport_string_from_index(UINT32 index);
r14260r14261
8484   void validate_begin();
8585   void validate_end();
8686   void validate_one(const game_driver &driver);
87   
87
8888   // internal sub-checks
8989   void validate_core();
9090   void validate_inlines();
r14260r14261
106106   void output_via_delegate(output_delegate &delegate, const char *format, ...);
107107
108108   // internal driver list
109   driver_enumerator       m_drivlist;
110   
109   driver_enumerator      m_drivlist;
110
111111   // error tracking
112112   int                  m_errors;
113113   int                  m_warnings;
r14260r14261
128128   int_map             m_region_map;
129129
130130   // callbacks
131   output_delegate         m_saved_error_output;
132   output_delegate         m_saved_warning_output;
131   output_delegate         m_saved_error_output;
132   output_delegate         m_saved_warning_output;
133133};
134134
135135#endif
src/emu/romload.c
r14260r14261
154154
155155chd_file *get_disk_handle(running_machine &machine, const char *region)
156156{
157    for (open_chd *curdisk = machine.romload_data->chd_list.first(); curdisk != NULL; curdisk = curdisk->next())
157   for (open_chd *curdisk = machine.romload_data->chd_list.first(); curdisk != NULL; curdisk = curdisk->next())
158158      if (strcmp(curdisk->region(), region) == 0)
159159         return curdisk->chd();
160160   return NULL;
src/emu/imagedev/floppy.c
r14260r14261
203203   fd = fopen(filename.cstr(), "r");
204204   if(!fd)
205205      return 0;
206   
206
207207   io_generic io;
208208   io.file = fd;
209209   io.procs = &stdio_ioprocs_noclose;
r14260r14261
610610
611611ui_menu_control_floppy_image::ui_menu_control_floppy_image(running_machine &machine, render_container *container, device_image_interface *_image) : ui_menu_control_device_image(machine, container, _image)
612612{
613   floppy_image_device *fd = static_cast<floppy_image_device *>(image);   
613   floppy_image_device *fd = static_cast<floppy_image_device *>(image);
614614   const floppy_image_format_t *fif_list = fd->get_formats();
615615   int fcnt = 0;
616616   for(const floppy_image_format_t *i = fif_list; i; i = i->next)
617617      fcnt++;
618   
618
619619   format_array = global_alloc_array(floppy_image_format_t *, fcnt);
620620   input_format = output_format = 0;
621621   input_filename = output_filename = "";
r14260r14261
628628
629629void ui_menu_control_floppy_image::do_load_create()
630630{
631   floppy_image_device *fd = static_cast<floppy_image_device *>(image);   
631   floppy_image_device *fd = static_cast<floppy_image_device *>(image);
632632   if(input_filename == "") {
633633      int err = fd->create(output_filename, 0, NULL);
634634      if (err != 0) {
r14260r14261
678678
679679void ui_menu_control_floppy_image::handle()
680680{
681   floppy_image_device *fd = static_cast<floppy_image_device *>(image);   
681   floppy_image_device *fd = static_cast<floppy_image_device *>(image);
682682   switch(state) {
683683   case DO_CREATE: {
684684      floppy_image_format_t *fif_list = fd->get_formats();
src/emu/device.c
r14260r14261
110110     m_clock(clock),
111111     m_clock_scale(1.0),
112112     m_attoseconds_per_clock((clock == 0) ? 0 : HZ_TO_ATTOSECONDS(clock)),
113     
113
114114     m_debug(NULL),
115115     m_region(NULL),
116116     m_machine_config(mconfig),
r14260r14261
148148     m_clock(clock),
149149     m_clock_scale(1.0),
150150     m_attoseconds_per_clock((clock == 0) ? 0 : HZ_TO_ATTOSECONDS(clock)),
151     
151
152152     m_debug(NULL),
153153     m_region(NULL),
154154     m_machine_config(mconfig),
r14260r14261
262262
263263   // reset the device
264264   device_reset();
265   
265
266266   // reset all child devices
267267   for (device_t *child = m_subdevice_list.first(); child != NULL; child = child->next())
268268      child->reset();
269   
269
270270   // now allow for some post-child reset action
271271   device_reset_after_children();
272272
r14260r14261
695695            if (part == curdevice->m_basetag)
696696               break;
697697      }
698   
698
699699   // if we got a match, add to the fast map
700700   if (curdevice != NULL)
701701   {
r14260r14261
719719      tag++;
720720      result.cpy(":");
721721   }
722   
722
723723   // otherwise, start with our path
724724   else
725725   {
r14260r14261
735735      // copy everything up to there
736736      result.cat(tag, caret - tag);
737737      tag = caret + 1;
738     
738
739739      // strip trailing colons
740740      int len = result.len();
741741      while (result[--len] == ':')
742742         result.substr(0, len);
743   
743
744744      // remove the last path part, leaving the last colon
745745      if (result != ":")
746746      {
r14260r14261
792792   for (device_t *scan = iter.first(); scan != NULL; scan = iter.next())
793793      scan->m_device_map.remove(&old);
794794
795   // create a new device, and substitute it for the old one   
795   // create a new device, and substitute it for the old one
796796   device_t *device = (*type)(mconfig(), tag, this, clock);
797797   m_subdevice_list.replace_and_remove(*device, old);
798798
src/emu/device.h
r14260r14261
470470        m_current(NULL),
471471        m_curdepth(0),
472472        m_maxdepth(maxdepth) { }
473   
473
474474   // getters
475475   device_t *current() const { return m_current; }
476476
r14260r14261
480480   // reset and return first item
481481   device_t *first()
482482   {
483      m_current = m_root;
483      m_current = m_root;
484484      return m_current;
485485   }
486486
r14260r14261
502502            return m_current;
503503         }
504504      }
505     
505
506506      // search next for neighbors up the ownership chain
507507      while (m_curdepth > 0)
508508      {
r14260r14261
511511         if (m_current != NULL)
512512            return m_current;
513513
514         // no? try our parent         
514         // no? try our parent
515515         start = start->owner();
516516         m_curdepth--;
517517      }
518     
518
519519      // returned to the top; we're done
520520      return m_current = NULL;
521521   }
522   
522
523523   // return the number of items available
524524   int count()
525525   {
526      int result = 0;
526      int result = 0;
527527      for (device_t *item = first(); item != NULL; item = next())
528528         result++;
529529      return result;
530530   }
531   
531
532532   // return the index of a given item in the virtual list
533533   int indexof(device_t &device)
534534   {
r14260r14261
591591            return downcast<_DeviceClass *>(device);
592592      return NULL;
593593   }
594   
594
595595   // return the number of items available
596596   int count()
597597   {
598      int result = 0;
598      int result = 0;
599599      for (_DeviceClass *item = first(); item != NULL; item = next())
600600         result++;
601601      return result;
602602   }
603   
603
604604   // return the index of a given item in the virtual list
605605   int indexof(_DeviceClass &device)
606606   {
r14260r14261
641641
642642   // getters
643643   _InterfaceClass *current() const { return m_current; }
644   
644
645645   // setters
646646   void set_current(_InterfaceClass &current) { m_current = &current; m_iterator.set_current(current.device()); }
647647
r14260r14261
662662            return m_current;
663663      return NULL;
664664   }
665   
665
666666   // return the number of items available
667667   int count()
668668   {
669      int result = 0;
669      int result = 0;
670670      for (_InterfaceClass *item = first(); item != NULL; item = next())
671671         result++;
672672      return result;
673673   }
674   
674
675675   // return the index of a given item in the virtual list
676676   int indexof(_InterfaceClass &intrf)
677677   {
r14260r14261
755755
756756
757757//-------------------------------------------------
758//  siblingdevice - given a tag, find the device
758//  siblingdevice - given a tag, find the device
759759//  by name relative to this device's parent
760760//-------------------------------------------------
761761
r14260r14261
768768   // empty string or NULL means this device
769769   if (tag == NULL || *tag == 0)
770770      return const_cast<device_t *>(this);
771   
771
772772   // leading caret implies the owner, just skip it
773773   if (tag[0] == '^') tag++;
774774
src/emu/audit.c
r14260r14261
234234   int found = 0;
235235
236236   // iterate over sample entries
237   samples_device_iterator iter(m_enumerator.config().root_device());
237   samples_device_iterator iter(m_enumerator.config().root_device());
238238   for (samples_device *device = iter.first(); device != NULL; device = iter.next())
239239   {
240240      const samples_interface *intf = reinterpret_cast<const samples_interface *>(device->static_config());
src/emu/memory.c
r14260r14261
22332233         // determine full tag
22342234         astring fulltag;
22352235         device().siblingtag(fulltag, entry->m_region);
2236         
2236
22372237         // set the memory address
22382238         entry->m_memory = machine().region(fulltag.cstr())->base() + entry->m_rgnoffs;
22392239      }
src/emu/machine/scsihd.c
r14260r14261
257257   // Attempt to register save state entry after state registration is closed!
258258   state_save_register_item( machine, "scsihd", diskregion, 0, our_this->lba );
259259   state_save_register_item( machine, "scsihd", diskregion, 0, our_this->blocks );
260   
260
261261   // try to locate the CHD from a DISK_REGION
262262   our_this->handle = get_disk_handle(machine, diskregion);
263263   our_this->disk = hard_disk_open(our_this->handle);
264264   our_this->is_image_device = false;
265   
265
266266   if (our_this->disk == NULL)
267267   {
268268      // try to locate the CHD from an image device
269269      harddisk_image_device *image_device = machine.device<harddisk_image_device>(diskregion);
270     
270
271271      if (image_device != NULL)
272272      {
273273         our_this->handle = image_device->get_chd_file();
r14260r14261
275275         our_this->is_image_device = true;
276276      }
277277   }
278   
278
279279   if (our_this->disk == NULL)
280280   {
281281      // try to locate the CHD from an image subdevice
r14260r14261
290290         }
291291      }
292292   }
293   
293
294294   if (our_this->disk != NULL)
295295   {
296296      // get hard disk sector size from CHD metadata
src/emu/machine/6522via.c
r14260r14261
2727#include "devhelpr.h"
2828
2929/***************************************************************************
30   PARAMETERS
30    PARAMETERS
3131***************************************************************************/
3232
3333#define TRACE_VIA      0
3434
3535
3636/***************************************************************************
37   MACROS
37    MACROS
3838***************************************************************************/
3939
4040/* Macros for PCR */
r14260r14261
106106
107107
108108/***************************************************************************
109   INLINE FUNCTIONS
109    INLINE FUNCTIONS
110110***************************************************************************/
111111
112112inline void via6522_device::set_irq_line(int state)
r14260r14261
578578      CLR_PA_INT();
579579
580580      /* If CA2 is configured as output and in pulse or handshake mode,
581         CA2 is set now */
581           CA2 is set now */
582582      if (CA2_PULSE_OUTPUT(m_pcr))
583583      {
584584         /* call the CA2 output function */
r14260r14261
742742      CLR_PB_INT();
743743
744744      /* If CB2 is configured as output and in pulse or handshake mode,
745         CB2 is set now */
745           CB2 is set now */
746746      if (CB2_AUTO_HS(m_pcr))
747747      {
748748         if (m_out_cb2)
r14260r14261
10151015         set_int(INT_CA1);
10161016
10171017         /* CA2 is configured as output and in pulse or handshake mode,
1018            CA2 is cleared now */
1018               CA2 is cleared now */
10191019         if (CA2_AUTO_HS(m_pcr))
10201020         {
10211021            if (!m_out_ca2)
r14260r14261
10891089         set_int(INT_CB1);
10901090
10911091         /* CB2 is configured as output and in pulse or handshake mode,
1092            CB2 is cleared now */
1092               CB2 is cleared now */
10931093         if (CB2_AUTO_HS(m_pcr))
10941094         {
10951095            if (!m_out_cb2)
src/emu/machine/generic.c
r14260r14261
320320{
321321   running_machine &machine = device.machine();
322322
323   // start with either basename or basename_biosnum   
323   // start with either basename or basename_biosnum
324324   result.cpy(machine.basename());
325325   if (rom_system_bios(machine) != 0 && rom_default_bios(machine) != rom_system_bios(machine))
326326      result.catprintf("_%d", rom_system_bios(machine) - 1);
src/emu/machine/im6402.c
r14260r14261
3838inline void im6402_device::set_dr(int state)
3939{
4040   m_dr = state;
41   
41
4242   m_out_dr_func(state);
4343}
4444 
r14260r14261
5050inline void im6402_device::set_tbre(int state)
5151{
5252   m_tbre = state;
53   
53
5454   m_out_tbre_func(state);
5555}
5656 
r14260r14261
6262inline void im6402_device::set_tre(int state)
6363{
6464   m_tre = state;
65   
65
6666   m_out_tre_func(state);
6767}
6868 
r14260r14261
8686   {
8787      receive_register_extract();
8888      m_rbr = get_received_char();
89     
89
9090      if (m_dr)
9191      {
9292         m_oe = 1;
9393      }
94     
94
9595      set_dr(ASSERT_LINE);
9696   }
9797}
r14260r14261
106106   if (is_transmit_register_empty() && !m_tbre)
107107   {
108108      transmit_register_setup(m_tbr);
109     
109
110110      set_tbre(ASSERT_LINE);
111111      set_tre(CLEAR_LINE);
112112   }
113   
113
114114   if (!is_transmit_register_empty())
115115   {
116116      int bit = transmit_register_get_data_bit();
117           
117
118118      m_out_tro_func(bit);
119119      serial_connection_out();
120     
120
121121      if (is_transmit_register_empty())
122122      {
123123         set_tre(ASSERT_LINE);
r14260r14261
226226   m_pe = 0;
227227   m_fe = 0;
228228   m_oe = 0;
229   
229
230230   set_dr(CLEAR_LINE);
231231   set_tbre(ASSERT_LINE);
232232   set_tre(ASSERT_LINE);
r14260r14261
292292   if (state)
293293   {
294294      m_rrc_count++;
295     
295
296296      if (m_rrc_count == 16)
297297      {
298298         receive();
r14260r14261
311311   if (state)
312312   {
313313      m_trc_count++;
314     
314
315315      if (m_trc_count == 16)
316316      {
317317         transmit();
318318         m_trc_count = 0;
319319      }
320   }     
320   }
321321}
322322 
323323 
r14260r14261
436436      int word_length = 5 + ((m_cls2 << 1) | m_cls1);
437437      int stop_bits = 1 + m_sbs ? ((word_length == 5) ? 0.5 : 1) : 0;
438438      int parity_code;
439       
440      if (m_pi) parity_code = SERIAL_PARITY_NONE; 
441      else if (m_epe) parity_code = SERIAL_PARITY_EVEN; 
439 
440      if (m_pi) parity_code = SERIAL_PARITY_NONE;
441      else if (m_epe) parity_code = SERIAL_PARITY_EVEN;
442442      else parity_code = SERIAL_PARITY_ODD;
443     
443
444444      set_data_frame(word_length, stop_bits, parity_code);
445445   }
446446}
src/emu/machine/im6402.h
r14260r14261
2929                   RRI  20 |_____________| 21  MR
3030 
3131 
32            NOTE:   PIN      IM6402      IM6403
33                  ---------------------------
34                  2      N/C         CONTROL
35                  17      RRC         OSC IN
36                  40      TRC         OSC OUT
37               
32                NOTE:   PIN     IM6402      IM6403
33                        ---------------------------
34                        2       N/C         CONTROL
35                        17      RRC         OSC IN
36                        40      TRC         OSC OUT
37 
3838***************************************************************************/
3939 
4040#pragma once
r14260r14261
7070{
7171   int m_rrc;
7272   int m_trc;
73   
73
7474   devcb_read_line      m_in_rri_cb;
7575   devcb_write_line   m_out_tro_cb;
7676   devcb_write_line   m_out_dr_cb;
r14260r14261
8181 
8282// ======================> im6402_device
8383 
84class im6402_device :  public device_t,
84class im6402_device :  public device_t,
8585                  public device_serial_interface,
8686                  public im6402_interface
8787{
r14260r14261
9191 
9292   DECLARE_READ8_MEMBER( read );
9393   DECLARE_WRITE8_MEMBER( write );
94   
94
9595   DECLARE_READ_LINE_MEMBER( dr_r );
9696   DECLARE_READ_LINE_MEMBER( tbre_r );
9797   DECLARE_READ_LINE_MEMBER( tre_r );
r14260r14261
118118   virtual void device_start();
119119   virtual void device_reset();
120120   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
121   
121
122122   // device_serial_interface overrides
123123   virtual void input_callback(UINT8 state);
124124 
r14260r14261
128128   inline void set_tre(int state);
129129   inline void receive();
130130   inline void transmit();
131   
131
132132   static const device_timer_id TIMER_RX = 0;
133133   static const device_timer_id TIMER_TX = 1;
134134 
r14260r14261
145145   int m_pe;
146146   int m_fe;
147147   int m_oe;
148   
148
149149   // control
150150   int m_cls1;
151151   int m_cls2;
r14260r14261
153153   int m_sfd;
154154   int m_epe;
155155   int m_pi;
156   
156
157157   // receiver
158158   UINT8 m_rbr;
159159   int   m_rrc_count;
160   
160
161161   // transmitter
162162   UINT8 m_tbr;
163163   int   m_trc_count;
164   
164
165165   // timers
166166   emu_timer *m_rx_timer;
167167   emu_timer *m_tx_timer;
src/emu/screen.c
r14260r14261
430430   assert(height > 0);
431431   assert(visarea.min_x >= 0);
432432   assert(visarea.min_y >= 0);
433//   assert(visarea.max_x < width);
434//   assert(visarea.max_y < height);
433//  assert(visarea.max_x < width);
434//  assert(visarea.max_y < height);
435435   assert(m_type == SCREEN_TYPE_VECTOR || visarea.min_x < width);
436436   assert(m_type == SCREEN_TYPE_VECTOR || visarea.min_y < height);
437437   assert(frame_period > 0);
r14260r14261
509509   // doesn't apply for vector games
510510   if (m_type == SCREEN_TYPE_VECTOR)
511511      return;
512   
512
513513   // determine effective size to allocate
514514   INT32 effwidth = MAX(m_width, m_visarea.max_x + 1);
515515   INT32 effheight = MAX(m_height, m_visarea.max_y + 1);
src/emu/mconfig.c
r14260r14261
8080         if (!options.exists(owner.tag()+1))
8181            selval = slot->get_default_card(*this, options);
8282
83         if (selval != NULL && strlen(selval) != 0)
83         if (selval != NULL && strlen(selval) != 0)
8484         {
8585            bool found = false;
86            for (int i = 0; intf[i].name != NULL; i++)
86            for (int i = 0; intf[i].name != NULL; i++)
8787            {
8888               if (strcmp(selval, intf[i].name) == 0)
8989               {
r14260r14261
143143   // if there's an owner, let the owner do the work
144144   if (owner != NULL)
145145      return owner->add_subdevice(type, tag, clock);
146     
146
147147   // otherwise, allocate the device directly
148148   assert(m_root_device == NULL);
149149   m_root_device = (*type)(*this, tag, owner, clock);
r14260r14261
171171      mame_printf_warning("Warning: attempting to replace non-existent device '%s'\n", tag);
172172      return device_add(owner, tag, type, clock);
173173   }
174   
174
175175   // let the device's owner do the work
176176   return device->owner()->replace_subdevice(*device, type, tag, clock);
177177}
src/lib/formats/flopimg.c
r14260r14261
940940
941941/***************************************************************************
942942
943   New implementation
943    New implementation
944944
945945****************************************************************************
946946
src/lib/formats/flopimg.h
r14260r14261
226226public:
227227   floppy_image_format_t();
228228   virtual ~floppy_image_format_t();
229   
229
230230   /*! @brief Identify an image.
231     The identify function tests if the image is valid
232     for this particular format.
233     @param io buffer containing the image data.
234     @param form_factor Physical form factor of disk, from the enum
235     in floppy_image
236     @return 1 if image valid, 0 otherwise.
237   */
231      The identify function tests if the image is valid
232      for this particular format.
233      @param io buffer containing the image data.
234      @param form_factor Physical form factor of disk, from the enum
235      in floppy_image
236      @return 1 if image valid, 0 otherwise.
237    */
238238   virtual int identify(io_generic *io, UINT32 form_factor) = 0;
239   
239
240240   /*! @brief Load an image.
241     The load function opens an image file and converts it to the
242     internal MESS floppy representation.
243     @param io source buffer containing the image data.
244     @param form_factor Physical form factor of disk, from the enum
245     in floppy_image
246     @param image output buffer for data in MESS internal format.
247     @return true on success, false otherwise.
248   */
241      The load function opens an image file and converts it to the
242      internal MESS floppy representation.
243      @param io source buffer containing the image data.
244      @param form_factor Physical form factor of disk, from the enum
245      in floppy_image
246      @param image output buffer for data in MESS internal format.
247      @return true on success, false otherwise.
248    */
249249    virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image) = 0;
250   
250
251251    /*! @brief Save an image.
252252      The save function writes back an image from the MESS internal
253253      floppy representation to the appropriate format on disk.
254254      @param io output buffer for the data in the on-disk format.
255255      @param image source buffer containing data in MESS internal format.
256     @return true on success, false otherwise.
256      @return true on success, false otherwise.
257257    */
258258   virtual bool save(io_generic *io, floppy_image *image);
259259
r14260r14261
275275   //! @param file_name
276276   //! @returns true if file matches the extension.
277277   bool extension_matches(const char *file_name) const;
278   
278
279279protected:
280280   //! Input for convert_to_edge
281281   enum {
r14260r14261
289289   // **** Reader helpers ****
290290
291291   //! Struct designed for easy track data description. Contains an opcode and two params.
292   
292
293293   //! Optional, you can always do things by hand, but useful nevertheless.
294294   //! A vector of these structures describes one track.
295   
295
296296   struct desc_e {
297297      int type,   //!< An opcode
298         p1,     //!< first param
299         p2;     //!< second param
298         p1,    //!< first param
299         p2;    //!< second param
300300   };
301   
301
302302   //! Opcodes of the format description language used by generate_track()
303303   enum {
304304      END,                    //!< End of description
r14260r14261
347347
348348
349349   /*! @brief Generate one track according to the description vector.
350       @param desc track data description
351       @param track
352       @param head
353       @param sect a vector indexed by sector id.
354       @param sect_count number of sectors.
355       @param track_size in _cells_, i.e. 100000 for a usual 2us-per-cell track at 300rpm.
356       @param image
357   */
350        @param desc track data description
351        @param track
352        @param head
353        @param sect a vector indexed by sector id.
354        @param sect_count number of sectors.
355        @param track_size in _cells_, i.e. 100000 for a usual 2us-per-cell track at 300rpm.
356        @param image
357    */
358358   void generate_track(const desc_e *desc, int track, int head, const desc_s *sect, int sect_count, int track_size, floppy_image *image);
359359
360360   /*! @brief Generate a track from cell binary values, MSB-first.
361       @param track
362       @param head
363       @param trackbuf track input buffer.
364       @param track_size in cells, not bytes.
365       @param image
366   */
361        @param track
362        @param head
363        @param trackbuf track input buffer.
364        @param track_size in cells, not bytes.
365        @param image
366    */
367367   void generate_track_from_bitstream(int track, int head, const UINT8 *trackbuf, int track_size, floppy_image *image);
368368
369369   //! @brief Generate a track from cell level values (0/1/W/D/N).
370   
370
371371   /*! Note that this function needs to be able to split cells in two,
372       so no time value should be less than 2, and even values are a
373       good idea.
374   */
372        so no time value should be less than 2, and even values are a
373        good idea.
374    */
375375   /*! @param track
376      @param head
377       @param trackbuf track input buffer.
378       @param track_size in cells, not bytes.
379      @param splice_pos is the position of the track splice.  For normal
380       formats, use -1.  For protected formats, you're supposed to
381       know. trackbuf may be modified at that position or after.
382       @param image
383   */
376        @param head
377        @param trackbuf track input buffer.
378        @param track_size in cells, not bytes.
379        @param splice_pos is the position of the track splice.  For normal
380        formats, use -1.  For protected formats, you're supposed to
381        know. trackbuf may be modified at that position or after.
382        @param image
383    */
384384   void generate_track_from_levels(int track, int head, UINT32 *trackbuf, int track_size, int splice_pos, floppy_image *image);
385385
386386   //! Normalize the times in a cell buffer to sum up to 200000000
r14260r14261
401401
402402   //   Fastcopy Pro optimized formats, with fake sector header for
403403   //   faster verify and skew/interleave where appropriate
404   static const desc_e atari_st_fcp_9[];
404   static const desc_e atari_st_fcp_9[];
405405   static const desc_e *const atari_st_fcp_10[10];
406406   static const desc_e atari_st_fcp_11[];
407407
r14260r14261
422422   // **** Writer helpers ****
423423
424424   /*! @brief Rebuild a cell bitstream for a track.
425       Takes the cell standard
426       angular size as a parameter, gives out a msb-first bitstream.
425        Takes the cell standard
426        angular size as a parameter, gives out a msb-first bitstream.
427427
428       Beware that fuzzy bits will always give out the same value.
429       @param track
430       @param head
431       @param cell_size
432       @param trackbuf Output buffer size should be 34% more than the nominal number
433       of cells (the dpll tolerates a cell size down to 75% of the
434       nominal one, with gives a cell count of 1/0.75=1.333... times
435       the nominal one).
436       @param track_size Output size is given in bits (cells).
437       @param image
438   */
428        Beware that fuzzy bits will always give out the same value.
429        @param track
430        @param head
431        @param cell_size
432        @param trackbuf Output buffer size should be 34% more than the nominal number
433        of cells (the dpll tolerates a cell size down to 75% of the
434        nominal one, with gives a cell count of 1/0.75=1.333... times
435        the nominal one).
436        @param track_size Output size is given in bits (cells).
437        @param image
438    */
439439   /*! @verbatim
440    Computing the standard angular size of a cell is
441    simple. Noting:
442      d = standard cell duration in microseconds
443      r = motor rotational speed in rpm
444    then:
445      a = r * d * 10 / 3.
446    Some values:
447      Type           Cell    RPM    Size
440     Computing the standard angular size of a cell is
441     simple. Noting:
442       d = standard cell duration in microseconds
443       r = motor rotational speed in rpm
444     then:
445       a = r * d * 10 / 3.
446     Some values:
447       Type           Cell    RPM    Size
448448
449    C1541 tr  1-17   3.25    300    3250
450    C1541 tr 18-24   3.50    300    3500
451    C1541 tr 25-30   3.75    300    3750
452    C1541 tr 31+     4.00    300    4000
453    5.25" SD         4       300    4000
454    5.25" DD         2       300    2000
455    5.25" HD         1       360    1200
456    3.5" SD          4       300    4000
457    3.5" DD          2       300    2000
458    3.5" HD          1       300    1000
459    3.5" ED          0.5     300     500
460    @endverbatim
461    */
449     C1541 tr  1-17   3.25    300    3250
450     C1541 tr 18-24   3.50    300    3500
451     C1541 tr 25-30   3.75    300    3750
452     C1541 tr 31+     4.00    300    4000
453     5.25" SD         4       300    4000
454     5.25" DD         2       300    2000
455     5.25" HD         1       360    1200
456     3.5" SD          4       300    4000
457     3.5" DD          2       300    2000
458     3.5" HD          1       300    1000
459     3.5" ED          0.5     300     500
460     @endverbatim
461     */
462462
463463   void generate_bitstream_from_track(int track, int head, int cell_size,  UINT8 *trackbuf, int &track_size, floppy_image *image);
464   
464
465465   //! Defines a standard sector for extracting.
466466   struct desc_xs {
467467      int track,   //!< Track for this sector
r14260r14261
484484
485485
486486   //! @brief Get a geometry (including sectors) from an image.
487   
487
488488    //!   PC-type sectors with MFM encoding
489489   void get_geometry_mfm_pc(floppy_image *image, int cell_size, int &track_count, int &head_count, int &sector_count);
490490
r14260r14261
519519private:
520520   enum { CRC_NONE, CRC_AMIGA, CRC_CCITT, CRC_MACHEAD };
521521   enum { MAX_CRC_COUNT = 64 };
522   
522
523523   //! Holds data used internally for generating CRCs.
524524   struct gen_crc_info {
525525      int type, //!< Type of CRC
r14260r14261
598598      TIME_MASK = 0x0fffffff,
599599      MG_MASK   = 0xf0000000,
600600      MG_SHIFT  = 28,   //!< Bitshift constant for magnetic orientation data
601      MG_A      = (0 << MG_SHIFT),     //!< - 0, MG_A -> Magnetic orientation A
601      MG_A      = (0 << MG_SHIFT),   //!< - 0, MG_A -> Magnetic orientation A
602602      MG_B      = (1 << MG_SHIFT),   //!< - 1, MG_B -> Magnetic orientation B
603603      MG_N      = (2 << MG_SHIFT),   //!< - 2, MG_N -> Non-magnetized zone (neutral)
604604      MG_D      = (3 << MG_SHIFT)    //!< - 3, MG_D -> Damaged zone, reads as neutral but cannot be changed by writing
r14260r14261
626626
627627   //! floppy_image constructor
628628   /*!
629     @param _tracks number of tracks.
630     @param _heads number of heads.
631     @param _form_factor form factor of drive (from enum)
632   */
629      @param _tracks number of tracks.
630      @param _heads number of heads.
631      @param _form_factor form factor of drive (from enum)
632    */
633633   floppy_image(int tracks, int heads, UINT32 form_factor);
634634   virtual ~floppy_image();
635   
635
636636   //! @return the form factor.
637637   UINT32 get_form_factor() { return form_factor; }
638638   //! @return the variant.
639639   UINT32 get_variant() { return variant; }
640640   //! @param v the variant.
641   void set_variant(UINT32 v) { variant = v; } 
641   void set_variant(UINT32 v) { variant = v; }
642642
643643   /*!
644     @param track
645     @param head
646     @param size size of this track
647   */
644      @param track
645      @param head
646      @param size size of this track
647    */
648648   void set_track_size(int track, int head, UINT32 size) { track_size[track][head] = size; ensure_alloc(track, head); }
649   
649
650650    /*!
651651      @param track track number
652      @param head head number
652      @param head head number
653653      @return a pointer to the data buffer for this track and head
654654    */
655655   UINT32 *get_buffer(int track, int head) { return cell_data[track][head]; }
r14260r14261
657657   //! @param track
658658   //! @param head
659659   UINT32 get_track_size(int track, int head) { return track_size[track][head]; }
660   
660
661661   //! Sets the write splice position.
662662   //! The "track splice" information indicates where to start writing
663663   //! if you try to rewrite a physical disk with the data.  Some
r14260r14261
666666   //! representation is the angular position relative to the index.
667667
668668   /*! @param track
669       @param head
670       @param pos the position
671   */
669        @param head
670        @param pos the position
671    */
672672   void set_write_splice_position(int track, int head, UINT32 pos) { write_splice[track][head] = pos; }
673673   //! @return the current write splice position.
674674   UINT32 get_write_splice_position(int track, int head) const { return write_splice[track][head]; }
r14260r14261
683683   static const char *get_variant_name(UINT32 form_factor, UINT32 variant);
684684
685685private:
686   
686
687687   enum {
688688      MAX_FLOPPY_HEADS = 2,
689689      MAX_FLOPPY_TRACKS = 84
src/lib/libflac/include/flac/stream_encoder.h
r14260r14261
244244
245245   FLAC__STREAM_ENCODER_UNINITIALIZED,
246246   /**< The encoder is in the uninitialized state; one of the
247    * FLAC__stream_encoder_init_*() functions must be called before samples
248    * can be processed.
249    */
247     * FLAC__stream_encoder_init_*() functions must be called before samples
248     * can be processed.
249     */
250250
251251   FLAC__STREAM_ENCODER_OGG_ERROR,
252252   /**< An error occurred in the underlying Ogg layer.  */
253253
254254   FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR,
255255   /**< An error occurred in the underlying verify stream decoder;
256    * check FLAC__stream_encoder_get_verify_decoder_state().
257    */
256     * check FLAC__stream_encoder_get_verify_decoder_state().
257     */
258258
259259   FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA,
260260   /**< The verify decoder detected a mismatch between the original
261    * audio signal and the decoded audio signal.
262    */
261     * audio signal and the decoded audio signal.
262     */
263263
264264   FLAC__STREAM_ENCODER_CLIENT_ERROR,
265265   /**< One of the callbacks returned a fatal error. */
266266
267267   FLAC__STREAM_ENCODER_IO_ERROR,
268268   /**< An I/O error occurred while opening/reading/writing a file.
269    * Check \c errno.
270    */
269     * Check \c errno.
270     */
271271
272272   FLAC__STREAM_ENCODER_FRAMING_ERROR,
273273   /**< An error occurred while writing the stream; usually, the
274    * write_callback returned an error.
275    */
274     * write_callback returned an error.
275     */
276276
277277   FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR
278278   /**< Memory allocation failed. */
r14260r14261
299299
300300   FLAC__STREAM_ENCODER_INIT_STATUS_UNSUPPORTED_CONTAINER,
301301   /**< The library was not compiled with support for the given container
302    * format.
303    */
302     * format.
303     */
304304
305305   FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_CALLBACKS,
306306   /**< A required callback was not supplied. */
r14260r14261
310310
311311   FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BITS_PER_SAMPLE,
312312   /**< The encoder has an invalid setting for bits-per-sample.
313    * FLAC supports 4-32 bps but the reference encoder currently supports
314    * only up to 24 bps.
315    */
313     * FLAC supports 4-32 bps but the reference encoder currently supports
314     * only up to 24 bps.
315     */
316316
317317   FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_SAMPLE_RATE,
318318   /**< The encoder has an invalid setting for the input sample rate. */
r14260r14261
334334
335335   FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA,
336336   /**< The metadata input to the encoder is invalid, in one of the following ways:
337    * - FLAC__stream_encoder_set_metadata() was called with a null pointer but a block count > 0
338    * - One of the metadata blocks contains an undefined type
339    * - It contains an illegal CUESHEET as checked by FLAC__format_cuesheet_is_legal()
340    * - It contains an illegal SEEKTABLE as checked by FLAC__format_seektable_is_legal()
341    * - It contains more than one SEEKTABLE block or more than one VORBIS_COMMENT block
342    */
337     * - FLAC__stream_encoder_set_metadata() was called with a null pointer but a block count > 0
338     * - One of the metadata blocks contains an undefined type
339     * - It contains an illegal CUESHEET as checked by FLAC__format_cuesheet_is_legal()
340     * - It contains an illegal SEEKTABLE as checked by FLAC__format_seektable_is_legal()
341     * - It contains more than one SEEKTABLE block or more than one VORBIS_COMMENT block
342     */
343343
344344   FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED
345345   /**< FLAC__stream_encoder_init_*() was called when the encoder was
346    * already initialized, usually because
347    * FLAC__stream_encoder_finish() was not called.
348    */
346     * already initialized, usually because
347     * FLAC__stream_encoder_finish() was not called.
348     */
349349
350350} FLAC__StreamEncoderInitStatus;
351351
src/lib/libflac/include/flac/metadata.h
r14260r14261
762762
763763   FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH,
764764   /**< FLAC__metadata_chain_write() was called on a chain read by
765    *   FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(),
766    *   or
767    *   FLAC__metadata_chain_write_with_callbacks()/FLAC__metadata_chain_write_with_callbacks_and_tempfile()
768    *   was called on a chain read by
769    *   FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg().
770    *   Matching read/write methods must always be used. */
765     *   FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(),
766     *   or
767     *   FLAC__metadata_chain_write_with_callbacks()/FLAC__metadata_chain_write_with_callbacks_and_tempfile()
768     *   was called on a chain read by
769     *   FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg().
770     *   Matching read/write methods must always be used. */
771771
772772   FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL
773773   /**< FLAC__metadata_chain_write_with_callbacks() was called when the
774    *   chain write requires a tempfile; use
775    *   FLAC__metadata_chain_write_with_callbacks_and_tempfile() instead.
776    *   Or, FLAC__metadata_chain_write_with_callbacks_and_tempfile() was
777    *   called when the chain write does not require a tempfile; use
778    *   FLAC__metadata_chain_write_with_callbacks() instead.
779    *   Always check FLAC__metadata_chain_check_if_tempfile_needed()
780    *   before writing via callbacks. */
774     *   chain write requires a tempfile; use
775     *   FLAC__metadata_chain_write_with_callbacks_and_tempfile() instead.
776     *   Or, FLAC__metadata_chain_write_with_callbacks_and_tempfile() was
777     *   called when the chain write does not require a tempfile; use
778     *   FLAC__metadata_chain_write_with_callbacks() instead.
779     *   Always check FLAC__metadata_chain_check_if_tempfile_needed()
780     *   before writing via callbacks. */
781781
782782} FLAC__Metadata_ChainStatus;
783783
src/lib/libflac/include/flac/stream_decoder.h
r14260r14261
208208
209209   FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC,
210210   /**< The decoder is ready to or is in the process of searching for the
211    * frame sync code.
212    */
211     * frame sync code.
212     */
213213
214214   FLAC__STREAM_DECODER_READ_FRAME,
215215   /**< The decoder is ready to or is in the process of reading a frame. */
r14260r14261
222222
223223   FLAC__STREAM_DECODER_SEEK_ERROR,
224224   /**< An error occurred while seeking.  The decoder must be flushed
225    * with FLAC__stream_decoder_flush() or reset with
226    * FLAC__stream_decoder_reset() before decoding can continue.
227    */
225     * with FLAC__stream_decoder_flush() or reset with
226     * FLAC__stream_decoder_reset() before decoding can continue.
227     */
228228
229229   FLAC__STREAM_DECODER_ABORTED,
230230   /**< The decoder was aborted by the read callback. */
231231
232232   FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR,
233233   /**< An error occurred allocating memory.  The decoder is in an invalid
234    * state and can no longer be used.
235    */
234     * state and can no longer be used.
235     */
236236
237237   FLAC__STREAM_DECODER_UNINITIALIZED
238238   /**< The decoder is in the uninitialized state; one of the
239    * FLAC__stream_decoder_init_*() functions must be called before samples
240    * can be processed.
241    */
239     * FLAC__stream_decoder_init_*() functions must be called before samples
240     * can be processed.
241     */
242242
243243} FLAC__StreamDecoderState;
244244
r14260r14261
259259
260260   FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER,
261261   /**< The library was not compiled with support for the given container
262    * format.
263    */
262     * format.
263     */
264264
265265   FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS,
266266   /**< A required callback was not supplied. */
r14260r14261
270270
271271   FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE,
272272   /**< fopen() failed in FLAC__stream_decoder_init_file() or
273    * FLAC__stream_decoder_init_ogg_file(). */
273    * FLAC__stream_decoder_init_ogg_file(). */
274274
275275   FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED
276276   /**< FLAC__stream_decoder_init_*() was called when the decoder was
277    * already initialized, usually because
278    * FLAC__stream_decoder_finish() was not called.
279    */
277     * already initialized, usually because
278     * FLAC__stream_decoder_finish() was not called.
279     */
280280
281281} FLAC__StreamDecoderInitStatus;
282282
r14260r14261
297297
298298   FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM,
299299   /**< The read was attempted while at the end of the stream.  Note that
300    * the client must only return this value when the read callback was
301    * called when already at the end of the stream.  Otherwise, if the read
302    * itself moves to the end of the stream, the client should still return
303    * the data and \c FLAC__STREAM_DECODER_READ_STATUS_CONTINUE, and then on
304    * the next read callback it should return
305    * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM with a byte count
306    * of \c 0.
307    */
300     * the client must only return this value when the read callback was
301     * called when already at the end of the stream.  Otherwise, if the read
302     * itself moves to the end of the stream, the client should still return
303     * the data and \c FLAC__STREAM_DECODER_READ_STATUS_CONTINUE, and then on
304     * the next read callback it should return
305     * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM with a byte count
306     * of \c 0.
307     */
308308
309309   FLAC__STREAM_DECODER_READ_STATUS_ABORT
310310   /**< An unrecoverable error occurred.  The decoder will return from the process call. */
src/lib/libflac/include/flac/format.h
r14260r14261
8484
8585
8686/*
87   Most of the values described in this file are defined by the FLAC
88   format specification.  There is nothing to tune here.
87    Most of the values described in this file are defined by the FLAC
88    format specification.  There is nothing to tune here.
8989*/
9090
9191/** The largest legal metadata type code. */
r14260r14261
193193typedef enum {
194194   FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE = 0,
195195   /**< Residual is coded by partitioning into contexts, each with it's own
196    * 4-bit Rice parameter. */
196    * 4-bit Rice parameter. */
197197
198198   FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 = 1
199199   /**< Residual is coded by partitioning into contexts, each with it's own
200    * 5-bit Rice parameter. */
200    * 5-bit Rice parameter. */
201201} FLAC__EntropyCodingMethodType;
202202
203203/** Maps a FLAC__EntropyCodingMethodType to a C string.
r14260r14261
217217
218218   unsigned *raw_bits;
219219   /**< Widths for escape-coded partitions.  Will be non-zero for escaped
220    * partitions and zero for unescaped partitions.
221    */
220     * partitions and zero for unescaped partitions.
221     */
222222
223223   unsigned capacity_by_order;
224224   /**< The capacity of the \a parameters and \a raw_bits arrays
225    * specified as an order, i.e. the number of array elements
226    * allocated is 2 ^ \a capacity_by_order.
227    */
225     * specified as an order, i.e. the number of array elements
226     * allocated is 2 ^ \a capacity_by_order.
227     */
228228} FLAC__EntropyCodingMethod_PartitionedRiceContents;
229229
230230/** Header for a Rice partitioned residual.  (c.f. <A HREF="../format.html#partitioned_rice">format specification</A>)
r14260r14261
425425
426426   FLAC__FrameNumberType number_type;
427427   /**< The numbering scheme used for the frame.  As a convenience, the
428    * decoder will always convert a frame number to a sample number because
429    * the rules are complex. */
428     * decoder will always convert a frame number to a sample number because
429     * the rules are complex. */
430430
431431   union {
432432      FLAC__uint32 frame_number;
433433      FLAC__uint64 sample_number;
434434   } number;
435435   /**< The frame number or sample number of first sample in frame;
436    * use the \a number_type value to determine which to use. */
436    * use the \a number_type value to determine which to use. */
437437
438438   FLAC__uint8 crc;
439439   /**< CRC-8 (polynomial = x^8 + x^2 + x^1 + x^0, initialized with 0)
440    * of the raw frame header bytes, meaning everything before the CRC byte
441    * including the sync code.
442    */
440     * of the raw frame header bytes, meaning everything before the CRC byte
441     * including the sync code.
442     */
443443} FLAC__FrameHeader;
444444
445445extern FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC; /**< == 0x3ffe; the frame header sync code */
r14260r14261
459459typedef struct {
460460   FLAC__uint16 crc;
461461   /**< CRC-16 (polynomial = x^16 + x^15 + x^2 + x^0, initialized with
462    * 0) of the bytes before the crc, back to and including the frame header
463    * sync code.
464    */
462     * 0) of the bytes before the crc, back to and including the frame header
463     * sync code.
464     */
465465} FLAC__FrameFooter;
466466
467467extern FLAC_API const unsigned FLAC__FRAME_FOOTER_CRC_LEN; /**< == 16 (bits) */
r14260r14261
551551typedef struct {
552552   int dummy;
553553   /**< Conceptually this is an empty struct since we don't store the
554    * padding bytes.  Empty structs are not allowed by some C compilers,
555    * hence the dummy.
556    */
554     * padding bytes.  Empty structs are not allowed by some C compilers,
555     * hence the dummy.
556     */
557557} FLAC__StreamMetadata_Padding;
558558
559559
r14260r14261
574574
575575   FLAC__uint64 stream_offset;
576576   /**< The offset, in bytes, of the target frame with respect to
577    * beginning of the first frame. */
577    * beginning of the first frame. */
578578
579579   unsigned frame_samples;
580580   /**< The number of samples in the target frame. */
r14260r14261
644644typedef struct {
645645   FLAC__uint64 offset;
646646   /**< Offset in samples, relative to the track offset, of the index
647    * point.
648    */
647     * point.
648     */
649649
650650   FLAC__byte number;
651651   /**< The index point number. */
r14260r14261
700700typedef struct {
701701   char media_catalog_number[129];
702702   /**< Media catalog number, in ASCII printable characters 0x20-0x7e.  In
703    * general, the media catalog number may be 0 to 128 bytes long; any
704    * unused characters should be right-padded with NUL characters.
705    */
703     * general, the media catalog number may be 0 to 128 bytes long; any
704     * unused characters should be right-padded with NUL characters.
705     */
706706
707707   FLAC__uint64 lead_in;
708708   /**< The number of lead-in samples. */
r14260r14261
769769
770770   char *mime_type;
771771   /**< Picture data's MIME type, in ASCII printable characters
772    * 0x20-0x7e, NUL terminated.  For best compatibility with players,
773    * use picture data of MIME type \c image/jpeg or \c image/png.  A
774    * MIME type of '-->' is also allowed, in which case the picture
775    * data should be a complete URL.  In file storage, the MIME type is
776    * stored as a 32-bit length followed by the ASCII string with no NUL
777    * terminator, but is converted to a plain C string in this structure
778    * for convenience.
779    */
772     * 0x20-0x7e, NUL terminated.  For best compatibility with players,
773     * use picture data of MIME type \c image/jpeg or \c image/png.  A
774     * MIME type of '-->' is also allowed, in which case the picture
775     * data should be a complete URL.  In file storage, the MIME type is
776     * stored as a 32-bit length followed by the ASCII string with no NUL
777     * terminator, but is converted to a plain C string in this structure
778     * for convenience.
779     */
780780
781781   FLAC__byte *description;
782782   /**< Picture's description in UTF-8, NUL terminated.  In file storage,
783    * the description is stored as a 32-bit length followed by the UTF-8
784    * string with no NUL terminator, but is converted to a plain C string
785    * in this structure for convenience.
786    */
783     * the description is stored as a 32-bit length followed by the UTF-8
784     * string with no NUL terminator, but is converted to a plain C string
785     * in this structure for convenience.
786     */
787787
788788   FLAC__uint32 width;
789789   /**< Picture's width in pixels. */
r14260r14261
796796
797797   FLAC__uint32 colors;
798798   /**< For indexed palettes (like GIF), picture's number of colors (the
799    * number of palette entries), or \c 0 for non-indexed (i.e. 2^depth).
800    */
799     * number of palette entries), or \c 0 for non-indexed (i.e. 2^depth).
800     */
801801
802802   FLAC__uint32 data_length;
803803   /**< Length of binary picture data in bytes. */
r14260r14261
831831typedef struct {
832832   FLAC__MetadataType type;
833833   /**< The type of the metadata block; used determine which member of the
834    * \a data union to dereference.  If type >= FLAC__METADATA_TYPE_UNDEFINED
835    * then \a data.unknown must be used. */
834     * \a data union to dereference.  If type >= FLAC__METADATA_TYPE_UNDEFINED
835     * then \a data.unknown must be used. */
836836
837837   FLAC__bool is_last;
838838   /**< \c true if this metadata block is the last, else \a false */
r14260r14261
851851      FLAC__StreamMetadata_Unknown unknown;
852852   } data;
853853   /**< Polymorphic block data; use the \a type value to determine which
854    * to use. */
854    * to use. */
855855} FLAC__StreamMetadata;
856856
857857extern FLAC_API const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN; /**< == 1 (bit) */
src/lib/libflac/include/private/lpc.h
r14260r14261
4242#ifndef FLAC__INTEGER_ONLY_LIBRARY
4343
4444/*
45 *   FLAC__lpc_window_data()
46 *   --------------------------------------------------------------------
47 *   Applies the given window to the data.
45 *  FLAC__lpc_window_data()
46 *  --------------------------------------------------------------------
47 *  Applies the given window to the data.
4848 *  OPT: asm implementation
4949 *
50 *   IN in[0,data_len-1]
51 *   IN window[0,data_len-1]
52 *   OUT out[0,lag-1]
53 *   IN data_len
50 *  IN in[0,data_len-1]
51 *  IN window[0,data_len-1]
52 *  OUT out[0,lag-1]
53 *  IN data_len
5454 */
5555void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], unsigned data_len);
5656
5757/*
58 *   FLAC__lpc_compute_autocorrelation()
59 *   --------------------------------------------------------------------
60 *   Compute the autocorrelation for lags between 0 and lag-1.
61 *   Assumes data[] outside of [0,data_len-1] == 0.
62 *   Asserts that lag > 0.
58 *  FLAC__lpc_compute_autocorrelation()
59 *  --------------------------------------------------------------------
60 *  Compute the autocorrelation for lags between 0 and lag-1.
61 *  Assumes data[] outside of [0,data_len-1] == 0.
62 *  Asserts that lag > 0.
6363 *
64 *   IN data[0,data_len-1]
65 *   IN data_len
66 *   IN 0 < lag <= data_len
67 *   OUT autoc[0,lag-1]
64 *  IN data[0,data_len-1]
65 *  IN data_len
66 *  IN 0 < lag <= data_len
67 *  OUT autoc[0,lag-1]
6868 */
6969void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
7070#ifndef FLAC__NO_ASM
r14260r14261
8080#endif
8181
8282/*
83 *   FLAC__lpc_compute_lp_coefficients()
84 *   --------------------------------------------------------------------
85 *   Computes LP coefficients for orders 1..max_order.
86 *   Do not call if autoc[0] == 0.0.  This means the signal is zero
87 *   and there is no point in calculating a predictor.
83 *  FLAC__lpc_compute_lp_coefficients()
84 *  --------------------------------------------------------------------
85 *  Computes LP coefficients for orders 1..max_order.
86 *  Do not call if autoc[0] == 0.0.  This means the signal is zero
87 *  and there is no point in calculating a predictor.
8888 *
89 *   IN autoc[0,max_order]                      autocorrelation values
90 *   IN 0 < max_order <= FLAC__MAX_LPC_ORDER    max LP order to compute
91 *   OUT lp_coeff[0,max_order-1][0,max_order-1] LP coefficients for each order
92 *   *** IMPORTANT:
93 *   *** lp_coeff[0,max_order-1][max_order,FLAC__MAX_LPC_ORDER-1] are untouched
94 *   OUT error[0,max_order-1]                   error for each order (more
95 *                                              specifically, the variance of
96 *                                              the error signal times # of
97 *                                              samples in the signal)
89 *  IN autoc[0,max_order]                      autocorrelation values
90 *  IN 0 < max_order <= FLAC__MAX_LPC_ORDER    max LP order to compute
91 *  OUT lp_coeff[0,max_order-1][0,max_order-1] LP coefficients for each order
92 *  *** IMPORTANT:
93 *  *** lp_coeff[0,max_order-1][max_order,FLAC__MAX_LPC_ORDER-1] are untouched
94 *  OUT error[0,max_order-1]                   error for each order (more
95 *                                             specifically, the variance of
96 *                                             the error signal times # of
97 *                                             samples in the signal)
9898 *
99 *   Example: if max_order is 9, the LP coefficients for order 9 will be
100 *            in lp_coeff[8][0,8], the LP coefficients for order 8 will be
101 *          in lp_coeff[7][0,7], etc.
99 *  Example: if max_order is 9, the LP coefficients for order 9 will be
100 *           in lp_coeff[8][0,8], the LP coefficients for order 8 will be
101 *           in lp_coeff[7][0,7], etc.
102102 */
103103void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned *max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], FLAC__double error[]);
104104
105105/*
106 *   FLAC__lpc_quantize_coefficients()
107 *   --------------------------------------------------------------------
108 *   Quantizes the LP coefficients.  NOTE: precision + bits_per_sample
109 *   must be less than 32 (sizeof(FLAC__int32)*8).
106 *  FLAC__lpc_quantize_coefficients()
107 *  --------------------------------------------------------------------
108 *  Quantizes the LP coefficients.  NOTE: precision + bits_per_sample
109 *  must be less than 32 (sizeof(FLAC__int32)*8).
110110 *
111 *   IN lp_coeff[0,order-1]    LP coefficients
112 *   IN order                  LP order
113 *   IN FLAC__MIN_QLP_COEFF_PRECISION < precision
114 *                             desired precision (in bits, including sign
115 *                             bit) of largest coefficient
116 *   OUT qlp_coeff[0,order-1]  quantized coefficients
117 *   OUT shift                 # of bits to shift right to get approximated
118 *                             LP coefficients.  NOTE: could be negative.
119 *   RETURN 0 => quantization OK
120 *          1 => coefficients require too much shifting for *shift to
111 *  IN lp_coeff[0,order-1]    LP coefficients
112 *  IN order                  LP order
113 *  IN FLAC__MIN_QLP_COEFF_PRECISION < precision
114 *                            desired precision (in bits, including sign
115 *                            bit) of largest coefficient
116 *  OUT qlp_coeff[0,order-1]  quantized coefficients
117 *  OUT shift                 # of bits to shift right to get approximated
118 *                            LP coefficients.  NOTE: could be negative.
119 *  RETURN 0 => quantization OK
120 *         1 => coefficients require too much shifting for *shift to
121121 *              fit in the LPC subframe header.  'shift' is unset.
122122 *         2 => coefficients are all zero, which is bad.  'shift' is
123123 *              unset.
r14260r14261
125125int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order, unsigned precision, FLAC__int32 qlp_coeff[], int *shift);
126126
127127/*
128 *   FLAC__lpc_compute_residual_from_qlp_coefficients()
129 *   --------------------------------------------------------------------
130 *   Compute the residual signal obtained from sutracting the predicted
131 *   signal from the original.
128 *  FLAC__lpc_compute_residual_from_qlp_coefficients()
129 *  --------------------------------------------------------------------
130 *  Compute the residual signal obtained from sutracting the predicted
131 *  signal from the original.
132132 *
133 *   IN data[-order,data_len-1] original signal (NOTE THE INDICES!)
134 *   IN data_len                length of original signal
135 *   IN qlp_coeff[0,order-1]    quantized LP coefficients
136 *   IN order > 0               LP order
137 *   IN lp_quantization         quantization of LP coefficients in bits
138 *   OUT residual[0,data_len-1] residual signal
133 *  IN data[-order,data_len-1] original signal (NOTE THE INDICES!)
134 *  IN data_len                length of original signal
135 *  IN qlp_coeff[0,order-1]    quantized LP coefficients
136 *  IN order > 0               LP order
137 *  IN lp_quantization         quantization of LP coefficients in bits
138 *  OUT residual[0,data_len-1] residual signal
139139 */
140140void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
141141void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
r14260r14261
151151#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */
152152
153153/*
154 *   FLAC__lpc_restore_signal()
155 *   --------------------------------------------------------------------
156 *   Restore the original signal by summing the residual and the
157 *   predictor.
154 *  FLAC__lpc_restore_signal()
155 *  --------------------------------------------------------------------
156 *  Restore the original signal by summing the residual and the
157 *  predictor.
158158 *
159 *   IN residual[0,data_len-1]  residual signal
160 *   IN data_len                length of original signal
161 *   IN qlp_coeff[0,order-1]    quantized LP coefficients
162 *   IN order > 0               LP order
163 *   IN lp_quantization         quantization of LP coefficients in bits
164 *   *** IMPORTANT: the caller must pass in the historical samples:
165 *   IN  data[-order,-1]        previously-reconstructed historical samples
166 *   OUT data[0,data_len-1]     original signal
159 *  IN residual[0,data_len-1]  residual signal
160 *  IN data_len                length of original signal
161 *  IN qlp_coeff[0,order-1]    quantized LP coefficients
162 *  IN order > 0               LP order
163 *  IN lp_quantization         quantization of LP coefficients in bits
164 *  *** IMPORTANT: the caller must pass in the historical samples:
165 *  IN  data[-order,-1]        previously-reconstructed historical samples
166 *  OUT data[0,data_len-1]     original signal
167167 */
168168void FLAC__lpc_restore_signal(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
169169void FLAC__lpc_restore_signal_wide(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
r14260r14261
182182#ifndef FLAC__INTEGER_ONLY_LIBRARY
183183
184184/*
185 *   FLAC__lpc_compute_expected_bits_per_residual_sample()
186 *   --------------------------------------------------------------------
187 *   Compute the expected number of bits per residual signal sample
188 *   based on the LP error (which is related to the residual variance).
185 *  FLAC__lpc_compute_expected_bits_per_residual_sample()
186 *  --------------------------------------------------------------------
187 *  Compute the expected number of bits per residual signal sample
188 *  based on the LP error (which is related to the residual variance).
189189 *
190 *   IN lpc_error >= 0.0   error returned from calculating LP coefficients
191 *   IN total_samples > 0  # of samples in residual signal
192 *   RETURN                expected bits per sample
190 *  IN lpc_error >= 0.0   error returned from calculating LP coefficients
191 *  IN total_samples > 0  # of samples in residual signal
192 *  RETURN                expected bits per sample
193193 */
194194FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample(FLAC__double lpc_error, unsigned total_samples);
195195FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(FLAC__double lpc_error, FLAC__double error_scale);
196196
197197/*
198 *   FLAC__lpc_compute_best_order()
199 *   --------------------------------------------------------------------
200 *   Compute the best order from the array of signal errors returned
201 *   during coefficient computation.
198 *  FLAC__lpc_compute_best_order()
199 *  --------------------------------------------------------------------
200 *  Compute the best order from the array of signal errors returned
201 *  during coefficient computation.
202202 *
203 *   IN lpc_error[0,max_order-1] >= 0.0  error returned from calculating LP coefficients
204 *   IN max_order > 0                    max LP order
205 *   IN total_samples > 0                # of samples in residual signal
206 *   IN overhead_bits_per_order          # of bits overhead for each increased LP order
207 *                                       (includes warmup sample size and quantized LP coefficient)
208 *   RETURN [1,max_order]                best order
203 *  IN lpc_error[0,max_order-1] >= 0.0  error returned from calculating LP coefficients
204 *  IN max_order > 0                    max LP order
205 *  IN total_samples > 0                # of samples in residual signal
206 *  IN overhead_bits_per_order          # of bits overhead for each increased LP order
207 *                                      (includes warmup sample size and quantized LP coefficient)
208 *  RETURN [1,max_order]                best order
209209 */
210210unsigned FLAC__lpc_compute_best_order(const FLAC__double lpc_error[], unsigned max_order, unsigned total_samples, unsigned overhead_bits_per_order);
211211
src/lib/libflac/include/private/fixed.h
r14260r14261
4040#include "flac/format.h"
4141
4242/*
43 *   FLAC__fixed_compute_best_predictor()
44 *   --------------------------------------------------------------------
45 *   Compute the best fixed predictor and the expected bits-per-sample
43 *  FLAC__fixed_compute_best_predictor()
44 *  --------------------------------------------------------------------
45 *  Compute the best fixed predictor and the expected bits-per-sample
4646 *  of the residual signal for each order.  The _wide() version uses
4747 *  64-bit integers which is statistically necessary when bits-per-
4848 *  sample + log2(blocksize) > 30
4949 *
50 *   IN data[0,data_len-1]
51 *   IN data_len
52 *   OUT residual_bits_per_sample[0,FLAC__MAX_FIXED_ORDER]
50 *  IN data[0,data_len-1]
51 *  IN data_len
52 *  OUT residual_bits_per_sample[0,FLAC__MAX_FIXED_ORDER]
5353 */
5454#ifndef FLAC__INTEGER_ONLY_LIBRARY
5555unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
r14260r14261
6767#endif
6868
6969/*
70 *   FLAC__fixed_compute_residual()
71 *   --------------------------------------------------------------------
72 *   Compute the residual signal obtained from sutracting the predicted
73 *   signal from the original.
70 *  FLAC__fixed_compute_residual()
71 *  --------------------------------------------------------------------
72 *  Compute the residual signal obtained from sutracting the predicted
73 *  signal from the original.
7474 *
75 *   IN data[-order,data_len-1]        original signal (NOTE THE INDICES!)
76 *   IN data_len                       length of original signal
77 *   IN order <= FLAC__MAX_FIXED_ORDER fixed-predictor order
78 *   OUT residual[0,data_len-1]        residual signal
75 *  IN data[-order,data_len-1]        original signal (NOTE THE INDICES!)
76 *  IN data_len                       length of original signal
77 *  IN order <= FLAC__MAX_FIXED_ORDER fixed-predictor order
78 *  OUT residual[0,data_len-1]        residual signal
7979 */
8080void FLAC__fixed_compute_residual(const FLAC__int32 data[], unsigned data_len, unsigned order, FLAC__int32 residual[]);
8181
8282/*
83 *   FLAC__fixed_restore_signal()
84 *   --------------------------------------------------------------------
85 *   Restore the original signal by summing the residual and the
86 *   predictor.
83 *  FLAC__fixed_restore_signal()
84 *  --------------------------------------------------------------------
85 *  Restore the original signal by summing the residual and the
86 *  predictor.
8787 *
88 *   IN residual[0,data_len-1]         residual signal
89 *   IN data_len                       length of original signal
90 *   IN order <= FLAC__MAX_FIXED_ORDER fixed-predictor order
91 *   *** IMPORTANT: the caller must pass in the historical samples:
92 *   IN  data[-order,-1]               previously-reconstructed historical samples
93 *   OUT data[0,data_len-1]            original signal
88 *  IN residual[0,data_len-1]         residual signal
89 *  IN data_len                       length of original signal
90 *  IN order <= FLAC__MAX_FIXED_ORDER fixed-predictor order
91 *  *** IMPORTANT: the caller must pass in the historical samples:
92 *  IN  data[-order,-1]               previously-reconstructed historical samples
93 *  OUT data[0,data_len-1]            original signal
9494 */
9595void FLAC__fixed_restore_signal(const FLAC__int32 residual[], unsigned data_len, unsigned order, FLAC__int32 data[]);
9696
src/lib/libflac/include/private/float.h
r14260r14261
7474#define FLAC__fixedpoint_div(x, y) ( (FLAC__fixedpoint) ( ( ((FLAC__int64)(x)<<32) / (FLAC__int64)(y) ) >> 16 ) )
7575
7676/*
77 *   FLAC__fixedpoint_log2()
78 *   --------------------------------------------------------------------
79 *   Returns the base-2 logarithm of the fixed-point number 'x' using an
80 *   algorithm by Knuth for x >= 1.0
77 *  FLAC__fixedpoint_log2()
78 *  --------------------------------------------------------------------
79 *  Returns the base-2 logarithm of the fixed-point number 'x' using an
80 *  algorithm by Knuth for x >= 1.0
8181 *
82 *   'fracbits' is the number of fractional bits of 'x'.  'fracbits' must
83 *   be < 32 and evenly divisible by 4 (0 is OK but not very precise).
82 *  'fracbits' is the number of fractional bits of 'x'.  'fracbits' must
83 *  be < 32 and evenly divisible by 4 (0 is OK but not very precise).
8484 *
85 *   'precision' roughly limits the number of iterations that are done;
86 *   use (unsigned)(-1) for maximum precision.
85 *  'precision' roughly limits the number of iterations that are done;
86 *  use (unsigned)(-1) for maximum precision.
8787 *
88 *   If 'x' is less than one -- that is, x < (1<<fracbits) -- then this
89 *   function will punt and return 0.
88 *  If 'x' is less than one -- that is, x < (1<<fracbits) -- then this
89 *  function will punt and return 0.
9090 *
91 *   The return value will also have 'fracbits' fractional bits.
91 *  The return value will also have 'fracbits' fractional bits.
9292 */
9393FLAC__uint32 FLAC__fixedpoint_log2(FLAC__uint32 x, unsigned fracbits, unsigned precision);
9494
src/lib/libflac/include/private/window.h
r14260r14261
4242#ifndef FLAC__INTEGER_ONLY_LIBRARY
4343
4444/*
45 *   FLAC__window_*()
46 *   --------------------------------------------------------------------
47 *   Calculates window coefficients according to different apodization
48 *   functions.
45 *  FLAC__window_*()
46 *  --------------------------------------------------------------------
47 *  Calculates window coefficients according to different apodization
48 *  functions.
4949 *
50 *   OUT window[0,L-1]
51 *   IN L (number of points in window)
50 *  OUT window[0,L-1]
51 *  IN L (number of points in window)
5252 */
5353void FLAC__window_bartlett(FLAC__real *window, const FLAC__int32 L);
5454void FLAC__window_bartlett_hann(FLAC__real *window, const FLAC__int32 L);
src/lib/libflac/include/flac++/encoder.h
r14260r14261
7979   namespace Encoder {
8080
8181      /** \ingroup flacpp_encoder
82       *  \brief
83       *  This class wraps the ::FLAC__StreamEncoder.  If you are
84       *  encoding to a file, FLAC::Encoder::File may be more
85       *  convenient.
86       *
87       * The usage of this class is similar to FLAC__StreamEncoder,
88       * except instead of providing callbacks to
89       * FLAC__stream_encoder_init*_stream(), you will inherit from this
90       * class and override the virtual callback functions with your
91       * own implementations, then call init() or init_ogg().  The rest of
92       * the calls work the same as in the C layer.
93       *
94       * Only the write callback is mandatory.  The others are
95       * optional; this class provides default implementations that do
96       * nothing.  In order for some STREAMINFO and SEEKTABLE data to
97       * be written properly, you must overide seek_callback() and
98       * tell_callback(); see FLAC__stream_encoder_init_stream() as to
99       * why.
100       */
82         *  \brief
83         *  This class wraps the ::FLAC__StreamEncoder.  If you are
84         *  encoding to a file, FLAC::Encoder::File may be more
85         *  convenient.
86         *
87         * The usage of this class is similar to FLAC__StreamEncoder,
88         * except instead of providing callbacks to
89         * FLAC__stream_encoder_init*_stream(), you will inherit from this
90         * class and override the virtual callback functions with your
91         * own implementations, then call init() or init_ogg().  The rest of
92         * the calls work the same as in the C layer.
93         *
94         * Only the write callback is mandatory.  The others are
95         * optional; this class provides default implementations that do
96         * nothing.  In order for some STREAMINFO and SEEKTABLE data to
97         * be written properly, you must overide seek_callback() and
98         * tell_callback(); see FLAC__stream_encoder_init_stream() as to
99         * why.
100         */
101101      class FLACPP_API Stream {
102102      public:
103103         /** This class is a wrapper around FLAC__StreamEncoderState.
104          */
104            */
105105         class FLACPP_API State {
106106         public:
107107            inline State(::FLAC__StreamEncoderState state): state_(state) { }
r14260r14261
117117
118118         //@{
119119         /** Call after construction to check the that the object was created
120          *  successfully.  If not, use get_state() to find out why not.
121          *
122          */
120             *  successfully.  If not, use get_state() to find out why not.
121             *
122             */
123123         virtual bool is_valid() const;
124124         inline operator bool() const { return is_valid(); } ///< See is_valid()
125125         //@}
r14260r14261
210210      };
211211
212212      /** \ingroup flacpp_encoder
213       *  \brief
214       *  This class wraps the ::FLAC__StreamEncoder.  If you are
215       *  not encoding to a file, you may need to use
216       *  FLAC::Encoder::Stream.
217       *
218       * The usage of this class is similar to FLAC__StreamEncoder,
219       * except instead of providing callbacks to
220       * FLAC__stream_encoder_init*_FILE() or
221       * FLAC__stream_encoder_init*_file(), you will inherit from this
222       * class and override the virtual callback functions with your
223       * own implementations, then call init() or init_ogg().  The rest
224       * of the calls work the same as in the C layer.
225       *
226       * There are no mandatory callbacks; all the callbacks from
227       * FLAC::Encoder::Stream are implemented here fully and support
228       * full post-encode STREAMINFO and SEEKTABLE updating.  There is
229       * only an optional progress callback which you may override to
230       * get periodic reports on the progress of the encode.
231       */
213         *  \brief
214         *  This class wraps the ::FLAC__StreamEncoder.  If you are
215         *  not encoding to a file, you may need to use
216         *  FLAC::Encoder::Stream.
217         *
218         * The usage of this class is similar to FLAC__StreamEncoder,
219         * except instead of providing callbacks to
220         * FLAC__stream_encoder_init*_FILE() or
221         * FLAC__stream_encoder_init*_file(), you will inherit from this
222         * class and override the virtual callback functions with your
223         * own implementations, then call init() or init_ogg().  The rest
224         * of the calls work the same as in the C layer.
225         *
226         * There are no mandatory callbacks; all the callbacks from
227         * FLAC::Encoder::Stream are implemented here fully and support
228         * full post-encode STREAMINFO and SEEKTABLE updating.  There is
229         * only an optional progress callback which you may override to
230         * get periodic reports on the progress of the encode.
231         */
232232      class FLACPP_API File: public Stream {
233233      public:
234234         File();
src/lib/libflac/include/flac++/metadata.h
r14260r14261
8181      // ============================================================
8282
8383      /** \defgroup flacpp_metadata_object FLAC++/metadata.h: metadata object classes
84       *  \ingroup flacpp_metadata
85       *
86       * This module contains classes representing FLAC metadata
87       * blocks in memory.
88       *
89       * The behavior closely mimics the C layer interface; be
90       * sure to read the detailed description of the
91       * \link flac_metadata_object C metadata object module \endlink.
92       *
93       * Any time a metadata object is constructed or assigned, you
94       * should check is_valid() to make sure the underlying
95       * ::FLAC__StreamMetadata object was able to be created.
96       *
97       * \warning
98       * When the get_*() methods of any metadata object method
99       * return you a const pointer, DO NOT disobey and write into it.
100       * Always use the set_*() methods.
101       *
102       * \{
103       */
84         *  \ingroup flacpp_metadata
85         *
86         * This module contains classes representing FLAC metadata
87         * blocks in memory.
88         *
89         * The behavior closely mimics the C layer interface; be
90         * sure to read the detailed description of the
91         * \link flac_metadata_object C metadata object module \endlink.
92         *
93         * Any time a metadata object is constructed or assigned, you
94         * should check is_valid() to make sure the underlying
95         * ::FLAC__StreamMetadata object was able to be created.
96         *
97         * \warning
98         * When the get_*() methods of any metadata object method
99         * return you a const pointer, DO NOT disobey and write into it.
100         * Always use the set_*() methods.
101         *
102         * \{
103         */
104104
105105      /** Base class for all metadata block types.
106       *  See the \link flacpp_metadata_object overview \endlink for more.
107       */
106         *  See the \link flacpp_metadata_object overview \endlink for more.
107         */
108108      class FLACPP_API Prototype {
109109      protected:
110110         //@{
111111         /** Constructs a copy of the given object.  This form
112          *  always performs a deep copy.
113          */
112             *  always performs a deep copy.
113             */
114114         Prototype(const Prototype &);
115115         Prototype(const ::FLAC__StreamMetadata &);
116116         Prototype(const ::FLAC__StreamMetadata *);
117117         //@}
118118
119119         /** Constructs an object with copy control.  When \a copy
120          *  is \c true, behaves identically to
121          *  FLAC::Metadata::Prototype::Prototype(const ::FLAC__StreamMetadata *object).
122          *  When \a copy is \c false, the instance takes ownership of
123          *  the pointer and the ::FLAC__StreamMetadata object will
124          *  be freed by the destructor.
125          *
126          *  \assert
127          *    \code object != NULL \endcode
128          */
120             *  is \c true, behaves identically to
121             *  FLAC::Metadata::Prototype::Prototype(const ::FLAC__StreamMetadata *object).
122             *  When \a copy is \c false, the instance takes ownership of
123             *  the pointer and the ::FLAC__StreamMetadata object will
124             *  be freed by the destructor.
125             *
126             *  \assert
127             *    \code object != NULL \endcode
128             */
129129         Prototype(::FLAC__StreamMetadata *object, bool copy);
130130
131131         //@{
r14260r14261
136136         //@}
137137
138138         /** Assigns an object with copy control.  See
139          *  Prototype(::FLAC__StreamMetadata *object, bool copy).
140          */
139             *  Prototype(::FLAC__StreamMetadata *object, bool copy).
140             */
141141         Prototype &assign_object(::FLAC__StreamMetadata *object, bool copy);
142142
143143         /** Deletes the underlying ::FLAC__StreamMetadata object.
144          */
144            */
145145         virtual void clear();
146146
147147         ::FLAC__StreamMetadata *object_;
148148      public:
149149         /** Deletes the underlying ::FLAC__StreamMetadata object.
150          */
150            */
151151         virtual ~Prototype();
152152
153153         //@{
154154         /** Check for equality, performing a deep compare by following pointers.
155          */
155            */
156156         inline bool operator==(const Prototype &) const;
157157         inline bool operator==(const ::FLAC__StreamMetadata &) const;
158158         inline bool operator==(const ::FLAC__StreamMetadata *) const;
r14260r14261
169169         friend class Iterator;
170170
171171         /** Returns \c true if the object was correctly constructed
172          *  (i.e. the underlying ::FLAC__StreamMetadata object was
173          *  properly allocated), else \c false.
174          */
172             *  (i.e. the underlying ::FLAC__StreamMetadata object was
173             *  properly allocated), else \c false.
174             */
175175         inline bool is_valid() const;
176176
177177         /** Returns \c true if this block is the last block in a
178          *  stream, else \c false.
179          *
180          * \assert
181          *   \code is_valid() \endcode
182          */
178             *  stream, else \c false.
179             *
180             * \assert
181             *   \code is_valid() \endcode
182             */
183183         bool get_is_last() const;
184184
185185         /** Returns the type of the block.
186          *
187          * \assert
188          *   \code is_valid() \endcode
189          */
186             *
187             * \assert
188             *   \code is_valid() \endcode
189             */
190190         ::FLAC__MetadataType get_type() const;
191191
192192         /** Returns the stream length of the metadata block.
193          *
194          * \note
195          *   The length does not include the metadata block header,
196          *   per spec.
197          *
198          * \assert
199          *   \code is_valid() \endcode
200          */
193             *
194             * \note
195             *   The length does not include the metadata block header,
196             *   per spec.
197             *
198             * \assert
199             *   \code is_valid() \endcode
200             */
201201         unsigned get_length() const;
202202
203203         /** Sets the "is_last" flag for the block.  When using the iterators
204          *  it is not necessary to set this flag; they will do it for you.
205          *
206          * \assert
207          *   \code is_valid() \endcode
208          */
204             *  it is not necessary to set this flag; they will do it for you.
205             *
206             * \assert
207             *   \code is_valid() \endcode
208             */
209209         void set_is_last(bool);
210210
211211         /** Returns a pointer to the underlying ::FLAC__StreamMetadata
212          *  object.  This can be useful for plugging any holes between
213          *  the C++ and C interfaces.
214          *
215          * \assert
216          *   \code is_valid() \endcode
217          */
212             *  object.  This can be useful for plugging any holes between
213             *  the C++ and C interfaces.
214             *
215             * \assert
216             *   \code is_valid() \endcode
217             */
218218         inline operator const ::FLAC__StreamMetadata *() const;
219219      private:
220220         /** Private and undefined so you can't use it. */
r14260r14261
264264
265265
266266      /** STREAMINFO metadata block.
267       *  See the \link flacpp_metadata_object overview \endlink for more,
268       *  and the <A HREF="../format.html#metadata_block_streaminfo">format specification</A>.
269       */
267         *  See the \link flacpp_metadata_object overview \endlink for more,
268         *  and the <A HREF="../format.html#metadata_block_streaminfo">format specification</A>.
269         */
270270      class FLACPP_API StreamInfo : public Prototype {
271271      public:
272272         StreamInfo();
273273
274274         //@{
275275         /** Constructs a copy of the given object.  This form
276          *  always performs a deep copy.
277          */
276             *  always performs a deep copy.
277             */
278278         inline StreamInfo(const StreamInfo &object): Prototype(object) { }
279279         inline StreamInfo(const ::FLAC__StreamMetadata &object): Prototype(object) { }
280280         inline StreamInfo(const ::FLAC__StreamMetadata *object): Prototype(object) { }
281281         //@}
282282
283283         /** Constructs an object with copy control.  See
284          *  Prototype(::FLAC__StreamMetadata *object, bool copy).
285          */
284             *  Prototype(::FLAC__StreamMetadata *object, bool copy).
285             */
286286         inline StreamInfo(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
287287
288288         ~StreamInfo();
r14260r14261
295295         //@}
296296
297297         /** Assigns an object with copy control.  See
298          *  Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
299          */
298             *  Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
299             */
300300         inline StreamInfo &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
301301
302302         //@{
r14260r14261
338338      };
339339
340340      /** PADDING metadata block.
341       *  See the \link flacpp_metadata_object overview \endlink for more,
342       *  and the <A HREF="../format.html#metadata_block_padding">format specification</A>.
343       */
341         *  See the \link flacpp_metadata_object overview \endlink for more,
342         *  and the <A HREF="../format.html#metadata_block_padding">format specification</A>.
343         */
344344      class FLACPP_API Padding : public Prototype {
345345      public:
346346         Padding();
347347
348348         //@{
349349         /** Constructs a copy of the given object.  This form
350          *  always performs a deep copy.
351          */
350             *  always performs a deep copy.
351             */
352352         inline Padding(const Padding &object): Prototype(object) { }
353353         inline Padding(const ::FLAC__StreamMetadata &object): Prototype(object) { }
354354         inline Padding(const ::FLAC__StreamMetadata *object): Prototype(object) { }
355355         //@}
356356
357357         /** Constructs an object with copy control.  See
358          *  Prototype(::FLAC__StreamMetadata *object, bool copy).
359          */
358             *  Prototype(::FLAC__StreamMetadata *object, bool copy).
359             */
360360         inline Padding(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
361361
362362         ~Padding();
r14260r14261
369369         //@}
370370
371371         /** Assigns an object with copy control.  See
372          *  Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
373          */
372             *  Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
373             */
374374         inline Padding &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
375375
376376         //@{
r14260r14261
391391      };
392392
393393      /** APPLICATION metadata block.
394       *  See the \link flacpp_metadata_object overview \endlink for more,
395       *  and the <A HREF="../format.html#metadata_block_application">format specification</A>.
396       */
394         *  See the \link flacpp_metadata_object overview \endlink for more,
395         *  and the <A HREF="../format.html#metadata_block_application">format specification</A>.
396         */
397397      class FLACPP_API Application : public Prototype {
398398      public:
399399         Application();
400400         //
401401         //@{
402402         /** Constructs a copy of the given object.  This form
403          *  always performs a deep copy.
404          */
403             *  always performs a deep copy.
404             */
405405         inline Application(const Application &object): Prototype(object) { }
406406         inline Application(const ::FLAC__StreamMetadata &object): Prototype(object) { }
407407         inline Application(const ::FLAC__StreamMetadata *object): Prototype(object) { }
408408         //@}
409409
410410         /** Constructs an object with copy control.  See
411          *  Prototype(::FLAC__StreamMetadata *object, bool copy).
412          */
411             *  Prototype(::FLAC__StreamMetadata *object, bool copy).
412             */
413413         inline Application(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
414414
415415         ~Application();
r14260r14261
422422         //@}
423423
424424         /** Assigns an object with copy control.  See
425          *  Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
426          */
425             *  Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
426             */
427427         inline Application &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
428428
429429         //@{
r14260r14261
450450      };
451451
452452      /** SEEKTABLE metadata block.
453       *  See the \link flacpp_metadata_object overview \endlink for more,
454       *  and the <A HREF="../format.html#metadata_block_seektable">format specification</A>.
455       */
453         *  See the \link flacpp_metadata_object overview \endlink for more,
454         *  and the <A HREF="../format.html#metadata_block_seektable">format specification</A>.
455         */
456456      class FLACPP_API SeekTable : public Prototype {
457457      public:
458458         SeekTable();
459459
460460         //@{
461461         /** Constructs a copy of the given object.  This form
462          *  always performs a deep copy.
463          */
462             *  always performs a deep copy.
463             */
464464         inline SeekTable(const SeekTable &object): Prototype(object) { }
465465         inline SeekTable(const ::FLAC__StreamMetadata &object): Prototype(object) { }
466466         inline SeekTable(const ::FLAC__StreamMetadata *object): Prototype(object) { }
467467         //@}
468468
469469         /** Constructs an object with copy control.  See
470          *  Prototype(::FLAC__StreamMetadata *object, bool copy).
471          */
470             *  Prototype(::FLAC__StreamMetadata *object, bool copy).
471             */
472472         inline SeekTable(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
473473
474474         ~SeekTable();
r14260r14261
481481         //@}
482482
483483         /** Assigns an object with copy control.  See
484          *  Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
485          */
484             *  Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
485             */
486486         inline SeekTable &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
487487
488488         //@{
r14260r14261
516516      };
517517
518518      /** VORBIS_COMMENT metadata block.
519       *  See the \link flacpp_metadata_object overview \endlink for more,
520       *  and the <A HREF="../format.html#metadata_block_vorbis_comment">format specification</A>.
521       */
519         *  See the \link flacpp_metadata_object overview \endlink for more,
520         *  and the <A HREF="../format.html#metadata_block_vorbis_comment">format specification</A>.
521         */
522522      class FLACPP_API VorbisComment : public Prototype {
523523      public:
524524         /** Convenience class for encapsulating Vorbis comment
525          *  entries.  An entry is a vendor string or a comment
526          *  field.  In the case of a vendor string, the field
527          *  name is undefined; only the field value is relevant.
528          *
529          *  A \a field as used in the methods refers to an
530          *  entire 'NAME=VALUE' string; for convenience the
531          *  string is NUL-terminated.  A length field is
532          *  required in the unlikely event that the value
533          *  contains contain embedded NULs.
534          *
535          *  A \a field_name is what is on the left side of the
536          *  first '=' in the \a field.  By definition it is ASCII
537          *  and so is NUL-terminated and does not require a
538          *  length to describe it.  \a field_name is undefined
539          *  for a vendor string entry.
540          *
541          *  A \a field_value is what is on the right side of the
542          *  first '=' in the \a field.  By definition, this may
543          *  contain embedded NULs and so a \a field_value_length
544          *  is required to describe it.  However in practice,
545          *  embedded NULs are not known to be used, so it is
546          *  generally safe to treat field values as NUL-
547          *  terminated UTF-8 strings.
548          *
549          *  Always check is_valid() after the constructor or operator=
550          *  to make sure memory was properly allocated and that the
551          *  Entry conforms to the Vorbis comment specification.
552          */
525             *  entries.  An entry is a vendor string or a comment
526             *  field.  In the case of a vendor string, the field
527             *  name is undefined; only the field value is relevant.
528             *
529             *  A \a field as used in the methods refers to an
530             *  entire 'NAME=VALUE' string; for convenience the
531             *  string is NUL-terminated.  A length field is
532             *  required in the unlikely event that the value
533             *  contains contain embedded NULs.
534             *
535             *  A \a field_name is what is on the left side of the
536             *  first '=' in the \a field.  By definition it is ASCII
537             *  and so is NUL-terminated and does not require a
538             *  length to describe it.  \a field_name is undefined
539             *  for a vendor string entry.
540             *
541             *  A \a field_value is what is on the right side of the
542             *  first '=' in the \a field.  By definition, this may
543             *  contain embedded NULs and so a \a field_value_length
544             *  is required to describe it.  However in practice,
545             *  embedded NULs are not known to be used, so it is
546             *  generally safe to treat field values as NUL-
547             *  terminated UTF-8 strings.
548             *
549             *  Always check is_valid() after the constructor or operator=
550             *  to make sure memory was properly allocated and that the
551             *  Entry conforms to the Vorbis comment specification.
552             */
553553         class FLACPP_API Entry {
554554         public:
555555            Entry();
r14260r14261
607607
608608         //@{
609609         /** Constructs a copy of the given object.  This form
610          *  always performs a deep copy.
611          */
610             *  always performs a deep copy.
611             */
612612         inline VorbisComment(const VorbisComment &object): Prototype(object) { }
613613         inline VorbisComment(const ::FLAC__StreamMetadata &object): Prototype(object) { }
614614         inline VorbisComment(const ::FLAC__StreamMetadata *object): Prototype(object) { }
615615         //@}
616616
617617         /** Constructs an object with copy control.  See
618          *  Prototype(::FLAC__StreamMetadata *object, bool copy).
619          */
618             *  Prototype(::FLAC__StreamMetadata *object, bool copy).
619             */
620620         inline VorbisComment(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
621621
622622         ~VorbisComment();
r14260r14261
629629         //@}
630630
631631         /** Assigns an object with copy control.  See
632          *  Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
633          */
632             *  Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
633             */
634634         inline VorbisComment &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
635635
636636         //@{
r14260r14261
668668      };
669669
670670      /** CUESHEET metadata block.
671       *  See the \link flacpp_metadata_object overview \endlink for more,
672       *  and the <A HREF="../format.html#metadata_block_cuesheet">format specification</A>.
673       */
671         *  See the \link flacpp_metadata_object overview \endlink for more,
672         *  and the <A HREF="../format.html#metadata_block_cuesheet">format specification</A>.
673         */
674674      class FLACPP_API CueSheet : public Prototype {
675675      public:
676676         /** Convenience class for encapsulating a cue sheet
677          *  track.
678          *
679          *  Always check is_valid() after the constructor or operator=
680          *  to make sure memory was properly allocated.
681          */
677             *  track.
678             *
679             *  Always check is_valid() after the constructor or operator=
680             *  to make sure memory was properly allocated.
681             */
682682         class FLACPP_API Track {
683683         protected:
684684            ::FLAC__StreamMetadata_CueSheet_Track *object_;
r14260r14261
710710            void set_type(unsigned value);
711711            inline void set_pre_emphasis(bool value) { object_->pre_emphasis = value? 1 : 0; }
712712
713             void set_index(unsigned i, const ::FLAC__StreamMetadata_CueSheet_Index &index);
713            void set_index(unsigned i, const ::FLAC__StreamMetadata_CueSheet_Index &index);
714714            //@@@ It's awkward but to insert/delete index points
715715            //@@@ you must use the routines in the CueSheet class.
716716         };
r14260r14261
719719
720720         //@{
721721         /** Constructs a copy of the given object.  This form
722          *  always performs a deep copy.
723          */
722             *  always performs a deep copy.
723             */
724724         inline CueSheet(const CueSheet &object): Prototype(object) { }
725725         inline CueSheet(const ::FLAC__StreamMetadata &object): Prototype(object) { }
726726         inline CueSheet(const ::FLAC__StreamMetadata *object): Prototype(object) { }
727727         //@}
728728
729729         /** Constructs an object with copy control.  See
730          *  Prototype(::FLAC__StreamMetadata *object, bool copy).
731          */
730             *  Prototype(::FLAC__StreamMetadata *object, bool copy).
731             */
732732         inline CueSheet(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
733733
734734         ~CueSheet();
r14260r14261
741741         //@}
742742
743743         /** Assigns an object with copy control.  See
744          *  Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
745          */
744             *  Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
745             */
746746         inline CueSheet &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
747747
748748         //@{
r14260r14261
795795      };
796796
797797      /** PICTURE metadata block.
798       *  See the \link flacpp_metadata_object overview \endlink for more,
799       *  and the <A HREF="../format.html#metadata_block_picture">format specification</A>.
800       */
798         *  See the \link flacpp_metadata_object overview \endlink for more,
799         *  and the <A HREF="../format.html#metadata_block_picture">format specification</A>.
800         */
801801      class FLACPP_API Picture : public Prototype {
802802      public:
803803         Picture();
804804
805805         //@{
806806         /** Constructs a copy of the given object.  This form
807          *  always performs a deep copy.
808          */
807             *  always performs a deep copy.
808             */
809809         inline Picture(const Picture &object): Prototype(object) { }
810810         inline Picture(const ::FLAC__StreamMetadata &object): Prototype(object) { }
811811         inline Picture(const ::FLAC__StreamMetadata *object): Prototype(object) { }
812812         //@}
813813
814814         /** Constructs an object with copy control.  See
815          *  Prototype(::FLAC__StreamMetadata *object, bool copy).
816          */
815             *  Prototype(::FLAC__StreamMetadata *object, bool copy).
816             */
817817         inline Picture(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
818818
819819         ~Picture();
r14260r14261
826826         //@}
827827
828828         /** Assigns an object with copy control.  See
829          *  Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
830          */
829             *  Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
830             */
831831         inline Picture &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
832832
833833         //@{
r14260r14261
872872      };
873873
874874      /** Opaque metadata block for storing unknown types.
875       *  This should not be used unless you know what you are doing;
876       *  it is currently used only internally to support forward
877       *  compatibility of metadata blocks.
878       *  See the \link flacpp_metadata_object overview \endlink for more,
879       */
875         *  This should not be used unless you know what you are doing;
876         *  it is currently used only internally to support forward
877         *  compatibility of metadata blocks.
878         *  See the \link flacpp_metadata_object overview \endlink for more,
879         */
880880      class FLACPP_API Unknown : public Prototype {
881881      public:
882882         Unknown();
883883         //
884884         //@{
885885         /** Constructs a copy of the given object.  This form
886          *  always performs a deep copy.
887          */
886             *  always performs a deep copy.
887             */
888888         inline Unknown(const Unknown &object): Prototype(object) { }
889889         inline Unknown(const ::FLAC__StreamMetadata &object): Prototype(object) { }
890890         inline Unknown(const ::FLAC__StreamMetadata *object): Prototype(object) { }
891891         //@}
892892
893893         /** Constructs an object with copy control.  See
894          *  Prototype(::FLAC__StreamMetadata *object, bool copy).
895          */
894             *  Prototype(::FLAC__StreamMetadata *object, bool copy).
895             */
896896         inline Unknown(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
897897
898898         ~Unknown();
r14260r14261
905905         //@}
906906
907907         /** Assigns an object with copy control.  See
908          *  Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
909          */
908             *  Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
909             */
910910         inline Unknown &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
911911
912912         //@{
r14260r14261
934934
935935
936936      /** \defgroup flacpp_metadata_level0 FLAC++/metadata.h: metadata level 0 interface
937       *  \ingroup flacpp_metadata
938       *
939       *  \brief
940       *  Level 0 metadata iterators.
941       *
942       *  See the \link flac_metadata_level0 C layer equivalent \endlink
943       *  for more.
944       *
945       * \{
946       */
937         *  \ingroup flacpp_metadata
938         *
939         *  \brief
940         *  Level 0 metadata iterators.
941         *
942         *  See the \link flac_metadata_level0 C layer equivalent \endlink
943         *  for more.
944         *
945         * \{
946         */
947947
948948      FLACPP_API bool get_streaminfo(const char *filename, StreamInfo &streaminfo); ///< See FLAC__metadata_get_streaminfo().
949949
r14260r14261
960960
961961
962962      /** \defgroup flacpp_metadata_level1 FLAC++/metadata.h: metadata level 1 interface
963       *  \ingroup flacpp_metadata
964       *
965       *  \brief
966       *  Level 1 metadata iterator.
967       *
968       *  The flow through the iterator in the C++ layer is similar
969       *  to the C layer:
970       *    - Create a SimpleIterator instance
971       *    - Check SimpleIterator::is_valid()
972       *    - Call SimpleIterator::init() and check the return
973       *    - Traverse and/or edit.  Edits are written to file
974       *      immediately.
975       *    - Destroy the SimpleIterator instance
976       *
977       *  The ownership of pointers in the C++ layer follows that in
978       *  the C layer, i.e.
979       *    - The objects returned by get_block() are yours to
980       *      modify, but changes are not reflected in the FLAC file
981       *      until you call set_block().  The objects are also
982       *      yours to delete; they are not automatically deleted
983       *      when passed to set_block() or insert_block_after().
984       *
985       *  See the \link flac_metadata_level1 C layer equivalent \endlink
986       *  for more.
987       *
988       * \{
989       */
963         *  \ingroup flacpp_metadata
964         *
965         *  \brief
966         *  Level 1 metadata iterator.
967         *
968         *  The flow through the iterator in the C++ layer is similar
969         *  to the C layer:
970         *    - Create a SimpleIterator instance
971         *    - Check SimpleIterator::is_valid()
972         *    - Call SimpleIterator::init() and check the return
973         *    - Traverse and/or edit.  Edits are written to file
974         *      immediately.
975         *    - Destroy the SimpleIterator instance
976         *
977         *  The ownership of pointers in the C++ layer follows that in
978         *  the C layer, i.e.
979         *    - The objects returned by get_block() are yours to
980         *      modify, but changes are not reflected in the FLAC file
981         *      until you call set_block().  The objects are also
982         *      yours to delete; they are not automatically deleted
983         *      when passed to set_block() or insert_block_after().
984         *
985         *  See the \link flac_metadata_level1 C layer equivalent \endlink
986         *  for more.
987         *
988         * \{
989         */
990990
991991      /** This class is a wrapper around the FLAC__metadata_simple_iterator
992       *  structures and methods; see the
993       * \link flacpp_metadata_level1 usage guide \endlink and
994       * ::FLAC__Metadata_SimpleIterator.
995       */
992         *  structures and methods; see the
993         * \link flacpp_metadata_level1 usage guide \endlink and
994         * ::FLAC__Metadata_SimpleIterator.
995         */
996996      class FLACPP_API SimpleIterator {
997997      public:
998998         /** This class is a wrapper around FLAC__Metadata_SimpleIteratorStatus.
999          */
999            */
10001000         class FLACPP_API Status {
10011001         public:
10021002            inline Status(::FLAC__Metadata_SimpleIteratorStatus status): status_(status) { }
r14260r14261
10381038
10391039
10401040      /** \defgroup flacpp_metadata_level2 FLAC++/metadata.h: metadata level 2 interface
1041       *  \ingroup flacpp_metadata
1042       *
1043       *  \brief
1044       *  Level 2 metadata iterator.
1045       *
1046       *  The flow through the iterator in the C++ layer is similar
1047       *  to the C layer:
1048       *    - Create a Chain instance
1049       *    - Check Chain::is_valid()
1050       *    - Call Chain::read() and check the return
1051       *    - Traverse and/or edit with an Iterator or with
1052       *      Chain::merge_padding() or Chain::sort_padding()
1053       *    - Write changes back to FLAC file with Chain::write()
1054       *    - Destroy the Chain instance
1055       *
1056       *  The ownership of pointers in the C++ layer is slightly
1057       *  different than in the C layer, i.e.
1058       *    - The objects returned by Iterator::get_block() are NOT
1059       *      owned by the iterator and should be deleted by the
1060       *      caller when finished, BUT, when you modify the block,
1061       *      it will directly edit what's in the chain and you do
1062       *      not need to call Iterator::set_block().  However the
1063       *      changes will not be reflected in the FLAC file until
1064       *      the chain is written with Chain::write().
1065       *    - When you pass an object to Iterator::set_block(),
1066       *      Iterator::insert_block_before(), or
1067       *      Iterator::insert_block_after(), the iterator takes
1068       *      ownership of the block and it will be deleted by the
1069       *      chain.
1070       *
1071       *  See the \link flac_metadata_level2 C layer equivalent \endlink
1072       *  for more.
1073       *
1074       * \{
1075       */
1041         *  \ingroup flacpp_metadata
1042         *
1043         *  \brief
1044         *  Level 2 metadata iterator.
1045         *
1046         *  The flow through the iterator in the C++ layer is similar
1047         *  to the C layer:
1048         *    - Create a Chain instance
1049         *    - Check Chain::is_valid()
1050         *    - Call Chain::read() and check the return
1051         *    - Traverse and/or edit with an Iterator or with
1052         *      Chain::merge_padding() or Chain::sort_padding()
1053         *    - Write changes back to FLAC file with Chain::write()
1054         *    - Destroy the Chain instance
1055         *
1056         *  The ownership of pointers in the C++ layer is slightly
1057         *  different than in the C layer, i.e.
1058         *    - The objects returned by Iterator::get_block() are NOT
1059         *      owned by the iterator and should be deleted by the
1060         *      caller when finished, BUT, when you modify the block,
1061         *      it will directly edit what's in the chain and you do
1062         *      not need to call Iterator::set_block().  However the
1063         *      changes will not be reflected in the FLAC file until
1064         *      the chain is written with Chain::write().
1065         *    - When you pass an object to Iterator::set_block(),
1066         *      Iterator::insert_block_before(), or
1067         *      Iterator::insert_block_after(), the iterator takes
1068         *      ownership of the block and it will be deleted by the
1069         *      chain.
1070         *
1071         *  See the \link flac_metadata_level2 C layer equivalent \endlink
1072         *  for more.
1073         *
1074         * \{
1075         */
10761076
10771077      /** This class is a wrapper around the FLAC__metadata_chain
1078       *  structures and methods; see the
1079       * \link flacpp_metadata_level2 usage guide \endlink and
1080       * ::FLAC__Metadata_Chain.
1081       */
1078         *  structures and methods; see the
1079         * \link flacpp_metadata_level2 usage guide \endlink and
1080         * ::FLAC__Metadata_Chain.
1081         */
10821082      class FLACPP_API Chain {
10831083      public:
10841084         /** This class is a wrapper around FLAC__Metadata_ChainStatus.
1085          */
1085            */
10861086         class FLACPP_API Status {
10871087         public:
10881088            inline Status(::FLAC__Metadata_ChainStatus status): status_(status) { }
r14260r14261
11191119      };
11201120
11211121      /** This class is a wrapper around the FLAC__metadata_iterator
1122       *  structures and methods; see the
1123       * \link flacpp_metadata_level2 usage guide \endlink and
1124       * ::FLAC__Metadata_Iterator.
1125       */
1122         *  structures and methods; see the
1123         * \link flacpp_metadata_level2 usage guide \endlink and
1124         * ::FLAC__Metadata_Iterator.
1125         */
11261126      class FLACPP_API Iterator {
11271127      public:
11281128         Iterator();
src/lib/libflac/include/flac++/decoder.h
r14260r14261
7878   namespace Decoder {
7979
8080      /** \ingroup flacpp_decoder
81       *  \brief
82       *  This class wraps the ::FLAC__StreamDecoder.  If you are
83       *  decoding from a file, FLAC::Decoder::File may be more
84       *  convenient.
85       *
86       * The usage of this class is similar to FLAC__StreamDecoder,
87       * except instead of providing callbacks to
88       * FLAC__stream_decoder_init*_stream(), you will inherit from this
89       * class and override the virtual callback functions with your
90       * own implementations, then call init() or init_ogg().  The rest
91       * of the calls work the same as in the C layer.
92       *
93       * Only the read, write, and error callbacks are mandatory.  The
94       * others are optional; this class provides default
95       * implementations that do nothing.  In order for seeking to work
96       * you must overide seek_callback(), tell_callback(),
97       * length_callback(), and eof_callback().
98       */
81         *  \brief
82         *  This class wraps the ::FLAC__StreamDecoder.  If you are
83         *  decoding from a file, FLAC::Decoder::File may be more
84         *  convenient.
85         *
86         * The usage of this class is similar to FLAC__StreamDecoder,
87         * except instead of providing callbacks to
88         * FLAC__stream_decoder_init*_stream(), you will inherit from this
89         * class and override the virtual callback functions with your
90         * own implementations, then call init() or init_ogg().  The rest
91         * of the calls work the same as in the C layer.
92         *
93         * Only the read, write, and error callbacks are mandatory.  The
94         * others are optional; this class provides default
95         * implementations that do nothing.  In order for seeking to work
96         * you must overide seek_callback(), tell_callback(),
97         * length_callback(), and eof_callback().
98         */
9999      class FLACPP_API Stream {
100100      public:
101101         /** This class is a wrapper around FLAC__StreamDecoderState.
102          */
102            */
103103         class FLACPP_API State {
104104         public:
105105            inline State(::FLAC__StreamDecoderState state): state_(state) { }
r14260r14261
115115
116116         //@{
117117         /** Call after construction to check the that the object was created
118          *  successfully.  If not, use get_state() to find out why not.
119          */
118             *  successfully.  If not, use get_state() to find out why not.
119             */
120120         virtual bool is_valid() const;
121121         inline operator bool() const { return is_valid(); } ///< See is_valid()
122122         //@}
r14260r14261
201201      };
202202
203203      /** \ingroup flacpp_decoder
204       *  \brief
205       *  This class wraps the ::FLAC__StreamDecoder.  If you are
206       *  not decoding from a file, you may need to use
207       *  FLAC::Decoder::Stream.
208       *
209       * The usage of this class is similar to FLAC__StreamDecoder,
210       * except instead of providing callbacks to
211       * FLAC__stream_decoder_init*_FILE() or
212       * FLAC__stream_decoder_init*_file(), you will inherit from this
213       * class and override the virtual callback functions with your
214       * own implementations, then call init() or init_off().  The rest
215       * of the calls work the same as in the C layer.
216       *
217       * Only the write, and error callbacks from FLAC::Decoder::Stream
218       * are mandatory.  The others are optional; this class provides
219       * full working implementations for all other callbacks and
220       * supports seeking.
221       */
204         *  \brief
205         *  This class wraps the ::FLAC__StreamDecoder.  If you are
206         *  not decoding from a file, you may need to use
207         *  FLAC::Decoder::Stream.
208         *
209         * The usage of this class is similar to FLAC__StreamDecoder,
210         * except instead of providing callbacks to
211         * FLAC__stream_decoder_init*_FILE() or
212         * FLAC__stream_decoder_init*_file(), you will inherit from this
213         * class and override the virtual callback functions with your
214         * own implementations, then call init() or init_off().  The rest
215         * of the calls work the same as in the C layer.
216         *
217         * Only the write, and error callbacks from FLAC::Decoder::Stream
218         * are mandatory.  The others are optional; this class provides
219         * full working implementations for all other callbacks and
220         * supports seeking.
221         */
222222      class FLACPP_API File: public Stream {
223223      public:
224224         File();
src/lib/libflac/libflac/fixed.c
r14260r14261
7575   if(err <= n)
7676      return 0;
7777   /*
78    * The above two things tell us 1) n fits in 16 bits; 2) err/n > 1.
79    * These allow us later to know we won't lose too much precision in the
80    * fixed-point division (err<<fracbits)/n.
81    */
78     * The above two things tell us 1) n fits in 16 bits; 2) err/n > 1.
79     * These allow us later to know we won't lose too much precision in the
80     * fixed-point division (err<<fracbits)/n.
81     */
8282
8383   fracbits = (8*sizeof(err)) - (FLAC__bitmath_ilog2(err)+1);
8484
r14260r14261
8787   /* err now holds err/n with fracbits fractional bits */
8888
8989   /*
90    * Whittle err down to 16 bits max.  16 significant bits is enough for
91    * our purposes.
92    */
90     * Whittle err down to 16 bits max.  16 significant bits is enough for
91     * our purposes.
92     */
9393   FLAC__ASSERT(err > 0);
9494   bits = FLAC__bitmath_ilog2(err)+1;
9595   if(bits > 16) {
r14260r14261
118118      return 0;
119119
120120   /*
121    * The return value must have 16 fractional bits.  Since the whole part
122    * of the base-2 log of a 32 bit number must fit in 5 bits, and fracbits
123    * must be >= -3, these assertion allows us to be able to shift rbps
124    * left if necessary to get 16 fracbits without losing any bits of the
125    * whole part of rbps.
126    *
127    * There is a slight chance due to accumulated error that the whole part
128    * will require 6 bits, so we use 6 in the assertion.  Really though as
129    * long as it fits in 13 bits (32 - (16 - (-3))) we are fine.
130    */
121     * The return value must have 16 fractional bits.  Since the whole part
122     * of the base-2 log of a 32 bit number must fit in 5 bits, and fracbits
123     * must be >= -3, these assertion allows us to be able to shift rbps
124     * left if necessary to get 16 fracbits without losing any bits of the
125     * whole part of rbps.
126     *
127     * There is a slight chance due to accumulated error that the whole part
128     * will require 6 bits, so we use 6 in the assertion.  Really though as
129     * long as it fits in 13 bits (32 - (16 - (-3))) we are fine.
130     */
131131   FLAC__ASSERT((int)FLAC__bitmath_ilog2(rbps)+1 <= fracbits + 6);
132132   FLAC__ASSERT(fracbits >= -3);
133133
r14260r14261
154154   if(err <= n)
155155      return 0;
156156   /*
157    * The above two things tell us 1) n fits in 16 bits; 2) err/n > 1.
158    * These allow us later to know we won't lose too much precision in the
159    * fixed-point division (err<<fracbits)/n.
160    */
157     * The above two things tell us 1) n fits in 16 bits; 2) err/n > 1.
158     * These allow us later to know we won't lose too much precision in the
159     * fixed-point division (err<<fracbits)/n.
160     */
161161
162162   fracbits = (8*sizeof(err)) - (FLAC__bitmath_ilog2_wide(err)+1);
163163
r14260r14261
166166   /* err now holds err/n with fracbits fractional bits */
167167
168168   /*
169    * Whittle err down to 16 bits max.  16 significant bits is enough for
170    * our purposes.
171    */
169     * Whittle err down to 16 bits max.  16 significant bits is enough for
170     * our purposes.
171     */
172172   FLAC__ASSERT(err > 0);
173173   bits = FLAC__bitmath_ilog2_wide(err)+1;
174174   if(bits > 16) {
r14260r14261
197197      return 0;
198198
199199   /*
200    * The return value must have 16 fractional bits.  Since the whole part
201    * of the base-2 log of a 32 bit number must fit in 5 bits, and fracbits
202    * must be >= -3, these assertion allows us to be able to shift rbps
203    * left if necessary to get 16 fracbits without losing any bits of the
204    * whole part of rbps.
205    *
206    * There is a slight chance due to accumulated error that the whole part
207    * will require 6 bits, so we use 6 in the assertion.  Really though as
208    * long as it fits in 13 bits (32 - (16 - (-3))) we are fine.
209    */
200     * The return value must have 16 fractional bits.  Since the whole part
201     * of the base-2 log of a 32 bit number must fit in 5 bits, and fracbits
202     * must be >= -3, these assertion allows us to be able to shift rbps
203     * left if necessary to get 16 fracbits without losing any bits of the
204     * whole part of rbps.
205     *
206     * There is a slight chance due to accumulated error that the whole part
207     * will require 6 bits, so we use 6 in the assertion.  Really though as
208     * long as it fits in 13 bits (32 - (16 - (-3))) we are fine.
209     */
210210   FLAC__ASSERT((int)FLAC__bitmath_ilog2(rbps)+1 <= fracbits + 6);
211211   FLAC__ASSERT(fracbits >= -3);
212212
r14260r14261
290290   FLAC__int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]);
291291   FLAC__int32 error, save;
292292   /* total_error_* are 64-bits to avoid overflow when encoding
293    * erratic signals when the bits-per-sample and blocksize are
294    * large.
295    */
293     * erratic signals when the bits-per-sample and blocksize are
294     * large.
295     */
296296   FLAC__uint64 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0;
297297   unsigned i, order;
298298
src/lib/libflac/libflac/bitreader.c
r14260r14261
217217   }
218218
219219   /*
220    * set the target for reading, taking into account word alignment and endianness
221    */
220     * set the target for reading, taking into account word alignment and endianness
221     */
222222   bytes = (br->capacity - br->words) * FLAC__BYTES_PER_WORD - br->bytes;
223223   if(bytes == 0)
224224      return false; /* no space left, buffer is too small; see note for FLAC__BITREADER_DEFAULT_CAPACITY  */
225225   target = ((FLAC__byte*)(br->buffer+br->words)) + br->bytes;
226226
227227   /* before reading, if the existing reader looks like this (say brword is 32 bits wide)
228    *   bitstream :  11 22 33 44 55            br->words=1 br->bytes=1 (partial tail word is left-justified)
229    *   buffer[BE]:  11 22 33 44 55 ?? ?? ??   (shown layed out as bytes sequentially in memory)
230    *   buffer[LE]:  44 33 22 11 ?? ?? ?? 55   (?? being don't-care)
231    *                               ^^-------target, bytes=3
232    * on LE machines, have to byteswap the odd tail word so nothing is
233    * overwritten:
234    */
228     *   bitstream :  11 22 33 44 55            br->words=1 br->bytes=1 (partial tail word is left-justified)
229     *   buffer[BE]:  11 22 33 44 55 ?? ?? ??   (shown layed out as bytes sequentially in memory)
230     *   buffer[LE]:  44 33 22 11 ?? ?? ?? 55   (?? being don't-care)
231     *                               ^^-------target, bytes=3
232     * on LE machines, have to byteswap the odd tail word so nothing is
233     * overwritten:
234     */
235235#if WORDS_BIGENDIAN
236236#else
237237   if(br->bytes)
r14260r14261
239239#endif
240240
241241   /* now it looks like:
242    *   bitstream :  11 22 33 44 55            br->words=1 br->bytes=1
243    *   buffer[BE]:  11 22 33 44 55 ?? ?? ??
244    *   buffer[LE]:  44 33 22 11 55 ?? ?? ??
245    *                               ^^-------target, bytes=3
246    */
242     *   bitstream :  11 22 33 44 55            br->words=1 br->bytes=1
243     *   buffer[BE]:  11 22 33 44 55 ?? ?? ??
244     *   buffer[LE]:  44 33 22 11 55 ?? ?? ??
245     *                               ^^-------target, bytes=3
246     */
247247
248248   /* read in the data; note that the callback may return a smaller number of bytes */
249249   if(!br->read_callback(target, &bytes, br->client_data))
250250      return false;
251251
252252   /* after reading bytes 66 77 88 99 AA BB CC DD EE FF from the client:
253    *   bitstream :  11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF
254    *   buffer[BE]:  11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF ??
255    *   buffer[LE]:  44 33 22 11 55 66 77 88 99 AA BB CC DD EE FF ??
256    * now have to byteswap on LE machines:
257    */
253     *   bitstream :  11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF
254     *   buffer[BE]:  11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF ??
255     *   buffer[LE]:  44 33 22 11 55 66 77 88 99 AA BB CC DD EE FF ??
256     * now have to byteswap on LE machines:
257     */
258258#if WORDS_BIGENDIAN
259259#else
260260   end = (br->words*FLAC__BYTES_PER_WORD + br->bytes + bytes + (FLAC__BYTES_PER_WORD-1)) / FLAC__BYTES_PER_WORD;
r14260r14261
270270#endif
271271
272272   /* now it looks like:
273    *   bitstream :  11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF
274    *   buffer[BE]:  11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF ??
275    *   buffer[LE]:  44 33 22 11 88 77 66 55 CC BB AA 99 ?? FF EE DD
276    * finally we'll update the reader values:
277    */
273     *   bitstream :  11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF
274     *   buffer[BE]:  11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF ??
275     *   buffer[LE]:  44 33 22 11 88 77 66 55 CC BB AA 99 ?? FF EE DD
276     * finally we'll update the reader values:
277     */
278278   end = br->words*FLAC__BYTES_PER_WORD + br->bytes + bytes;
279279   br->words = end / FLAC__BYTES_PER_WORD;
280280   br->bytes = end % FLAC__BYTES_PER_WORD;
r14260r14261
293293   FLAC__BitReader *br = (FLAC__BitReader*)calloc(1, sizeof(FLAC__BitReader));
294294
295295   /* calloc() implies:
296      memset(br, 0, sizeof(FLAC__BitReader));
297      br->buffer = 0;
298      br->capacity = 0;
299      br->words = br->bytes = 0;
300      br->consumed_words = br->consumed_bits = 0;
301      br->read_callback = 0;
302      br->client_data = 0;
303   */
296        memset(br, 0, sizeof(FLAC__BitReader));
297        br->buffer = 0;
298        br->capacity = 0;
299        br->words = br->bytes = 0;
300        br->consumed_words = br->consumed_bits = 0;
301        br->read_callback = 0;
302        br->client_data = 0;
303    */
304304   return br;
305305}
306306
r14260r14261
487487   }
488488   else {
489489      /* in this case we're starting our read at a partial tail word;
490       * the reader has guaranteed that we have at least 'bits' bits
491       * available to read, which makes this case simpler.
492       */
490         * the reader has guaranteed that we have at least 'bits' bits
491         * available to read, which makes this case simpler.
492         */
493493      /* OPT: taking out the consumed_bits==0 "else" case below might make things faster if less code allows the compiler to inline this function */
494494      if(br->consumed_bits) {
495495         /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */
r14260r14261
566566FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, unsigned bits)
567567{
568568   /*
569    * OPT: a faster implementation is possible but probably not that useful
570    * since this is only called a couple of times in the metadata readers.
571    */
569     * OPT: a faster implementation is possible but probably not that useful
570     * since this is only called a couple of times in the metadata readers.
571     */
572572   FLAC__ASSERT(0 != br);
573573   FLAC__ASSERT(0 != br->buffer);
574574
r14260r14261
740740         }
741741      }
742742      /* at this point we've eaten up all the whole words; have to try
743       * reading through any tail bytes before calling the read callback.
744       * this is a repeat of the above logic adjusted for the fact we
745       * don't have a whole word.  note though if the client is feeding
746       * us data a byte at a time (unlikely), br->consumed_bits may not
747       * be zero.
748       */
743         * reading through any tail bytes before calling the read callback.
744         * this is a repeat of the above logic adjusted for the fact we
745         * don't have a whole word.  note though if the client is feeding
746         * us data a byte at a time (unlikely), br->consumed_bits may not
747         * be zero.
748         */
749749      if(br->bytes) {
750750         const unsigned end = br->bytes * 8;
751751         brword b = (br->buffer[br->consumed_words] & (FLAC__WORD_ALL_ONES << (FLAC__BITS_PER_WORD-end))) << br->consumed_bits;
r14260r14261
808808   unsigned bits; /* the # of binary LSBs left to read to finish a rice codeword */
809809
810810   /* try and get br->consumed_words and br->consumed_bits into register;
811    * must remember to flush them back to *br before calling other
812    * bitwriter functions that use them, and before returning */
811     * must remember to flush them back to *br before calling other
812     * bitwriter functions that use them, and before returning */
813813   register unsigned cwords;
814814   register unsigned cbits;
815815
r14260r14261
863863            }
864864         }
865865         /* at this point we've eaten up all the whole words; have to try
866          * reading through any tail bytes before calling the read callback.
867          * this is a repeat of the above logic adjusted for the fact we
868          * don't have a whole word.  note though if the client is feeding
869          * us data a byte at a time (unlikely), br->consumed_bits may not
870          * be zero.
871          */
866             * reading through any tail bytes before calling the read callback.
867             * this is a repeat of the above logic adjusted for the fact we
868             * don't have a whole word.  note though if the client is feeding
869             * us data a byte at a time (unlikely), br->consumed_bits may not
870             * be zero.
871             */
872872         if(br->bytes) {
873873            const unsigned end = br->bytes * 8;
874874            brword b = (br->buffer[cwords] & (FLAC__WORD_ALL_ONES << (FLAC__BITS_PER_WORD-end))) << cbits;
r14260r14261
889889            }
890890         }
891891         /* flush registers and read; bitreader_read_from_client_() does
892          * not touch br->consumed_bits at all but we still need to set
893          * it in case it fails and we have to return false.
894          */
892             * not touch br->consumed_bits at all but we still need to set
893             * it in case it fails and we have to return false.
894             */
895895         br->consumed_bits = cbits;
896896         br->consumed_words = cwords;
897897         if(!bitreader_read_from_client_(br))
r14260r14261
905905      if(bits) {
906906         while((br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits < bits) {
907907            /* flush registers and read; bitreader_read_from_client_() does
908             * not touch br->consumed_bits at all but we still need to set
909             * it in case it fails and we have to return false.
910             */
908                 * not touch br->consumed_bits at all but we still need to set
909                 * it in case it fails and we have to return false.
910                 */
911911            br->consumed_bits = cbits;
912912            br->consumed_words = cwords;
913913            if(!bitreader_read_from_client_(br))
r14260r14261
948948         }
949949         else {
950950            /* in this case we're starting our read at a partial tail word;
951             * the reader has guaranteed that we have at least 'bits' bits
952             * available to read, which makes this case simpler.
953             */
951                 * the reader has guaranteed that we have at least 'bits' bits
952                 * available to read, which makes this case simpler.
953                 */
954954            uval <<= bits;
955955            if(cbits) {
956956               /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */
r14260r14261
989989   unsigned uval = 0;
990990
991991   /* try and get br->consumed_words and br->consumed_bits into register;
992    * must remember to flush them back to *br before calling other
993    * bitwriter functions that use them, and before returning */
992     * must remember to flush them back to *br before calling other
993     * bitwriter functions that use them, and before returning */
994994   register unsigned cwords;
995995   register unsigned cbits;
996996   unsigned ucbits; /* keep track of the number of unconsumed bits in the buffer */
r14260r14261
10461046            }
10471047         }
10481048         /* at this point we've eaten up all the whole words; have to try
1049          * reading through any tail bytes before calling the read callback.
1050          * this is a repeat of the above logic adjusted for the fact we
1051          * don't have a whole word.  note though if the client is feeding
1052          * us data a byte at a time (unlikely), br->consumed_bits may not
1053          * be zero.
1054          */
1049             * reading through any tail bytes before calling the read callback.
1050             * this is a repeat of the above logic adjusted for the fact we
1051             * don't have a whole word.  note though if the client is feeding
1052             * us data a byte at a time (unlikely), br->consumed_bits may not
1053             * be zero.
1054             */
10551055         if(br->bytes) {
10561056            const unsigned end = br->bytes * 8;
10571057            brword b = (br->buffer[cwords] & ~(FLAC__WORD_ALL_ONES >> end)) << cbits;
r14260r14261
10711071            }
10721072         }
10731073         /* flush registers and read; bitreader_read_from_client_() does
1074          * not touch br->consumed_bits at all but we still need to set
1075          * it in case it fails and we have to return false.
1076          */
1074             * not touch br->consumed_bits at all but we still need to set
1075             * it in case it fails and we have to return false.
1076             */
10771077         br->consumed_bits = cbits;
10781078         br->consumed_words = cwords;
10791079         if(!bitreader_read_from_client_(br))
r14260r14261
10811081         cwords = br->consumed_words;
10821082         ucbits = (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits + uval;
10831083         /* + uval to offset our count by the # of unary bits already
1084          * consumed before the read, because we will add these back
1085          * in all at once at break1
1086          */
1084             * consumed before the read, because we will add these back
1085             * in all at once at break1
1086             */
10871087      }
10881088break1:
10891089      ucbits -= uval;
r14260r14261
10951095      if(parameter) {
10961096         while(ucbits < parameter) {
10971097            /* flush registers and read; bitreader_read_from_client_() does
1098             * not touch br->consumed_bits at all but we still need to set
1099             * it in case it fails and we have to return false.
1100             */
1098                 * not touch br->consumed_bits at all but we still need to set
1099                 * it in case it fails and we have to return false.
1100                 */
11011101            br->consumed_bits = cbits;
11021102            br->consumed_words = cwords;
11031103            if(!bitreader_read_from_client_(br))
r14260r14261
11351135         }
11361136         else {
11371137            /* in this case we're starting our read at a partial tail word;
1138             * the reader has guaranteed that we have at least 'parameter'
1139             * bits available to read, which makes this case simpler.
1140             */
1138                 * the reader has guaranteed that we have at least 'parameter'
1139                 * bits available to read, which makes this case simpler.
1140                 */
11411141            uval <<= parameter;
11421142            if(cbits) {
11431143               /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */
src/lib/libflac/libflac/float.c
r14260r14261
5757static const FLAC__uint32 log2_lookup[][LOG2_LOOKUP_PRECISION] = {
5858   {
5959      /*
60       * 0 fraction bits
61       */
60         * 0 fraction bits
61         */
6262      /* undefined */ 0x00000000,
6363      /* lg(2/1) = */ 0x00000001,
6464      /* lg(4/3) = */ 0x00000000,
r14260r14261
7878   },
7979   {
8080      /*
81       * 4 fraction bits
82       */
81         * 4 fraction bits
82         */
8383      /* undefined */ 0x00000000,
8484      /* lg(2/1) = */ 0x00000010,
8585      /* lg(4/3) = */ 0x00000007,
r14260r14261
9999   },
100100   {
101101      /*
102       * 8 fraction bits
103       */
102         * 8 fraction bits
103         */
104104      /* undefined */ 0x00000000,
105105      /* lg(2/1) = */ 0x00000100,
106106      /* lg(4/3) = */ 0x0000006a,
r14260r14261
120120   },
121121   {
122122      /*
123       * 12 fraction bits
124       */
123         * 12 fraction bits
124         */
125125      /* undefined */ 0x00000000,
126126      /* lg(2/1) = */ 0x00001000,
127127      /* lg(4/3) = */ 0x000006a4,
r14260r14261
141141   },
142142   {
143143      /*
144       * 16 fraction bits
145       */
144         * 16 fraction bits
145         */
146146      /* undefined */ 0x00000000,
147147      /* lg(2/1) = */ 0x00010000,
148148      /* lg(4/3) = */ 0x00006a40,
r14260r14261
162162   },
163163   {
164164      /*
165       * 20 fraction bits
166       */
165         * 20 fraction bits
166         */
167167      /* undefined */ 0x00000000,
168168      /* lg(2/1) = */ 0x00100000,
169169      /* lg(4/3) = */ 0x0006a3fe,
r14260r14261
183183   },
184184   {
185185      /*
186       * 24 fraction bits
187       */
186         * 24 fraction bits
187         */
188188      /* undefined */ 0x00000000,
189189      /* lg(2/1) = */ 0x01000000,
190190      /* lg(4/3) = */ 0x006a3fe6,
r14260r14261
204204   },
205205   {
206206      /*
207       * 28 fraction bits
208       */
207         * 28 fraction bits
208         */
209209      /* undefined */ 0x00000000,
210210      /* lg(2/1) = */ 0x10000000,
211211      /* lg(4/3) = */ 0x06a3fe5c,
r14260r14261
229229static const FLAC__uint64 log2_lookup_wide[] = {
230230   {
231231      /*
232       * 32 fraction bits
233       */
232         * 32 fraction bits
233         */
234234      /* undefined */ 0x00000000,
235235      /* lg(2/1) = */ FLAC__U64L(0x100000000),
236236      /* lg(4/3) = */ FLAC__U64L(0x6a3fe5c6),
r14260r14261
250250   },
251251   {
252252      /*
253       * 48 fraction bits
254       */
253         * 48 fraction bits
254         */
255255      /* undefined */ 0x00000000,
256256      /* lg(2/1) = */ FLAC__U64L(0x1000000000000),
257257      /* lg(4/3) = */ FLAC__U64L(0x6a3fe5c60429),
r14260r14261
282282
283283   if(x < ONE)
284284      return 0;
285   
285
286286   if(precision > LOG2_LOOKUP_PRECISION)
287287      precision = LOG2_LOOKUP_PRECISION;
288288
src/lib/libflac/libflac/metadata_object.c
r14260r14261
268268         /* we have to make sure that the string we're taking over is null-terminated */
269269
270270         /*
271          * Stripping the const from src->entry is OK since we're taking
272          * ownership of the pointer.  This is a hack around a deficiency
273          * in the API where the same function is used for 'copy' and
274          * 'own', but the source entry is a const pointer.  If we were
275          * precise, the 'own' flavor would be a separate function with a
276          * non-const source pointer.  But it's not, so we hack away.
277          */
271             * Stripping the const from src->entry is OK since we're taking
272             * ownership of the pointer.  This is a hack around a deficiency
273             * in the API where the same function is used for 'copy' and
274             * 'own', but the source entry is a const pointer.  If we were
275             * precise, the 'own' flavor would be a separate function with a
276             * non-const source pointer.  But it's not, so we hack away.
277             */
278278         if(!ensure_null_terminated_((FLAC__byte**)(&src->entry), src->length))
279279            return false;
280280         *dest = *src;
r14260r14261
447447            break;
448448         case FLAC__METADATA_TYPE_PADDING:
449449            /* calloc() took care of this for us:
450            object->length = 0;
451            */
450                object->length = 0;
451                */
452452            break;
453453         case FLAC__METADATA_TYPE_APPLICATION:
454454            object->length = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8;
455455            /* calloc() took care of this for us:
456            object->data.application.data = 0;
457            */
456                object->data.application.data = 0;
457                */
458458            break;
459459         case FLAC__METADATA_TYPE_SEEKTABLE:
460460            /* calloc() took care of this for us:
461            object->length = 0;
462            object->data.seek_table.num_points = 0;
463            object->data.seek_table.points = 0;
464            */
461                object->length = 0;
462                object->data.seek_table.num_points = 0;
463                object->data.seek_table.points = 0;
464                */
465465            break;
466466         case FLAC__METADATA_TYPE_VORBIS_COMMENT:
467467            object->data.vorbis_comment.vendor_string.length = (unsigned)strlen(FLAC__VENDOR_STRING);
r14260r14261
490490            object->data.picture.mime_type = 0;
491491            object->data.picture.description = 0;
492492            /* calloc() took care of this for us:
493            object->data.picture.width = 0;
494            object->data.picture.height = 0;
495            object->data.picture.depth = 0;
496            object->data.picture.colors = 0;
497            object->data.picture.data_length = 0;
498            object->data.picture.data = 0;
499            */
493                object->data.picture.width = 0;
494                object->data.picture.height = 0;
495                object->data.picture.depth = 0;
496                object->data.picture.colors = 0;
497                object->data.picture.data_length = 0;
498                object->data.picture.data = 0;
499                */
500500            /* now initialize mime_type and description with empty strings to make things easier on the client */
501501            if(!copy_cstring_(&object->data.picture.mime_type, "")) {
502502               free(object);
r14260r14261
511511            break;
512512         default:
513513            /* calloc() took care of this for us:
514            object->length = 0;
515            object->data.unknown.data = 0;
516            */
514                object->length = 0;
515                object->data.unknown.data = 0;
516                */
517517            break;
518518      }
519519   }
r14260r14261
13301330      memcpy(entry->entry+nn+1, field_value, nv);
13311331      entry->entry[entry->length] = '\0';
13321332   }
1333   
1333
13341334   return true;
13351335}
13361336
src/lib/libflac/libflac/bitwriter.c
r14260r14261
123123   new_capacity = bw->words + ((bw->bits + bits_to_add + FLAC__BITS_PER_WORD - 1) / FLAC__BITS_PER_WORD);
124124
125125   /* it's possible (due to pessimism in the growth estimation that
126    * leads to this call) that we don't actually need to grow
127    */
126     * leads to this call) that we don't actually need to grow
127     */
128128   if(bw->capacity >= new_capacity)
129129      return true;
130130
r14260r14261
288288void FLAC__bitwriter_release_buffer(FLAC__BitWriter *bw)
289289{
290290   /* nothing to do.  in the future, strict checking of a 'writer-is-in-
291    * get-mode' flag could be added everywhere and then cleared here
292    */
291     * get-mode' flag could be added everywhere and then cleared here
292     */
293293   (void)bw;
294294}
295295
r14260r14261
629629         }
630630         else {
631631            /* if bw->bits == 0, left==FLAC__BITS_PER_WORD which will always
632             * be > lsbits (because of previous assertions) so it would have
633             * triggered the (lsbits<left) case above.
634             */
632                 * be > lsbits (because of previous assertions) so it would have
633                 * triggered the (lsbits<left) case above.
634                 */
635635            FLAC__ASSERT(bw->bits);
636636            FLAC__ASSERT(left < FLAC__BITS_PER_WORD);
637637            bw->accum <<= left;
src/lib/libflac/libflac/metadata_iterators.c
r14260r14261
264264   (void)decoder;
265265
266266   /*
267    * we assume we only get here when the one metadata block we were
268    * looking for was passed to us
269    */
267     * we assume we only get here when the one metadata block we were
268     * looking for was passed to us
269     */
270270   if(!cd->got_error && 0 == cd->object) {
271271      if(0 == (cd->object = FLAC__metadata_object_clone(metadata)))
272272         cd->got_error = true;
r14260r14261
906906   FLAC__Metadata_ChainStatus status;
907907   off_t first_offset, last_offset;
908908   /*
909    * This is the length of the chain initially read from the FLAC file.
910    * it is used to compare against the current length to decide whether
911    * or not the whole file has to be rewritten.
912    */
909     * This is the length of the chain initially read from the FLAC file.
910     * it is used to compare against the current length to decide whether
911     * or not the whole file has to be rewritten.
912     */
913913   off_t initial_length;
914914   /* @@@ hacky, these are currently only needed by ogg reader */
915915   FLAC__IOHandle handle;
r14260r14261
16131613FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata_Chain *chain, FLAC__bool use_padding)
16141614{
16151615   /* This does all the same checks that are in chain_prepare_for_write_()
1616    * but doesn't actually alter the chain.  Make sure to update the logic
1617    * here if chain_prepare_for_write_() changes.
1618    */
1616     * but doesn't actually alter the chain.  Make sure to update the logic
1617     * here if chain_prepare_for_write_() changes.
1618     */
16191619   const off_t current_length = chain_calculate_length_(chain);
16201620
16211621   FLAC__ASSERT(0 != chain);
r14260r14261
18111811   FLAC__ASSERT(0 != chain);
18121812
18131813   /*
1814    * Don't try and be too smart... this simple algo is good enough for
1815    * the small number of nodes that we deal with.
1816    */
1814     * Don't try and be too smart... this simple algo is good enough for
1815     * the small number of nodes that we deal with.
1816     */
18171817   for(i = 0, node = chain->head; i < chain->nodes; i++) {
18181818      if(node->data->type == FLAC__METADATA_TYPE_PADDING) {
18191819         save = node->next;
r14260r14261
18351835   FLAC__Metadata_Iterator *iterator = (FLAC__Metadata_Iterator*)calloc(1, sizeof(FLAC__Metadata_Iterator));
18361836
18371837   /* calloc() implies:
1838      iterator->current = 0;
1839      iterator->chain = 0;
1840   */
1838        iterator->current = 0;
1839        iterator->chain = 0;
1840    */
18411841
18421842   return iterator;
18431843}
r14260r14261
20872087   *length = unpack_uint32_(raw_header + 1, 3);
20882088
20892089   /* Note that we don't check:
2090    *    if(iterator->type >= FLAC__METADATA_TYPE_UNDEFINED)
2091    * we just will read in an opaque block
2092    */
2090     *    if(iterator->type >= FLAC__METADATA_TYPE_UNDEFINED)
2091     * we just will read in an opaque block
2092     */
20932093
20942094   return true;
20952095}
r14260r14261
21262126   b = buffer;
21272127
21282128   /* we are using hardcoded numbers for simplicity but we should
2129    * probably eventually write a bit-level unpacker and use the
2130    * _STREAMINFO_ constants.
2131    */
2129     * probably eventually write a bit-level unpacker and use the
2130     * _STREAMINFO_ constants.
2131     */
21322132   block->min_blocksize = unpack_uint32_(b, 2); b += 2;
21332133   block->max_blocksize = unpack_uint32_(b, 2); b += 2;
21342134   block->min_framesize = unpack_uint32_(b, 3); b += 3;
r14260r14261
25552555   const unsigned bps1 = block->bits_per_sample - 1;
25562556
25572557   /* we are using hardcoded numbers for simplicity but we should
2558    * probably eventually write a bit-level packer and use the
2559    * _STREAMINFO_ constants.
2560    */
2558     * probably eventually write a bit-level packer and use the
2559     * _STREAMINFO_ constants.
2560     */
25612561   pack_uint32_(block->min_blocksize, buffer, 2);
25622562   pack_uint32_(block->max_blocksize, buffer+2, 2);
25632563   pack_uint32_(block->min_framesize, buffer+4, 3);
r14260r14261
30663066
30673067   if(fixup_is_last_code != 0) {
30683068      /*
3069       * if code == 1, it means a block was appended to the end so
3070       *   we have to clear the is_last flag of the previous block
3071       * if code == -1, it means the last block was deleted so
3072       *   we have to set the is_last flag of the previous block
3073       */
3069         * if code == 1, it means a block was appended to the end so
3070         *   we have to clear the is_last flag of the previous block
3071         * if code == -1, it means the last block was deleted so
3072         *   we have to set the is_last flag of the previous block
3073         */
30743074      /* MAGIC NUMBERs here; we know the is_last flag is the high bit of the byte at this location */
30753075      FLAC__byte x;
30763076      if(0 != fseeko(*tempfile, fixup_is_last_flag_offset, SEEK_SET)) {
src/lib/libflac/libflac/lpc.c
r14260r14261
7171   FLAC__ASSERT(lag <= data_len);
7272
7373   /*
74    * Technically we should subtract the mean first like so:
75    *   for(i = 0; i < data_len; i++)
76    *     data[i] -= mean;
77    * but it appears not to make enough of a difference to matter, and
78    * most signals are already closely centered around zero
79    */
74     * Technically we should subtract the mean first like so:
75     *   for(i = 0; i < data_len; i++)
76     *     data[i] -= mean;
77     * but it appears not to make enough of a difference to matter, and
78     * most signals are already closely centered around zero
79     */
8080   while(lag--) {
8181      for(i = lag, d = 0.0; i < data_len; i++)
8282         d += data[i] * data[i - lag];
r14260r14261
8585#endif
8686
8787   /*
88    * this version tends to run faster because of better data locality
89    * ('data_len' is usually much larger than 'lag')
90    */
88     * this version tends to run faster because of better data locality
89     * ('data_len' is usually much larger than 'lag')
90     */
9191   FLAC__real d;
9292   unsigned sample, coeff;
9393   const unsigned limit = data_len - lag;
r14260r14261
223223      }
224224   }
225225   /* negative shift is very rare but due to design flaw, negative shift is
226    * a NOP in the decoder, so it must be handled specially by scaling down
227    * coeffs
228    */
226     * a NOP in the decoder, so it must be handled specially by scaling down
227     * coeffs
228     */
229229   else {
230230      const int nshift = -(*shift);
231231      FLAC__double error = 0.0;
r14260r14261
297297   }
298298
299299   /* Here's a slower but clearer version:
300   for(i = 0; i < data_len; i++) {
301      sum = 0;
302      for(j = 0; j < order; j++)
303         sum += qlp_coeff[j] * data[i-j-1];
304      residual[i] = data[i] - (sum >> lp_quantization);
305   }
306   */
300    for(i = 0; i < data_len; i++) {
301        sum = 0;
302        for(j = 0; j < order; j++)
303            sum += qlp_coeff[j] * data[i-j-1];
304        residual[i] = data[i] - (sum >> lp_quantization);
305    }
306    */
307307}
308308#else /* fully unrolled version for normal use */
309309{
r14260r14261
314314   FLAC__ASSERT(order <= 32);
315315
316316   /*
317    * We do unique versions up to 12th order since that's the subset limit.
318    * Also they are roughly ordered to match frequency of occurrence to
319    * minimize branching.
320    */
317     * We do unique versions up to 12th order since that's the subset limit.
318     * Also they are roughly ordered to match frequency of occurrence to
319     * minimize branching.
320     */
321321   if(order <= 12) {
322322      if(order > 8) {
323323         if(order > 10) {
r14260r14261
576576   FLAC__ASSERT(order <= 32);
577577
578578   /*
579    * We do unique versions up to 12th order since that's the subset limit.
580    * Also they are roughly ordered to match frequency of occurrence to
581    * minimize branching.
582    */
579     * We do unique versions up to 12th order since that's the subset limit.
580     * Also they are roughly ordered to match frequency of occurrence to
581     * minimize branching.
582     */
583583   if(order <= 12) {
584584      if(order > 8) {
585585         if(order > 10) {
r14260r14261
827827   }
828828
829829   /* Here's a slower but clearer version:
830   for(i = 0; i < data_len; i++) {
831      sum = 0;
832      for(j = 0; j < order; j++)
833         sum += qlp_coeff[j] * data[i-j-1];
834      data[i] = residual[i] + (sum >> lp_quantization);
835   }
836   */
830    for(i = 0; i < data_len; i++) {
831        sum = 0;
832        for(j = 0; j < order; j++)
833            sum += qlp_coeff[j] * data[i-j-1];
834        data[i] = residual[i] + (sum >> lp_quantization);
835    }
836    */
837837}
838838#else /* fully unrolled version for normal use */
839839{
r14260r14261
844844   FLAC__ASSERT(order <= 32);
845845
846846   /*
847    * We do unique versions up to 12th order since that's the subset limit.
848    * Also they are roughly ordered to match frequency of occurrence to
849    * minimize branching.
850    */
847     * We do unique versions up to 12th order since that's the subset limit.
848     * Also they are roughly ordered to match frequency of occurrence to
849     * minimize branching.
850     */
851851   if(order <= 12) {
852852      if(order > 8) {
853853         if(order > 10) {
r14260r14261
11061106   FLAC__ASSERT(order <= 32);
11071107
11081108   /*
1109    * We do unique versions up to 12th order since that's the subset limit.
1110    * Also they are roughly ordered to match frequency of occurrence to
1111    * minimize branching.
1112    */
1109     * We do unique versions up to 12th order since that's the subset limit.
1110     * Also they are roughly ordered to match frequency of occurrence to
1111     * minimize branching.
1112     */
11131113   if(order <= 12) {
11141114      if(order > 8) {
11151115         if(order > 10) {
src/lib/libflac/libflac/stream_decoder.c
r14260r14261
398398#endif
399399
400400   /*
401    * get the CPU info and set the function pointers
402    */
401     * get the CPU info and set the function pointers
402     */
403403   FLAC__cpu_info(&decoder->private_->cpuinfo);
404404   /* first default to the non-asm routines */
405405   decoder->private_->local_lpc_restore_signal = FLAC__lpc_restore_signal;
r14260r14261
547547      return decoder->protected_->state = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS;
548548
549549   /*
550    * To make sure that our file does not go unclosed after an error, we
551    * must assign the FILE pointer before any further error can occur in
552    * this routine.
553    */
550     * To make sure that our file does not go unclosed after an error, we
551     * must assign the FILE pointer before any further error can occur in
552     * this routine.
553     */
554554   if(file == stdin)
555555      file = get_binary_stdin_(); /* just to be safe */
556556
r14260r14261
610610   FLAC__ASSERT(0 != decoder);
611611
612612   /*
613    * To make sure that our file does not go unclosed after an error, we
614    * have to do the same entrance checks here that are later performed
615    * in FLAC__stream_decoder_init_FILE() before the FILE* is assigned.
616    */
613     * To make sure that our file does not go unclosed after an error, we
614     * have to do the same entrance checks here that are later performed
615     * in FLAC__stream_decoder_init_FILE() before the FILE* is assigned.
616     */
617617   if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
618618      return decoder->protected_->state = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED;
619619
r14260r14261
665665      return true;
666666
667667   /* see the comment in FLAC__seekable_stream_decoder_reset() as to why we
668    * always call FLAC__MD5Final()
669    */
668     * always call FLAC__MD5Final()
669     */
670670   FLAC__MD5Final(decoder->private_->computed_md5sum, &decoder->private_->md5context);
671671
672672   if(decoder->private_->has_seek_table && 0 != decoder->private_->seek_table.data.seek_table.points) {
r14260r14261
677677   FLAC__bitreader_free(decoder->private_->input);
678678   for(i = 0; i < FLAC__MAX_CHANNELS; i++) {
679679      /* WATCHOUT:
680       * FLAC__lpc_restore_signal_asm_ia32_mmx() requires that the
681       * output arrays have a buffer of up to 3 zeroes in front
682       * (at negative indices) for alignment purposes; we use 4
683       * to keep the data well-aligned.
684       */
680         * FLAC__lpc_restore_signal_asm_ia32_mmx() requires that the
681         * output arrays have a buffer of up to 3 zeroes in front
682         * (at negative indices) for alignment purposes; we use 4
683         * to keep the data well-aligned.
684         */
685685      if(0 != decoder->private_->output[i]) {
686686         free(decoder->private_->output[i]-4);
687687         decoder->private_->output[i] = 0;
r14260r14261
985985#endif
986986
987987   /* Rewind if necessary.  If FLAC__stream_decoder_init() is calling us,
988    * (internal_reset_hack) don't try to rewind since we are already at
989    * the beginning of the stream and don't want to fail if the input is
990    * not seekable.
991    */
988     * (internal_reset_hack) don't try to rewind since we are already at
989     * the beginning of the stream and don't want to fail if the input is
990     * not seekable.
991     */
992992   if(!decoder->private_->internal_reset_hack) {
993993      if(decoder->private_->file == stdin)
994994         return false; /* can't rewind stdin, reset fails */
r14260r14261
10081008   }
10091009   decoder->private_->do_md5_checking = decoder->protected_->md5_checking;
10101010   /*
1011    * This goes in reset() and not flush() because according to the spec, a
1012    * fixed-blocksize stream must stay that way through the whole stream.
1013    */
1011     * This goes in reset() and not flush() because according to the spec, a
1012     * fixed-blocksize stream must stay that way through the whole stream.
1013     */
10141014   decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size = 0;
10151015
10161016   /* We initialize the FLAC__MD5Context even though we may never use it.  This
1017    * is because md5 checking may be turned on to start and then turned off if
1018    * a seek occurs.  So we init the context here and finalize it in
1019    * FLAC__stream_decoder_finish() to make sure things are always cleaned up
1020    * properly.
1021    */
1017     * is because md5 checking may be turned on to start and then turned off if
1018     * a seek occurs.  So we init the context here and finalize it in
1019     * FLAC__stream_decoder_finish() to make sure things are always cleaned up
1020     * properly.
1021     */
10221022   FLAC__MD5Init(&decoder->private_->md5context);
10231023
10241024   decoder->private_->first_frame_offset = 0;
r14260r14261
12761276{
12771277    #if 0
12781278   /* if something breaks here it is probably due to the presence or
1279    * absence of an underscore before the identifiers 'setmode',
1280    * 'fileno', and/or 'O_BINARY'; check your system header files.
1281    */
1279     * absence of an underscore before the identifiers 'setmode',
1280     * 'fileno', and/or 'O_BINARY'; check your system header files.
1281     */
12821282#if defined _MSC_VER || defined __MINGW32__
12831283   _setmode(_fileno(stdin), _O_BINARY);
1284#elif defined __CYGWIN__
1284#elif defined __CYGWIN__
12851285   /* almost certainly not needed for any modern Cygwin, but let's be safe... */
12861286   setmode(_fileno(stdin), _O_BINARY);
12871287#elif defined __EMX__
r14260r14261
13141314
13151315   for(i = 0; i < channels; i++) {
13161316      /* WATCHOUT:
1317       * FLAC__lpc_restore_signal_asm_ia32_mmx() requires that the
1318       * output arrays have a buffer of up to 3 zeroes in front
1319       * (at negative indices) for alignment purposes; we use 4
1320       * to keep the data well-aligned.
1321       */
1317         * FLAC__lpc_restore_signal_asm_ia32_mmx() requires that the
1318         * output arrays have a buffer of up to 3 zeroes in front
1319         * (at negative indices) for alignment purposes; we use 4
1320         * to keep the data well-aligned.
1321         */
13221322      tmp = (FLAC__int32*)safe_malloc_muladd2_(sizeof(FLAC__int32), /*times (*/size, /*+*/4/*)*/);
13231323      if(tmp == 0) {
13241324         decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
r14260r14261
13281328      decoder->private_->output[i] = tmp + 4;
13291329
13301330      /* WATCHOUT:
1331       * minimum of quadword alignment for PPC vector optimizations is REQUIRED:
1332       */
1331         * minimum of quadword alignment for PPC vector optimizations is REQUIRED:
1332         */
13331333      if(!FLAC__memory_alloc_aligned_int32_array(size, &decoder->private_->residual_unaligned[i], &decoder->private_->residual[i])) {
13341334         decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
13351335         return false;
r14260r14261
20092009      return false;
20102010   for(channel = 0; channel < decoder->private_->frame.header.channels; channel++) {
20112011      /*
2012       * first figure the correct bits-per-sample of the subframe
2013       */
2012         * first figure the correct bits-per-sample of the subframe
2013         */
20142014      unsigned bps = decoder->private_->frame.header.bits_per_sample;
20152015      switch(decoder->private_->frame.header.channel_assignment) {
20162016         case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT:
r14260r14261
20352035            FLAC__ASSERT(0);
20362036      }
20372037      /*
2038       * now read it
2039       */
2038         * now read it
2039         */
20402040      if(!read_subframe_(decoder, channel, bps, do_full_decode))
20412041         return false;
20422042      if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or got corruption */
r14260r14261
20482048      return true;
20492049
20502050   /*
2051    * Read the frame CRC-16 from the footer and check
2052    */
2051     * Read the frame CRC-16 from the footer and check
2052     */
20532053   frame_crc = FLAC__bitreader_get_read_crc16(decoder->private_->input);
20542054   if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__FRAME_FOOTER_CRC_LEN))
20552055      return false; /* read_callback_ sets the state for us */
r14260r14261
21512151      is_unparseable = true;
21522152
21532153   /*
2154    * Note that along the way as we read the header, we look for a sync
2155    * code inside.  If we find one it would indicate that our original
2156    * sync was bad since there cannot be a sync code in a valid header.
2157    *
2158    * Three kinds of things can go wrong when reading the frame header:
2159    *  1) We may have sync'ed incorrectly and not landed on a frame header.
2160    *     If we don't find a sync code, it can end up looking like we read
2161    *     a valid but unparseable header, until getting to the frame header
2162    *     CRC.  Even then we could get a false positive on the CRC.
2163    *  2) We may have sync'ed correctly but on an unparseable frame (from a
2164    *     future encoder).
2165    *  3) We may be on a damaged frame which appears valid but unparseable.
2166    *
2167    * For all these reasons, we try and read a complete frame header as
2168    * long as it seems valid, even if unparseable, up until the frame
2169    * header CRC.
2170    */
2154     * Note that along the way as we read the header, we look for a sync
2155     * code inside.  If we find one it would indicate that our original
2156     * sync was bad since there cannot be a sync code in a valid header.
2157     *
2158     * Three kinds of things can go wrong when reading the frame header:
2159     *  1) We may have sync'ed incorrectly and not landed on a frame header.
2160     *     If we don't find a sync code, it can end up looking like we read
2161     *     a valid but unparseable header, until getting to the frame header
2162     *     CRC.  Even then we could get a false positive on the CRC.
2163     *  2) We may have sync'ed correctly but on an unparseable frame (from a
2164     *     future encoder).
2165     *  3) We may be on a damaged frame which appears valid but unparseable.
2166     *
2167     * For all these reasons, we try and read a complete frame header as
2168     * long as it seems valid, even if unparseable, up until the frame
2169     * header CRC.
2170     */
21712171
21722172   /*
2173    * read in the raw header as bytes so we can CRC it, and parse it on the way
2174    */
2173     * read in the raw header as bytes so we can CRC it, and parse it on the way
2174     */
21752175   for(i = 0; i < 2; i++) {
21762176      if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8))
21772177         return false; /* read_callback_ sets the state for us */
r14260r14261
24622462      decoder->private_->frame.subframes[channel].wasted_bits = 0;
24632463
24642464   /*
2465    * Lots of magic numbers here
2466    */
2465     * Lots of magic numbers here
2466     */
24672467   if(x & 0x80) {
24682468      send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC);
24692469      decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
r14260r14261
26632663   if(do_full_decode) {
26642664      memcpy(decoder->private_->output[channel], subframe->warmup, sizeof(FLAC__int32) * order);
26652665      /*@@@@@@ technically not pessimistic enough, should be more like
2666      if( (FLAC__uint64)order * ((((FLAC__uint64)1)<<bps)-1) * ((1<<subframe->qlp_coeff_precision)-1) < (((FLAC__uint64)-1) << 32) )
2667      */
2666        if( (FLAC__uint64)order * ((((FLAC__uint64)1)<<bps)-1) * ((1<<subframe->qlp_coeff_precision)-1) < (((FLAC__uint64)-1) << 32) )
2667        */
26682668      if(bps + subframe->qlp_coeff_precision + FLAC__bitmath_ilog2(order) <= 32)
26692669         if(bps <= 16 && subframe->qlp_coeff_precision <= 16) {
26702670            if(order <= 8)
r14260r14261
27932793   }
27942794   else if(*bytes > 0) {
27952795      /* While seeking, it is possible for our seek to land in the
2796       * middle of audio data that looks exactly like a frame header
2797       * from a future version of an encoder.  When that happens, our
2798       * error callback will get an
2799       * FLAC__STREAM_DECODER_UNPARSEABLE_STREAM and increment its
2800       * unparseable_frame_count.  But there is a remote possibility
2801       * that it is properly synced at such a "future-codec frame",
2802       * so to make sure, we wait to see many "unparseable" errors in
2803       * a row before bailing out.
2804       */
2796         * middle of audio data that looks exactly like a frame header
2797         * from a future version of an encoder.  When that happens, our
2798         * error callback will get an
2799         * FLAC__STREAM_DECODER_UNPARSEABLE_STREAM and increment its
2800         * unparseable_frame_count.  But there is a remote possibility
2801         * that it is properly synced at such a "future-codec frame",
2802         * so to make sure, we wait to see many "unparseable" errors in
2803         * a row before bailing out.
2804         */
28052805      if(decoder->private_->is_seeking && decoder->private_->unparseable_frame_count > 20) {
28062806         decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED;
28072807         return false;
r14260r14261
28452845      return false;
28462846   }
28472847   /* [1] @@@ HACK NOTE: The end-of-stream checking has to be hacked around
2848    * for Ogg FLAC.  This is because the ogg decoder aspect can lose sync
2849    * and at the same time hit the end of the stream (for example, seeking
2850    * to a point that is after the beginning of the last Ogg page).  There
2851    * is no way to report an Ogg sync loss through the callbacks (see note
2852    * in read_callback_ogg_aspect_()) so it returns CONTINUE with *bytes==0.
2853    * So to keep the decoder from stopping at this point we gate the call
2854    * to the eof_callback and let the Ogg decoder aspect set the
2855    * end-of-stream state when it is needed.
2856    */
2848     * for Ogg FLAC.  This is because the ogg decoder aspect can lose sync
2849     * and at the same time hit the end of the stream (for example, seeking
2850     * to a point that is after the beginning of the last Ogg page).  There
2851     * is no way to report an Ogg sync loss through the callbacks (see note
2852     * in read_callback_ogg_aspect_()) so it returns CONTINUE with *bytes==0.
2853     * So to keep the decoder from stopping at this point we gate the call
2854     * to the eof_callback and let the Ogg decoder aspect set the
2855     * end-of-stream state when it is needed.
2856     */
28572857}
28582858
28592859#if FLAC__HAS_OGG
r14260r14261
28632863      case FLAC__OGG_DECODER_ASPECT_READ_STATUS_OK:
28642864         return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
28652865      /* we don't really have a way to handle lost sync via read
2866       * callback so we'll let it pass and let the underlying
2867       * FLAC decoder catch the error
2868       */
2866         * callback so we'll let it pass and let the underlying
2867         * FLAC decoder catch the error
2868         */
28692869      case FLAC__OGG_DECODER_ASPECT_READ_STATUS_LOST_SYNC:
28702870         return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
28712871      case FLAC__OGG_DECODER_ASPECT_READ_STATUS_END_OF_STREAM:
r14260r14261
29412941   }
29422942   else {
29432943      /*
2944       * If we never got STREAMINFO, turn off MD5 checking to save
2945       * cycles since we don't have a sum to compare to anyway
2946       */
2944         * If we never got STREAMINFO, turn off MD5 checking to save
2945         * cycles since we don't have a sum to compare to anyway
2946         */
29472947      if(!decoder->private_->has_stream_info)
29482948         decoder->private_->do_md5_checking = false;
29492949      if(decoder->private_->do_md5_checking) {
r14260r14261
29892989   if(max_framesize > 0)
29902990      approx_bytes_per_frame = (max_framesize + min_framesize) / 2 + 1;
29912991   /*
2992    * Check if it's a known fixed-blocksize stream.  Note that though
2993    * the spec doesn't allow zeroes in the STREAMINFO block, we may
2994    * never get a STREAMINFO block when decoding so the value of
2995    * min_blocksize might be zero.
2996    */
2992     * Check if it's a known fixed-blocksize stream.  Note that though
2993     * the spec doesn't allow zeroes in the STREAMINFO block, we may
2994     * never get a STREAMINFO block when decoding so the value of
2995     * min_blocksize might be zero.
2996     */
29972997   else if(min_blocksize == max_blocksize && min_blocksize > 0) {
29982998      /* note there are no () around 'bps/8' to keep precision up since it's an integer calulation */
29992999      approx_bytes_per_frame = min_blocksize * channels * bps/8 + 64;
r14260r14261
30023002      approx_bytes_per_frame = 4096 * channels * bps/8 + 64;
30033003
30043004   /*
3005    * First, we set an upper and lower bound on where in the
3006    * stream we will search.  For now we assume the worst case
3007    * scenario, which is our best guess at the beginning of
3008    * the first frame and end of the stream.
3009    */
3005     * First, we set an upper and lower bound on where in the
3006     * stream we will search.  For now we assume the worst case
3007     * scenario, which is our best guess at the beginning of
3008     * the first frame and end of the stream.
3009     */
30103010   lower_bound = first_frame_offset;
30113011   lower_bound_sample = 0;
30123012   upper_bound = stream_length;
30133013   upper_bound_sample = total_samples > 0 ? total_samples : target_sample /*estimate it*/;
30143014
30153015   /*
3016    * Now we refine the bounds if we have a seektable with
3017    * suitable points.  Note that according to the spec they
3018    * must be ordered by ascending sample number.
3019    *
3020    * Note: to protect against invalid seek tables we will ignore points
3021    * that have frame_samples==0 or sample_number>=total_samples
3022    */
3016     * Now we refine the bounds if we have a seektable with
3017     * suitable points.  Note that according to the spec they
3018     * must be ordered by ascending sample number.
3019     *
3020     * Note: to protect against invalid seek tables we will ignore points
3021     * that have frame_samples==0 or sample_number>=total_samples
3022     */
30233023   if(seek_table) {
30243024      FLAC__uint64 new_lower_bound = lower_bound;
30253025      FLAC__uint64 new_upper_bound = upper_bound;
r14260r14261
30663066
30673067   FLAC__ASSERT(upper_bound_sample >= lower_bound_sample);
30683068   /* there are 2 insidious ways that the following equality occurs, which
3069    * we need to fix:
3070    *  1) total_samples is 0 (unknown) and target_sample is 0
3071    *  2) total_samples is 0 (unknown) and target_sample happens to be
3072    *     exactly equal to the last seek point in the seek table; this
3073    *     means there is no seek point above it, and upper_bound_samples
3074    *     remains equal to the estimate (of target_samples) we made above
3075    * in either case it does not hurt to move upper_bound_sample up by 1
3076    */
3069     * we need to fix:
3070     *  1) total_samples is 0 (unknown) and target_sample is 0
3071     *  2) total_samples is 0 (unknown) and target_sample happens to be
3072     *     exactly equal to the last seek point in the seek table; this
3073     *     means there is no seek point above it, and upper_bound_samples
3074     *     remains equal to the estimate (of target_samples) we made above
3075     * in either case it does not hurt to move upper_bound_sample up by 1
3076     */
30773077   if(upper_bound_sample == lower_bound_sample)
30783078      upper_bound_sample++;
30793079
r14260r14261
31113111         return false;
31123112      }
31133113      /* Now we need to get a frame.  First we need to reset our
3114       * unparseable_frame_count; if we get too many unparseable
3115       * frames in a row, the read callback will return
3116       * FLAC__STREAM_DECODER_READ_STATUS_ABORT, causing
3117       * FLAC__stream_decoder_process_single() to return false.
3118       */
3114         * unparseable_frame_count; if we get too many unparseable
3115         * frames in a row, the read callback will return
3116         * FLAC__STREAM_DECODER_READ_STATUS_ABORT, causing
3117         * FLAC__stream_decoder_process_single() to return false.
3118         */
31193119      decoder->private_->unparseable_frame_count = 0;
31203120      if(!FLAC__stream_decoder_process_single(decoder)) {
31213121         decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
r14260r14261
31423142         }
31433143         /* our last move backwards wasn't big enough, try again */
31443144         approx_bytes_per_frame = approx_bytes_per_frame? approx_bytes_per_frame * 2 : 16;
3145         continue;   
3145         continue;
31463146      }
31473147      /* allow one seek over upper bound, so we can get a correct upper_bound_sample for streams with unknown total_samples */
31483148      first_seek = false;
3149     
3149
31503150      /* make sure we are not seeking in corrupted stream */
31513151      if (this_frame_sample < lower_bound_sample) {
31523152         decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
r14260r14261
31863186   FLAC__bool did_a_seek;
31873187   unsigned iteration = 0;
31883188
3189   /* In the first iterations, we will calculate the target byte position
3190    * by the distance from the target sample to left_sample and
3191    * right_sample (let's call it "proportional search").  After that, we
3192    * will switch to binary search.
3193    */
3189   /* In the first iterations, we will calculate the target byte position
3190     * by the distance from the target sample to left_sample and
3191     * right_sample (let's call it "proportional search").  After that, we
3192     * will switch to binary search.
3193     */
31943194   unsigned BINARY_SEARCH_AFTER_ITERATION = 2;
31953195
31963196   /* We will switch to a linear search once our current sample is less
3197    * than this number of samples ahead of the target sample
3198    */
3197     * than this number of samples ahead of the target sample
3198     */
31993199   static const FLAC__uint64 LINEAR_SEARCH_WITHIN_SAMPLES = FLAC__MAX_BLOCK_SIZE * 2;
32003200
32013201   /* If the total number of samples is unknown, use a large value, and
3202    * force binary search immediately.
3203    */
3202     * force binary search immediately.
3203     */
32043204   if(right_sample == 0) {
32053205      right_sample = (FLAC__uint64)(-1);
32063206      BINARY_SEARCH_AFTER_ITERATION = 0;
r14260r14261
32283228               pos = (FLAC__int64)((((target_sample-left_sample)>>8) * ((right_pos-left_pos)>>8)) / ((right_sample-left_sample)>>16));
32293229#endif
32303230            /* @@@ TODO: might want to limit pos to some distance
3231             * before EOF, to make sure we land before the last frame,
3232             * thereby getting a this_frame_sample and so having a better
3233             * estimate.
3234             */
3231                 * before EOF, to make sure we land before the last frame,
3232                 * thereby getting a this_frame_sample and so having a better
3233                 * estimate.
3234                 */
32353235         }
32363236
32373237         /* physical seek */
r14260r14261
32563256      if(!decoder->private_->got_a_frame) {
32573257         if(did_a_seek) {
32583258            /* this can happen if we seek to a point after the last frame; we drop
3259             * to binary search right away in this case to avoid any wasted
3260             * iterations of proportional search.
3261             */
3259                 * to binary search right away in this case to avoid any wasted
3260                 * iterations of proportional search.
3261                 */
32623262            right_pos = pos;
32633263            BINARY_SEARCH_AFTER_ITERATION = 0;
32643264         }
32653265         else {
32663266            /* this can probably only happen if total_samples is unknown and the
3267             * target_sample is past the end of the stream
3268             */
3267                 * target_sample is past the end of the stream
3268                 */
32693269            decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
32703270            return false;
32713271         }
r14260r14261
32813281         if (did_a_seek) {
32823282            if (this_frame_sample <= target_sample) {
32833283               /* The 'equal' case should not happen, since
3284                * FLAC__stream_decoder_process_single()
3285                * should recognize that it has hit the
3286                * target sample and we would exit through
3287                * the 'break' above.
3288                */
3284                     * FLAC__stream_decoder_process_single()
3285                     * should recognize that it has hit the
3286                     * target sample and we would exit through
3287                     * the 'break' above.
3288                     */
32893289               FLAC__ASSERT(this_frame_sample != target_sample);
32903290
32913291               left_sample = this_frame_sample;
src/lib/libflac/libflac/md5.c
r14260r14261
143143{
144144   register FLAC__uint32 x;
145145   do {
146      x = *buf;
146      x = *buf;
147147      x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff);
148148      *buf++ = (x >> 16) | (x << 16);
149149   } while (--words);
src/lib/libflac/libflac/cpu.c
r14260r14261
211211#endif
212212
213213      /*
214       * now have to check for OS support of SSE/SSE2
215       */
214         * now have to check for OS support of SSE/SSE2
215         */
216216      if(info->data.ia32.fxsr || info->data.ia32.sse || info->data.ia32.sse2) {
217217#if defined FLAC__NO_SSE_OS
218218         /* assume user knows better than us; turn it off */
src/lib/libflac/libflac/stream_encoder.c
r14260r14261
8888 * parameter estimation in this encoder is very good, almost always
8989 * yielding compression within 0.1% of the optimal parameters.
9090 */
91#undef ENABLE_RICE_PARAMETER_SEARCH
91#undef ENABLE_RICE_PARAMETER_SEARCH
9292
9393
9494typedef struct {
r14260r14261
224224#endif
225225
226226static unsigned evaluate_verbatim_subframe_(
227   FLAC__StreamEncoder *encoder,
227   FLAC__StreamEncoder *encoder,
228228   const FLAC__int32 signal[],
229229   unsigned blocksize,
230230   unsigned subframe_bps,
r14260r14261
406406   FLAC__uint64 *abs_residual_partition_sums_unaligned;
407407   unsigned *raw_bits_per_partition_unaligned;
408408   /*
409    * These fields have been moved here from private function local
410    * declarations merely to save stack space during encoding.
411    */
409     * These fields have been moved here from private function local
410     * declarations merely to save stack space during encoding.
411     */
412412#ifndef FLAC__INTEGER_ONLY_LIBRARY
413413   FLAC__real lp_coeff[FLAC__MAX_LPC_ORDER][FLAC__MAX_LPC_ORDER]; /* from process_subframe_() */
414414#endif
415415   FLAC__EntropyCodingMethod_PartitionedRiceContents partitioned_rice_contents_extra[2]; /* from find_best_partition_order_() */
416416   /*
417    * The data for the verify section
418    */
417     * The data for the verify section
418     */
419419   struct {
420420      FLAC__StreamDecoder *decoder;
421421      EncoderStateHint state_hint;
r14260r14261
825825            metadata_picture_has_type1 = true;
826826            /* standard icon must be 32x32 pixel PNG */
827827            if(
828               m->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD &&
828               m->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD &&
829829               (
830830                  (strcmp(m->data.picture.mime_type, "image/png") && strcmp(m->data.picture.mime_type, "-->")) ||
831831                  m->data.picture.width != 32 ||
r14260r14261
894894   encoder->private_->use_wide_by_partition = (false); /*@@@ need to set this */
895895
896896   /*
897    * get the CPU info and set the function pointers
898    */
897     * get the CPU info and set the function pointers
898     */
899899   FLAC__cpu_info(&encoder->private_->cpuinfo);
900900   /* first default to the non-asm routines */
901901#ifndef FLAC__INTEGER_ONLY_LIBRARY
r14260r14261
977977   }
978978
979979   /*
980    * Set up the verify stuff if necessary
981    */
980     * Set up the verify stuff if necessary
981     */
982982   if(encoder->protected_->verify) {
983983      /*
984       * First, set up the fifo which will hold the
985       * original signal to compare against
986       */
984         * First, set up the fifo which will hold the
985         * original signal to compare against
986         */
987987      encoder->private_->verify.input_fifo.size = encoder->protected_->blocksize+OVERREAD_;
988988      for(i = 0; i < encoder->protected_->channels; i++) {
989989         if(0 == (encoder->private_->verify.input_fifo.data[i] = (FLAC__int32*)safe_malloc_mul_2op_(sizeof(FLAC__int32), /*times*/encoder->private_->verify.input_fifo.size))) {
r14260r14261
994994      encoder->private_->verify.input_fifo.tail = 0;
995995
996996      /*
997       * Now set up a stream decoder for verification
998       */
997         * Now set up a stream decoder for verification
998         */
999999      encoder->private_->verify.decoder = FLAC__stream_decoder_new();
10001000      if(0 == encoder->private_->verify.decoder) {
10011001         encoder->protected_->state = FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR;
r14260r14261
10151015   encoder->private_->verify.error_stats.got = 0;
10161016
10171017   /*
1018    * These must be done before we write any metadata, because that
1019    * calls the write_callback, which uses these values.
1020    */
1018     * These must be done before we write any metadata, because that
1019     * calls the write_callback, which uses these values.
1020     */
10211021   encoder->private_->first_seekpoint_to_check = 0;
10221022   encoder->private_->samples_written = 0;
10231023   encoder->protected_->streaminfo_offset = 0;
r14260r14261
10251025   encoder->protected_->audio_offset = 0;
10261026
10271027   /*
1028    * write the stream header
1029    */
1028     * write the stream header
1029     */
10301030   if(encoder->protected_->verify)
10311031      encoder->private_->verify.state_hint = ENCODER_IN_MAGIC;
10321032   if(!FLAC__bitwriter_write_raw_uint32(encoder->private_->frame, FLAC__STREAM_SYNC, FLAC__STREAM_SYNC_LEN)) {
r14260r14261
10391039   }
10401040
10411041   /*
1042    * write the STREAMINFO metadata block
1043    */
1042     * write the STREAMINFO metadata block
1043     */
10441044   if(encoder->protected_->verify)
10451045      encoder->private_->verify.state_hint = ENCODER_IN_METADATA;
10461046   encoder->private_->streaminfo.type = FLAC__METADATA_TYPE_STREAMINFO;
r14260r14261
10671067   }
10681068
10691069   /*
1070    * Now that the STREAMINFO block is written, we can init this to an
1071    * absurdly-high value...
1072    */
1070     * Now that the STREAMINFO block is written, we can init this to an
1071     * absurdly-high value...
1072     */
10731073   encoder->private_->streaminfo.data.stream_info.min_framesize = (1u << FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN) - 1;
10741074   /* ... and clear this to 0 */
10751075   encoder->private_->streaminfo.data.stream_info.total_samples = 0;
10761076
10771077   /*
1078    * Check to see if the supplied metadata contains a VORBIS_COMMENT;
1079    * if not, we will write an empty one (FLAC__add_metadata_block()
1080    * automatically supplies the vendor string).
1081    *
1082    * WATCHOUT: the Ogg FLAC mapping requires us to write this block after
1083    * the STREAMINFO.  (In the case that metadata_has_vorbis_comment is
1084    * true it will have already insured that the metadata list is properly
1085    * ordered.)
1086    */
1078     * Check to see if the supplied metadata contains a VORBIS_COMMENT;
1079     * if not, we will write an empty one (FLAC__add_metadata_block()
1080     * automatically supplies the vendor string).
1081     *
1082     * WATCHOUT: the Ogg FLAC mapping requires us to write this block after
1083     * the STREAMINFO.  (In the case that metadata_has_vorbis_comment is
1084     * true it will have already insured that the metadata list is properly
1085     * ordered.)
1086     */
10871087   if(!metadata_has_vorbis_comment) {
10881088      FLAC__StreamMetadata vorbis_comment;
10891089      vorbis_comment.type = FLAC__METADATA_TYPE_VORBIS_COMMENT;
r14260r14261
11041104   }
11051105
11061106   /*
1107    * write the user's metadata blocks
1108    */
1107     * write the user's metadata blocks
1108     */
11091109   for(i = 0; i < encoder->protected_->num_metadata_blocks; i++) {
11101110      encoder->protected_->metadata[i]->is_last = (i == encoder->protected_->num_metadata_blocks - 1);
11111111      if(!FLAC__add_metadata_block(encoder->protected_->metadata[i], encoder->private_->frame)) {
r14260r14261
11721172      /*is_ogg=*/true
11731173   );
11741174}
1175
1175
11761176static FLAC__StreamEncoderInitStatus init_FILE_internal_(
11771177   FLAC__StreamEncoder *encoder,
11781178   FILE *file,
r14260r14261
11961196   }
11971197
11981198   /*
1199    * To make sure that our file does not go unclosed after an error, we
1200    * must assign the FILE pointer before any further error can occur in
1201    * this routine.
1202    */
1199     * To make sure that our file does not go unclosed after an error, we
1200     * must assign the FILE pointer before any further error can occur in
1201     * this routine.
1202     */
12031203   if(file == stdout)
12041204      file = get_binary_stdout_(); /* just to be safe */
12051205
r14260r14261
12341234
12351235   return init_status;
12361236}
1237
1237
12381238FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_FILE(
12391239   FLAC__StreamEncoder *encoder,
12401240   FILE *file,
r14260r14261
12441244{
12451245   return init_FILE_internal_(encoder, file, progress_callback, client_data, /*is_ogg=*/false);
12461246}
1247
1247
12481248FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_FILE(
12491249   FLAC__StreamEncoder *encoder,
12501250   FILE *file,
r14260r14261
12681268   FLAC__ASSERT(0 != encoder);
12691269
12701270   /*
1271    * To make sure that our file does not go unclosed after an error, we
1272    * have to do the same entrance checks here that are later performed
1273    * in FLAC__stream_encoder_init_FILE() before the FILE* is assigned.
1274    */
1271     * To make sure that our file does not go unclosed after an error, we
1272     * have to do the same entrance checks here that are later performed
1273     * in FLAC__stream_encoder_init_FILE() before the FILE* is assigned.
1274     */
12751275   if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
12761276      return FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED;
12771277
r14260r14261
20332033
20342034   j = k = 0;
20352035   /*
2036    * we have several flavors of the same basic loop, optimized for
2037    * different conditions:
2038    */
2036     * we have several flavors of the same basic loop, optimized for
2037     * different conditions:
2038     */
20392039   if(encoder->protected_->do_mid_side_stereo && channels == 2) {
20402040      /*
2041       * stereo coding: unroll channel loop
2042       */
2041         * stereo coding: unroll channel loop
2042         */
20432043      do {
20442044         if(encoder->protected_->verify)
20452045            append_to_verify_fifo_interleaved_(&encoder->private_->verify.input_fifo, buffer, j, channels, min(blocksize+OVERREAD_-encoder->private_->current_sample_number, samples-j));
r14260r14261
20732073   }
20742074   else {
20752075      /*
2076       * independent channel coding: buffer each channel in inner loop
2077       */
2076         * independent channel coding: buffer each channel in inner loop
2077         */
20782078      do {
20792079         if(encoder->protected_->verify)
20802080            append_to_verify_fifo_interleaved_(&encoder->private_->verify.input_fifo, buffer, j, channels, min(blocksize+OVERREAD_-encoder->private_->current_sample_number, samples-j));
r14260r14261
22592259   ok = true;
22602260
22612261   /* WATCHOUT: FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx()
2262    * requires that the input arrays (in our case the integer signals)
2263    * have a buffer of up to 3 zeroes in front (at negative indices) for
2264    * alignment purposes; we use 4 in front to keep the data well-aligned.
2265    */
2262     * requires that the input arrays (in our case the integer signals)
2263     * have a buffer of up to 3 zeroes in front (at negative indices) for
2264     * alignment purposes; we use 4 in front to keep the data well-aligned.
2265     */
22662266
22672267   for(i = 0; ok && i < encoder->protected_->channels; i++) {
22682268      ok = ok && FLAC__memory_alloc_aligned_int32_array(new_blocksize+4+OVERREAD_, &encoder->private_->integer_signal_unaligned[i], &encoder->private_->integer_signal[i]);
r14260r14261
24362436   }
24372437
24382438   /*
2439    * Watch for the STREAMINFO block and first SEEKTABLE block to go by and store their offsets.
2440    */
2439     * Watch for the STREAMINFO block and first SEEKTABLE block to go by and store their offsets.
2440     */
24412441   if(samples == 0) {
24422442      FLAC__MetadataType type = (buffer[0] & 0x7f);
24432443      if(type == FLAC__METADATA_TYPE_STREAMINFO)
r14260r14261
24472447   }
24482448
24492449   /*
2450    * Mark the current seek point if hit (if audio_offset == 0 that
2451    * means we're still writing metadata and haven't hit the first
2452    * frame yet)
2453    */
2450     * Mark the current seek point if hit (if audio_offset == 0 that
2451     * means we're still writing metadata and haven't hit the first
2452     * frame yet)
2453     */
24542454   if(0 != encoder->private_->seek_table && encoder->protected_->audio_offset > 0 && encoder->private_->seek_table->num_points > 0) {
24552455      const unsigned blocksize = FLAC__stream_encoder_get_blocksize(encoder);
24562456      const FLAC__uint64 frame_first_sample = encoder->private_->samples_written;
r14260r14261
24682468            encoder->private_->seek_table->points[i].frame_samples = blocksize;
24692469            encoder->private_->first_seekpoint_to_check++;
24702470            /* DO NOT: "break;" and here's why:
2471             * The seektable template may contain more than one target
2472             * sample for any given frame; we will keep looping, generating
2473             * duplicate seekpoints for them, and we'll clean it up later,
2474             * just before writing the seektable back to the metadata.
2475             */
2471                 * The seektable template may contain more than one target
2472                 * sample for any given frame; we will keep looping, generating
2473                 * duplicate seekpoints for them, and we'll clean it up later,
2474                 * just before writing the seektable back to the metadata.
2475                 */
24762476         }
24772477         else {
24782478            encoder->private_->first_seekpoint_to_check++;
r14260r14261
25022502      encoder->private_->bytes_written += bytes;
25032503      encoder->private_->samples_written += samples;
25042504      /* we keep a high watermark on the number of frames written because
2505       * when the encoder goes back to write metadata, 'current_frame'
2506       * will drop back to 0.
2507       */
2505         * when the encoder goes back to write metadata, 'current_frame'
2506         * will drop back to 0.
2507         */
25082508      encoder->private_->frames_written = max(encoder->private_->frames_written, encoder->private_->current_frame_number+1);
25092509   }
25102510   else
r14260r14261
25272527   FLAC__ASSERT(metadata->type == FLAC__METADATA_TYPE_STREAMINFO);
25282528
25292529   /* All this is based on intimate knowledge of the stream header
2530    * layout, but a change to the header format that would break this
2531    * would also break all streams encoded in the previous format.
2532    */
2530     * layout, but a change to the header format that would break this
2531     * would also break all streams encoded in the previous format.
2532     */
25332533
25342534   /*
2535    * Write MD5 signature
2536    */
2535     * Write MD5 signature
2536     */
25372537   {
25382538      const unsigned md5_offset =
25392539         FLAC__STREAM_METADATA_HEADER_LENGTH +
r14260r14261
25602560   }
25612561
25622562   /*
2563    * Write total samples
2564    */
2563     * Write total samples
2564     */
25652565   {
25662566      const unsigned total_samples_byte_offset =
25672567         FLAC__STREAM_METADATA_HEADER_LENGTH +
r14260r14261
25932593   }
25942594
25952595   /*
2596    * Write min/max framesize
2597    */
2596     * Write min/max framesize
2597     */
25982598   {
25992599      const unsigned min_framesize_offset =
26002600         FLAC__STREAM_METADATA_HEADER_LENGTH +
r14260r14261
26212621   }
26222622
26232623   /*
2624    * Write seektable
2625    */
2624     * Write seektable
2625     */
26262626   if(0 != encoder->private_->seek_table && encoder->private_->seek_table->num_points > 0 && encoder->protected_->seektable_offset > 0) {
26272627      unsigned i;
26282628
r14260r14261
26922692   FLAC__ASSERT(0 != encoder->private_->seek_callback);
26932693
26942694   /* Pre-check that client supports seeking, since we don't want the
2695    * ogg_helper code to ever have to deal with this condition.
2696    */
2695     * ogg_helper code to ever have to deal with this condition.
2696     */
26972697   if(encoder->private_->seek_callback(encoder, 0, encoder->private_->client_data) == FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED)
26982698      return;
26992699
27002700   /* All this is based on intimate knowledge of the stream header
2701    * layout, but a change to the header format that would break this
2702    * would also break all streams encoded in the previous format.
2703    */
2701     * layout, but a change to the header format that would break this
2702     * would also break all streams encoded in the previous format.
2703     */
27042704
27052705   /**
2706    ** Write STREAMINFO stats
2707    **/
2706     ** Write STREAMINFO stats
2707     **/
27082708   simple_ogg_page__init(&page);
27092709   if(!simple_ogg_page__get_at(encoder, encoder->protected_->streaminfo_offset, &page, encoder->private_->seek_callback, encoder->private_->read_callback, encoder->private_->client_data)) {
27102710      simple_ogg_page__clear(&page);
r14260r14261
27122712   }
27132713
27142714   /*
2715    * Write MD5 signature
2716    */
2715     * Write MD5 signature
2716     */
27172717   {
27182718      const unsigned md5_offset =
27192719         FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH +
r14260r14261
27382738   }
27392739
27402740   /*
2741    * Write total samples
2742    */
2741     * Write total samples
2742     */
27432743   {
27442744      const unsigned total_samples_byte_offset =
27452745         FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH +
r14260r14261
27702770   }
27712771
27722772   /*
2773    * Write min/max framesize
2774    */
2773     * Write min/max framesize
2774     */
27752775   {
27762776      const unsigned min_framesize_offset =
27772777         FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH +
r14260r14261
28012801   simple_ogg_page__clear(&page);
28022802
28032803   /*
2804    * Write seektable
2805    */
2804     * Write seektable
2805     */
28062806   if(0 != encoder->private_->seek_table && encoder->private_->seek_table->num_points > 0 && encoder->protected_->seektable_offset > 0) {
28072807      unsigned i;
28082808      FLAC__byte *p;
r14260r14261
28652865   FLAC__ASSERT(encoder->protected_->state == FLAC__STREAM_ENCODER_OK);
28662866
28672867   /*
2868    * Accumulate raw signal to the MD5 signature
2869    */
2868     * Accumulate raw signal to the MD5 signature
2869     */
28702870   if(encoder->protected_->do_md5 && !FLAC__MD5Accumulate(&encoder->private_->md5context, (const FLAC__int32 * const *)encoder->private_->integer_signal, encoder->protected_->channels, encoder->protected_->blocksize, (encoder->protected_->bits_per_sample+7) / 8)) {
28712871      encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
28722872      return false;
28732873   }
28742874
28752875   /*
2876    * Process the frame header and subframes into the frame bitbuffer
2877    */
2876     * Process the frame header and subframes into the frame bitbuffer
2877     */
28782878   if(!process_subframes_(encoder, is_fractional_block)) {
28792879      /* the above function sets the state for us in case of an error */
28802880      return false;
28812881   }
28822882
28832883   /*
2884    * Zero-pad the frame to a byte_boundary
2885    */
2884     * Zero-pad the frame to a byte_boundary
2885     */
28862886   if(!FLAC__bitwriter_zero_pad_to_byte_boundary(encoder->private_->frame)) {
28872887      encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
28882888      return false;
28892889   }
28902890
28912891   /*
2892    * CRC-16 the whole thing
2893    */
2892     * CRC-16 the whole thing
2893     */
28942894   FLAC__ASSERT(FLAC__bitwriter_is_byte_aligned(encoder->private_->frame));
28952895   if(
28962896      !FLAC__bitwriter_get_write_crc16(encoder->private_->frame, &crc) ||
r14260r14261
29012901   }
29022902
29032903   /*
2904    * Write it
2905    */
2904     * Write it
2905     */
29062906   if(!write_bitbuffer_(encoder, encoder->protected_->blocksize, is_last_block)) {
29072907      /* the above function sets the state for us in case of an error */
29082908      return false;
29092909   }
29102910
29112911   /*
2912    * Get ready for the next frame
2913    */
2912     * Get ready for the next frame
2913     */
29142914   encoder->private_->current_sample_number = 0;
29152915   encoder->private_->current_frame_number++;
29162916   encoder->private_->streaminfo.data.stream_info.total_samples += (FLAC__uint64)encoder->protected_->blocksize;
r14260r14261
29252925   FLAC__bool do_independent, do_mid_side;
29262926
29272927   /*
2928    * Calculate the min,max Rice partition orders
2929    */
2928     * Calculate the min,max Rice partition orders
2929     */
29302930   if(is_fractional_block) {
29312931      max_partition_order = 0;
29322932   }
r14260r14261
29372937   min_partition_order = min(min_partition_order, max_partition_order);
29382938
29392939   /*
2940    * Setup the frame
2941    */
2940     * Setup the frame
2941     */
29422942   frame_header.blocksize = encoder->protected_->blocksize;
29432943   frame_header.sample_rate = encoder->protected_->sample_rate;
29442944   frame_header.channels = encoder->protected_->channels;
r14260r14261
29482948   frame_header.number.frame_number = encoder->private_->current_frame_number;
29492949
29502950   /*
2951    * Figure out what channel assignments to try
2952    */
2951     * Figure out what channel assignments to try
2952     */
29532953   if(encoder->protected_->do_mid_side_stereo) {
29542954      if(encoder->protected_->loose_mid_side_stereo) {
29552955         if(encoder->private_->loose_mid_side_stereo_frame_count == 0) {
r14260r14261
29742974   FLAC__ASSERT(do_independent || do_mid_side);
29752975
29762976   /*
2977    * Check for wasted bits; set effective bps for each subframe
2978    */
2977     * Check for wasted bits; set effective bps for each subframe
2978     */
29792979   if(do_independent) {
29802980      for(channel = 0; channel < encoder->protected_->channels; channel++) {
29812981         const unsigned w = get_wasted_bits_(encoder->private_->integer_signal[channel], encoder->protected_->blocksize);
r14260r14261
29932993   }
29942994
29952995   /*
2996    * First do a normal encoding pass of each independent channel
2997    */
2996     * First do a normal encoding pass of each independent channel
2997     */
29982998   if(do_independent) {
29992999      for(channel = 0; channel < encoder->protected_->channels; channel++) {
30003000         if(!
r14260r14261
30173017   }
30183018
30193019   /*
3020    * Now do mid and side channels if requested
3021    */
3020     * Now do mid and side channels if requested
3021     */
30223022   if(do_mid_side) {
30233023      FLAC__ASSERT(encoder->protected_->channels == 2);
30243024
r14260r14261
30433043   }
30443044
30453045   /*
3046    * Compose the frame bitbuffer
3047    */
3046     * Compose the frame bitbuffer
3047     */
30483048   if(do_mid_side) {
30493049      unsigned left_bps = 0, right_bps = 0; /* initialized only to prevent superfluous compiler warning */
30503050      FLAC__Subframe *left_subframe = 0, *right_subframe = 0; /* initialized only to prevent superfluous compiler warning */
r14260r14261
37343734
37353735   {
37363736      /*
3737       * We are allowed to de-const the pointer based on our special
3738       * knowledge; it is const to the outside world.
3739       */
3737         * We are allowed to de-const the pointer based on our special
3738         * knowledge; it is const to the outside world.
3739         */
37403740      FLAC__EntropyCodingMethod_PartitionedRiceContents* prc = (FLAC__EntropyCodingMethod_PartitionedRiceContents*)best_ecm->data.partitioned_rice.contents;
37413741      unsigned partition;
37423742
r14260r14261
37463746      if(do_escape_coding)
37473747         memcpy(prc->raw_bits, private_->partitioned_rice_contents_extra[best_parameters_index].raw_bits, sizeof(unsigned)*(1<<(best_partition_order)));
37483748      /*
3749       * Now need to check if the type should be changed to
3750       * FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 based on the
3751       * size of the rice parameters.
3752       */
3749         * Now need to check if the type should be changed to
3750         * FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 based on the
3751         * size of the rice parameters.
3752         */
37533753      for(partition = 0; partition < (1u<<best_partition_order); partition++) {
37543754         if(prc->parameters[partition] >= FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER) {
37553755            best_ecm->type = FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2;
r14260r14261
39323932      )
39333933      - (partition_samples >> 1)
39343934      /* -(partition_samples>>1) to subtract out extra contributions to the abs_residual_partition_sum.
3935       * The actual number of bits used is closer to the sum(for all i in the partition) of  abs(residual[i])>>(rice_parameter-1)
3936       * By using the abs_residual_partition sum, we also add in bits in the LSBs that would normally be shifted out.
3937       * So the subtraction term tries to guess how many extra bits were contributed.
3938       * If the LSBs are randomly distributed, this should average to 0.5 extra bits per sample.
3939       */
3935         * The actual number of bits used is closer to the sum(for all i in the partition) of  abs(residual[i])>>(rice_parameter-1)
3936         * By using the abs_residual_partition sum, we also add in bits in the LSBs that would normally be shifted out.
3937         * So the subtraction term tries to guess how many extra bits were contributed.
3938         * If the LSBs are randomly distributed, this should average to 0.5 extra bits per sample.
3939         */
39403940   ;
39413941}
39423942#endif
r14260r14261
40384038         }
40394039         mean = abs_residual_partition_sums[partition];
40404040         /* we are basically calculating the size in bits of the
4041          * average residual magnitude in the partition:
4042          *   rice_parameter = floor(log2(mean/partition_samples))
4043          * 'mean' is not a good name for the variable, it is
4044          * actually the sum of magnitudes of all residual values
4045          * in the partition, so the actual mean is
4046          * mean/partition_samples
4047          */
4041             * average residual magnitude in the partition:
4042             *   rice_parameter = floor(log2(mean/partition_samples))
4043             * 'mean' is not a good name for the variable, it is
4044             * actually the sum of magnitudes of all residual values
4045             * in the partition, so the actual mean is
4046             * mean/partition_samples
4047             */
40484048         for(rice_parameter = 0, k = partition_samples; k < mean; rice_parameter++, k <<= 1)
40494049            ;
40504050         if(rice_parameter >= rice_parameter_limit) {
r14260r14261
41744174   else {
41754175      if(encoded_bytes == 0) {
41764176         /*
4177          * If we get here, a FIFO underflow has occurred,
4178          * which means there is a bug somewhere.
4179          */
4177             * If we get here, a FIFO underflow has occurred,
4178             * which means there is a bug somewhere.
4179             */
41804180         FLAC__ASSERT(0);
41814181         return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
41824182      }
r14260r14261
43064306      FLAC__bool call_it = 0 != encoder->private_->progress_callback && (
43074307#if FLAC__HAS_OGG
43084308         /* We would like to be able to use 'samples > 0' in the
4309          * clause here but currently because of the nature of our
4310          * Ogg writing implementation, 'samples' is always 0 (see
4311          * ogg_encoder_aspect.c).  The downside is extra progress
4312          * callbacks.
4313          */
4309             * clause here but currently because of the nature of our
4310             * Ogg writing implementation, 'samples' is always 0 (see
4311             * ogg_encoder_aspect.c).  The downside is extra progress
4312             * callbacks.
4313             */
43144314         encoder->private_->is_ogg? true :
43154315#endif
43164316         samples > 0
43174317      );
43184318      if(call_it) {
43194319         /* NOTE: We have to add +bytes, +samples, and +1 to the stats
4320          * because at this point in the callback chain, the stats
4321          * have not been updated.  Only after we return and control
4322          * gets back to write_frame_() are the stats updated
4323          */
4320             * because at this point in the callback chain, the stats
4321             * have not been updated.  Only after we return and control
4322             * gets back to write_frame_() are the stats updated
4323             */
43244324         encoder->private_->progress_callback(encoder, encoder->private_->bytes_written+bytes, encoder->private_->samples_written+samples, encoder->private_->frames_written+(samples?1:0), encoder->private_->total_frames_estimate, encoder->private_->client_data);
43254325      }
43264326      return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
r14260r14261
43364336{
43374337#if 0
43384338    /* if something breaks here it is probably due to the presence or
4339    * absence of an underscore before the identifiers 'setmode',
4340    * 'fileno', and/or 'O_BINARY'; check your system header files.
4341    */
4339     * absence of an underscore before the identifiers 'setmode',
4340     * 'fileno', and/or 'O_BINARY'; check your system header files.
4341     */
43424342#if defined _MSC_VER || defined __MINGW32__
43434343   _setmode(_fileno(stdout), _O_BINARY);
43444344#elif defined __CYGWIN__
src/lib/libflac/libflac/stream_encoder_framing.c
r14260r14261
5959      return false;
6060
6161   /*
62    * First, for VORBIS_COMMENTs, adjust the length to reflect our vendor string
63    */
62     * First, for VORBIS_COMMENTs, adjust the length to reflect our vendor string
63     */
6464   i = metadata->length;
6565   if(metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) {
6666      FLAC__ASSERT(metadata->data.vorbis_comment.vendor_string.length == 0 || 0 != metadata->data.vorbis_comment.vendor_string.entry);
src/lib/libjpeg/jddctmgr.c
r14260r14261
275275    case JDCT_ISLOW:
276276      {
277277   /* For LL&M IDCT method, multipliers are equal to raw quantization
278    * coefficients, but are stored as ints to ensure access efficiency.
279    */
278     * coefficients, but are stored as ints to ensure access efficiency.
279     */
280280   ISLOW_MULT_TYPE * ismtbl = (ISLOW_MULT_TYPE *) compptr->dct_table;
281281   for (i = 0; i < DCTSIZE2; i++) {
282282     ismtbl[i] = (ISLOW_MULT_TYPE) qtbl->quantval[i];
r14260r14261
288288    case JDCT_IFAST:
289289      {
290290   /* For AA&N IDCT method, multipliers are equal to quantization
291    * coefficients scaled by scalefactor[row]*scalefactor[col], where
292    *   scalefactor[0] = 1
293    *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
294    * For integer operation, the multiplier table is to be scaled by
295    * IFAST_SCALE_BITS.
296    */
291     * coefficients scaled by scalefactor[row]*scalefactor[col], where
292     *   scalefactor[0] = 1
293     *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
294     * For integer operation, the multiplier table is to be scaled by
295     * IFAST_SCALE_BITS.
296     */
297297   IFAST_MULT_TYPE * ifmtbl = (IFAST_MULT_TYPE *) compptr->dct_table;
298298#define CONST_BITS 14
299299   static const INT16 aanscales[DCTSIZE2] = {
r14260r14261
322322    case JDCT_FLOAT:
323323      {
324324   /* For float AA&N IDCT method, multipliers are equal to quantization
325    * coefficients scaled by scalefactor[row]*scalefactor[col], where
326    *   scalefactor[0] = 1
327    *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
328    * We apply a further scale factor of 1/8.
329    */
325     * coefficients scaled by scalefactor[row]*scalefactor[col], where
326     *   scalefactor[0] = 1
327     *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
328     * We apply a further scale factor of 1/8.
329     */
330330   FLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table;
331331   int row, col;
332332   static const double aanscalefactor[DCTSIZE] = {
src/lib/libjpeg/jerror.c
r14260r14261
220220/*
221221 * Fill in the standard error-handling methods in a jpeg_error_mgr object.
222222 * Typical call is:
223 *   struct jpeg_compress_struct cinfo;
224 *   struct jpeg_error_mgr err;
223 *  struct jpeg_compress_struct cinfo;
224 *  struct jpeg_error_mgr err;
225225 *
226 *   cinfo.err = jpeg_std_error(&err);
226 *  cinfo.err = jpeg_std_error(&err);
227227 * after which the application may override some of the methods.
228228 */
229229 
src/lib/libjpeg/jchuff.c
r14260r14261
186186      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
187187              SIZEOF(c_derived_tbl));
188188  dtbl = *pdtbl;
189 
189
190190  /* Figure C.1: make table of Huffman code length for each symbol */
191191 
192192  p = 0;
r14260r14261
199199  }
200200  huffsize[p] = 0;
201201  lastp = p;
202 
202
203203  /* Figure C.2: generate the codes themselves */
204204  /* We also validate that the counts represent a legal Huffman code tree. */
205205 
r14260r14261
219219    code <<= 1;
220220    si++;
221221  }
222 
222
223223  /* Figure C.3: generate encoding tables */
224224  /* These are code and size indexed by symbol value */
225225 
r14260r14261
316316    ERREXIT(state->cinfo, JERR_HUFF_MISSING_CODE);
317317 
318318  put_buffer &= (((INT32) 1)<<size) - 1; /* mask off any extra bits in code */
319 
319
320320  put_bits += size;      /* new number of bits in buffer */
321 
321
322322  put_buffer <<= 24 - put_bits; /* align incoming bits */
323323 
324324  put_buffer |= state->cur.put_buffer; /* and merge with old buffer contents */
325 
325
326326  while (put_bits >= 8) {
327327    int c = (int) ((put_buffer >> 16) & 0xFF);
328   
328
329329    emit_byte_s(state, c, return FALSE);
330330    if (c == 0xFF) {      /* need to stuff a zero byte? */
331331      emit_byte_s(state, 0, return FALSE);
r14260r14261
358358    return;         /* do nothing if we're only getting stats */
359359 
360360  put_buffer &= (((INT32) 1)<<size) - 1; /* mask off any extra bits in code */
361 
361
362362  put_bits += size;      /* new number of bits in buffer */
363363 
364364  put_buffer <<= 24 - put_bits; /* align incoming bits */
r14260r14261
580580      /* This code assumes we are on a two's complement machine */
581581      temp2--;
582582    }
583   
583
584584    /* Find the number of bits needed for the magnitude of the coefficient */
585585    nbits = 0;
586586    while (temp) {
r14260r14261
592592     */
593593    if (nbits > MAX_COEF_BITS+1)
594594      ERREXIT(cinfo, JERR_BAD_DCT_COEF);
595   
595
596596    /* Count/emit the Huffman-coded symbol for the number of bits */
597597    emit_dc_symbol(entropy, compptr->dc_tbl_no, nbits);
598   
598
599599    /* Emit that number of bits of the value, if positive, */
600600    /* or the complement of its magnitude, if negative. */
601601    if (nbits)         /* emit_bits rejects calls with size 0 */
r14260r14261
651651  block = MCU_data[0];
652652 
653653  /* Encode the AC coefficients per section G.1.2.2, fig. G.3 */
654 
654
655655  r = 0;         /* r = run length of zeros */
656   
656
657657  for (k = cinfo->Ss; k <= Se; k++) {
658658    if ((temp = (*block)[natural_order[k]]) == 0) {
659659      r++;
r14260r14261
830830  }
831831 
832832  /* Encode the AC coefficients per section G.1.2.3, fig. G.7 */
833 
833
834834  r = 0;         /* r = run length of zeros */
835835  BR = 0;         /* BR = count of buffered bits added now */
836836  BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */
r14260r14261
11271127  register int k, r;
11281128  int Se = cinfo->lim_Se;
11291129  const int * natural_order = cinfo->natural_order;
1130 
1130
11311131  /* Encode the DC coefficient difference per section F.1.2.1 */
1132 
1132
11331133  temp = block[0] - last_dc_val;
11341134  if (temp < 0)
11351135    temp = -temp;
1136 
1136
11371137  /* Find the number of bits needed for the magnitude of the coefficient */
11381138  nbits = 0;
11391139  while (temp) {
r14260r14261
11481148 
11491149  /* Count the Huffman symbol for the number of bits */
11501150  dc_counts[nbits]++;
1151 
1151
11521152  /* Encode the AC coefficients per section F.1.2.2 */
1153 
1153
11541154  r = 0;         /* r = run length of zeros */
1155 
1155
11561156  for (k = 1; k <= Se; k++) {
11571157    if ((temp = block[natural_order[k]]) == 0) {
11581158      r++;
r14260r14261
11621162   ac_counts[0xF0]++;
11631163   r -= 16;
11641164      }
1165     
1165
11661166      /* Find the number of bits needed for the magnitude of the coefficient */
11671167      if (temp < 0)
11681168   temp = -temp;
1169     
1169
11701170      /* Find the number of bits needed for the magnitude of the coefficient */
11711171      nbits = 1;      /* there must be at least one 1 bit */
11721172      while ((temp >>= 1))
r14260r14261
11741174      /* Check for out-of-range coefficient values */
11751175      if (nbits > MAX_COEF_BITS)
11761176   ERREXIT(cinfo, JERR_BAD_DCT_COEF);
1177     
1177
11781178      /* Count Huffman symbol for run length / number of bits */
11791179      ac_counts[(r << 4) + nbits]++;
1180     
1180
11811181      r = 0;
11821182    }
11831183  }
r14260r14261
12691269  MEMZERO(codesize, SIZEOF(codesize));
12701270  for (i = 0; i < 257; i++)
12711271    others[i] = -1;      /* init links to empty */
1272 
1272
12731273  freq[256] = 1;      /* make sure 256 has a nonzero count */
12741274  /* Including the pseudo-symbol 256 in the Huffman procedure guarantees
12751275   * that no real symbol is given code-value of all ones, because 256
r14260r14261
13041304    /* Done if we've merged everything into one frequency */
13051305    if (c2 < 0)
13061306      break;
1307   
1307
13081308    /* Else merge the two counts/trees */
13091309    freq[c1] += freq[c2];
13101310    freq[c2] = 0;
r14260r14261
13151315      c1 = others[c1];
13161316      codesize[c1]++;
13171317    }
1318   
1318
13191319    others[c1] = c2;      /* chain c2 onto c1's tree branch */
1320   
1320
13211321    /* Increment the codesize of everything in c2's tree branch */
13221322    codesize[c2]++;
13231323    while (others[c2] >= 0) {
r14260r14261
13481348   * shortest nonzero BITS entry is converted into a prefix for two code words
13491349   * one bit longer.
13501350   */
1351 
1351
13521352  for (i = MAX_CLEN; i > 16; i--) {
13531353    while (bits[i] > 0) {
13541354      j = i - 2;      /* find length of new prefix to be used */
13551355      while (bits[j] == 0)
13561356   j--;
1357     
1357
13581358      bits[i] -= 2;      /* remove two symbols */
13591359      bits[i-1]++;      /* one goes in this length */
13601360      bits[j+1] += 2;      /* two new symbols in this length */
r14260r14261
13661366  while (bits[i] == 0)      /* find largest codelength still in use */
13671367    i--;
13681368  bits[i]--;
1369 
1369
13701370  /* Return final symbol counts (only for lengths 0..16) */
13711371  MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits));
1372 
1372
13731373  /* Return a list of the symbols sorted by code length */
13741374  /* It's not real clear to me why we don't need to consider the codelength
13751375   * changes made above, but the JPEG spec seems to think this works.
src/lib/libjpeg/jdhuff.c
r14260r14261
120120 * before using GET_BITS, PEEK_BITS, or DROP_BITS.
121121 * The variables get_buffer and bits_left are assumed to be locals,
122122 * but the state struct might not be (jpeg_huff_decode needs this).
123 *   CHECK_BIT_BUFFER(state,n,action);
124 *      Ensure there are N bits in get_buffer; if suspend, take action.
123 *  CHECK_BIT_BUFFER(state,n,action);
124 *      Ensure there are N bits in get_buffer; if suspend, take action.
125125 *      val = GET_BITS(n);
126 *      Fetch next N bits.
126 *      Fetch next N bits.
127127 *      val = PEEK_BITS(n);
128 *      Fetch next N bits without removing them from the buffer.
129 *   DROP_BITS(n);
130 *      Discard next N bits.
128 *      Fetch next N bits without removing them from the buffer.
129 *  DROP_BITS(n);
130 *      Discard next N bits.
131131 * The value N should be a simple variable, not an expression, because it
132132 * is evaluated multiple times.
133133 */
r14260r14261
350350              SIZEOF(d_derived_tbl));
351351  dtbl = *pdtbl;
352352  dtbl->pub = htbl;      /* fill in back link */
353 
353
354354  /* Figure C.1: make table of Huffman code length for each symbol */
355355 
356356  p = 0;
r14260r14261
363363  }
364364  huffsize[p] = 0;
365365  numsymbols = p;
366 
366
367367  /* Figure C.2: generate the codes themselves */
368368  /* We also validate that the counts represent a legal Huffman code tree. */
369 
369
370370  code = 0;
371371  si = huffsize[0];
372372  p = 0;
r14260r14261
493493      /* If it's 0xFF, check and discard stuffed zero byte */
494494      if (c == 0xFF) {
495495   /* Loop here to discard any padding FF's on terminating marker,
496    * so that we can save a valid unread_marker value.  NOTE: we will
497    * accept multiple FF's followed by a 0 as meaning a single FF data
498    * byte.  This data pattern is not valid according to the standard.
499    */
496     * so that we can save a valid unread_marker value.  NOTE: we will
497     * accept multiple FF's followed by a 0 as meaning a single FF data
498     * byte.  This data pattern is not valid according to the standard.
499     */
500500   do {
501501     if (bytes_in_buffer == 0) {
502502       if (! (*cinfo->src->fill_input_buffer) (cinfo))
r14260r14261
513513     c = 0xFF;
514514   } else {
515515     /* Oops, it's actually a marker indicating end of compressed data.
516      * Save the marker code for later use.
517      * Fine point: it might appear that we should save the marker into
518      * bitread working state, not straight into permanent state.  But
519      * once we have hit a marker, we cannot need to suspend within the
520      * current MCU, because we will read no more bytes from the data
521      * source.  So it is OK to update permanent state right away.
522      */
516       * Save the marker code for later use.
517       * Fine point: it might appear that we should save the marker into
518       * bitread working state, not straight into permanent state.  But
519       * once we have hit a marker, we cannot need to suspend within the
520       * current MCU, because we will read no more bytes from the data
521       * source.  So it is OK to update permanent state right away.
522       */
523523     cinfo->unread_marker = c;
524524     /* See if we need to insert some fake zero bits. */
525525     goto no_more_bytes;
r14260r14261
671671/*
672672 * Huffman MCU decoding.
673673 * Each of these routines decodes and returns one MCU's worth of
674 * Huffman-compressed coefficients.
674 * Huffman-compressed coefficients.
675675 * The coefficients are reordered from zigzag order into natural array order,
676676 * but are not dequantized.
677677 *
r14260r14261
693693 
694694METHODDEF(boolean)
695695decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
696{   
696{
697697  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
698698  int Al = cinfo->Al;
699699  register int s, r;
r14260r14261
764764 
765765METHODDEF(boolean)
766766decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
767{   
767{
768768  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
769769  register int s, k, r;
770770  unsigned int EOBRUN;
r14260r14261
853853 
854854METHODDEF(boolean)
855855decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
856{   
856{
857857  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
858858  int p1 = 1 << cinfo->Al;   /* 1 in the bit position being coded */
859859  int blkn;
r14260r14261
902902 
903903METHODDEF(boolean)
904904decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
905{   
905{
906906  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
907907  register int s, k, r;
908908  unsigned int EOBRUN;
r14260r14261
976976     /* note s = 0 for processing ZRL */
977977   }
978978   /* Advance over already-nonzero coefs and r still-zero coefs,
979    * appending correction bits to the nonzeroes.  A correction bit is 1
980    * if the absolute value of the coefficient must be increased.
981    */
979     * appending correction bits to the nonzeroes.  A correction bit is 1
980     * if the absolute value of the coefficient must be increased.
981     */
982982   do {
983983     thiscoef = *block + natural_order[k];
984984     if (*thiscoef != 0) {
r14260r14261
11271127       r = GET_BITS(s);
11281128       s = HUFF_EXTEND(r, s);
11291129       /* Output coefficient in natural (dezigzagged) order.
1130        * Note: the extra entries in natural_order[] will save us
1131        * if k > Se, which could happen if the data is corrupted.
1132        */
1130         * Note: the extra entries in natural_order[] will save us
1131         * if k > Se, which could happen if the data is corrupted.
1132         */
11331133       (*block)[natural_order[k]] = (JCOEF) s;
11341134     } else {
11351135       if (r != 15)
r14260r14261
12511251       r = GET_BITS(s);
12521252       s = HUFF_EXTEND(r, s);
12531253       /* Output coefficient in natural (dezigzagged) order.
1254        * Note: the extra entries in jpeg_natural_order[] will save us
1255        * if k >= DCTSIZE2, which could happen if the data is corrupted.
1256        */
1254         * Note: the extra entries in jpeg_natural_order[] will save us
1255         * if k >= DCTSIZE2, which could happen if the data is corrupted.
1256         */
12571257       (*block)[jpeg_natural_order[k]] = (JCOEF) s;
12581258     } else {
12591259       if (r != 15)
src/lib/libjpeg/jcmaster.c
r14260r14261
88 *
99 * This file contains master control logic for the JPEG compressor.
1010 * These routines are concerned with parameter validation, initial setup,
11 * and inter-pass control (determining the number of passes and the work
11 * and inter-pass control (determining the number of passes and the work
1212 * to be done in each pass).
1313 */
1414 
r14260r14261
381381#ifdef C_PROGRESSIVE_SUPPORTED
382382    cinfo->progressive_mode = TRUE;
383383    last_bitpos_ptr = & last_bitpos[0][0];
384    for (ci = 0; ci < cinfo->num_components; ci++)
384    for (ci = 0; ci < cinfo->num_components; ci++)
385385      for (coefi = 0; coefi < DCTSIZE2; coefi++)
386386   *last_bitpos_ptr++ = -1;
387387#else
r14260r14261
389389#endif
390390  } else {
391391    cinfo->progressive_mode = FALSE;
392    for (ci = 0; ci < cinfo->num_components; ci++)
392    for (ci = 0; ci < cinfo->num_components; ci++)
393393      component_sent[ci] = FALSE;
394394  }
395395 
r14260r14261
575575{
576576  int ci, mcublks, tmp;
577577  jpeg_component_info *compptr;
578 
578
579579  if (cinfo->comps_in_scan == 1) {
580   
580
581581    /* Noninterleaved (single-component) scan */
582582    compptr = cinfo->cur_comp_info[0];
583   
583
584584    /* Overall image size in MCUs */
585585    cinfo->MCUs_per_row = compptr->width_in_blocks;
586586    cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
587   
587
588588    /* For noninterleaved scan, always one block per MCU */
589589    compptr->MCU_width = 1;
590590    compptr->MCU_height = 1;
r14260r14261
597597    tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
598598    if (tmp == 0) tmp = compptr->v_samp_factor;
599599    compptr->last_row_height = tmp;
600   
600
601601    /* Prepare array describing MCU composition */
602602    cinfo->blocks_in_MCU = 1;
603603    cinfo->MCU_membership[0] = 0;
604   
604
605605  } else {
606   
606
607607    /* Interleaved (multi-component) scan */
608608    if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
609609      ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,
610610          MAX_COMPS_IN_SCAN);
611   
611
612612    /* Overall image size in MCUs */
613613    cinfo->MCUs_per_row = (JDIMENSION)
614614      jdiv_round_up((long) cinfo->jpeg_width,
r14260r14261
616616    cinfo->MCU_rows_in_scan = (JDIMENSION)
617617      jdiv_round_up((long) cinfo->jpeg_height,
618618          (long) (cinfo->max_v_samp_factor * cinfo->block_size));
619   
619
620620    cinfo->blocks_in_MCU = 0;
621   
621
622622    for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
623623      compptr = cinfo->cur_comp_info[ci];
624624      /* Sampling factors give # of blocks of component in each MCU */
r14260r14261
641641   cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
642642      }
643643    }
644   
644
645645  }
646646 
647647  /* Convert restart specified in rows to actual MCU count. */
src/lib/libjpeg/jdmaster.c
r14260r14261
191191 * processes are inner loops and need to be as fast as possible.  On most
192192 * machines, particularly CPUs with pipelines or instruction prefetch,
193193 * a (subscript-check-less) C table lookup
194 *      x = sample_range_limit[x];
194 *      x = sample_range_limit[x];
195195 * is faster than explicit tests
196 *      if (x < 0)  x = 0;
197 *      else if (x > MAXJSAMPLE)  x = MAXJSAMPLE;
196 *      if (x < 0)  x = 0;
197 *      else if (x > MAXJSAMPLE)  x = MAXJSAMPLE;
198198 * These processes all use a common table prepared by the routine below.
199199 *
200200 * For most steps we can mathematically guarantee that the initial value
201201 * of x is within MAXJSAMPLE+1 of the legal range, so a table running from
202202 * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient.  But for the initial
203 * limiting step (just after the IDCT), a wildly out-of-range value is
203 * limiting step (just after the IDCT), a wildly out-of-range value is
204204 * possible if the input data is corrupt.  To avoid any chance of indexing
205205 * off the end of memory and getting a bad-pointer trap, we perform the
206206 * post-IDCT limiting thus:
207 *      x = range_limit[x & MASK];
207 *      x = range_limit[x & MASK];
208208 * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit
209209 * samples.  Under normal circumstances this is more than enough range and
210210 * a correct output will be generated; with bogus input data the mask will
src/lib/libjpeg/jidctfst.c
r14260r14261
196196     * With typical images and quantization tables, half or more of the
197197     * column DCT calculations can be simplified this way.
198198     */
199   
199
200200    if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
201201   inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 &&
202202   inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 &&
r14260r14261
212212      wsptr[DCTSIZE*5] = dcval;
213213      wsptr[DCTSIZE*6] = dcval;
214214      wsptr[DCTSIZE*7] = dcval;
215     
215
216216      inptr++;         /* advance pointers to next column */
217217      quantptr++;
218218      wsptr++;
219219      continue;
220220    }
221   
221
222222    /* Even part */
223223 
224224    tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
r14260r14261
236236    tmp3 = tmp10 - tmp13;
237237    tmp1 = tmp11 + tmp12;
238238    tmp2 = tmp11 - tmp12;
239   
239
240240    /* Odd part */
241241 
242242    tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
r14260r14261
273273    quantptr++;
274274    wsptr++;
275275  }
276 
276
277277  /* Pass 2: process rows from work array, store into output array. */
278278  /* Note that we must descale the results by a factor of 8 == 2**3, */
279279  /* and also undo the PASS1_BITS scaling. */
r14260r14261
288288     * test takes more time than it's worth.  In that case this section
289289     * may be commented out.
290290     */
291   
291
292292#ifndef NO_ZERO_ROW_TEST
293293    if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 &&
294294   wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
295295      /* AC terms all zero */
296296      JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3)
297297              & RANGE_MASK];
298     
298
299299      outptr[0] = dcval;
300300      outptr[1] = dcval;
301301      outptr[2] = dcval;
r14260r14261
309309      continue;
310310    }
311311#endif
312   
312
313313    /* Even part */
314314 
315315    tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]);
src/lib/libjpeg/jcparam.c
r14260r14261
204204    { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 };
205205  static const UINT8 val_dc_luminance[] =
206206    { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
207 
207
208208  static const UINT8 bits_dc_chrominance[17] =
209209    { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };
210210  static const UINT8 val_dc_chrominance[] =
211211    { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
212 
212
213213  static const UINT8 bits_ac_luminance[17] =
214214    { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d };
215215  static const UINT8 val_ac_luminance[] =
r14260r14261
234234      0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
235235      0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
236236      0xf9, 0xfa };
237 
237
238238  static const UINT8 bits_ac_chrominance[17] =
239239    { /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 };
240240  static const UINT8 val_ac_chrominance[] =
r14260r14261
259259      0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
260260      0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
261261      0xf9, 0xfa };
262 
262
263263  add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[0],
264264       bits_dc_luminance, val_dc_luminance);
265265  add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[0],
src/lib/libjpeg/jquant1.c
r14260r14261
105105 * Errors are accumulated into the array fserrors[], at a resolution of
106106 * 1/16th of a pixel count.  The error at a given pixel is propagated
107107 * to its not-yet-processed neighbors using the standard F-S fractions,
108 *      ...   (here)   7/16
109 *      3/16   5/16   1/16
108 *      ... (here)  7/16
109 *      3/16    5/16    1/16
110110 * We work left-to-right on even rows, right-to-left on odd rows.
111111 *
112112 * We can get away with a single array (holding one row's worth of errors)
r14260r14261
424424 
425425/*
426426 * Create the ordered-dither tables.
427 * Components having the same number of representative colors may
427 * Components having the same number of representative colors may
428428 * share a dither table.
429429 */
430430 
r14260r14261
542542 
543543      for (col = width; col > 0; col--) {
544544   /* Form pixel value + dither, range-limit to 0..MAXJSAMPLE,
545    * select output value, accumulate into output code for this pixel.
546    * Range-limiting need not be done explicitly, as we have extended
547    * the colorindex table to produce the right answers for out-of-range
548    * inputs.  The maximum dither is +- MAXJSAMPLE; this sets the
549    * required amount of padding.
550    */
545     * select output value, accumulate into output code for this pixel.
546     * Range-limiting need not be done explicitly, as we have extended
547     * the colorindex table to produce the right answers for out-of-range
548     * inputs.  The maximum dither is +- MAXJSAMPLE; this sets the
549     * required amount of padding.
550     */
551551   *output_ptr += colorindex_ci[GETJSAMPLE(*input_ptr)+dither[col_index]];
552552   input_ptr += nc;
553553   output_ptr++;
r14260r14261
662662 
663663      for (col = width; col > 0; col--) {
664664   /* cur holds the error propagated from the previous pixel on the
665    * current line.  Add the error propagated from the previous line
666    * to form the complete error correction term for this pixel, and
667    * round the error term (which is expressed * 16) to an integer.
668    * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct
669    * for either sign of the error value.
670    * Note: errorptr points to *previous* column's array entry.
671    */
665     * current line.  Add the error propagated from the previous line
666     * to form the complete error correction term for this pixel, and
667     * round the error term (which is expressed * 16) to an integer.
668     * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct
669     * for either sign of the error value.
670     * Note: errorptr points to *previous* column's array entry.
671     */
672672   cur = RIGHT_SHIFT(cur + errorptr[dir] + 8, 4);
673673   /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE.
674    * The maximum error is +- MAXJSAMPLE; this sets the required size
675    * of the range_limit array.
676    */
674     * The maximum error is +- MAXJSAMPLE; this sets the required size
675     * of the range_limit array.
676     */
677677   cur += GETJSAMPLE(*input_ptr);
678678   cur = GETJSAMPLE(range_limit[cur]);
679679   /* Select output value, accumulate into output code for this pixel */
r14260r14261
684684   /* pixel code, because the colormap is orthogonal. */
685685   cur -= GETJSAMPLE(colormap_ci[pixcode]);
686686   /* Compute error fractions to be propagated to adjacent pixels.
687    * Add these into the running sums, and simultaneously shift the
688    * next-line error sums left by 1 column.
689    */
687     * Add these into the running sums, and simultaneously shift the
688     * next-line error sums left by 1 column.
689     */
690690   bnexterr = cur;
691691   delta = cur * 2;
692692   cur += delta;      /* form error * 3 */
r14260r14261
696696   belowerr = bnexterr;
697697   cur += delta;      /* form error * 7 */
698698   /* At this point cur contains the 7/16 error value to be propagated
699    * to the next pixel on the current line, and all the errors for the
700    * next line have been shifted over. We are therefore ready to move on.
701    */
699     * to the next pixel on the current line, and all the errors for the
700     * next line have been shifted over. We are therefore ready to move on.
701     */
702702   input_ptr += dirnc;   /* advance input ptr to next column */
703703   output_ptr += dir;   /* advance output ptr to next column */
704704   errorptr += dir;   /* advance errorptr to current column */
src/lib/libjpeg/jquant2.c
r14260r14261
4141 * color space, and repeatedly splits the "largest" remaining box until we
4242 * have as many boxes as desired colors.  Then the mean color in each
4343 * remaining box becomes one of the possible output colors.
44 *
44 *
4545 * The second pass over the image maps each input pixel to the closest output
4646 * color (optionally after applying a Floyd-Steinberg dithering correction).
4747 * This mapping is logically trivial, but making it go fast enough requires
r14260r14261
158158 * Errors are accumulated into the array fserrors[], at a resolution of
159159 * 1/16th of a pixel count.  The error at a given pixel is propagated
160160 * to its not-yet-processed neighbors using the standard F-S fractions,
161 *      ...   (here)   7/16
162 *      3/16   5/16   1/16
161 *      ... (here)  7/16
162 *      3/16    5/16    1/16
163163 * We work left-to-right on even rows, right-to-left on odd rows.
164164 *
165165 * We can get away with a single array (holding one row's worth of errors)
r14260r14261
278278  register int i;
279279  register long maxc = 0;
280280  boxptr which = NULL;
281 
281
282282  for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) {
283283    if (boxp->colorcount > maxc && boxp->volume > 0) {
284284      which = boxp;
r14260r14261
298298  register int i;
299299  register INT32 maxv = 0;
300300  boxptr which = NULL;
301 
301
302302  for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) {
303303    if (boxp->volume > maxv) {
304304      which = boxp;
r14260r14261
321321  int c0min,c0max,c1min,c1max,c2min,c2max;
322322  INT32 dist0,dist1,dist2;
323323  long ccount;
324 
324
325325  c0min = boxp->c0min;  c0max = boxp->c0max;
326326  c1min = boxp->c1min;  c1max = boxp->c1max;
327327  c2min = boxp->c2min;  c2max = boxp->c2max;
328 
328
329329  if (c0max > c0min)
330330    for (c0 = c0min; c0 <= c0max; c0++)
331331      for (c1 = c1min; c1 <= c1max; c1++) {
r14260r14261
405405  dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE;
406406  dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE;
407407  boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2;
408 
408
409409  /* Now scan remaining volume of box and compute population */
410410  ccount = 0;
411411  for (c0 = c0min; c0 <= c0max; c0++)
r14260r14261
511511  long c0total = 0;
512512  long c1total = 0;
513513  long c2total = 0;
514 
514
515515  c0min = boxp->c0min;  c0max = boxp->c0max;
516516  c1min = boxp->c1min;  c1max = boxp->c1max;
517517  c2min = boxp->c2min;  c2max = boxp->c2max;
518 
518
519519  for (c0 = c0min; c0 <= c0max; c0++)
520520    for (c1 = c1min; c1 <= c1max; c1++) {
521521      histp = & histogram[c0][c1][c2min];
r14260r14261
528528   }
529529      }
530530    }
531 
531
532532  cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total);
533533  cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total);
534534  cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total);
r14260r14261
797797  bptr = bestdist;
798798  for (i = BOX_C0_ELEMS*BOX_C1_ELEMS*BOX_C2_ELEMS-1; i >= 0; i--)
799799    *bptr++ = 0x7FFFFFFFL;
800 
800
801801  /* For each color selected by find_nearby_colors,
802802   * compute its distance to the center of each cell in the box.
803803   * If that's less than best-so-far, update best distance and color number.
804804   */
805 
805
806806  /* Nominal steps between cell centers ("x" in Thomas article) */
807807#define STEP_C0  ((1 << C0_SHIFT) * C0_SCALE)
808808#define STEP_C1  ((1 << C1_SHIFT) * C1_SCALE)
809809#define STEP_C2  ((1 << C2_SHIFT) * C2_SCALE)
810 
810
811811  for (i = 0; i < numcolors; i++) {
812812    icolor = GETJSAMPLE(colorlist[i]);
813813    /* Compute (square of) distance from minc0/c1/c2 to this color */
r14260r14261
881881  minc0 = (c0 << BOX_C0_SHIFT) + ((1 << C0_SHIFT) >> 1);
882882  minc1 = (c1 << BOX_C1_SHIFT) + ((1 << C1_SHIFT) >> 1);
883883  minc2 = (c2 << BOX_C2_SHIFT) + ((1 << C2_SHIFT) >> 1);
884 
884
885885  /* Determine which colormap entries are close enough to be candidates
886886   * for the nearest entry to some cell in the update box.
887887   */
src/lib/libjpeg/jcarith.c
r14260r14261
216216 */
217217 
218218LOCAL(void)
219arith_encode (j_compress_ptr cinfo, unsigned char *st, int val)
219arith_encode (j_compress_ptr cinfo, unsigned char *st, int val)
220220{
221221  register arith_entropy_ptr e = (arith_entropy_ptr) cinfo->entropy;
222222  register unsigned char nl, nm;
r14260r14261
278278   e->zc += e->sc;  /* carry-over converts stacked 0xFF bytes to 0x00 */
279279   e->sc = 0;
280280   /* Note: The 3 spacer bits in the C register guarantee
281    * that the new buffer byte can't be 0xFF here
282    * (see page 160 in the P&M JPEG book). */
281     * that the new buffer byte can't be 0xFF here
282     * (see page 160 in the P&M JPEG book). */
283283   e->buffer = temp & 0xFF;  /* new output byte, might overflow later */
284284      } else if (temp == 0xFF) {
285285   ++e->sc;  /* stack 0xFF byte (which might overflow later) */
src/lib/libjpeg/jdct.h
r14260r14261
88 * This include file contains common declarations for the forward and
99 * inverse DCT modules.  These declarations are private to the DCT managers
1010 * (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms.
11 * The individual DCT algorithms are kept in separate files to ease
11 * The individual DCT algorithms are kept in separate files to ease
1212 * machine-dependent tuning (e.g., assembly coding).
1313 */
1414 
src/lib/libjpeg/jccolor.c
r14260r14261
3131 * YCbCr is defined per CCIR 601-1, except that Cb and Cr are
3232 * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
3333 * The conversion equations to be implemented are therefore
34 *   Y  =  0.29900 * R + 0.58700 * G + 0.11400 * B
35 *   Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B  + CENTERJSAMPLE
36 *   Cr =  0.50000 * R - 0.41869 * G - 0.08131 * B  + CENTERJSAMPLE
34 *  Y  =  0.29900 * R + 0.58700 * G + 0.11400 * B
35 *  Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B  + CENTERJSAMPLE
36 *  Cr =  0.50000 * R - 0.41869 * G - 0.08131 * B  + CENTERJSAMPLE
3737 * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)
3838 * Note: older versions of the IJG code used a zero offset of MAXJSAMPLE/2,
3939 * rather than CENTERJSAMPLE, for Cb and Cr.  This gave equal positive and
src/lib/libjpeg/jmemmgr.c
r14260r14261
238238 * machines, but may be too small if longs are 64 bits or more.
239239 */
240240 
241static const size_t first_pool_slop[JPOOL_NUMPOOLS] =
241static const size_t first_pool_slop[JPOOL_NUMPOOLS] =
242242{
243243   1600,         /* first PERMANENT pool */
244244   16000         /* first IMAGE pool */
245245};
246246 
247static const size_t extra_pool_slop[JPOOL_NUMPOOLS] =
247static const size_t extra_pool_slop[JPOOL_NUMPOOLS] =
248248{
249249   0,         /* additional PERMANENT pools */
250250   5000         /* additional IMAGE pools */
src/lib/libjpeg/jcmarker.c
r14260r14261
1919  M_SOF1  = 0xc1,
2020  M_SOF2  = 0xc2,
2121  M_SOF3  = 0xc3,
22 
22
2323  M_SOF5  = 0xc5,
2424  M_SOF6  = 0xc6,
2525  M_SOF7  = 0xc7,
26 
26
2727  M_JPG   = 0xc8,
2828  M_SOF9  = 0xc9,
2929  M_SOF10 = 0xca,
3030  M_SOF11 = 0xcb,
31 
31
3232  M_SOF13 = 0xcd,
3333  M_SOF14 = 0xce,
3434  M_SOF15 = 0xcf,
35 
35
3636  M_DHT   = 0xc4,
37 
37
3838  M_DAC   = 0xcc,
39 
39
4040  M_RST0  = 0xd0,
4141  M_RST1  = 0xd1,
4242  M_RST2  = 0xd2,
r14260r14261
4545  M_RST5  = 0xd5,
4646  M_RST6  = 0xd6,
4747  M_RST7  = 0xd7,
48 
48
4949  M_SOI   = 0xd8,
5050  M_EOI   = 0xd9,
5151  M_SOS   = 0xda,
r14260r14261
5454  M_DRI   = 0xdd,
5555  M_DHP   = 0xde,
5656  M_EXP   = 0xdf,
57 
57
5858  M_APP0  = 0xe0,
5959  M_APP1  = 0xe1,
6060  M_APP2  = 0xe2,
r14260r14261
7171  M_APP13 = 0xed,
7272  M_APP14 = 0xee,
7373  M_APP15 = 0xef,
74 
74
7575  M_JPG0  = 0xf0,
7676  M_JPG13 = 0xfd,
7777  M_COM   = 0xfe,
78 
78
7979  M_TEM   = 0x01,
80 
80
8181  M_ERROR = 0x100
8282} JPEG_MARKER;
8383 
r14260r14261
188188{
189189  JHUFF_TBL * htbl;
190190  int length, i;
191 
191
192192  if (is_ac) {
193193    htbl = cinfo->ac_huff_tbl_ptrs[index];
194194    index += 0x10;      /* output index has AC bit set */
r14260r14261
198198 
199199  if (htbl == NULL)
200200    ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index);
201 
201
202202  if (! htbl->sent_table) {
203203    emit_marker(cinfo, M_DHT);
204   
204
205205    length = 0;
206206    for (i = 1; i <= 16; i++)
207207      length += htbl->bits[i];
208   
208
209209    emit_2bytes(cinfo, length + 2 + 1 + 16);
210210    emit_byte(cinfo, index);
211   
211
212212    for (i = 1; i <= 16; i++)
213213      emit_byte(cinfo, htbl->bits[i]);
214   
214
215215    for (i = 0; i < length; i++)
216216      emit_byte(cinfo, htbl->huffval[i]);
217   
217
218218    htbl->sent_table = TRUE;
219219  }
220220}
r14260r14261
274274/* Emit a DRI marker */
275275{
276276  emit_marker(cinfo, M_DRI);
277 
277
278278  emit_2bytes(cinfo, 4);   /* fixed length */
279279 
280280  emit_2bytes(cinfo, (int) cinfo->restart_interval);
r14260r14261
287287{
288288  int ci;
289289  jpeg_component_info *compptr;
290 
290
291291  emit_marker(cinfo, code);
292 
292
293293  emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */
294294 
295295  /* Make sure image isn't bigger than SOF field can handle */
r14260r14261
318318{
319319  int i, td, ta;
320320  jpeg_component_info *compptr;
321 
321
322322  emit_marker(cinfo, M_SOS);
323 
323
324324  emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */
325 
325
326326  emit_byte(cinfo, cinfo->comps_in_scan);
327 
327
328328  for (i = 0; i < cinfo->comps_in_scan; i++) {
329329    compptr = cinfo->cur_comp_info[i];
330330    emit_byte(cinfo, compptr->component_id);
r14260r14261
352352/* Emit a pseudo SOS marker */
353353{
354354  emit_marker(cinfo, M_SOS);
355 
355
356356  emit_2bytes(cinfo, 2 + 1 + 3); /* length */
357 
357
358358  emit_byte(cinfo, 0); /* Ns */
359359 
360360  emit_byte(cinfo, 0); /* Ss */
r14260r14261
368368/* Emit a JFIF-compliant APP0 marker */
369369{
370370  /*
371   * Length of APP0 block   (2 bytes)
372   * Block ID         (4 bytes - ASCII "JFIF")
373   * Zero byte         (1 byte to terminate the ID string)
374   * Version Major, Minor   (2 bytes - major first)
375   * Units         (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm)
376   * Xdpu         (2 bytes - dots per unit horizontal)
377   * Ydpu         (2 bytes - dots per unit vertical)
378   * Thumbnail X size      (1 byte)
379   * Thumbnail Y size      (1 byte)
371   * Length of APP0 block   (2 bytes)
372   * Block ID           (4 bytes - ASCII "JFIF")
373   * Zero byte          (1 byte to terminate the ID string)
374   * Version Major, Minor   (2 bytes - major first)
375   * Units          (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm)
376   * Xdpu           (2 bytes - dots per unit horizontal)
377   * Ydpu           (2 bytes - dots per unit vertical)
378   * Thumbnail X size       (1 byte)
379   * Thumbnail Y size       (1 byte)
380380   */
381 
381
382382  emit_marker(cinfo, M_APP0);
383 
383
384384  emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */
385385 
386386  emit_byte(cinfo, 0x4A);   /* Identifier: ASCII "JFIF" */
r14260r14261
403403/* Emit an Adobe APP14 marker */
404404{
405405  /*
406   * Length of APP14 block   (2 bytes)
407   * Block ID         (5 bytes - ASCII "Adobe")
408   * Version Number      (2 bytes - currently 100)
409   * Flags0         (2 bytes - currently 0)
410   * Flags1         (2 bytes - currently 0)
411   * Color transform      (1 byte)
406   * Length of APP14 block  (2 bytes)
407   * Block ID           (5 bytes - ASCII "Adobe")
408   * Version Number     (2 bytes - currently 100)
409   * Flags0         (2 bytes - currently 0)
410   * Flags1         (2 bytes - currently 0)
411   * Color transform        (1 byte)
412412   *
413413   * Although Adobe TN 5116 mentions Version = 101, all the Adobe files
414414   * now in circulation seem to use Version = 100, so that's what we write.
r14260r14261
417417   * YCbCr, 2 if it's YCCK, 0 otherwise.  Adobe's definition has to do with
418418   * whether the encoder performed a transformation, which is pretty useless.
419419   */
420 
420
421421  emit_marker(cinfo, M_APP14);
422 
422
423423  emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */
424424 
425425  emit_byte(cinfo, 0x41);   /* Identifier: ASCII "Adobe" */
r14260r14261
514514  int ci, prec;
515515  boolean is_baseline;
516516  jpeg_component_info *compptr;
517 
517
518518  /* Emit DQT for each quantization table.
519519   * Note that emit_dqt() suppresses any duplicate tables.
520520   */
src/lib/libjpeg/jdsample.c
r14260r14261
119119  /* Not more than the distance to the end of the image.  Need this test
120120   * in case the image height is not a multiple of max_v_samp_factor:
121121   */
122  if (num_rows > upsample->rows_to_go)
122  if (num_rows > upsample->rows_to_go)
123123    num_rows = upsample->rows_to_go;
124124  /* And not more than what the client can accept: */
125125  out_rows_avail -= *out_row_ctr;
src/lib/libjpeg/jdmarker.c
r14260r14261
2323  M_SOF1  = 0xc1,
2424  M_SOF2  = 0xc2,
2525  M_SOF3  = 0xc3,
26 
26
2727  M_SOF5  = 0xc5,
2828  M_SOF6  = 0xc6,
2929  M_SOF7  = 0xc7,
30 
30
3131  M_JPG   = 0xc8,
3232  M_SOF9  = 0xc9,
3333  M_SOF10 = 0xca,
3434  M_SOF11 = 0xcb,
35 
35
3636  M_SOF13 = 0xcd,
3737  M_SOF14 = 0xce,
3838  M_SOF15 = 0xcf,
39 
39
4040  M_DHT   = 0xc4,
41 
41
4242  M_DAC   = 0xcc,
43 
43
4444  M_RST0  = 0xd0,
4545  M_RST1  = 0xd1,
4646  M_RST2  = 0xd2,
r14260r14261
4949  M_RST5  = 0xd5,
5050  M_RST6  = 0xd6,
5151  M_RST7  = 0xd7,
52 
52
5353  M_SOI   = 0xd8,
5454  M_EOI   = 0xd9,
5555  M_SOS   = 0xda,
r14260r14261
5858  M_DRI   = 0xdd,
5959  M_DHP   = 0xde,
6060  M_EXP   = 0xdf,
61 
61
6262  M_APP0  = 0xe0,
6363  M_APP1  = 0xe1,
6464  M_APP2  = 0xe2,
r14260r14261
7575  M_APP13 = 0xed,
7676  M_APP14 = 0xee,
7777  M_APP15 = 0xef,
78 
78
7979  M_JPG0  = 0xf0,
8080  M_JPG13 = 0xfd,
8181  M_COM   = 0xfe,
82 
82
8383  M_TEM   = 0x01,
84 
84
8585  M_ERROR = 0x100
8686} JPEG_MARKER;
8787 
r14260r14261
199199/* Process an SOI marker */
200200{
201201  int i;
202 
202
203203  TRACEMS(cinfo, 1, JTRC_SOI);
204204 
205205  if (cinfo->marker->saw_SOI)
r14260r14261
278278    cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small)
279279         ((j_common_ptr) cinfo, JPOOL_IMAGE,
280280          cinfo->num_components * SIZEOF(jpeg_component_info));
281 
281
282282  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
283283       ci++, compptr++) {
284284    compptr->component_index = ci;
r14260r14261
330330  for (i = 0; i < n; i++) {
331331    INPUT_BYTE(cinfo, cc, return FALSE);
332332    INPUT_BYTE(cinfo, c, return FALSE);
333   
333
334334    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
335335    ci++, compptr++) {
336336      if (cc == compptr->component_id)
r14260r14261
344344    cinfo->cur_comp_info[i] = compptr;
345345    compptr->dc_tbl_no = (c >> 4) & 15;
346346    compptr->ac_tbl_no = (c     ) & 15;
347   
347
348348    TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc,
349349        compptr->dc_tbl_no, compptr->ac_tbl_no);
350350  }
r14260r14261
384384 
385385  INPUT_2BYTES(cinfo, length, return FALSE);
386386  length -= 2;
387 
387
388388  while (length > 0) {
389389    INPUT_BYTE(cinfo, index, return FALSE);
390390    INPUT_BYTE(cinfo, val, return FALSE);
r14260r14261
433433 
434434  INPUT_2BYTES(cinfo, length, return FALSE);
435435  length -= 2;
436 
436
437437  while (length > 16) {
438438    INPUT_BYTE(cinfo, index, return FALSE);
439439 
440440    TRACEMS1(cinfo, 1, JTRC_DHT, index);
441     
441
442442    bits[0] = 0;
443443    count = 0;
444444    for (i = 1; i <= 16; i++) {
r14260r14261
478478 
479479    if (*htblptr == NULL)
480480      *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
481 
481
482482    MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits));
483483    MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval));
484484  }
r14260r14261
515515 
516516    if (n >= NUM_QUANT_TBLS)
517517      ERREXIT1(cinfo, JERR_DQT_INDEX, n);
518     
518
519519    if (cinfo->quant_tbl_ptrs[n] == NULL)
520520      cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo);
521521    quant_ptr = cinfo->quant_tbl_ptrs[n];
r14260r14261
590590  INPUT_VARS(cinfo);
591591 
592592  INPUT_2BYTES(cinfo, length, return FALSE);
593 
593
594594  if (length != 4)
595595    ERREXIT(cinfo, JERR_BAD_LENGTH);
596596 
r14260r14261
887887 
888888  INPUT_2BYTES(cinfo, length, return FALSE);
889889  length -= 2;
890 
890
891891  TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length);
892892 
893893  INPUT_SYNC(cinfo);      /* do before skip_input_data */
r14260r14261
10591059   return JPEG_SUSPENDED;
10601060      cinfo->unread_marker = 0;   /* processed the marker */
10611061      return JPEG_REACHED_SOS;
1062   
1062
10631063    case M_EOI:
10641064      TRACEMS(cinfo, 1, JTRC_EOI);
10651065      cinfo->unread_marker = 0;   /* processed the marker */
10661066      return JPEG_REACHED_EOI;
1067     
1067
10681068    case M_DAC:
10691069      if (! get_dac(cinfo))
10701070   return JPEG_SUSPENDED;
10711071      break;
1072     
1072
10731073    case M_DHT:
10741074      if (! get_dht(cinfo))
10751075   return JPEG_SUSPENDED;
10761076      break;
1077     
1077
10781078    case M_DQT:
10791079      if (! get_dqt(cinfo))
10801080   return JPEG_SUSPENDED;
10811081      break;
1082     
1082
10831083    case M_DRI:
10841084      if (! get_dri(cinfo))
10851085   return JPEG_SUSPENDED;
10861086      break;
1087     
1087
10881088    case M_APP0:
10891089    case M_APP1:
10901090    case M_APP2:
r14260r14261
11051105      cinfo->unread_marker - (int) M_APP0]) (cinfo))
11061106   return JPEG_SUSPENDED;
11071107      break;
1108     
1108
11091109    case M_COM:
11101110      if (! (*((my_marker_ptr) cinfo->marker)->process_COM) (cinfo))
11111111   return JPEG_SUSPENDED;
r14260r14261
12391239{
12401240  int marker = cinfo->unread_marker;
12411241  int action = 1;
1242 
1242
12431243  /* Always put up a warning. */
12441244  WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired);
1245 
1245
12461246  /* Outer loop handles repeated decision after scanning forward. */
12471247  for (;;) {
12481248    if (marker < (int) M_SOF0)
src/lib/libjpeg/jidctflt.c
r14260r14261
9595     * With typical images and quantization tables, half or more of the
9696     * column DCT calculations can be simplified this way.
9797     */
98   
98
9999    if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
100100   inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 &&
101101   inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 &&
102102   inptr[DCTSIZE*7] == 0) {
103103      /* AC terms all zero */
104104      FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
105     
105
106106      wsptr[DCTSIZE*0] = dcval;
107107      wsptr[DCTSIZE*1] = dcval;
108108      wsptr[DCTSIZE*2] = dcval;
r14260r14261
111111      wsptr[DCTSIZE*5] = dcval;
112112      wsptr[DCTSIZE*6] = dcval;
113113      wsptr[DCTSIZE*7] = dcval;
114     
114
115115      inptr++;         /* advance pointers to next column */
116116      quantptr++;
117117      wsptr++;
118118      continue;
119119    }
120   
120
121121    /* Even part */
122122 
123123    tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
r14260r14261
135135    tmp3 = tmp10 - tmp13;
136136    tmp1 = tmp11 + tmp12;
137137    tmp2 = tmp11 - tmp12;
138   
138
139139    /* Odd part */
140140 
141141    tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
r14260r14261
172172    quantptr++;
173173    wsptr++;
174174  }
175 
175
176176  /* Pass 2: process rows from work array, store into output array. */
177177 
178178  wsptr = workspace;
r14260r14261
183183     * the simplification applies less often (typically 5% to 10% of the time).
184184     * And testing floats for zero is relatively expensive, so we don't bother.
185185     */
186   
186
187187    /* Even part */
188188 
189189    /* Apply signed->unsigned and prepare float->int conversion */
r14260r14261
227227    outptr[5] = range_limit[((int) (tmp2 - tmp5)) & RANGE_MASK];
228228    outptr[3] = range_limit[((int) (tmp3 + tmp4)) & RANGE_MASK];
229229    outptr[4] = range_limit[((int) (tmp3 - tmp4)) & RANGE_MASK];
230   
230
231231    wsptr += DCTSIZE;      /* advance pointer to next row */
232232  }
233233}
src/lib/libjpeg/jctrans.c
r14260r14261
315315       xindex = 0;
316316     }
317317     /* Fill in any dummy blocks needed in this row.
318      * Dummy blocks are filled in the same way as in jccoefct.c:
319      * all zeroes in the AC entries, DC entries equal to previous
320      * block's DC value.  The init routine has already zeroed the
321      * AC entries, so we need only set the DC entries correctly.
322      */
318       * Dummy blocks are filled in the same way as in jccoefct.c:
319       * all zeroes in the AC entries, DC entries equal to previous
320       * block's DC value.  The init routine has already zeroed the
321       * AC entries, so we need only set the DC entries correctly.
322       */
323323     for (; xindex < compptr->MCU_width; xindex++) {
324324       MCU_buffer[blkn] = coef->dummy_buffer[blkn];
325325       MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0];
src/lib/libjpeg/jidctint.c
r14260r14261
225225 
226226    /* Even part: reverse the even part of the forward DCT. */
227227    /* The rotator is sqrt(2)*c(-6). */
228   
228
229229    z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
230230    z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
231231 
r14260r14261
256256    tmp1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
257257    tmp2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
258258    tmp3 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
259   
259
260260    z2 = tmp0 + tmp2;
261261    z3 = tmp1 + tmp3;
262262 
r14260r14261
288288    wsptr[DCTSIZE*5] = (int) RIGHT_SHIFT(tmp12 - tmp1, CONST_BITS-PASS1_BITS);
289289    wsptr[DCTSIZE*3] = (int) RIGHT_SHIFT(tmp13 + tmp0, CONST_BITS-PASS1_BITS);
290290    wsptr[DCTSIZE*4] = (int) RIGHT_SHIFT(tmp13 - tmp0, CONST_BITS-PASS1_BITS);
291   
291
292292    inptr++;         /* advance pointers to next column */
293293    quantptr++;
294294    wsptr++;
r14260r14261
332332 
333333    /* Even part: reverse the even part of the forward DCT. */
334334    /* The rotator is sqrt(2)*c(-6). */
335   
335
336336    z2 = (INT32) wsptr[2];
337337    z3 = (INT32) wsptr[6];
338338 
r14260r14261
346346 
347347    tmp0 = (z2 + z3) << CONST_BITS;
348348    tmp1 = (z2 - z3) << CONST_BITS;
349   
349
350350    tmp10 = tmp0 + tmp2;
351351    tmp13 = tmp0 - tmp2;
352352    tmp11 = tmp1 + tmp3;
r14260r14261
835835 
836836    tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
837837    tmp2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
838   
838
839839    tmp10 = (tmp0 + tmp2) << PASS1_BITS;
840840    tmp12 = (tmp0 - tmp2) << PASS1_BITS;
841841 
r14260r14261
28512851     * With typical images and quantization tables, half or more of the
28522852     * column DCT calculations can be simplified this way.
28532853     */
2854   
2854
28552855    if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
28562856   inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 &&
28572857   inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 &&
28582858   inptr[DCTSIZE*7] == 0) {
28592859      /* AC terms all zero */
28602860      int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS;
2861     
2861
28622862      wsptr[DCTSIZE*0] = dcval;
28632863      wsptr[DCTSIZE*1] = dcval;
28642864      wsptr[DCTSIZE*2] = dcval;
r14260r14261
28672867      wsptr[DCTSIZE*5] = dcval;
28682868      wsptr[DCTSIZE*6] = dcval;
28692869      wsptr[DCTSIZE*7] = dcval;
2870     
2870
28712871      inptr++;         /* advance pointers to next column */
28722872      quantptr++;
28732873      wsptr++;
28742874      continue;
28752875    }
2876   
2876
28772877    /* Even part: reverse the even part of the forward DCT. */
28782878    /* The rotator is sqrt(2)*c(-6). */
2879   
2879
28802880    z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
28812881    z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
2882   
2882
28832883    z1 = MULTIPLY(z2 + z3, FIX_0_541196100);
28842884    tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865);
28852885    tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065);
2886   
2886
28872887    z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
28882888    z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);
28892889    z2 <<= CONST_BITS;
r14260r14261
28932893 
28942894    tmp0 = z2 + z3;
28952895    tmp1 = z2 - z3;
2896   
2896
28972897    tmp10 = tmp0 + tmp2;
28982898    tmp13 = tmp0 - tmp2;
28992899    tmp11 = tmp1 + tmp3;
29002900    tmp12 = tmp1 - tmp3;
2901   
2901
29022902    /* Odd part per figure 8; the matrix is unitary and hence its
29032903     * transpose is its inverse.  i0..i3 are y7,y5,y3,y1 respectively.
29042904     */
2905   
2905
29062906    tmp0 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
29072907    tmp1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
29082908    tmp2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
29092909    tmp3 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
2910   
2910
29112911    z2 = tmp0 + tmp2;
29122912    z3 = tmp1 + tmp3;
29132913 
r14260r14261
29282928    tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
29292929    tmp1 += z1 + z3;
29302930    tmp2 += z1 + z2;
2931   
2931
29322932    /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
2933   
2933
29342934    wsptr[DCTSIZE*0] = (int) RIGHT_SHIFT(tmp10 + tmp3, CONST_BITS-PASS1_BITS);
29352935    wsptr[DCTSIZE*7] = (int) RIGHT_SHIFT(tmp10 - tmp3, CONST_BITS-PASS1_BITS);
29362936    wsptr[DCTSIZE*1] = (int) RIGHT_SHIFT(tmp11 + tmp2, CONST_BITS-PASS1_BITS);
r14260r14261
29392939    wsptr[DCTSIZE*5] = (int) RIGHT_SHIFT(tmp12 - tmp1, CONST_BITS-PASS1_BITS);
29402940    wsptr[DCTSIZE*3] = (int) RIGHT_SHIFT(tmp13 + tmp0, CONST_BITS-PASS1_BITS);
29412941    wsptr[DCTSIZE*4] = (int) RIGHT_SHIFT(tmp13 - tmp0, CONST_BITS-PASS1_BITS);
2942   
2942
29432943    inptr++;         /* advance pointers to next column */
29442944    quantptr++;
29452945    wsptr++;
r14260r14261
36883688 
36893689    z2 = (INT32) wsptr[2];
36903690    z3 = (INT32) wsptr[6];
3691   
3691
36923692    z1 = MULTIPLY(z2 + z3, FIX_0_541196100);
36933693    tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865);
36943694    tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065);
3695   
3695
36963696    /* Add fudge factor here for final descale. */
36973697    z2 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
36983698    z3 = (INT32) wsptr[4];
3699   
3699
37003700    tmp0 = (z2 + z3) << CONST_BITS;
37013701    tmp1 = (z2 - z3) << CONST_BITS;
3702   
3702
37033703    tmp10 = tmp0 + tmp2;
37043704    tmp13 = tmp0 - tmp2;
37053705    tmp11 = tmp1 + tmp3;
r14260r14261
38193819    wsptr[6*2] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS);
38203820    wsptr[6*1] = (int) RIGHT_SHIFT(tmp2, CONST_BITS-PASS1_BITS);
38213821  }
3822 
3822
38233823  /* Pass 2: process 3 rows from work array, store into output array.
38243824   * 6-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/12).
38253825   */
r14260r14261
41344134    wsptr[8*7]  = (int) RIGHT_SHIFT(tmp27 + tmp13, CONST_BITS-PASS1_BITS);
41354135    wsptr[8*8]  = (int) RIGHT_SHIFT(tmp27 - tmp13, CONST_BITS-PASS1_BITS);
41364136  }
4137 
4137
41384138  /* Pass 2: process rows from work array, store into output array. */
41394139  /* Note that we must descale the results by a factor of 8 == 2**3, */
41404140  /* and also undo the PASS1_BITS scaling. */
r14260r14261
41424142  wsptr = workspace;
41434143  for (ctr = 0; ctr < 16; ctr++) {
41444144    outptr = output_buf[ctr] + output_col;
4145   
4145
41464146    /* Even part: reverse the even part of the forward DCT. */
41474147    /* The rotator is sqrt(2)*c(-6). */
4148   
4148
41494149    z2 = (INT32) wsptr[2];
41504150    z3 = (INT32) wsptr[6];
4151   
4151
41524152    z1 = MULTIPLY(z2 + z3, FIX_0_541196100);
41534153    tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865);
41544154    tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065);
4155   
4155
41564156    /* Add fudge factor here for final descale. */
41574157    z2 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
41584158    z3 = (INT32) wsptr[4];
4159   
4159
41604160    tmp0 = (z2 + z3) << CONST_BITS;
41614161    tmp1 = (z2 - z3) << CONST_BITS;
4162   
4162
41634163    tmp10 = tmp0 + tmp2;
41644164    tmp13 = tmp0 - tmp2;
41654165    tmp11 = tmp1 + tmp3;
41664166    tmp12 = tmp1 - tmp3;
4167   
4167
41684168    /* Odd part per figure 8; the matrix is unitary and hence its
41694169     * transpose is its inverse.  i0..i3 are y7,y5,y3,y1 respectively.
41704170     */
4171   
4171
41724172    tmp0 = (INT32) wsptr[7];
41734173    tmp1 = (INT32) wsptr[5];
41744174    tmp2 = (INT32) wsptr[3];
41754175    tmp3 = (INT32) wsptr[1];
4176   
4176
41774177    z2 = tmp0 + tmp2;
41784178    z3 = tmp1 + tmp3;
41794179 
r14260r14261
41944194    tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
41954195    tmp1 += z1 + z3;
41964196    tmp2 += z1 + z2;
4197   
4197
41984198    /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
4199   
4199
42004200    outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp3,
42014201                     CONST_BITS+PASS1_BITS+3)
42024202             & RANGE_MASK];
r14260r14261
42214221    outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp13 - tmp0,
42224222                     CONST_BITS+PASS1_BITS+3)
42234223             & RANGE_MASK];
4224   
4224
42254225    wsptr += DCTSIZE;      /* advance pointer to next row */
42264226  }
42274227}
r14260r14261
47944794 
47954795    z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
47964796    z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
4797   
4797
47984798    z1 = MULTIPLY(z2 + z3, FIX_0_541196100);
47994799    tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865);
48004800    tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065);
4801   
4801
48024802    z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
48034803    z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);
48044804    z2 <<= CONST_BITS;
r14260r14261
48084808 
48094809    tmp0 = z2 + z3;
48104810    tmp1 = z2 - z3;
4811   
4811
48124812    tmp10 = tmp0 + tmp2;
48134813    tmp13 = tmp0 - tmp2;
48144814    tmp11 = tmp1 + tmp3;
r14260r14261
49004900    outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp2,
49014901                     CONST_BITS+PASS1_BITS+3)
49024902             & RANGE_MASK];
4903   
4903
49044904    wsptr += 4;      /* advance pointer to next row */
49054905  }
49064906}
r14260r14261
51165116  quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
51175117 
51185118  /* Even part */
5119   
5119
51205120  tmp10 = DEQUANTIZE(coef_block[DCTSIZE*0], quantptr[DCTSIZE*0]);
51215121  /* Add fudge factor here for final descale. */
51225122  tmp10 += ONE << 2;
src/lib/libjpeg/jpegtran.c
r14260r14261
378378  jvirt_barray_ptr * dst_coef_arrays;
379379  int file_index;
380380  /* We assume all-in-memory processing and can therefore use only a
381   * single file pointer for sequential input and output operation.
381   * single file pointer for sequential input and output operation.
382382   */
383383  FILE * fp;
384384 
src/lib/libjpeg/jdinput.c
r14260r14261
391391{
392392  int ci, mcublks, tmp;
393393  jpeg_component_info *compptr;
394 
394
395395  if (cinfo->comps_in_scan == 1) {
396   
396
397397    /* Noninterleaved (single-component) scan */
398398    compptr = cinfo->cur_comp_info[0];
399   
399
400400    /* Overall image size in MCUs */
401401    cinfo->MCUs_per_row = compptr->width_in_blocks;
402402    cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
403   
403
404404    /* For noninterleaved scan, always one block per MCU */
405405    compptr->MCU_width = 1;
406406    compptr->MCU_height = 1;
r14260r14261
413413    tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
414414    if (tmp == 0) tmp = compptr->v_samp_factor;
415415    compptr->last_row_height = tmp;
416   
416
417417    /* Prepare array describing MCU composition */
418418    cinfo->blocks_in_MCU = 1;
419419    cinfo->MCU_membership[0] = 0;
420   
420
421421  } else {
422   
422
423423    /* Interleaved (multi-component) scan */
424424    if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
425425      ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,
426426          MAX_COMPS_IN_SCAN);
427   
427
428428    /* Overall image size in MCUs */
429429    cinfo->MCUs_per_row = (JDIMENSION)
430430      jdiv_round_up((long) cinfo->image_width,
r14260r14261
432432    cinfo->MCU_rows_in_scan = (JDIMENSION)
433433      jdiv_round_up((long) cinfo->image_height,
434434          (long) (cinfo->max_v_samp_factor * cinfo->block_size));
435   
435
436436    cinfo->blocks_in_MCU = 0;
437   
437
438438    for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
439439      compptr = cinfo->cur_comp_info[ci];
440440      /* Sampling factors give # of blocks of component in each MCU */
r14260r14261
457457   cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
458458      }
459459    }
460   
460
461461  }
462462}
463463 
r14260r14261
578578   }
579579   inputctl->inheaders = 0;
580580   /* Note: start_input_pass must be called by jdmaster.c
581    * before any more input can be consumed.  jdapimin.c is
582    * responsible for enforcing this sequencing.
583    */
581     * before any more input can be consumed.  jdapimin.c is
582     * responsible for enforcing this sequencing.
583     */
584584      } else {         /* 2nd or later SOS marker */
585585   if (! inputctl->pub.has_multiple_scans)
586586     ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */
r14260r14261
596596     ERREXIT(cinfo, JERR_SOF_NO_SOS);
597597      } else {
598598   /* Prevent infinite loop in coef ctlr's decompress_data routine
599    * if user set output_scan_number larger than number of scans.
600    */
599     * if user set output_scan_number larger than number of scans.
600     */
601601   if (cinfo->output_scan_number > cinfo->input_scan_number)
602602     cinfo->output_scan_number = cinfo->input_scan_number;
603603      }
src/lib/libjpeg/jdmerge.c
r14260r14261
1414 * (ie, box filtering), we can save some work in color conversion by
1515 * calculating all the output pixels corresponding to a pair of chroma
1616 * samples at one time.  In the conversion equations
17 *   R = Y           + K1 * Cr
18 *   G = Y + K2 * Cb + K3 * Cr
19 *   B = Y + K4 * Cb
17 *  R = Y           + K1 * Cr
18 *  G = Y + K2 * Cb + K3 * Cr
19 *  B = Y + K4 * Cb
2020 * only the Y term varies among the group of pixels corresponding to a pair
2121 * of chroma samples, so the rest of the terms can be calculated just once.
2222 * At typical sampling ratios, this eliminates half or three-quarters of the
2323 * multiplications needed for color conversion.
2424 *
2525 * This file currently provides implementations for the following cases:
26 *   YCbCr => RGB color conversion only.
27 *   Sampling ratios of 2h1v or 2h2v.
28 *   No scaling needed at upsample time.
29 *   Corner-aligned (non-CCIR601) sampling alignment.
26 *  YCbCr => RGB color conversion only.
27 *  Sampling ratios of 2h1v or 2h2v.
28 *  No scaling needed at upsample time.
29 *  Corner-aligned (non-CCIR601) sampling alignment.
3030 * Other special cases could be added, but in most applications these are
3131 * the only common cases.  (For uncommon cases we fall back on the more
3232 * general code in jdsample.c and jdcolor.c.)
src/lib/libjpeg/jdcoefct.c
r14260r14261
568568     DC9 = (int) next_block_row[1][0];
569569   }
570570   /* Compute coefficient estimates per K.8.
571    * An estimate is applied only if coefficient is still zero,
572    * and is not known to be fully accurate.
573    */
571     * An estimate is applied only if coefficient is still zero,
572     * and is not known to be fully accurate.
573     */
574574   /* AC01 */
575575   if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) {
576576     num = 36 * Q00 * (DC4 - DC6);
src/lib/libjpeg/jpeglib.h
r14260r14261
137137  /* The decompressor output side may not use these variables. */
138138  int dc_tbl_no;      /* DC entropy table selector (0..3) */
139139  int ac_tbl_no;      /* AC entropy table selector (0..3) */
140 
140
141141  /* Remaining fields should be treated as private by applications. */
142 
142
143143  /* These values are computed during compression or decompression startup: */
144144  /* Component's size in DCT blocks.
145145   * Any dummy blocks added to complete an MCU are not counted; therefore
r14260r14261
369369  UINT16 X_density;      /* Horizontal pixel density */
370370  UINT16 Y_density;      /* Vertical pixel density */
371371  boolean write_Adobe_marker;   /* should an Adobe marker be written? */
372 
372
373373  /* State variable: index of next scanline to be written to
374374   * jpeg_write_scanlines().  Application may use this to control its
375375   * processing loop, e.g., "while (next_scanline < image_height)".
r14260r14261
397397   * There are v_samp_factor * DCTSIZE sample rows of each component in an
398398   * "iMCU" (interleaved MCU) row.
399399   */
400 
400
401401  /*
402402   * These fields are valid during any one scan.
403403   * They describe the components and MCUs actually appearing in the scan.
r14260r14261
405405  int comps_in_scan;      /* # of JPEG components in this scan */
406406  jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
407407  /* *cur_comp_info[i] describes component that appears i'th in SOS */
408 
408
409409  JDIMENSION MCUs_per_row;   /* # of MCUs across the image */
410410  JDIMENSION MCU_rows_in_scan;   /* # of MCU rows in the image */
411 
411
412412  int blocks_in_MCU;      /* # of DCT blocks per MCU */
413413  int MCU_membership[C_MAX_BLOCKS_IN_MCU];
414414  /* MCU_membership[i] is index in cur_comp_info of component owning */
r14260r14261
691691#define JMSG_LENGTH_MAX  200   /* recommended size of format_message buffer */
692692  /* Reset error state variables at start of a new image */
693693  JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo));
694 
694
695695  /* The message ID code and any parameters are saved here.
696696   * A message can have one string parameter or up to 8 int parameters.
697697   */
r14260r14261
701701    int i[8];
702702    char s[JMSG_STR_PARM_MAX];
703703  } msg_parm;
704 
704
705705  /* Standard state variables for error facility */
706 
706
707707  int trace_level;      /* max msg_level that will be displayed */
708 
708
709709  /* For recoverable corrupt-data errors, we emit a warning message,
710710   * but keep going unless emit_message chooses to abort.  emit_message
711711   * should count warnings in num_warnings.  The surrounding application
r14260r14261
863863/* Short forms of external names for systems with brain-damaged linkers.
864864 * We shorten external names to be unique in the first six letters, which
865865 * is good enough for all known systems.
866 * (If your compiler itself needs names to be unique in less than 15
866 * (If your compiler itself needs names to be unique in less than 15
867867 * characters, you are out of luck.  Get a better compiler.)
868868 */
869869 
r14260r14261
10491049EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo));
10501050EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo));
10511051/* Return value is one of: */
1052/* #define JPEG_SUSPENDED   0    Suspended due to lack of input data */
1052/* #define JPEG_SUSPENDED   0    Suspended due to lack of input data */
10531053#define JPEG_REACHED_SOS   1 /* Reached start of new scan */
10541054#define JPEG_REACHED_EOI   2 /* Reached end of image */
10551055#define JPEG_ROW_COMPLETED   3 /* Completed one iMCU row */
src/lib/libjpeg/jdarith.c
r14260r14261
125125       data = 0xFF;   /* discard stuffed zero byte */
126126     else {
127127       /* Note: Different from the Huffman decoder, hitting
128        * a marker while processing the compressed data
129        * segment is legal in arithmetic coding.
130        * The convention is to supply zero data
131        * then until decoding is complete.
132        */
128         * a marker while processing the compressed data
129         * segment is legal in arithmetic coding.
130         * The convention is to supply zero data
131         * then until decoding is complete.
132         */
133133       cinfo->unread_marker = data;
134134       data = 0;
135135     }
r14260r14261
765765      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
766766              cinfo->num_components*DCTSIZE2*SIZEOF(int));
767767    coef_bit_ptr = & cinfo->coef_bits[0][0];
768    for (ci = 0; ci < cinfo->num_components; ci++)
768    for (ci = 0; ci < cinfo->num_components; ci++)
769769      for (i = 0; i < DCTSIZE2; i++)
770770   *coef_bit_ptr++ = -1;
771771  }
src/lib/libjpeg/jcmainct.c
r14260r14261
208208    if (main->pass_mode != JBUF_SAVE_SOURCE) {
209209      if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) {
210210   /* If compressor did not consume the whole row, then we must need to
211    * suspend processing and return to the application.  In this situation
212    * we pretend we didn't yet consume the last input row; otherwise, if
213    * it happened to be the last row of the image, the application would
214    * think we were done.
215    */
211     * suspend processing and return to the application.  In this situation
212     * we pretend we didn't yet consume the last input row; otherwise, if
213     * it happened to be the last row of the image, the application would
214     * think we were done.
215     */
216216   if (! main->suspended) {
217217     (*in_row_ctr)--;
218218     main->suspended = TRUE;
src/lib/libjpeg/jcapimin.c
r14260r14261
3737  if (version != JPEG_LIB_VERSION)
3838    ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
3939  if (structsize != SIZEOF(struct jpeg_compress_struct))
40    ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
40    ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
4141        (int) SIZEOF(struct jpeg_compress_struct), (int) structsize);
4242 
4343  /* For debugging purposes, we zero the whole master structure.
r14260r14261
244244 * To produce a pair of files containing abbreviated tables and abbreviated
245245 * image data, one would proceed as follows:
246246 *
247 *      initialize JPEG object
248 *      set JPEG parameters
249 *      set destination to table file
250 *      jpeg_write_tables(cinfo);
251 *      set destination to image file
252 *      jpeg_start_compress(cinfo, FALSE);
253 *      write data...
254 *      jpeg_finish_compress(cinfo);
247 *      initialize JPEG object
248 *      set JPEG parameters
249 *      set destination to table file
250 *      jpeg_write_tables(cinfo);
251 *      set destination to image file
252 *      jpeg_start_compress(cinfo, FALSE);
253 *      write data...
254 *      jpeg_finish_compress(cinfo);
255255 *
256256 * jpeg_write_tables has the side effect of marking all tables written
257257 * (same as jpeg_suppress_tables(..., TRUE)).  Thus a subsequent start_compress
src/lib/libjpeg/jdapimin.c
r14260r14261
3737  if (version != JPEG_LIB_VERSION)
3838    ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
3939  if (structsize != SIZEOF(struct jpeg_decompress_struct))
40    ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
40    ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
4141        (int) SIZEOF(struct jpeg_decompress_struct), (int) structsize);
4242 
4343  /* For debugging purposes, we zero the whole master structure.
r14260r14261
122122    cinfo->jpeg_color_space = JCS_GRAYSCALE;
123123    cinfo->out_color_space = JCS_GRAYSCALE;
124124    break;
125   
125
126126  case 3:
127127    if (cinfo->saw_JFIF_marker) {
128128      cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */
r14260r14261
157157    /* Always guess RGB is proper output colorspace. */
158158    cinfo->out_color_space = JCS_RGB;
159159    break;
160   
160
161161  case 4:
162162    if (cinfo->saw_Adobe_marker) {
163163      switch (cinfo->Adobe_transform) {
r14260r14261
178178    }
179179    cinfo->out_color_space = JCS_CMYK;
180180    break;
181   
181
182182  default:
183183    cinfo->jpeg_color_space = JCS_UNKNOWN;
184184    cinfo->out_color_space = JCS_UNKNOWN;
src/lib/libjpeg/jdcolor.c
r14260r14261
3434 * YCbCr is defined per CCIR 601-1, except that Cb and Cr are
3535 * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
3636 * The conversion equations to be implemented are therefore
37 *   R = Y                + 1.40200 * Cr
38 *   G = Y - 0.34414 * Cb - 0.71414 * Cr
39 *   B = Y + 1.77200 * Cb
37 *  R = Y                + 1.40200 * Cr
38 *  G = Y - 0.34414 * Cb - 0.71414 * Cr
39 *  B = Y + 1.77200 * Cb
4040 * where Cb and Cr represent the incoming values less CENTERJSAMPLE.
4141 * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)
4242 *
src/lib/libjpeg/jcdctmgr.c
r14260r14261
9090   qval = divisors[i];
9191   temp = workspace[i];
9292   /* Divide the coefficient value by qval, ensuring proper rounding.
93    * Since C does not specify the direction of rounding for negative
94    * quotients, we have to force the dividend positive for portability.
95    *
96    * In most files, at least half of the output values will be zero
97    * (at default quantization settings, more like three-quarters...)
98    * so we should ensure that this case is fast.  On many machines,
99    * a comparison is enough cheaper than a divide to make a special test
100    * a win.  Since both inputs will be nonnegative, we need only test
101    * for a < b to discover whether a/b is 0.
102    * If your machine's division is fast enough, define FAST_DIVIDE.
103    */
93     * Since C does not specify the direction of rounding for negative
94     * quotients, we have to force the dividend positive for portability.
95     *
96     * In most files, at least half of the output values will be zero
97     * (at default quantization settings, more like three-quarters...)
98     * so we should ensure that this case is fast.  On many machines,
99     * a comparison is enough cheaper than a divide to make a special test
100     * a win.  Since both inputs will be nonnegative, we need only test
101     * for a < b to discover whether a/b is 0.
102     * If your machine's division is fast enough, define FAST_DIVIDE.
103     */
104104#ifdef FAST_DIVIDE
105105#define DIVIDE_BY(a,b)   a /= b
106106#else
r14260r14261
153153   /* Apply the quantization and scaling factor */
154154   temp = workspace[i] * divisors[i];
155155   /* Round to nearest integer.
156    * Since C does not specify the direction of rounding for negative
157    * quotients, we have to force the dividend positive for portability.
158    * The maximum coefficient size is +-16K (for 12-bit data), so this
159    * code should work for either 16-bit or 32-bit ints.
160    */
156     * Since C does not specify the direction of rounding for negative
157     * quotients, we have to force the dividend positive for portability.
158     * The maximum coefficient size is +-16K (for 12-bit data), so this
159     * code should work for either 16-bit or 32-bit ints.
160     */
161161   output_ptr[i] = (JCOEF) ((int) (temp + (FAST_FLOAT) 16384.5) - 16384);
162162      }
163163    }
r14260r14261
376376    case JDCT_IFAST:
377377      {
378378   /* For AA&N IDCT method, divisors are equal to quantization
379    * coefficients scaled by scalefactor[row]*scalefactor[col], where
380    *   scalefactor[0] = 1
381    *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
382    * We apply a further scale factor of 8.
383    */
379     * coefficients scaled by scalefactor[row]*scalefactor[col], where
380     *   scalefactor[0] = 1
381     *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
382     * We apply a further scale factor of 8.
383     */
384384#define CONST_BITS 14
385385   static const INT16 aanscales[DCTSIZE2] = {
386386     /* precomputed values scaled up by 14 bits */
r14260r14261
415415    case JDCT_FLOAT:
416416      {
417417   /* For float AA&N IDCT method, divisors are equal to quantization
418    * coefficients scaled by scalefactor[row]*scalefactor[col], where
419    *   scalefactor[0] = 1
420    *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
421    * We apply a further scale factor of 8.
422    * What's actually stored is 1/divisor so that the inner loop can
423    * use a multiplication rather than a division.
424    */
418     * coefficients scaled by scalefactor[row]*scalefactor[col], where
419     *   scalefactor[0] = 1
420     *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
421     * We apply a further scale factor of 8.
422     * What's actually stored is 1/divisor so that the inner loop can
423     * use a multiplication rather than a division.
424     */
425425   FAST_FLOAT * fdtbl;
426426   int row, col;
427427   static const double aanscalefactor[DCTSIZE] = {
src/lib/lib.mak
r14260r14261
274274#-------------------------------------------------
275275
276276FLACOPTS=-DFLAC__NO_ASM -DHAVE_INTTYPES_H -DHAVE_ICONV -DHAVE_LANGINFO_CODESET -DHAVE_SOCKLEN_T -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
277
277
278278LIBFLACOBJS = \
279279   $(LIBOBJ)/libflac/bitmath.o \
280280   $(LIBOBJ)/libflac/bitreader.o \
src/lib/util/chd.c
r14260r14261
21422142               offset++;
21432143            }
21442144            for (secoff=0;secoff<CD_MAX_SUBCODE_DATA;secoff++)
2145            {     
2145            {
21462146               if (src[offset]!=0x00)
21472147                  is_likely_cd = false;
21482148
r14260r14261
21712171         tempbytes = bytes;
21722172         temperror = err;
21732173         tempstrategy = 0;
2174      }       
2174      }
21752175
21762176      /* try strategy 1 - flac */
21772177      if (chd->codecintf->secondary_compress != NULL)
21782178      {
21792179         strategy = 1;
2180         
2180
21812181         err = (*chd->codecintf->secondary_compress)(chd, src, &bytes);
21822182
21832183         /* check against previous compression attempt if that was successful */
r14260r14261
22172217   {
22182218      data = chd->compressed;
22192219      newentry.length = bytes;
2220     
2220
22212221      if (strategy == 0)
22222222      {
22232223         newentry.flags = MAP_ENTRY_TYPE_COMPRESSED;
r14260r14261
30853085      printf("ERROR: allocating encoder\n");
30863086      return CHDERR_COMPRESSION_ERROR;
30873087   }
3088   
3088
30893089   ok &= FLAC__stream_encoder_set_verify(encoder, false); // we trust libFLAC ;-)
30903090   ok &= FLAC__stream_encoder_set_compression_level(encoder, 8);
30913091   ok &= FLAC__stream_encoder_set_channels(encoder, 2);
r14260r14261
30943094   ok &= FLAC__stream_encoder_set_total_samples_estimate(encoder, 0);
30953095   ok &= FLAC__stream_encoder_set_streamable_subset(encoder, false);
30963096   ok &= FLAC__stream_encoder_set_blocksize(encoder, ((CD_MAX_SECTOR_DATA)*CD_FRAMES_PER_HUNK) );
3097   
3097
30983098   if (!ok)
30993099   {
31003100      printf("error setting up stream encoder\n");
r14260r14261
31213121            if (!swap) flac_encoder_client_ptr->pcm[i] = (FLAC__int32)(((FLAC__int16)(FLAC__int8)flac_encoder_client_ptr->tempbuffer[2*i] << 8) | (FLAC__int16)flac_encoder_client_ptr->tempbuffer[2*i+1]);
31223122            else       flac_encoder_client_ptr->pcm[i] = (FLAC__int32)(((FLAC__int16)(FLAC__int8)flac_encoder_client_ptr->tempbuffer[2*i+1] << 8) | (FLAC__int16)flac_encoder_client_ptr->tempbuffer[2*i]);
31233123         }
3124     
3124
31253125         ok = FLAC__stream_encoder_process_interleaved(encoder, flac_encoder_client_ptr->pcm, FLAC_ENCODER_READSIZE);
31263126      }
31273127
r14260r14261
31423142      printf("error finishing!\n");
31433143      return CHDERR_COMPRESSION_ERROR;
31443144   }
3145   
3145
31463146   int totalout = flac_encoder_client_ptr->flac_output_buffer_total-FLAC_HEADER_SIZE;
31473147
3148   
31493148
3149
31503150   FLAC__stream_encoder_delete(encoder);
31513151
31523152   if (totalout >= chd->header.hunkbytes)
r14260r14261
31973197   UINT64 amount_to_decode;
31983198};
31993199
3200FLAC__StreamDecoderWriteStatus flac_decoder_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *const buffer[], void *client_data)
3200FLAC__StreamDecoderWriteStatus flac_decoder_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *const buffer[], void *client_data)
32013201{
3202   
3202
32033203   int blocksize = frame->header.blocksize;
32043204   int i = 0;
32053205   while (blocksize && ((flac_decoder_data*)client_data)->amount_to_decode)
r14260r14261
32123212      ((flac_decoder_data*)client_data)->amount_to_decode-=4;
32133213      ((flac_decoder_data*)client_data)->writeoffset++;
32143214   }
3215   
3215
32163216   return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
32173217}
32183218
r14260r14261
32373237
32383238
32393239
3240void flac_decoder_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
3240void flac_decoder_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
32413241{
32423242
32433243}
32443244
3245void flac_decoder_error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
3245void flac_decoder_error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
32463246{
32473247
32483248}
r14260r14261
32593259   flac_decoder_client_ptr->readbuffer = (UINT8*)malloc(flac_decoder_client_ptr->readbuffersize);
32603260   flac_decoder_client_ptr->amount_to_decode =  (CD_MAX_SECTOR_DATA*CD_FRAMES_PER_HUNK);
32613261   int frames_to_decode = flac_decoder_client_ptr->amount_to_decode / CD_MAX_SECTOR_DATA;
3262           
3262
32633263   flac_decoder_client_ptr->writeoffset = 0;
32643264
32653265   memcpy(flac_decoder_client_ptr->readbuffer, flacHeader, FLAC_HEADER_SIZE);
r14260r14261
32743274   if(FLAC__stream_decoder_init_stream(
32753275      decoder,
32763276      flac_decoder_read_callback,
3277      NULL,
32783277      NULL,
32793278      NULL,
32803279      NULL,
3280      NULL,
32813281      flac_decoder_write_callback,
32823282      flac_decoder_metadata_callback,
32833283      flac_decoder_error_callback,
r14260r14261
33003300      return CHDERR_READ_ERROR;
33013301   }
33023302
3303   
3303
33043304   int srcoffset = 0;
33053305   UINT8* dest2 = (UINT8*)dest;
33063306   for (int frame = 0; frame<frames_to_decode;frame++)
33073307   {
33083308      int destoffset = frame * (CD_FRAME_SIZE);
3309               
33103309
3310
33113311      int index;
33123312
33133313      for (index = 0; index < 2352; index += 2 )
33143314      {
33153315         dest2[ destoffset + index +1 ] = flac_decoder_client_ptr->tempbuffer[srcoffset] & 0xff;
33163316         dest2[ destoffset + index ] = flac_decoder_client_ptr->tempbuffer[srcoffset] >> 8;
3317               
3317
33183318         srcoffset++;
33193319      }
33203320   }
3321   
33223321
3322
33233323   if (FLAC__stream_decoder_finish (decoder) != true)
33243324   {
33253325      printf("unable to finish FLAC decoder\n");
src/lib/util/cdrom.h
r14260r14261
5656#define CD_MAX_SUBCODE_DATA      (96)
5757
5858#define CD_FRAME_SIZE         (CD_MAX_SECTOR_DATA + CD_MAX_SUBCODE_DATA)
59#define CD_FRAMES_PER_HUNK      (8)
59#define CD_FRAMES_PER_HUNK      (4) // should be 8 for v5 CDs, with a 4-frame pad at the end to maintain SHA1 compatibility
6060
6161#define CD_METADATA_WORDS      (1+(CD_MAX_TRACKS * 6))
6262
src/lib/util/tagmap.h
r14260r14261
7878   class entry_t
7979   {
8080      friend class tagmap_t<_ElementType, _HashSize>;
81     
81
8282   public:
8383      // construction/destruction
8484      entry_t(const char *tag, UINT32 fullhash, _ElementType object)
r14260r14261
8686           m_fullhash(fullhash),
8787           m_tag(tag),
8888           m_object(object) { }
89   
89
9090      // accessors
9191      const astring &tag() const { return m_tag; }
9292      _ElementType object() const { return m_object; }
93     
93
9494      // setters
9595      void set_object(_ElementType object) { m_object = object; }
9696
r14260r14261
151151
152152   // find by tag
153153   _ElementType find(const char *tag) const { return find(tag, hash(tag)); }
154   
154
155155   // find by tag with precomputed hash
156156   _ElementType find(const char *tag, UINT32 fullhash) const
157157   {
r14260r14261
170170            return entry->object();
171171      return NULL;
172172   }
173   
173
174174   // return first object in the table
175175   entry_t *first() const { return next(NULL); }
176   
176
177177   // return next object in the table
178178   entry_t *next(entry_t *after) const
179179   {
r14260r14261
186186      for (UINT32 hashindex = firstindex; hashindex < ARRAY_LENGTH(m_table); hashindex++)
187187         if (m_table[hashindex] != NULL)
188188            return m_table[hashindex];
189     
189
190190      // all out
191191      return NULL;
192192   }
r14260r14261
194194private:
195195   // internal helpers
196196   tagmap_error add_common(const char *tag, _ElementType object, bool replace_if_duplicate, bool unique_hash);
197   
197
198198   // remove an entry given a pointer to its pointer
199199   void remove_common(entry_t **entryptr)
200200   {
r14260r14261
214214//**************************************************************************
215215
216216//-------------------------------------------------
217//  add_common - core implementation of a tagmap
217//  add_common - core implementation of a tagmap
218218//  addition
219219//-------------------------------------------------
220220
src/version.c
r14260r14261
3838***************************************************************************/
3939
4040extern const char build_version[];
41const char build_version[] = "0.144u6 ("__DATE__")";
41const char build_version[] = "0.144u7 ("__DATE__")";

Previous 15994 Revisions Next


© 1998-2018 The MESS Team