Previous 15994 Revisions Next

r12274 Tuesday 19th July, 2011 at 17:48:49 UTC by Sandro Ronco
[IQ151] Implemented vblank irq and removed the old hack. (no whatsnew)
[src/mess/drivers]iq151.c

src/mess/drivers/iq151.c
r12273r12274
2929- Line 32 does not scroll, should it show?
3030  (could be reserved for a status line in a terminal mode)
3131
32- Sort out the issue with memory location 6. If it isn't zero the computer hangs.
33  But if it is always forced to zero, the keys repeat way too fast. Timer
34  currently set to 3Hz for reasonable repeat, but it is far from perfect.
35
3632- Note that the system checks for 3E at C000, if exist, jump to C000;
3733  otherwise then checks for non-FF at C800, if so, jumps to C800. Could be
3834  extra roms or some sort of boot device.
r12273r12274
4541
4642#include "emu.h"
4743#include "cpu/i8085/i8085.h"
44#include "machine/pic8259.h"
4845#include "sound/speaker.h"
4946#include "imagedev/cartslot.h"
5047
r12273r12274
5956public:
6057   iq151_state(const machine_config &mconfig, device_type type, const char *tag)
6158      : driver_device(mconfig, type, tag),
62   m_speaker(*this, SPEAKER_TAG)
59        m_maincpu(*this, "maincpu"),
60        m_pic(*this, "pic8259"),
61        m_speaker(*this, SPEAKER_TAG)
6362   { }
6463
64   required_device<cpu_device> m_maincpu;
65   required_device<device_t> m_pic;
6566   required_device<device_t> m_speaker;
67
6668   DECLARE_READ8_MEMBER(keyboard_r);
6769   DECLARE_WRITE8_MEMBER(speaker_w);
68   UINT8 *m_p_ram;
70   DECLARE_WRITE_LINE_MEMBER(pic_set_int_line);
6971   UINT8 *m_p_videoram;
72   UINT8 m_vblank_irq_state;
7073   const UINT8 *m_p_chargen;
71   UINT8 m_framecnt;
7274   UINT8 m_width;
7375   virtual void machine_reset();
7476   virtual void video_start();
7577   virtual bool screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect);
7678
77
7879   // AMOS
7980   UINT8 *m_amos_banks[4];
8081   DECLARE_WRITE8_MEMBER(amos_bankswitch_w);
r12273r12274
132133   AM_RANGE( 0x84, 0x85 ) AM_READ(keyboard_r)
133134   AM_RANGE( 0x86, 0x86 ) AM_READ_PORT("X8")
134135   AM_RANGE( 0x87, 0x87 ) AM_WRITE(speaker_w)
136   AM_RANGE( 0x88, 0x89 ) AM_DEVREADWRITE_LEGACY("pic8259", pic8259_r, pic8259_w )
135137   AM_RANGE( 0xfe, 0xfe ) AM_READ_PORT("FE")
136138ADDRESS_MAP_END
137139
r12273r12274
236238   memory_set_bank(machine, "boot", 0);
237239}
238240
239static TIMER_DEVICE_CALLBACK( iq151a )
241WRITE_LINE_MEMBER( iq151_state::pic_set_int_line )
240242{
241   iq151_state *state = timer.machine().driver_data<iq151_state>();
242   state->m_p_ram[6]=0; // fixme
243   device_set_input_line(m_maincpu, 0, state ?  HOLD_LINE : CLEAR_LINE);
243244}
244245
246static INTERRUPT_GEN( iq151_vblank_interrupt )
247{
248   iq151_state *state = device->machine().driver_data<iq151_state>();
249
250   pic8259_ir6_w(state->m_pic, state->m_vblank_irq_state & 1);
251   state->m_vblank_irq_state ^= 1;
252}
253
254static IRQ_CALLBACK(iq151_irq_callback)
255{
256   iq151_state *state = device->machine().driver_data<iq151_state>();
257
258   return pic8259_acknowledge(state->m_pic);
259}
260
245261DRIVER_INIT( iq151 )
246262{
247263   iq151_state *state = machine.driver_data<iq151_state>();
r12273r12274
250266   memory_configure_bank(machine, "boot", 0, 2, &RAM[0x0000], 0xf800);
251267
252268   memset(state->m_amos_banks, 0, sizeof(state->m_amos_banks));
269
270   device_set_irq_callback(state->m_maincpu, iq151_irq_callback);
253271}
254272
255273MACHINE_RESET_MEMBER( iq151_state )
r12273r12274
258276   machine().primary_screen->set_visible_area(0, (m_width == 32 ? 32*8 : 64*6)-1, 0, 32*8-1);
259277   memory_set_bank(machine(), "boot", 1);
260278   machine().scheduler().timer_set(attotime::from_usec(5), FUNC(iq151_boot));
279
280   m_vblank_irq_state = 0;
261281}
262282
263283VIDEO_START_MEMBER( iq151_state )
264284{
265285   m_p_chargen = machine().region("chargen")->base();
266   m_p_ram = machine().region("maincpu")->base();
267286   m_width = 32;
268287}
269288
r12273r12274
275294   UINT8 y,ra,chr,gfx;
276295   UINT16 sy=0,x;
277296   UINT16 chrstart = (m_width == 32) ? 0x800 : 0; // choose which charrom to use
278   UINT16 ma = m_p_ram[0x20] | ((m_p_ram[0x21] & 7) << 8); // start of videoram
279   UINT16 cursor = m_p_ram[0x0c] | ((m_p_ram[0x0d] & 7) << 8); // cursor address
297   UINT16 ma = (m_width == 32) ? 0x400 : 0; // start of videoram
280298
281   m_framecnt++;
282
283299   for (y = 0; y < 32; y++)
284300   {
285301      for (ra = 0; ra < 8; ra++)
r12273r12274
297313            if (m_width == 32 && m_p_videoram[x] > 0x7f)
298314               gfx = ~gfx;
299315
300            //display cursor if at cursor position and flash on
301            if ( (x==cursor) && (m_framecnt & 0x08) )
302               gfx = 0xff;
303
304316            /* Display a scanline of a character */
305317            if (m_width == 32)
306318            {
r12273r12274
328340
329341WRITE8_MEMBER(iq151_state::amos_bankswitch_w)
330342{
331   address_space *prog_space = machine().device("maincpu")->memory().space(AS_PROGRAM);
343   address_space *prog_space = m_maincpu->memory().space(AS_PROGRAM);
332344
333345   if (m_amos_banks[data & 3] != NULL)
334346      prog_space->install_rom(0x8000, 0xbfff, m_amos_banks[data & 3]);
r12273r12274
339351
340352static DEVICE_IMAGE_LOAD( iq151_cart )
341353{
354   iq151_state *state = image.device().machine().driver_data<iq151_state>();
355
342356   if (image.software_entry() != NULL)
343357   {
344358      // get the cartridge type
345359      const char *cart_type = image.get_feature("cart_type");
346      address_space *space = image.device().machine().device("maincpu")->memory().space(AS_PROGRAM);
360      address_space *space = state->m_maincpu->memory().space(AS_PROGRAM);
347361
348362      if (!strcmp(cart_type, "BASIC6"))
349363      {
r12273r12274
362376      else if (!strncmp(cart_type, "AMOS", 4))
363377      {
364378         // AMOS cartridges
365         iq151_state *state = image.device().machine().driver_data<iq151_state>();
366379
367380         switch ((const char)cart_type[4])
368381         {
r12273r12274
379392         }
380393
381394         // install AMOS bankswitch handler
382         address_space *io = image.device().machine().device("maincpu")->memory().space(AS_IO);
395         address_space *io = state->m_maincpu->memory().space(AS_IO);
383396         io->install_write_handler(0xec, 0xef, write8_delegate(FUNC(iq151_state::amos_bankswitch_w), state));
384397
385398         return IMAGE_INIT_PASS;
r12273r12274
426439   GFXDECODE_ENTRY( "chargen", 0x0000, iq151_64_charlayout, 0, 1 )
427440GFXDECODE_END
428441
442const struct pic8259_interface iq151_pic8259_config =
443{
444   DEVCB_DRIVER_LINE_MEMBER(iq151_state, pic_set_int_line),
445   DEVCB_LINE_VCC,
446   DEVCB_NULL
447};
448
429449static MACHINE_CONFIG_START( iq151, iq151_state )
430450   /* basic machine hardware */
431451   MCFG_CPU_ADD("maincpu",I8080, XTAL_2MHz)
432452   MCFG_CPU_PROGRAM_MAP(iq151_mem)
433453   MCFG_CPU_IO_MAP(iq151_io)
454   MCFG_CPU_VBLANK_INT("screen", iq151_vblank_interrupt)
434455
435456   /* video hardware */
436457   MCFG_SCREEN_ADD("screen", RASTER)
r12273r12274
448469   MCFG_SOUND_ADD(SPEAKER_TAG, SPEAKER_SOUND, 0)
449470   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
450471
451   MCFG_TIMER_ADD_PERIODIC("iq151a", iq151a, attotime::from_hz(3) )
472   MCFG_PIC8259_ADD("pic8259", iq151_pic8259_config)
452473
453474   /* cartridge */
454475   // On real hardware only 4 slots are available, because one

Previous 15994 Revisions Next


© 1998-2018 The MESS Team