summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/drivers/instruct.c
diff options
context:
space:
mode:
author Oliver Stöneberg <firewave@users.noreply.github.com>2014-03-29 12:36:11 +0000
committer Oliver Stöneberg <firewave@users.noreply.github.com>2014-03-29 12:36:11 +0000
commit06ab983049ea4f2bfd3192a3223199b7d7f8e550 (patch)
tree83efb0f77494d3579c0275716be7f2e886f2f50b /src/mess/drivers/instruct.c
parentd6a32473f465f9f009e0bd7b7f76ce885787c3f8 (diff)
converted some more global_alloc_array() usage to dynamic_array/dynamic_buffer (nw)
Diffstat (limited to 'src/mess/drivers/instruct.c')
-rw-r--r--src/mess/drivers/instruct.c104
1 files changed, 47 insertions, 57 deletions
diff --git a/src/mess/drivers/instruct.c b/src/mess/drivers/instruct.c
index c4102308d99..20ec1feae02 100644
--- a/src/mess/drivers/instruct.c
+++ b/src/mess/drivers/instruct.c
@@ -339,73 +339,63 @@ QUICKLOAD_LOAD_MEMBER( instruct_state, instruct )
}
else
{
- UINT8* quick_data = global_alloc_array(UINT8, quick_length);
- if (!quick_data)
+ dynamic_buffer quick_data(quick_length);
+ read_ = image.fread( quick_data, quick_length);
+ if (read_ != quick_length)
{
- image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file");
- image.message(" Cannot open file");
+ image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file");
+ image.message(" Cannot read the file");
+ }
+ else if (quick_data[0] != 0xc5)
+ {
+ image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header");
+ image.message(" Invalid header");
}
else
{
- read_ = image.fread( quick_data, quick_length);
- if (read_ != quick_length)
- {
- image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file");
- image.message(" Cannot read the file");
- }
- else if (quick_data[0] != 0xc5)
+ exec_addr = quick_data[1] * 256 + quick_data[2];
+
+ if (exec_addr >= quick_length)
{
- image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header");
- image.message(" Invalid header");
+ image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file");
+ image.message(" Exec address beyond end of file");
}
else
{
- exec_addr = quick_data[1] * 256 + quick_data[2];
-
- if (exec_addr >= quick_length)
- {
- image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file");
- image.message(" Exec address beyond end of file");
- }
- else
- {
- // load to 0000-0FFE (standard ram + extra)
- read_ = 0xfff;
- if (quick_length < 0xfff)
- read_ = quick_length;
- m_p_ram[0] = 0x1f; // add jump for RST key
- for (i = 1; i < read_; i++)
- m_p_ram[i] = quick_data[i];
-
- // load to 1780-17BF (spare ram inside 2656)
- read_ = 0x17c0;
- if (quick_length < 0x17c0)
- read_ = quick_length;
- if (quick_length > 0x1780)
- for (i = 0x1780; i < read_; i++)
- m_p_smiram[i-0x1780] = quick_data[i];
-
- // put start address into PC so it can be debugged
- m_p_smiram[0x68] = m_p_ram[1];
- m_p_smiram[0x69] = m_p_ram[2];
-
- // load to 2000-7FFF (optional extra ram)
- if (quick_length > 0x2000)
- for (i = 0x2000; i < quick_length; i++)
- m_p_extram[i-0x2000] = quick_data[i];
-
- /* display a message about the loaded quickload */
- image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr);
-
- // Start the quickload - JP exec_addr
- m_maincpu->set_state_int(S2650_PC, 0);
-
- result = IMAGE_INIT_PASS;
- }
+ // load to 0000-0FFE (standard ram + extra)
+ read_ = 0xfff;
+ if (quick_length < 0xfff)
+ read_ = quick_length;
+ m_p_ram[0] = 0x1f; // add jump for RST key
+ for (i = 1; i < read_; i++)
+ m_p_ram[i] = quick_data[i];
+
+ // load to 1780-17BF (spare ram inside 2656)
+ read_ = 0x17c0;
+ if (quick_length < 0x17c0)
+ read_ = quick_length;
+ if (quick_length > 0x1780)
+ for (i = 0x1780; i < read_; i++)
+ m_p_smiram[i-0x1780] = quick_data[i];
+
+ // put start address into PC so it can be debugged
+ m_p_smiram[0x68] = m_p_ram[1];
+ m_p_smiram[0x69] = m_p_ram[2];
+
+ // load to 2000-7FFF (optional extra ram)
+ if (quick_length > 0x2000)
+ for (i = 0x2000; i < quick_length; i++)
+ m_p_extram[i-0x2000] = quick_data[i];
+
+ /* display a message about the loaded quickload */
+ image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr);
+
+ // Start the quickload - JP exec_addr
+ m_maincpu->set_state_int(S2650_PC, 0);
+
+ result = IMAGE_INIT_PASS;
}
}
-
- global_free_array(quick_data);
}
return result;