Previous 15994 Revisions Next

r5284 Monday 20th July, 2009 at 20:43:34 UTC by Miodrag Milanović
[PK8020] It boots but video still bad
[src/mess/drivers]pk8020.c
[src/mess/includes]pk8020.h
[src/mess/machine]pk8020.c
[src/mess/video]pk8020.c

src/mess/video/pk8020.c
r5283r5284
3939*/
4040
4141   for (y = 0; y < 16; y++)
42            {
43               for (x = 0; x < 64; x++)
44               {
45                  UINT8 chr = mess_ram[x +(y*64) + 0x20000] ;
46                  for (j = 0; j < 16; j++) {
47                     UINT8 code = gfx[((chr<<4) + j)];
48                     for (b = 0; b < 8; b++)
49                     {                       
50                        UINT8 col = ((code >> b) & 0x01) ? 0x0f : 0x00;
51                        *BITMAP_ADDR16(bitmap, (y*16)+j, x*8+(7-b)) =  col;
52                     }
53                  }
54               }
42   {
43      for (x = 0; x < 64; x++)
44      {
45         UINT8 chr = mess_ram[x +(y*64) + 0x20000] ;
46         for (j = 0; j < 16; j++) {
47            UINT8 code = gfx[((chr<<4) + j)];
48            for (b = 0; b < 8; b++)
49            {                       
50               UINT8 col = ((code >> b) & 0x01) ? ((pk8020_color >> 4)& 0xf)^ 0x0f : ((pk8020_color >> 1) & 0x07);
51               *BITMAP_ADDR16(bitmap, (y*16)+j, x*8+(7-b)) =  col;
5552            }
53         }
54      }
55   }
5656   return 0;
5757}
5858
src/mess/includes/pk8020.h
r5283r5284
77#ifndef PK8020_H_
88#define PK8020_H_
99
10#include "machine/i8255a.h"
11#include "machine/pit8253.h"
12#include "machine/pic8259.h"
13#include "machine/msm8251.h"
14#include "machine/wd17xx.h"
15#include "devices/basicdsk.h"
1016
1117/*----------- defined in machine/pk8020.c -----------*/
12
18extern UINT8 pk8020_color;
1319extern DRIVER_INIT( pk8020 );
1420extern MACHINE_RESET( pk8020 );
15
21extern const i8255a_interface pk8020_ppi8255_interface_1;
22extern const i8255a_interface pk8020_ppi8255_interface_2;
23extern const i8255a_interface pk8020_ppi8255_interface_3;
24extern const struct pit8253_config pk8020_pit8253_intf;
25extern const struct pic8259_interface pk8020_pic8259_config;
26extern DEVICE_IMAGE_LOAD( pk8020_floppy );
27extern INTERRUPT_GEN( pk8020_interrupt );
1628/*----------- defined in video/pk8020.c -----------*/
1729
1830extern PALETTE_INIT( pk8020 );
src/mess/machine/pk8020.c
r5283r5284
99
1010#include "driver.h"
1111#include "cpu/i8085/i8085.h"
12#include "machine/i8255a.h"
13
1412#include "includes/pk8020.h"
1513
16static UINT8 vpage =0;
14static UINT8 vpage = 0;
15static UINT8 attr = 0;
16static UINT8 takt = 0;
17UINT8 pk8020_color = 0;
1718
1819static void pk8020_set_bank(running_machine *machine,UINT8 data);
1920
2021/* Driver initialization */
2122DRIVER_INIT(pk8020)
2223{
23   memset(mess_ram,0,130*1024);
24   memset(mess_ram,0,129*1024);
2425}
2526
2627static READ8_HANDLER(keyboard_r)
r5283r5284
4748   line++;
4849   if (offset & 0x0080) retVal|=input_port_read(space->machine,keynames[line]);
4950   line++;
50   logerror("keyboard_r :%04x %02x\n",offset,retVal);
5151   return retVal;
5252}
5353
5454static READ8_HANDLER(sysreg_r)
5555{
56   logerror("sysreg_r %02x\n",offset);
5657   return 0xff;
5758}
5859static WRITE8_HANDLER(sysreg_w)
r5283r5284
6263      pk8020_set_bank(space->machine,data >> 2);
6364   } else if (BIT(offset,6)==0) {
6465      // Color
66      pk8020_color = data;
6567   } else if (BIT(offset,2)==0) {
66      // LED
68      // Palette set
69      UINT8 number = data & 0x0f;
70      UINT8 color = data >> 4;
71      UINT8 i = (color & 0x08) ?  0x3F : 0;
72      UINT8 r = ((color & 0x04) ? 0xC0 : 0) + i;
73      UINT8 g = ((color & 0x02) ? 0xC0 : 0) + i;
74      UINT8 b = ((color & 0x01) ? 0xC0 : 0) + i;               
75      palette_set_color( space->machine, number, MAKE_RGB(r,g,b) );
6776   }
6877}
6978
7079static READ8_HANDLER(text_r)
7180{
72   return mess_ram[0x20000+offset];
81   return mess_ram[0x20000+offset];   
7382}
7483
7584static WRITE8_HANDLER(text_w)
7685{
77//   logerror("text_w %02x %02x\n",offset,data);
7886   mess_ram[0x20000+offset] = data;
7987}
8088
r5283r5284
8391   const device_config *ppi1 = devtag_get_device(space->machine, "ppi8255_1");
8492   const device_config *ppi2 = devtag_get_device(space->machine, "ppi8255_2");
8593   const device_config *ppi3 = devtag_get_device(space->machine, "ppi8255_3");
86   logerror("devices_r %02x\n",offset);
94   const device_config *pit = devtag_get_device(space->machine, "pit8253");
95   const device_config *pic = devtag_get_device(space->machine, "pic8259");
96   const device_config *rs232 = devtag_get_device(space->machine, "rs232");
97   const device_config *lan = devtag_get_device(space->machine, "lan");
98   const device_config *fdc = devtag_get_device(space->machine, "wd1793");   
8799   switch(offset & 0x38)
88100   {
101      case 0x00:
102      case 0x18:
103      case 0x20:
104      case 0x28:
105      case 0x38:
106         //logerror("devices_r %02x %04x\n",offset,cpu_get_pc(space->cpu));
107         break;
108   }
109   
110   switch(offset & 0x38)
111   {
112      case 0x00: return pit8253_r(pit,offset & 3);
89113      case 0x08: return i8255a_r(ppi3,offset & 3);
114      case 0x10: switch(offset & 1) {
115                  case 0 : return msm8251_data_r(rs232,0);
116                     case 1 : return msm8251_status_r(rs232,0);
117               }
118               break;     
119      case 0x18: switch(offset & 3) {
120                  case 0 : return wd17xx_status_r(fdc,0);
121                  case 1 : return wd17xx_track_r(fdc,0);
122                  case 2 : return wd17xx_sector_r(fdc,0);
123                  case 3 : return wd17xx_data_r(fdc,0);
124               }
125               break;
126      case 0x20: switch(offset & 1) {
127                  case 0 : return msm8251_data_r(lan,0);
128                     case 1 : return msm8251_status_r(lan,0);
129               }
130               break;     
131      case 0x28: return pic8259_r(pic,offset & 1);
90132      case 0x30: return i8255a_r(ppi2,offset & 3);
91133      case 0x38: return i8255a_r(ppi1,offset & 3);
92           
93/*      case 0x00:   Timer_Write(Addres,Value);break; //xx00..03
94        case 0x08:   PPI3_Write (Addres,Value);break; //xx08..0B
95        case 0x10:   RS232_Write(Addres,Value);break; //xx10..11
96        case 0x18:   FDC_Write  (Addres,Value);break; //xx18..1B
97        case 0x20:   LAN_Write  (Addres,Value);break; //xx20..21
98        case 0x28:   PIC_Write  (Addres,Value);break; //xx28..29
99        case 0x30:   PPI2_Write (Addres,Value);break; //xx30..33
100        case 0x38:   PPI1_Write (Addres,Value);break; //xx38..3B*/
101134   }
102135   return 0xff;
103136}
r5283r5284
107140   const device_config *ppi1 = devtag_get_device(space->machine, "ppi8255_1");
108141   const device_config *ppi2 = devtag_get_device(space->machine, "ppi8255_2");
109142   const device_config *ppi3 = devtag_get_device(space->machine, "ppi8255_3");
110   logerror("devices_w %02x %02x\n",offset,data);
143   const device_config *pit = devtag_get_device(space->machine, "pit8253");
144   const device_config *pic = devtag_get_device(space->machine, "pic8259");
145   const device_config *rs232 = devtag_get_device(space->machine, "rs232");
146   const device_config *lan = devtag_get_device(space->machine, "lan");
147   const device_config *fdc = devtag_get_device(space->machine, "wd1793");
111148   switch(offset & 0x38)
112149   {
113      case 0x08: i8255a_w(ppi3,offset & 3,data); return;
114      case 0x30: i8255a_w(ppi2,offset & 3,data); return;
115      case 0x38: i8255a_w(ppi1,offset & 3,data); return;
116           
117/*      case 0x00:   Timer_Write(Addres,Value);break; //xx00..03
118        case 0x08:   PPI3_Write (Addres,Value);break; //xx08..0B
119        case 0x10:   RS232_Write(Addres,Value);break; //xx10..11
120        case 0x18:   FDC_Write  (Addres,Value);break; //xx18..1B
121        case 0x20:   LAN_Write  (Addres,Value);break; //xx20..21
122        case 0x28:   PIC_Write  (Addres,Value);break; //xx28..29
123        case 0x30:   PPI2_Write (Addres,Value);break; //xx30..33
124        case 0x38:   PPI1_Write (Addres,Value);break; //xx38..3B*/
150      case 0x00:
151      case 0x18:
152      case 0x20:
153      case 0x28:
154      case 0x38:
155         //logerror("devices_w %02x %02x %04x\n",offset,data,cpu_get_pc(space->cpu));
156         break;
125157   }
158   
159   switch(offset & 0x38)
160   {
161      case 0x00: pit8253_w(pit,offset & 3,data); break;
162      case 0x08: i8255a_w(ppi3,offset & 3,data); break;
163      case 0x10: switch(offset & 1) {
164                  case 0 : msm8251_data_w(rs232,0,data); break;
165                     case 1 : msm8251_control_w(rs232,0,data); break;
166               }
167               break;         
168      case 0x18: switch(offset & 3) {
169                  case 0 : wd17xx_command_w(fdc,0,data);
170                  case 1 : wd17xx_track_w(fdc,0,data);
171                  case 2 : wd17xx_sector_w(fdc,0,data);
172                  case 3 : wd17xx_data_w(fdc,0,data);
173               }
174               break;                 
175      case 0x20: switch(offset & 1) {
176                  case 0 : msm8251_data_w(lan,0,data); break;
177                     case 1 : msm8251_control_w(lan,0,data); break;
178               }
179               break;         
180      case 0x28: pic8259_w(pic,offset & 1,data);break;
181      case 0x30: i8255a_w(ppi2,offset & 3,data); break;
182      case 0x38: i8255a_w(ppi1,offset & 3,data); break;
183   }
126184}
127185
128186static void pk8020_set_bank(running_machine *machine,UINT8 data)
r5283r5284
772830               
773831   }
774832}
833
834static READ8_DEVICE_HANDLER(pk8020_porta_r)
835{   
836   return 0xf0 | (takt <<1) | (attr &1)<<3;
837}
838
839static WRITE8_DEVICE_HANDLER(pk8020_portc_w)
840{   
841   if (((data & 0x30) >> 4)==3) {
842      attr ^=1;
843   }
844}
845
846I8255A_INTERFACE( pk8020_ppi8255_interface_1 )
847{
848   DEVCB_HANDLER(pk8020_porta_r),
849   DEVCB_NULL,
850   DEVCB_NULL,
851   DEVCB_NULL,
852   DEVCB_NULL,
853   DEVCB_HANDLER(pk8020_portc_w)
854};
855static READ8_DEVICE_HANDLER(pk8020_unk_r)
856{   
857   return 0x00;
858}
859I8255A_INTERFACE( pk8020_ppi8255_interface_2 )
860{
861   DEVCB_HANDLER(pk8020_unk_r),
862   DEVCB_HANDLER(pk8020_unk_r),
863   DEVCB_HANDLER(pk8020_unk_r),
864   DEVCB_NULL,
865   DEVCB_NULL,
866   DEVCB_NULL
867};
868
869I8255A_INTERFACE( pk8020_ppi8255_interface_3 )
870{
871   DEVCB_NULL,
872   DEVCB_NULL,
873   DEVCB_NULL,
874   DEVCB_NULL,
875   DEVCB_NULL,
876   DEVCB_NULL
877};
878
879static PIT8253_OUTPUT_CHANGED(pk8020_pit_out0)
880{
881   // beep   
882}
883
884
885static PIT8253_OUTPUT_CHANGED(pk8020_pit_out1)
886{
887}
888
889static PIT8253_OUTPUT_CHANGED(pk8020_pit_out2)
890{   
891   pic8259_set_irq_line(devtag_get_device(device->machine, "pic8259"),5,state);
892}
893
894
895const struct pit8253_config pk8020_pit8253_intf =
896{
897   {
898      {
899         XTAL_20MHz / 10,
900         pk8020_pit_out0
901      },
902      {
903         XTAL_20MHz / 10,
904         pk8020_pit_out1
905      },
906      {
907         (XTAL_20MHz / 8) / 164,
908         pk8020_pit_out2
909      }
910   }
911};
912
913static PIC8259_SET_INT_LINE( pk8020_pic_set_int_line )
914{     
915   cputag_set_input_line(device->machine, "maincpu", 0, interrupt ?  HOLD_LINE : CLEAR_LINE); 
916}
917
918const struct pic8259_interface pk8020_pic8259_config = {
919   pk8020_pic_set_int_line
920};
921
922static IRQ_CALLBACK(pk8020_irq_callback)
923{   
924   return pic8259_acknowledge(devtag_get_device(device->machine, "pic8259"));
925}
926
775927MACHINE_RESET( pk8020 )
776928{
777929   pk8020_set_bank(machine,0);
930   cpu_set_irq_callback(cputag_get_cpu(machine, "maincpu"), pk8020_irq_callback);
778931}
932
933DEVICE_IMAGE_LOAD( pk8020_floppy )
934{
935   int size;
936
937   if (! image_has_been_created(image))
938      {
939      size = image_length(image);
940
941      switch (size)
942         {
943         case 800*1024:
944            break;
945         default:
946            return INIT_FAIL;
947         }
948      }
949   else
950      return INIT_FAIL;
951
952   if (device_load_basicdsk_floppy (image) != INIT_PASS)
953      return INIT_FAIL;
954
955   basicdsk_set_geometry (image, 80, 2, 5, 1024, 1, 0, FALSE);   
956   return INIT_PASS;
957}
958INTERRUPT_GEN( pk8020_interrupt )
959{
960   takt ^= 1;
961}
962
src/mess/drivers/pk8020.c
r5283r5284
135135      PORT_BIT(0xFF, IP_ACTIVE_HIGH, IPT_UNUSED)
136136INPUT_PORTS_END
137137
138static I8255A_INTERFACE( pk8020_ppi8255_interface_1 )
139{
140   DEVCB_NULL,
141   DEVCB_NULL,
142   DEVCB_NULL,
143   DEVCB_NULL,
144   DEVCB_NULL,
145   DEVCB_NULL
146};
147
148static I8255A_INTERFACE( pk8020_ppi8255_interface_2 )
149{
150   DEVCB_NULL,
151   DEVCB_NULL,
152   DEVCB_NULL,
153   DEVCB_NULL,
154   DEVCB_NULL,
155   DEVCB_NULL
156};
157
158static I8255A_INTERFACE( pk8020_ppi8255_interface_3 )
159{
160   DEVCB_NULL,
161   DEVCB_NULL,
162   DEVCB_NULL,
163   DEVCB_NULL,
164   DEVCB_NULL,
165   DEVCB_NULL
166};
167
168138/* Machine driver */
169139static MACHINE_DRIVER_START( pk8020 )
170140  /* basic machine hardware */
171141   MDRV_CPU_ADD("maincpu", 8080, XTAL_20MHz / 8)
172142   MDRV_CPU_PROGRAM_MAP(pk8020_mem)
173143   MDRV_CPU_IO_MAP(pk8020_io)
144   MDRV_CPU_VBLANK_INT("screen", pk8020_interrupt)
174145
175146   MDRV_MACHINE_RESET( pk8020 )
176147
r5283r5284
190161    MDRV_I8255A_ADD( "ppi8255_1", pk8020_ppi8255_interface_1 )
191162    MDRV_I8255A_ADD( "ppi8255_2", pk8020_ppi8255_interface_2 )   
192163    MDRV_I8255A_ADD( "ppi8255_3", pk8020_ppi8255_interface_3 )
164   
165    MDRV_PIT8253_ADD( "pit8253", pk8020_pit8253_intf )
166
167   MDRV_PIC8259_ADD( "pic8259", pk8020_pic8259_config )   
168   MDRV_MSM8251_ADD( "rs232", default_msm8251_interface)
169   MDRV_MSM8251_ADD( "lan", default_msm8251_interface)
170   
171   MDRV_WD1793_ADD( "wd1793", default_wd17xx_interface )   
193172MACHINE_DRIVER_END
194173
174 static void pk8020_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
175{
176   /* floppy */
177   switch(state)
178   {
179      /* --- the following bits of info are returned as 64-bit signed integers --- */
180      case MESS_DEVINFO_INT_COUNT:                     info->i = 4; break;
181
182      /* --- the following bits of info are returned as pointers to data or functions --- */
183      case MESS_DEVINFO_PTR_LOAD:                     info->load = device_load_pk8020_floppy; break;
184
185      /* --- the following bits of info are returned as NULL-terminated strings --- */
186      case MESS_DEVINFO_STR_FILE_EXTENSIONS:            strcpy(info->s = device_temp_str(), "kdi"); break;
187
188      default:                              legacybasicdsk_device_getinfo(devclass, state, info); break;
189   }   
190}
191
195192/* ROM definition */
196193
197194ROM_START( korvet )
r5283r5284
202199ROM_END
203200
204201static SYSTEM_CONFIG_START(pk8020)
205    CONFIG_RAM_DEFAULT((128 +2) * 1024)
202    CONFIG_RAM_DEFAULT((128 + 1) * 1024)
203    CONFIG_DEVICE(pk8020_floppy_getinfo);
206204SYSTEM_CONFIG_END
207205
208206/* Driver */
209207
210208/*    YEAR  NAME    PARENT  COMPAT  MACHINE     INPUT       INIT     CONFIG COMPANY                  FULLNAME   FLAGS */
211COMP( 1987, korvet,     0,      0,   pk8020,    pk8020,    pk8020, pk8020,  "",                 "PK-8020 Korvet",    GAME_NOT_WORKING)
209COMP( 1987, korvet,     0,      0,   pk8020,    pk8020,    pk8020, pk8020,  "",                 "PK8020 Korvet",    GAME_NOT_WORKING)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team