~ubuntu-branches/ubuntu/raring/mame/raring-proposed

« back to all changes in this revision

Viewing changes to mess/src/mess/drivers/paso1600.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Jordi Mallach, Emmanuel Kasper
  • Date: 2011-12-19 22:56:27 UTC
  • mfrom: (0.1.2)
  • Revision ID: package-import@ubuntu.com-20111219225627-ub5oga1oys4ogqzm
Tags: 0.144-1
[ Jordi Mallach ]
* Fix syntax errors in DEP5 copyright file (lintian).
* Use a versioned copyright Format specification field.
* Update Vcs-* URLs.
* Move transitional packages to the new metapackages section, and make
  them priority extra.
* Remove references to GNU/Linux and MESS sources from copyright.
* Add build variables for s390x.
* Use .xz tarballs as it cuts 4MB for the upstream sources.
* Add nplayers.ini as a patch. Update copyright file to add CC-BY-SA-3.0.

[ Emmanuel Kasper ]
* New upstream release. Closes: #651538.
* Add Free Desktop compliant png icons of various sizes taken from
  the hydroxygen iconset
* Mess is now built from a new source package, to avoid possible source
  incompatibilities between mame and the mess overlay.
* Mame-tools are not built from the mame source package anymore, but
  from the mess source package

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 
3
 
    Toshiba Pasopia 1600
4
 
 
5
 
    TODO:
6
 
    - charset ROM is WRONG! (needs a 8x16 or even a 16x16 one)
7
 
    - identify fdc type (needs a working floppy image)
8
 
 
9
 
****************************************************************************/
10
 
 
11
 
#include "emu.h"
12
 
#include "cpu/i86/i86.h"
13
 
#include "video/mc6845.h"
14
 
#include "machine/pic8259.h"
15
 
#include "machine/8237dma.h"
16
 
 
17
 
 
18
 
class paso1600_state : public driver_device
19
 
{
20
 
public:
21
 
        paso1600_state(const machine_config &mconfig, device_type type, const char *tag)
22
 
                : driver_device(mconfig, type, tag)
23
 
                { }
24
 
 
25
 
        UINT8 m_crtc_vreg[0x100],m_crtc_index;
26
 
 
27
 
        mc6845_device *m_mc6845;
28
 
        UINT8 *m_char_rom;
29
 
        UINT16 *m_vram;
30
 
        UINT16 *m_gvram;
31
 
 
32
 
        struct{
33
 
                UINT8 portb;
34
 
        }m_keyb;
35
 
};
36
 
 
37
 
#define mc6845_h_char_total     (state->m_crtc_vreg[0])
38
 
#define mc6845_h_display                (state->m_crtc_vreg[1])
39
 
#define mc6845_h_sync_pos               (state->m_crtc_vreg[2])
40
 
#define mc6845_sync_width               (state->m_crtc_vreg[3])
41
 
#define mc6845_v_char_total             (state->m_crtc_vreg[4])
42
 
#define mc6845_v_total_adj              (state->m_crtc_vreg[5])
43
 
#define mc6845_v_display                (state->m_crtc_vreg[6])
44
 
#define mc6845_v_sync_pos               (state->m_crtc_vreg[7])
45
 
#define mc6845_mode_ctrl                (state->m_crtc_vreg[8])
46
 
#define mc6845_tile_height              (state->m_crtc_vreg[9]+1)
47
 
#define mc6845_cursor_y_start   (state->m_crtc_vreg[0x0a])
48
 
#define mc6845_cursor_y_end     (state->m_crtc_vreg[0x0b])
49
 
#define mc6845_start_addr               (((state->m_crtc_vreg[0x0c]<<8) & 0x3f00) | (state->m_crtc_vreg[0x0d] & 0xff))
50
 
#define mc6845_cursor_addr      (((state->m_crtc_vreg[0x0e]<<8) & 0x3f00) | (state->m_crtc_vreg[0x0f] & 0xff))
51
 
#define mc6845_light_pen_addr   (((state->m_crtc_vreg[0x10]<<8) & 0x3f00) | (state->m_crtc_vreg[0x11] & 0xff))
52
 
#define mc6845_update_addr      (((state->m_crtc_vreg[0x12]<<8) & 0x3f00) | (state->m_crtc_vreg[0x13] & 0xff))
53
 
 
54
 
 
55
 
static VIDEO_START( paso1600 )
56
 
{
57
 
}
58
 
 
59
 
static SCREEN_UPDATE( paso1600 )
60
 
{
61
 
        paso1600_state *state = screen->machine().driver_data<paso1600_state>();
62
 
        int x,y;
63
 
        int xi,yi;
64
 
        UINT8 *gfx_rom = screen->machine().region("font")->base();
65
 
        #if 0
66
 
        UINT32 count;
67
 
        static int test_x;
68
 
 
69
 
        if(screen->machine().input().code_pressed(KEYCODE_Z))
70
 
                test_x++;
71
 
 
72
 
        if(screen->machine().input().code_pressed(KEYCODE_X))
73
 
                test_x--;
74
 
 
75
 
        popmessage("%d",test_x);
76
 
 
77
 
        count = 0;
78
 
 
79
 
        for(y=0;y<475;y++)
80
 
        {
81
 
                count &= 0xffff;
82
 
 
83
 
                for(x=0;x<test_x/16;x++)
84
 
                {
85
 
                        for(xi=0;xi<16;xi++)
86
 
                        {
87
 
                                int pen = (state->m_gvram[count] >> xi) & 1;
88
 
 
89
 
                                if(y < 475 && x*16+xi < 640) /* TODO: safety check */
90
 
                                        *BITMAP_ADDR16(bitmap, y, x*16+xi) = screen->machine().pens[pen];
91
 
                        }
92
 
 
93
 
                        count++;
94
 
                }
95
 
        }
96
 
        #endif
97
 
 
98
 
//  popmessage("%d %d %d",mc6845_h_display,mc6845_v_display,mc6845_tile_height);
99
 
 
100
 
        for(y=0;y<mc6845_v_display;y++)
101
 
        {
102
 
                for(x=0;x<mc6845_h_display;x++)
103
 
                {
104
 
                        int tile = state->m_vram[x+y*mc6845_h_display] & 0xff;
105
 
                        int color = (state->m_vram[x+y*mc6845_h_display] & 0x700) >> 8;
106
 
                        int pen;
107
 
 
108
 
                        for(yi=0;yi<19;yi++)
109
 
                        {
110
 
                                for(xi=0;xi<8;xi++)
111
 
                                {
112
 
                                        pen = (gfx_rom[tile*8+(yi >> 1)] >> (7-xi) & 1) ? color : -1;
113
 
 
114
 
                                        if(yi & 0x10)
115
 
                                                pen = -1;
116
 
 
117
 
                                        //if(pen != -1)
118
 
                                                if(y*19 < 475 && x*8+xi < 640) /* TODO: safety check */
119
 
                                                        *BITMAP_ADDR16(bitmap, y*19+yi, x*8+xi) = screen->machine().pens[pen];
120
 
                                }
121
 
                        }
122
 
                }
123
 
        }
124
 
 
125
 
        /* quick and dirty way to do the cursor */
126
 
        if(0)
127
 
        for(yi=0;yi<mc6845_tile_height;yi++)
128
 
        {
129
 
                for(xi=0;xi<8;xi++)
130
 
                {
131
 
                        if((mc6845_cursor_y_start & 0x60) != 0x20 && mc6845_h_display)
132
 
                        {
133
 
                                x = mc6845_cursor_addr % mc6845_h_display;
134
 
                                y = mc6845_cursor_addr / mc6845_h_display;
135
 
                                *BITMAP_ADDR16(bitmap, y*mc6845_tile_height+yi, x*8+xi) = screen->machine().pens[7];
136
 
                        }
137
 
                }
138
 
        }
139
 
 
140
 
        return 0;
141
 
}
142
 
 
143
 
static READ8_HANDLER( paso1600_pcg_r )
144
 
{
145
 
        paso1600_state *state = space->machine().driver_data<paso1600_state>();
146
 
 
147
 
        return state->m_char_rom[offset];
148
 
}
149
 
 
150
 
static WRITE8_HANDLER( paso1600_pcg_w )
151
 
{
152
 
        paso1600_state *state = space->machine().driver_data<paso1600_state>();
153
 
 
154
 
        state->m_char_rom[offset] = data;
155
 
        gfx_element_mark_dirty(space->machine().gfx[0], offset >> 3);
156
 
}
157
 
 
158
 
static WRITE8_HANDLER( paso1600_6845_address_w )
159
 
{
160
 
        paso1600_state *state = space->machine().driver_data<paso1600_state>();
161
 
 
162
 
        state->m_crtc_index = data;
163
 
        state->m_mc6845->address_w(*space, offset, data);
164
 
}
165
 
 
166
 
static WRITE8_HANDLER( paso1600_6845_data_w )
167
 
{
168
 
        paso1600_state *state = space->machine().driver_data<paso1600_state>();
169
 
 
170
 
        state->m_crtc_vreg[state->m_crtc_index] = data;
171
 
        state->m_mc6845->register_w(*space, offset, data);
172
 
}
173
 
 
174
 
static READ8_HANDLER( test_r )
175
 
{
176
 
        return 0;
177
 
}
178
 
 
179
 
static READ8_HANDLER( key_r )
180
 
{
181
 
        paso1600_state *state = space->machine().driver_data<paso1600_state>();
182
 
 
183
 
        switch(offset)
184
 
        {
185
 
                case 3:
186
 
                        if(state->m_keyb.portb == 1)
187
 
                                return 0;
188
 
 
189
 
                        return 0xff;
190
 
        }
191
 
 
192
 
        return 0xff;
193
 
}
194
 
 
195
 
static WRITE8_HANDLER( key_w )
196
 
{
197
 
        paso1600_state *state = space->machine().driver_data<paso1600_state>();
198
 
 
199
 
        switch(offset)
200
 
        {
201
 
                case 3: state->m_keyb.portb = data; break;
202
 
        }
203
 
}
204
 
 
205
 
static READ16_HANDLER( test_hi_r )
206
 
{
207
 
        return 0xffff;
208
 
}
209
 
 
210
 
static ADDRESS_MAP_START(paso1600_map, AS_PROGRAM, 16)
211
 
        ADDRESS_MAP_UNMAP_HIGH
212
 
        AM_RANGE(0x00000,0x7ffff) AM_RAM
213
 
        AM_RANGE(0xb0000,0xb0fff) AM_RAM AM_BASE_MEMBER(paso1600_state,m_vram) // tvram
214
 
        AM_RANGE(0xbfff0,0xbffff) AM_READWRITE8(paso1600_pcg_r,paso1600_pcg_w,0xffff)
215
 
        AM_RANGE(0xc0000,0xdffff) AM_RAM AM_BASE_MEMBER(paso1600_state,m_gvram)// gvram
216
 
        AM_RANGE(0xe0000,0xeffff) AM_ROM AM_REGION("kanji",0)// kanji rom, banked via port 0x93
217
 
        AM_RANGE(0xfe000,0xfffff) AM_ROM AM_REGION("ipl", 0)
218
 
ADDRESS_MAP_END
219
 
 
220
 
static ADDRESS_MAP_START(paso1600_io, AS_IO, 16)
221
 
        ADDRESS_MAP_UNMAP_LOW
222
 
        AM_RANGE(0x0000,0x000f) AM_DEVREADWRITE8("8237dma", i8237_r, i8237_w, 0xffff)
223
 
        AM_RANGE(0x0010,0x0011) AM_DEVREADWRITE8("pic8259", pic8259_r,pic8259_w, 0xffff) // i8259
224
 
        AM_RANGE(0x001a,0x001b) AM_READ(test_hi_r) // causes RAM error otherwise?
225
 
        AM_RANGE(0x0030,0x0033) AM_READWRITE8(key_r,key_w,0xffff) //UART keyboard?
226
 
        AM_RANGE(0x0048,0x0049) AM_READ(test_hi_r)
227
 
        AM_RANGE(0x0090,0x0091) AM_READWRITE8(test_r,paso1600_6845_address_w,0x00ff)
228
 
        AM_RANGE(0x0090,0x0091) AM_READWRITE8(test_r,paso1600_6845_data_w,0xff00)
229
 
//  AM_RANGE(0x00d8,0x00df) //fdc, unknown type
230
 
ADDRESS_MAP_END
231
 
 
232
 
/* Input ports */
233
 
static INPUT_PORTS_START( paso1600 )
234
 
INPUT_PORTS_END
235
 
 
236
 
static const gfx_layout paso1600_charlayout =
237
 
{
238
 
        8, 8,
239
 
        RGN_FRAC(1,1),
240
 
        1,
241
 
        { 0 },
242
 
        { STEP8(0,1) },
243
 
        { STEP8(0,8) },
244
 
        8*8
245
 
};
246
 
 
247
 
static GFXDECODE_START( paso1600 )
248
 
        GFXDECODE_ENTRY( "pcg", 0x0000, paso1600_charlayout, 0, 1 )
249
 
GFXDECODE_END
250
 
 
251
 
 
252
 
static const mc6845_interface mc6845_intf =
253
 
{
254
 
        "screen",       /* screen we are acting on */
255
 
        8,                      /* number of pixels per video memory address */
256
 
        NULL,           /* before pixel update callback */
257
 
        NULL,           /* row update callback */
258
 
        NULL,           /* after pixel update callback */
259
 
        DEVCB_NULL,     /* callback for display state changes */
260
 
        DEVCB_NULL,     /* callback for cursor state changes */
261
 
        DEVCB_NULL,     /* HSYNC callback */
262
 
        DEVCB_NULL,     /* VSYNC callback */
263
 
        NULL            /* update address callback */
264
 
};
265
 
 
266
 
static IRQ_CALLBACK(paso1600_irq_callback)
267
 
{
268
 
        return pic8259_acknowledge( device->machine().device( "pic8259" ) );
269
 
}
270
 
 
271
 
static WRITE_LINE_DEVICE_HANDLER( paso1600_set_int_line )
272
 
{
273
 
        //printf("%02x\n",interrupt);
274
 
        cputag_set_input_line(device->machine(), "maincpu", 0, state ? HOLD_LINE : CLEAR_LINE);
275
 
}
276
 
 
277
 
static const struct pic8259_interface paso1600_pic8259_config =
278
 
{
279
 
        DEVCB_LINE(paso1600_set_int_line),
280
 
        DEVCB_LINE_GND,
281
 
        DEVCB_NULL
282
 
};
283
 
 
284
 
static MACHINE_START(paso1600)
285
 
{
286
 
        paso1600_state *state = machine.driver_data<paso1600_state>();
287
 
 
288
 
        state->m_char_rom = machine.region("pcg")->base();
289
 
        state->m_mc6845 = machine.device<mc6845_device>("crtc");
290
 
        device_set_irq_callback(machine.device("maincpu"), paso1600_irq_callback);
291
 
}
292
 
 
293
 
 
294
 
static MACHINE_RESET(paso1600)
295
 
{
296
 
}
297
 
 
298
 
static READ8_HANDLER( pc_dma_read_byte )
299
 
{
300
 
//  paso1600_state *state = space->machine().driver_data<paso1600_state>();
301
 
        //offs_t page_offset = (((offs_t) state->m_dma_offset[0][state->m_dma_channel]) << 16)
302
 
        //  & 0xFF0000;
303
 
 
304
 
        return space->read_byte(0 + offset);
305
 
}
306
 
 
307
 
 
308
 
static WRITE8_HANDLER( pc_dma_write_byte )
309
 
{
310
 
//  paso1600_state *state = space->machine().driver_data<paso1600_state>();
311
 
        //offs_t page_offset = (((offs_t) state->m_dma_offset[0][state->m_dma_channel]) << 16)
312
 
        //  & 0xFF0000;
313
 
 
314
 
        space->write_byte(0 + offset, data);
315
 
}
316
 
 
317
 
static I8237_INTERFACE( paso1600_dma8237_interface )
318
 
{
319
 
        DEVCB_NULL,
320
 
        DEVCB_NULL,
321
 
        DEVCB_MEMORY_HANDLER("maincpu", PROGRAM, pc_dma_read_byte),
322
 
        DEVCB_MEMORY_HANDLER("maincpu", PROGRAM, pc_dma_write_byte),
323
 
        { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
324
 
        { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
325
 
        { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }
326
 
};
327
 
 
328
 
 
329
 
static MACHINE_CONFIG_START( paso1600, paso1600_state )
330
 
        /* basic machine hardware */
331
 
        MCFG_CPU_ADD("maincpu", I8086, 16000000/2)
332
 
        MCFG_CPU_PROGRAM_MAP(paso1600_map)
333
 
        MCFG_CPU_IO_MAP(paso1600_io)
334
 
 
335
 
        MCFG_MACHINE_START(paso1600)
336
 
        MCFG_MACHINE_RESET(paso1600)
337
 
 
338
 
        MCFG_PIC8259_ADD( "pic8259", paso1600_pic8259_config )
339
 
        MCFG_I8237_ADD("8237dma", 16000000/4, paso1600_dma8237_interface)
340
 
 
341
 
        /* video hardware */
342
 
        MCFG_SCREEN_ADD("screen", RASTER)
343
 
        MCFG_SCREEN_REFRESH_RATE(50)
344
 
        MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
345
 
        MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
346
 
        MCFG_SCREEN_SIZE(640, 480)
347
 
        MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1)
348
 
        MCFG_SCREEN_UPDATE(paso1600)
349
 
 
350
 
        MCFG_MC6845_ADD("crtc", H46505, 16000000/4, mc6845_intf)        /* unknown clock, hand tuned to get ~60 fps */
351
 
 
352
 
        MCFG_GFXDECODE(paso1600)
353
 
        MCFG_PALETTE_LENGTH(8)
354
 
//  MCFG_PALETTE_INIT(black_and_white)
355
 
 
356
 
        MCFG_VIDEO_START(paso1600)
357
 
MACHINE_CONFIG_END
358
 
 
359
 
ROM_START( paso1600 )
360
 
        ROM_REGION16_LE(0x2000,"ipl", 0)
361
 
        ROM_LOAD( "ipl.rom", 0x0000, 0x2000, CRC(cee4ebb7) SHA1(c23b30f8dc51f96c1c00e28aab61e77b50d261f0))
362
 
 
363
 
        ROM_REGION(0x2000,"pcg", ROMREGION_ERASE00)
364
 
 
365
 
        ROM_REGION( 0x800, "font", ROMREGION_ERASEFF )
366
 
        ROM_LOAD( "font.rom", 0x0000, 0x0800, BAD_DUMP CRC(a91c45a9) SHA1(a472adf791b9bac3dfa6437662e1a9e94a88b412)) //stolen from pasopia7
367
 
 
368
 
        ROM_REGION( 0x20000, "kanji", ROMREGION_ERASEFF )
369
 
        ROM_LOAD( "kanji.rom", 0x0000, 0x20000, NO_DUMP)
370
 
 
371
 
ROM_END
372
 
 
373
 
 
374
 
/*    YEAR  NAME        PARENT  COMPAT   MACHINE    INPUT    INIT    COMPANY           FULLNAME       FLAGS */
375
 
COMP ( 198?,paso1600,   0,          0,       paso1600,  paso1600, 0,    "Toshiba",  "Pasopia 1600" , GAME_NOT_WORKING|GAME_NO_SOUND)