Previous 15994 Revisions Next

r8896 Wednesday 25th August, 2010 at 09:33:57 UTC by Miodrag Milanović
[JR100] Made actual cassette load, also quickload for PRG files
[src/mess/drivers]jr100.c

src/mess/drivers/jr100.c
r8895r8896
1111#include "machine/6522via.h"
1212#include "devices/cassette.h"
1313#include "sound/wave.h"
14#include "sound/beep.h"
14#include "sound/speaker.h"
15#include "devices/snapquik.h"
1516
17static UINT8 *jr100_ram;
1618static UINT8 *jr100_vram;
1719static UINT8 *jr100_pcg;
1820static UINT8 keyboard_line;
1921static bool jr100_use_pcg;
22static UINT8 jr100_speaker;
2023
2124static ADDRESS_MAP_START(jr100_mem, ADDRESS_SPACE_PROGRAM, 8)
2225   ADDRESS_MAP_UNMAP_HIGH
23   AM_RANGE(0x0000, 0x3fff) AM_RAM
26   AM_RANGE(0x0000, 0x3fff) AM_RAM AM_BASE(&jr100_ram)
2427   AM_RANGE(0xc000, 0xc0ff) AM_RAM AM_BASE(&jr100_pcg)
25   AM_RANGE(0xc100, 0xc3ff) AM_RAM AM_BASE(&jr100_vram)
28   AM_RANGE(0xc100, 0xc3ff) AM_RAM AM_BASE(&jr100_vram)   
2629   AM_RANGE(0xc800, 0xc80f) AM_DEVREADWRITE("via", via_r, via_w)
2730   AM_RANGE(0xe000, 0xffff) AM_ROM   
2831ADDRESS_MAP_END
r8895r8896
173176static WRITE8_DEVICE_HANDLER(jr100_via_write_b )
174177{
175178   jr100_use_pcg = (data & 0x20) ? TRUE : FALSE;
179   jr100_speaker = data>>7;
176180}
177181
178182static const via6522_interface jr100_via_intf =
r8895r8896
199203   NULL
200204};
201205
202static TIMER_DEVICE_CALLBACK( cassette_tick )
206static TIMER_DEVICE_CALLBACK( sound_tick )
203207{
208   running_device *speaker = timer.machine->device("speaker");   
209   speaker_level_w(speaker,jr100_speaker);
210   jr100_speaker = 0;
211   
212   running_device *via = timer.machine->device("via");
213   double level = cassette_input(timer.machine->device("cassette"));
214   if (level > 0.0) {
215      via_ca1_w(via, 0);
216      via_cb1_w(via, 0);
217   } else {
218      via_ca1_w(via, 1);
219      via_cb1_w(via, 1);
220   }
221   
222   
223}
204224
225static UINT32 readByLittleEndian(UINT8 *buf,int pos)
226{
227   return buf[pos] + (buf[pos+1] << 8) + (buf[pos+2] << 16) + (buf[pos+3] << 24);
205228}
206229
230static QUICKLOAD_LOAD(jr100)
231{
232   int quick_length;
233   UINT8 buf[0x10000];
234   int read_;
235   quick_length = image.length();
236   if (quick_length >= 0xffff)
237      return IMAGE_INIT_FAIL;
238   read_ = image.fread(buf, quick_length);
239   if (read_ != quick_length)
240      return IMAGE_INIT_FAIL;
241
242   if (buf[0]!=0x50 || buf[1]!=0x52 || buf[2]!=0x4F || buf[3]!=0x47) {
243      // this is not PRG
244      return IMAGE_INIT_FAIL;
245   }
246   int pos = 4;
247   if (readByLittleEndian(buf,pos)!=1) {
248      // not version 1 of PRG file
249      return IMAGE_INIT_FAIL;
250   }
251   pos += 4;
252   UINT32 len =readByLittleEndian(buf,pos); pos+= 4;
253   pos += len; // skip name
254   UINT32 start_address = readByLittleEndian(buf,pos); pos+= 4;
255   UINT32 code_length   = readByLittleEndian(buf,pos); pos+= 4;
256   UINT32 flag         = readByLittleEndian(buf,pos); pos+= 4;
257   
258   UINT32 end_address = start_address + code_length - 1;
259   // copy code
260   memcpy(jr100_ram + start_address,buf + pos,code_length);
261   if (flag == 0) {
262      jr100_ram[end_address + 1] =  0xdf;
263      jr100_ram[end_address + 2] =  0xdf;
264      jr100_ram[end_address + 3] =  0xdf;
265      jr100_ram[6 ] = (end_address >> 8 & 0xFF);
266      jr100_ram[7 ] = (end_address & 0xFF);
267      jr100_ram[8 ] = ((end_address + 1) >> 8 & 0xFF);
268      jr100_ram[9 ] = ((end_address + 1) & 0xFF);
269      jr100_ram[10] = ((end_address + 2) >> 8 & 0xFF);
270      jr100_ram[11] = ((end_address + 2) & 0xFF);
271      jr100_ram[12] = ((end_address + 3) >> 8 & 0xFF);
272      jr100_ram[13] = ((end_address + 3) & 0xFF);
273    }
274   
275   return IMAGE_INIT_PASS;
276}
277
207278static MACHINE_DRIVER_START( jr100 )
208279    /* basic machine hardware */
209    MDRV_CPU_ADD("maincpu",M6802, XTAL_14_31818MHz / 16)
280    MDRV_CPU_ADD("maincpu",M6802, XTAL_14_31818MHz / 4) // clock devided internaly by 4
210281    MDRV_CPU_PROGRAM_MAP(jr100_mem)
211282
212283    MDRV_MACHINE_RESET(jr100)
r8895r8896
231302   MDRV_SPEAKER_STANDARD_MONO("mono")
232303   MDRV_SOUND_WAVE_ADD("wave", "cassette")
233304   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
305   MDRV_SOUND_ADD("speaker", SPEAKER, 0)
306   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
234307
235308   MDRV_CASSETTE_ADD( "cassette", jr100_cassette_config )   
236   MDRV_TIMER_ADD_PERIODIC("cassette_timer", cassette_tick, HZ(XTAL_14_31818MHz / 16))
309   
310   MDRV_TIMER_ADD_PERIODIC("sound_tick", sound_tick, HZ(XTAL_14_31818MHz / 16))
311   
312   /* quickload */
313   MDRV_QUICKLOAD_ADD("quickload", jr100, "prg", 0)   
237314MACHINE_DRIVER_END
238315
239316

Previous 15994 Revisions Next


© 1998-2018 The MESS Team