r8645 Tuesday 27th July, 2010 at 22:06:14 UTC by Angelo Salese
[BASIC MASTER LV3]: Added attribute ram latch and documented keyboard scancoding
[src/mess/drivers]bml3.c

src/mess/drivers/bml3.c
r8644r8645
1010#include "cpu/m6809/m6809.h"
1111#include "video/mc6845.h"
1212
13static UINT8 *work_ram;
1413static UINT16 cursor_addr,cursor_raster;
14static UINT8 attr_latch;
1515
1616static VIDEO_START( bml3 )
1717{
r8644r8645
2222   int x,y,count;
2323   int xi,yi;
2424   static UINT8 *gfx_rom = memory_region(screen->machine, "char");
25   static UINT8 *vram = memory_region(screen->machine, "vram");
2526
26   count = 0x0400;
27   count = 0x0000;
2728
2829   for(y=0;y<25;y++)
2930   {
3031      for(x=0;x<40;x++)
3132      {
32         int pen_b = work_ram[count+0x0000];
33         int pen_r = work_ram[count+0x0000];
34         int pen_g = work_ram[count+0x0000];
33         int tile = vram[count+0x0000];
34         int color = vram[count+0x4000] & 7;
35         //attr & 0x10 is used ... bitmap mode? (apparently bits 4 and 7 are used for that)
3536
3637         for(yi=0;yi<8;yi++)
3738         {
3839            for(xi=0;xi<8;xi++)
3940            {
40               int pen[3],color;
41               int pen;
4142
42               pen[0] = (gfx_rom[pen_b*8+yi] >> (7-xi) & 1) ? 1 : 0;
43               pen[1] = (gfx_rom[pen_r*8+yi] >> (7-xi) & 1) ? 2 : 0;
44               pen[2] = (gfx_rom[pen_g*8+yi] >> (7-xi) & 1) ? 4 : 0;
43               pen = (gfx_rom[tile*8+yi] >> (7-xi) & 1) ? color : 0;
4544
46               color = (pen[0]) | (pen[1]) | (pen[2]);
47
48               *BITMAP_ADDR16(bitmap, y*8+yi, x*8+xi) = screen->machine->pens[color];
45               *BITMAP_ADDR16(bitmap, y*8+yi, x*8+xi) = screen->machine->pens[pen];
4946            }
5047         }
5148
52         if(cursor_addr == count)
49         if(cursor_addr-0x400 == count)
5350         {
5451            int xc,yc,cursor_on;
5552
r8644r8645
103100   }
104101}
105102
103/*
104Keyboard scancode table (notice that we're using Sharp X1 char, so some bits might be different):
1050x00: right or space
1060x01: up
1070x02: ?
1080x03: left
1090x04: down
1100x05: right or space
1110x06
1120x07: (changes the items at the bottom, caps lock?)
1130x08
1140x09
1150x0a
1160x0b
1170x0c
1180x0d: 8
1190x0e: 9
1200x0f: *
1210x10: 7
1220x11: 4
1230x12: 6
1240x13: 8
1250x14: 0
1260x15: ^
1270x16: -
1280x17: 3
1290x18: backspace
1300x19: 5
1310x1a: 1
1320x1b: 2
1330x1c: 9
1340x1d: 7
1350x1e: backspace
1360x1f: Yen symbol?
1370x20: U
1380x21: R
1390x22: Y
1400x23: I
1410x24: P
1420x25: [
1430x26: @
1440x27: 0
1450x28: Q
1460x29: T
1470x2a: W
1480x2b: E
1490x2c: O
1500x2d: .
1510x2e: HOME
1520x2f: ENTER
1530x30: J
1540x31: F
1550x32: H
1560x33: K
1570x34: ;
1580x35: ]
1590x36: :
1600x37: 4
1610x38: A
1620x39: G
1630x3a: S
1640x3b: D
1650x3c: L
1660x3d: 5
1670x3e: 6
1680x3f: -
1690x40: M
1700x41: V
1710x42: N
1720x43: ,
1730x44: /
1740x45: /
1750x46: _
1760x47: 1
1770x48: Z
1780x49: B
1790x4a: X
1800x4b: C
1810x4c: .
1820x4d: 2
1830x4e: 3
1840x4f: +
1850x50: PF1
1860x51: PF2
1870x52: PF3
1880x53: PF4
1890x54: PF5
1900x55-0x7f: unused
191*/
192
193static READ8_HANDLER( bml3_keyboard_r )
194{
195   static int scancode;
196
197   if(input_code_pressed_once(space->machine, KEYCODE_Z))
198      scancode++;
199
200   if(input_code_pressed_once(space->machine, KEYCODE_X))
201      scancode--;
202
203   popmessage("%02x",scancode);
204
205   return scancode | 0x80;
206}
207
106208/* Note: this custom code is there just for simplicity, it'll be nuked in the end */
107209static READ8_HANDLER( bml3_io_r )
108210{
109211   static UINT8 *rom = memory_region(space->machine, "maincpu");
110212
111   if(offset < 0xc0)
213   if(offset == 0xc8) //???
214      return 0;
215
216   if(offset == 0xc9)
217      return 0x11; //put 320 x 200 mode
218
219   if(offset == 0xe0) return bml3_keyboard_r(space,0);
220
221//   if(offset == 0xcb || offset == 0xc4)
222
223//   if(offset == 0x40 || offset == 0x42 || offset == 0x44 || offset == 0x46)
224
225
226   if(offset < 0xf0)
112227   {
113228      logerror("I/O read [%02x] at PC=%04x\n",offset,cpu_get_pc(space->cpu));
114229      return 0;
115230   }
116231
117   if(offset == 0xc8) //this seems the keyboard status
118      return 0;
119
120   if(offset == 0xc9)
121      return 0x11; //put 320 x 200 mode
122
123232   /* TODO: pretty sure that there's a bankswitch for this */
124233   return rom[offset+0xff00];
125234}
r8644r8645
127236static WRITE8_HANDLER( bml3_io_w )
128237{
129238   if(offset == 0xc6 || offset == 0xc7) { bml3_6845_w(space,offset-0xc6,data); }
239   else if(offset == 0xd8)             { attr_latch = data; }
130240   else
131241   {
132242      logerror("I/O write %02x -> [%02x] at PC=%04x\n",data,offset,cpu_get_pc(space->cpu));
133243   }
134244}
135245
246static READ8_HANDLER( bml3_vram_r )
247{
248   static UINT8 *vram = memory_region(space->machine, "vram");
249
250   /* TODO: this presumably also triggers an attr latch read */
251
252   return vram[offset];
253}
254
255static WRITE8_HANDLER( bml3_vram_w )
256{
257   static UINT8 *vram = memory_region(space->machine, "vram");
258
259   vram[offset] = data;
260   vram[offset+0x4000] = attr_latch;
261}
262
136263static ADDRESS_MAP_START(bml3_mem, ADDRESS_SPACE_PROGRAM, 8)
137264   ADDRESS_MAP_UNMAP_HIGH
138   AM_RANGE(0x0000, 0x9fff) AM_RAM AM_BASE(&work_ram)
265   AM_RANGE(0x0000, 0x03ff) AM_RAM
266   AM_RANGE(0x0400, 0x43ff) AM_READWRITE(bml3_vram_r,bml3_vram_w)
267   AM_RANGE(0x4400, 0x9fff) AM_RAM
139268   AM_RANGE(0xff00, 0xffff) AM_READWRITE(bml3_io_r,bml3_io_w)
140269   AM_RANGE(0xa000, 0xffff) AM_ROM
141270ADDRESS_MAP_END
r8644r8645
164293   NULL      /* update address callback */
165294};
166295
296static INTERRUPT_GEN( bml3_irq )
297{
298   cputag_set_input_line(device->machine, "maincpu", M6809_IRQ_LINE, HOLD_LINE);
299}
167300
301static PALETTE_INIT( bml3 )
302{
303   int i;
304
305   for(i=0;i<8;i++)
306      palette_set_color_rgb(machine, i, pal1bit(i >> 1),pal1bit(i >> 2),pal1bit(i >> 0));
307}
308
309
168310static MACHINE_DRIVER_START( bml3 )
169311    /* basic machine hardware */
170312    MDRV_CPU_ADD("maincpu",M6809, XTAL_1MHz)
171313    MDRV_CPU_PROGRAM_MAP(bml3_mem)
314   MDRV_CPU_VBLANK_INT("screen", bml3_irq )
172315
173316    MDRV_MACHINE_RESET(bml3)
174317
r8644r8645
180323    MDRV_SCREEN_SIZE(640, 480)
181324    MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1)
182325    MDRV_PALETTE_LENGTH(8)
326   MDRV_PALETTE_INIT(bml3)
183327
184328   MDRV_MC6845_ADD("crtc", H46505, XTAL_3_579545MHz/4, mc6845_intf)   /* unknown clock, hand tuned to get ~60 fps */
185329
r8644r8645
195339    ROM_REGION( 0x800, "char", 0 )
196340   ROM_LOAD("char.rom", 0x00000, 0x00800, BAD_DUMP CRC(e3995a57) SHA1(1c1a0d8c9f4c446ccd7470516b215ddca5052fb2) ) //Taken from Sharp X1
197341   ROM_FILL( 0x0000, 0x0008, 0x00)
342
343    ROM_REGION( 0x8000, "vram", ROMREGION_ERASEFF )
198344ROM_END
199345
200346/* Driver */

Previous 509070 RevisionsNext 50


© 1998-2010 The MESS Team