Previous 15994 Revisions Next

r15282 Wednesday 23rd May, 2012 at 08:50:59 UTC by Robbbert
PIPBUG - added quickload for .pgm files
[src/mess/drivers]pipbug.c

src/mess/drivers/pipbug.c
r15281r15282
2828        The Baby 2650 (featured in Electronics Australia magazine in
2929        March 1977) has 256 bytes of RAM.
3030
31        The terminal is expected to have a papertape device attached, and
32        use it to save and load programs. PIPBUG still thinks it is talking
33        to the terminal, when in fact the data is flowing to the papertape
34        reader and punch.
3135
3236****************************************************************************/
3337
3438#include "emu.h"
3539#include "cpu/s2650/s2650.h"
3640#include "machine/terminal.h"
41#include "imagedev/snapquik.h"
3742
3843
3944class pipbug_state : public driver_device
r15281r15282
8590   DEVCB_NULL
8691};
8792
93QUICKLOAD_LOAD( pipbug )
94{
95   address_space *space = image.device().machine().device("maincpu")->memory().space(AS_PROGRAM);
96   int i;
97   int quick_addr = 0x0440;
98   int exec_addr;
99   int quick_length;
100   UINT8 *quick_data;
101   int read_;
102
103   quick_length = image.length();
104   quick_data = (UINT8*)malloc(quick_length);
105   if (!quick_data)
106   {
107      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file");
108      image.message(" Cannot open file");
109      return IMAGE_INIT_FAIL;
110   }
111
112   read_ = image.fread( quick_data, quick_length);
113   if (read_ != quick_length)
114   {
115      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file");
116      image.message(" Cannot read the file");
117      return IMAGE_INIT_FAIL;
118   }
119
120   if (quick_data[0] != 0xc4)
121   {
122      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header");
123      image.message(" Invalid header");
124      return IMAGE_INIT_FAIL;
125   }
126
127   exec_addr = quick_data[1] * 256 + quick_data[2];
128
129   if (exec_addr >= quick_length)
130   {
131      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file");
132      image.message(" Exec address beyond end of file");
133      return IMAGE_INIT_FAIL;
134   }
135
136   if (quick_length < 0x444)
137   {
138      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short");
139      image.message(" File too short");
140      return IMAGE_INIT_FAIL;
141   }
142
143   if (quick_length > 0x8000)
144   {
145      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too long");
146      image.message(" File too long");
147      return IMAGE_INIT_FAIL;
148   }
149
150   for (i = quick_addr; i < quick_length; i++)
151   {
152      space->write_byte(i, quick_data[i]);
153   }
154
155   /* display a message about the loaded quickload */
156   image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr);
157
158   // Start the quickload
159   cpu_set_reg(image.device().machine().device("maincpu"), STATE_GENPC, exec_addr);
160   return IMAGE_INIT_PASS;
161}
162
88163static MACHINE_CONFIG_START( pipbug, pipbug_state )
89164   /* basic machine hardware */
90165   MCFG_CPU_ADD("maincpu",S2650, XTAL_1MHz)
r15281r15282
93168
94169   /* video hardware */
95170   MCFG_SERIAL_TERMINAL_ADD(TERMINAL_TAG, terminal_intf, 110)
171
172   /* quickload */
173   MCFG_QUICKLOAD_ADD("quickload", pipbug, "pgm", 0)
96174MACHINE_CONFIG_END
97175
176
98177/* ROM definition */
99178ROM_START( pipbug )
100179   ROM_REGION( 0x8000, "maincpu", ROMREGION_ERASEFF )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team