Previous 15994 Revisions Next

r9818 Saturday 25th December, 2010 at 16:01:46 UTC by Wilbert Pol
[OSBEXEC] Adding a bit of meat to the skeleton.
[src/mess/drivers]osbexec.c
[src/mess/includes]osbexec.h

src/mess/includes/osbexec.h
r9817r9818
1/*****************************************************************************
2 *
3 * includes/osbexec.h
4 *
5 ****************************************************************************/
6
7#ifndef OSBEXEC_H_
8#define OSBEXEC_H_
9
10class osbexec_state : public driver_device
11{
12public:
13   osbexec_state(running_machine &machine, const driver_device_config_base &config)
14      : driver_device(machine, config) { }
15};
16
17
18#endif /* OSBEXEC_H_ */
src/mess/drivers/osbexec.c
r9817r9818
22
33    Osborne Executive driver file
44
5Screen is 80x24
56
7On boot at least bios seems to be enabled.
8Boot sequence:
9- set stack to and initialize Fxxx
10- write stuff to/initialize 2000-27FF
11- set PA to 80
12- initialize some more i/o
13- set PA to C0
14- test C000-CFFF
15- Set PA to 80
16- i/o things
17- Set PA to C0
18- Clear VRAM with 0x20
19- Write "PERFORMING SELF-TEST" to VRAM
20- Set PA to 80
21- (bp 0307)
22- Test 2000-27FF
23- Set SP to 27FF
24- Set PA to 80
25- Test 4000-FFFF
26- Set PA to 81
27- Test 4000-EFFF
28- (bp 2c6)
29- Test i/o
30
31
632***************************************************************************/
733
834#include "emu.h"
r9817r9818
1541#include "machine/6821pia.h"
1642#include "machine/pit8253.h"
1743#include "devices/messram.h"
18#include "includes/osbexec.h"
1944
2045
2146#define MAIN_CLOCK   23961600
2247
2348
49class osbexec_state : public driver_device
50{
51public:
52   osbexec_state(running_machine &machine, const driver_device_config_base &config)
53      : driver_device(machine, config) { }
54
55   region_info   *fontram_region;
56   region_info *vram_region;
57   UINT8   *fontram;
58   UINT8   *vram;
59   emu_timer *video_timer;
60
61   /* PIA 0 (UD12) */
62   UINT8   pia0_porta;
63
64
65   void set_banks(running_machine *machine)
66   {
67      UINT8 *messram_ptr = messram_get_ptr( machine->device("messram") );
68
69      if ( pia0_porta & 0x01 )
70         messram_ptr += 0x10000;
71
72      memory_set_bankptr( machine, "4000", messram_ptr + 0x4000 );
73      memory_set_bankptr( machine, "c000", messram_ptr + 0xc000 );
74      memory_set_bankptr( machine, "e000", messram_ptr + 0xe000 );
75
76      if ( pia0_porta & 0x80 )
77         memory_set_bankptr( machine, "0000", memory_region(machine, "maincpu") );
78
79      if ( pia0_porta & 0x40 )
80         memory_set_bankptr(machine, "c000", vram_region->base() );
81   }
82
83};
84
85
86static WRITE8_HANDLER( osbexec_0000_w )
87{
88   osbexec_state *state = space->machine->driver_data<osbexec_state>();
89
90   /* Font RAM writing is enabled when ROM bank is enabled */
91   if ( state->pia0_porta & 0x80 )
92   {
93      if ( offset < 0x1000 )
94         state->fontram[ offset ] = data;
95   }
96}
97
98
2499static ADDRESS_MAP_START( osbexec_mem, ADDRESS_SPACE_PROGRAM, 8 )
25   AM_RANGE( 0x0000, 0x1FFF ) AM_ROM
100   AM_RANGE( 0x0000, 0x1FFF ) AM_READ_BANK("0000") AM_WRITE( osbexec_0000_w )   /* ROM and maybe also banked ram */
101   AM_RANGE( 0x2000, 0x3FFF ) AM_RAM                                 /* Banked? RAM */
102   AM_RANGE( 0x4000, 0xBFFF ) AM_RAMBANK("4000")                        /* Banked ram */
103   AM_RANGE( 0xC000, 0xDFFF ) AM_RAMBANK("c000")                        /* Video ram / Banked RAM */
104   AM_RANGE( 0xE000, 0xEFFF ) AM_RAMBANK("e000")                        /* Banked ram */
105   AM_RANGE( 0xF000, 0xFFFF ) AM_RAM                                 /* 4KB of non-banked RAM for system stack etc */
26106ADDRESS_MAP_END
27107
28108
29109static ADDRESS_MAP_START( osbexec_io, ADDRESS_SPACE_IO, 8 )
30110   ADDRESS_MAP_UNMAP_HIGH
31111   ADDRESS_MAP_GLOBAL_MASK(0xff)
32   /* 0x00 - 0x01/0x03 - 6821 PIA @UD12 */
112   AM_RANGE( 0x00, 0x03 ) AM_DEVREADWRITE( "pia_0", pia6821_r, pia6821_w )      /* 6821 PIA UD12 */
33113   /* 0x04 - 0x07 - 8253 @UD1 */
34114   /* 0x08 - 0x0B - MB8877 @UB17 */
35115   /* 0x0c - 0x0f - SIO @UD4 */
r9817r9818
134214
135215
136216/*
217  UD12 - 6821 PIA
218
219  Port A:
220  PA7 - ROM BANK ENA
221  PA6 - VRAM BANK ENA
222  PA5 - BANK6ENA
223  PA4 - BANK5ENA
224  PA3 - BANK4ENA
225  PA2 - BANK3ENA
226  PA1 - BANK2ENA
227  PA0 - BANK1ENA
228*/
229
230static READ8_DEVICE_HANDLER( osbexec_pia0_a_r )
231{
232   osbexec_state *state = device->machine->driver_data<osbexec_state>();
233
234   return state->pia0_porta;
235}
236
237
238static WRITE8_DEVICE_HANDLER( osbexec_pia0_a_w )
239{
240   osbexec_state *state = device->machine->driver_data<osbexec_state>();
241
242   logerror("osbexec_pia0_a_w: %02x\n", data );
243
244   state->pia0_porta = data;
245
246   state->set_banks( device->machine );
247}
248
249
250static const pia6821_interface osbexec_pia0_config =
251{
252   DEVCB_HANDLER( osbexec_pia0_a_r ),   /* in_a_func */         /* port A - banking */
253   DEVCB_NULL,                     /* in_b_func */         /* modem / speaker */
254   DEVCB_NULL,                     /* in_ca1_func */      /* DMA IRQ */
255   DEVCB_NULL,                     /* in_cb1_func */      /* Vblank (rtc irq) */
256   DEVCB_NULL,                     /* in_ca2_func */
257   DEVCB_NULL,                     /* in_cb2_func */
258   DEVCB_HANDLER( osbexec_pia0_a_w ),   /* out_a_func */      /* port A - banking */
259   DEVCB_NULL,                     /* out_b_func */      /* modem / speaker */
260   DEVCB_NULL,                     /* out_ca2_func */      /* Keyboard strobe */
261   DEVCB_NULL,                     /* out_cb2_func */      /* 60/50 */
262   DEVCB_NULL,                     /* irq_a_func */      /* IRQ */
263   DEVCB_NULL                     /* irq_b_func */      /* IRQ */
264};
265
266
267static const pia6821_interface osbexec_pia1_config =
268{
269   DEVCB_NULL,                     /* in_a_func */
270   DEVCB_NULL,                     /* in_b_func */
271   DEVCB_NULL,                     /* in_ca1_func */
272   DEVCB_NULL,                     /* in_cb1_func */
273   DEVCB_NULL,                     /* in_ca2_func */
274   DEVCB_NULL,                     /* in_cb2_func */
275   DEVCB_NULL,                     /* out_a_func */
276   DEVCB_NULL,                     /* out_b_func */
277   DEVCB_NULL,                     /* out_ca2_func */
278   DEVCB_NULL,                     /* out_cb2_func */
279   DEVCB_NULL,                     /* irq_a_func */
280   DEVCB_NULL                     /* irq_b_func */
281};
282
283
284/*
137285 * The Osborne Executive supports the following disc formats: (TODO: Verify)
138286 * - Osborne single density: 40 tracks, 10 sectors per track, 256-byte sectors (100 KByte)
139287 * - Osborne double density: 40 tracks, 5 sectors per track, 1024-byte sectors (200 KByte)
r9817r9818
189337};
190338
191339
340static TIMER_CALLBACK( osbexec_video_callback )
341{
342   osbexec_state *state = machine->driver_data<osbexec_state>();
343   running_device *pia_0 = machine->device("pia_0");
344   int y = machine->primary_screen->vpos();
345
346   /* Start of frame */
347   if ( y == 0 )
348   {
349      /* Clear CB1 on PIA @ UD12 */
350      pia6821_cb1_w( pia_0, 0 );
351   }
352   else if ( y == 240 )
353   {
354      /* Set CB1 on PIA @ UD12 */
355      pia6821_cb1_w( pia_0, 1 );
356   }
357   if ( y < 240 )
358   {
359      UINT16 row_addr = ( y / 10 ) * 128;
360      UINT16 *p = BITMAP_ADDR16( machine->generic.tmpbitmap, y, 0 );
361      UINT8 char_line = y % 10;
362
363      for ( int x = 0; x < 64; x++ )
364      {
365         UINT8 ch = state->vram[ row_addr + x ];
366         UINT8 attr = state->vram[ 0x1000 + row_addr + x ];
367         UINT8 fg_col = ( attr & 0x80 ) ? 1 : 2;
368         UINT8 font_bits = state->fontram[ ( ( attr & 0x10 ) ? 0x800 : 0 ) + ch * 16 + char_line ];
369
370         /* Check for underline */
371         if ( ( attr & 0x40 ) && char_line == 9 )
372            font_bits = 0xFF;
373
374         for ( int b = 0; b < 8; b++ )
375         {
376            p[ x * 8 + b ] = ( font_bits & 0x80 ) ? fg_col : 0;
377            font_bits <<= 1;
378         }
379      }
380   }
381
382   timer_adjust_oneshot( state->video_timer, machine->primary_screen->time_until_pos( y + 1, 0 ), 0 );
383}
384
385
192386static DRIVER_INIT( osbexec )
193387{
388   osbexec_state *state = machine->driver_data<osbexec_state>();
389
390   state->fontram_region = machine->region_alloc( "fontram", 0x1000, 0 );
391   state->vram_region = machine->region_alloc( "vram", 0x2000, 0 );
392   state->vram = state->vram_region->base();
393   state->fontram = state->fontram_region->base();
394
395
396   memset( state->fontram, 0x00, 0x1000 );
397   memset( state->vram, 0x00, 0x2000 );
398
399   state->video_timer = timer_alloc( machine, osbexec_video_callback, NULL );
194400}
195401
196402
197403static MACHINE_RESET( osbexec )
198404{
405   osbexec_state *state = machine->driver_data<osbexec_state>();
406
407   state->pia0_porta = 0xC0;      /* Enable ROM and VRAM on reset */
408
409   state->set_banks( machine );
410
411   timer_adjust_oneshot( state->video_timer, machine->primary_screen->time_until_pos( 0, 0 ), 0 );
199412}
200413
201414
r9817r9818
208421
209422   MDRV_SCREEN_ADD("screen", RASTER)
210423   MDRV_SCREEN_FORMAT( BITMAP_FORMAT_INDEXED16 )
211   MDRV_SCREEN_RAW_PARAMS( MAIN_CLOCK/4, 512, 0, 416, 260, 0, 240 )   /* Most likely not correct */
424   MDRV_SCREEN_RAW_PARAMS( MAIN_CLOCK/2, 640, 0, 512, 260, 0, 240 )   /* May not be correct */
212425   MDRV_VIDEO_START( generic_bitmapped )
213426   MDRV_VIDEO_UPDATE( generic_bitmapped )
214427   MDRV_PALETTE_LENGTH( 3 )
r9817r9818
220433
221434//   MDRV_PIT8253_ADD( "pit", osbexec_pit_config )
222435
223//   MDRV_PIA6821_ADD( "pia_0", osbexec_pia0_config )
224//   MDRV_PIA6821_ADD( "pia_1", osbexec_pia1_config )
436   MDRV_PIA6821_ADD( "pia_0", osbexec_pia0_config )
437   MDRV_PIA6821_ADD( "pia_1", osbexec_pia1_config )
225438
226439//   MDRV_Z80SIO0_ADD( "sio", MAIN_CLOCK/6, osbexec_sio_config )
227440
r9817r9818
231444
232445   /* internal ram */
233446   MDRV_RAM_ADD("messram")
234   MDRV_RAM_DEFAULT_SIZE("68K")   /* 64KB Main RAM and 4Kbit video attribute RAM */
447   MDRV_RAM_DEFAULT_SIZE("128K")   /* 128KB Main RAM */
235448MACHINE_CONFIG_END
236449
237450

Previous 15994 Revisions Next


© 1998-2018 The MESS Team