Skip to content

Commit fbb446e

Browse files
committed
Fix up some stuff:
* formats/cassimg.cpp: Put allocation outside loop again, check more allocations for failure. * pc8801_flop.xml: Actually mark clones as clones, transliterate title for S.F.3.D. * apple/macadb.cpp: Tidy a little.
1 parent 802bce3 commit fbb446e

File tree

4 files changed

+43
-39
lines changed

4 files changed

+43
-39
lines changed

hash/pc8801_flop.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29122,7 +29122,7 @@ Start and Program Disks OK, the remaining part is damaged (missing d88 headers?)
2912229122
</software>
2912329123

2912429124
<software name="sf3dthxg">
29125-
<description>S.F.3.D - Original Operation Thanksgiving</description>
29125+
<description>Point X Senryō Sakusen S.F.3.D - Original Operation Thanksgiving</description>
2912629126
<year>1986</year>
2912729127
<publisher>クロスメディアソフト (Cross Media Soft)</publisher>
2912829128
<!-- PC8801 -->
@@ -29135,8 +29135,8 @@ Start and Program Disks OK, the remaining part is damaged (missing d88 headers?)
2913529135
</part>
2913629136
</software>
2913729137

29138-
<software name="sf3dthxga">
29139-
<description>S.F.3.D - Original Operation Thanksgiving (alt)</description>
29138+
<software name="sf3dthxga" cloneof="sf3dthxg">
29139+
<description>Point X Senryō Sakusen S.F.3.D - Original Operation Thanksgiving (alt)</description>
2914029140
<year>1986</year>
2914129141
<publisher>クロスメディアソフト (Cross Media Soft)</publisher>
2914229142
<!-- PC8801 -->

src/lib/formats/cassimg.cpp

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,8 @@ cassette_image::error cassette_image::legacy_construct(const LegacyWaveFiller *l
791791
error err;
792792
int length;
793793
int sample_count;
794-
std::vector<int16_t> samples;
794+
std::unique_ptr<int16_t []> samples;
795+
std::unique_ptr<uint8_t []> chunk;
795796
int pos = 0;
796797
uint64_t offset = 0;
797798

@@ -814,15 +815,21 @@ cassette_image::error cassette_image::legacy_construct(const LegacyWaveFiller *l
814815
/* determine number of samples */
815816
if (args.chunk_sample_calc != nullptr)
816817
{
817-
if (size > 0x7FFFFFFF)
818+
if (size > 0x7fffffff)
818819
{
819820
err = error::OUT_OF_MEMORY;
820821
goto done;
821822
}
822823

823-
std::vector<uint8_t> bytes(size);
824-
image_read(&bytes[0], 0, size);
825-
sample_count = args.chunk_sample_calc(&bytes[0], (int)size);
824+
std::unique_ptr<uint8_t []> bytes(new (std::nothrow) uint8_t [size]);
825+
if (!bytes)
826+
{
827+
err = error::OUT_OF_MEMORY;
828+
goto done;
829+
}
830+
831+
image_read(bytes.get(), 0, size);
832+
sample_count = args.chunk_sample_calc(bytes.get(), (int)size);
826833

827834
// chunk_sample_calc functions report errors by returning negative numbers
828835
if (sample_count < 0)
@@ -842,7 +849,12 @@ cassette_image::error cassette_image::legacy_construct(const LegacyWaveFiller *l
842849
sample_count += args.header_samples + args.trailer_samples;
843850

844851
/* allocate a buffer for the completed samples */
845-
samples.resize(sample_count);
852+
samples.reset(new (std::nothrow) int16_t [sample_count]);
853+
if (!samples)
854+
{
855+
err = error::OUT_OF_MEMORY;
856+
goto done;
857+
}
846858

847859
/* if there has to be a header */
848860
if (args.header_samples > 0)
@@ -857,11 +869,15 @@ cassette_image::error cassette_image::legacy_construct(const LegacyWaveFiller *l
857869
}
858870

859871
/* convert the file data to samples */
872+
chunk.reset(new (std::nothrow) uint8_t [args.chunk_size]);
873+
if (!chunk)
874+
{
875+
err = error::OUT_OF_MEMORY;
876+
goto done;
877+
}
860878
while ((pos < sample_count) && (offset < size))
861879
{
862-
/* allocate a buffer for the binary data */
863-
std::vector<uint8_t> chunk(args.chunk_size);
864-
image_read(&chunk[0], offset, args.chunk_size);
880+
image_read(chunk.get(), offset, args.chunk_size);
865881
offset += args.chunk_size;
866882

867883
/*
@@ -871,10 +887,10 @@ cassette_image::error cassette_image::legacy_construct(const LegacyWaveFiller *l
871887
without knowing how much data available in the image. Having wrong header with size bigger than image couses illegal
872888
access beyond image data.
873889
Desired state is:
874-
length = args.fill_wave(&samples[pos], args.chunk_size, &chunk[0]);
890+
length = args.fill_wave(&samples[pos], args.chunk_size, chunk.get());
875891
aslo the fix for tap is commented out in 'tap_cas_fill_wave'
876892
*/
877-
length = args.fill_wave(&samples[pos], sample_count - pos, &chunk[0]);
893+
length = args.fill_wave(&samples[pos], sample_count - pos, chunk.get());
878894
if (length < 0)
879895
{
880896
err = error::INVALID_IMAGE;
@@ -884,6 +900,7 @@ cassette_image::error cassette_image::legacy_construct(const LegacyWaveFiller *l
884900
if (length == 0)
885901
break;
886902
}
903+
chunk.reset();
887904

888905
/* if there has to be a trailer */
889906
if (args.trailer_samples > 0)

src/mame/alesis/midiverb.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// copyright-holders:m1macrophage
33

44
/*
5-
The Midiverb is a digital delay & reverb unit.
5+
The MIDIverb is a digital delay & reverb unit.
66
77
The computer portion of the device is very simple. The firmware runs on a
88
80C31 microcontroller. It reads the 4 buttons, drives the two 7-segment
@@ -17,7 +17,7 @@ silence program is also enabled temporarily when switching between effects.
1717
Finally, there is a wet/dry control knob. For more information on the audio
1818
hardware, see midiverb_state::configure_audio().
1919
20-
An interesting aspect of the Midiverb is its DSP, which is built out of discrete
20+
An interesting aspect of the MIDIverb is its DSP, which is built out of discrete
2121
logic components and runs custom microcode. Each microcode instruction consists
2222
of a 2-bit opcode and 14-bit RAM delta offset. The effects program makes up the
2323
top 6 bits of the microcode ROM address, and the DSP just loops over the 128
@@ -653,4 +653,3 @@ ROM_END
653653
} // anonymous namespace
654654

655655
SYST(1986, midiverb, 0, 0, midiverb, midiverb, midiverb_state, empty_init, "Alesis", "MIDIverb", MACHINE_SUPPORTS_SAVE)
656-

src/mame/apple/macadb.cpp

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -476,27 +476,19 @@ void macadb_device::portable_update_keyboard()
476476

477477
bool macadb_device::adb_pollmouse()
478478
{
479-
s32 NewX, NewY, NewButton;
479+
s32 const NewButton = m_mouse0->read() & 0x03;
480+
s32 const NewX = m_mouse1->read();
481+
s32 const NewY = m_mouse2->read();
480482

481-
NewButton = m_mouse0->read() & 0x03;
482-
NewX = m_mouse1->read();
483-
NewY = m_mouse2->read();
484-
485-
if ((NewX != m_lastmousex) || (NewY != m_lastmousey) || (NewButton != m_lastbutton))
486-
{
487-
return true;
488-
}
489-
490-
return false;
483+
return (NewX != m_lastmousex) || (NewY != m_lastmousey) || (NewButton != m_lastbutton);
491484
}
492485

493486
void macadb_device::adb_accummouse(u8 *MouseX, u8 *MouseY )
494487
{
495488
int MouseCountX = 0, MouseCountY = 0;
496-
int NewX, NewY;
497489

498-
NewX = m_mouse1->read();
499-
NewY = m_mouse2->read();
490+
int const NewX = m_mouse1->read();
491+
int const NewY = m_mouse2->read();
500492

501493
// printf("pollmouse: X %d Y %d\n", NewX, NewY);
502494

@@ -538,10 +530,8 @@ void macadb_device::adb_accummouse(u8 *MouseX, u8 *MouseY )
538530

539531
void macadb_device::adb_talk()
540532
{
541-
int addr, reg;
542-
543-
addr = (m_command>>4);
544-
reg = (m_command & 3);
533+
int const addr = m_command >> 4;
534+
int const reg = m_command & 3;
545535

546536
// printf("Mac sent %x (cmd %d addr %d reg %d mr %d kr %d)\n", m_command, (m_command>>2)&3, addr, reg, m_mouseaddr, m_keybaddr);
547537

@@ -612,10 +602,8 @@ void macadb_device::adb_talk()
612602
this->adb_accummouse(&mouseX, &mouseY);
613603
}
614604
//printf("X %x Y %x\n", mouseX, mouseY);
615-
m_buffer[0] = (m_lastbutton & 0x01) ? 0x00 : 0x80;
616-
m_buffer[0] |= mouseY & 0x7f;
617-
m_buffer[1] = (m_lastbutton & 0x02) ? 0x00 : 0x80;
618-
m_buffer[1] |= mouseX & 0x7f;
605+
m_buffer[0] = (BIT(~m_lastbutton, 0) << 7) | (mouseY & 0x7f);
606+
m_buffer[1] = (BIT(~m_lastbutton, 1) << 7) | (mouseX & 0x7f);
619607

620608
if ((m_buffer[0] != m_last_mouse[0]) || (m_buffer[1] != m_last_mouse[1]))
621609
{

0 commit comments

Comments
 (0)