Previous 15994 Revisions Next

r5981 Tuesday 6th October, 2009 at 05:52:28 UTC by Barry Rodewald
[FMTOWNS] Added serial ROM interface, and fake serial ROM data.
[src/mess/drivers]fmtowns.c

src/mess/drivers/fmtowns.c
r5980r5981
105105static UINT8 towns_kanji_code_h;
106106static UINT8 towns_kanji_code_l;
107107static int towns_selected_drive;
108static UINT8* towns_serial_rom;
109static int towns_srom_position;
110static UINT8 towns_srom_clk;
111static UINT8 towns_srom_reset;
108112
109113static void towns_update_video_banks(const address_space* space);
110114
115static void towns_init_serial_rom(void)
116{
117   // TODO: init serial ROM contents
118   int x,y;
119   char code[7] = "USTIJUF";
120   memset(towns_serial_rom,0,256/8);
121   
122   for(x=72;x<=194;x++)  // set these bits to 1
123      towns_serial_rom[x/8] |= (1 << (x%8));
124   
125   y=0;
126   for(x=195;x<=251;x++)
127   {
128      if(code[y/8] & (1 << (y % 8)))
129         towns_serial_rom[x/8] |= (1 << (x%8));
130   }
131   
132   // add Machine ID
133   towns_serial_rom[7] = 0x01;
134   towns_serial_rom[8] = 0x01;
135   
136   // serial number?
137   towns_serial_rom[2] = 0x10;
138   towns_serial_rom[3] = 0x6e;
139   towns_serial_rom[4] = 0x54;
140   towns_serial_rom[5] = 0x32;
141   towns_serial_rom[6] = 0x10;
142}
143
111144static READ8_HANDLER(towns_system_r)
112145{
146   UINT8 ret = 0;
147   
113148   switch(offset)
114149   {
115150      case 0x00:
r5980r5981
119154         logerror("SYS: port 0x25 read\n");
120155         return 0x00;
121156      case 0x06:
122         logerror("SYS: (0x26) timer read\n");
157         //logerror("SYS: (0x26) timer read\n");
123158         ftimer -= 0x13;
124159         return ftimer;
125160      case 0x08:
r5980r5981
132167         logerror("SYS: (0x31) Machine ID read\n");
133168         return 0x01;
134169      case 0x12:
135         logerror("SYS: (0x32) Serial(?) read\n");
136         return 0x00;
170         /* Bit 0 = data, bit 6 = CLK, bit 7 = RESET, bit 5 is always 1? */
171         ret = (towns_serial_rom[towns_srom_position/8] & (1 << (towns_srom_position%8))) ? 1 : 0;
172         ret |= towns_srom_clk;
173         ret |= towns_srom_reset;
174         //logerror("SYS: (0x32) Serial ROM read [0x%02x, pos=%i]\n",ret,towns_srom_position);
175         return ret;
137176      default:
138         logerror("SYS: Unknown system port read (0x%02x)\n",offset);
177         //logerror("SYS: Unknown system port read (0x%02x)\n",offset+0x20);
139178         return 0x00;
140179   }
141180}
r5980r5981
155194         nmi_mask = data & 0x01;
156195         break;
157196      case 0x12:
158         logerror("SYS: (0x32) Serial(?) write %02x\n",data);
197         //logerror("SYS: (0x32) Serial ROM write %02x\n",data);
198         // clocks on low-to-high transition
199         if((data & 0x40) && towns_srom_clk == 0) // CLK
200         {  // advance to next bit
201            towns_srom_position++;
202         }
203         if((data & 0x80) && towns_srom_reset == 0) // reset
204         {  // reset to beginning
205            towns_srom_position = 0;
206         }         
207         towns_srom_clk = data & 0x40;
208         towns_srom_reset = data & 0x80;
159209         break;
160210      default:
161211         logerror("SYS: Unknown system port write 0x%02x (0x%02x)\n",data,offset);
r5980r5981
244294      case 0x06:
245295         return wd17xx_data_r(fdc,offset/2);
246296      case 0x08:  // selected drive status?
247         logerror("FDC: read from offset 0x08\n");
297         //logerror("FDC: read from offset 0x08\n");
248298         if(towns_selected_drive < 1 || towns_selected_drive > 2)
249299            return 0x01;
250300         else
r5980r5981
285335         // bit 5 - CLKSEL
286336         if(data & 0x10)
287337         {
288            if(towns_selected_drive != 0)
338            if(towns_selected_drive != 0 && towns_selected_drive < 2)
289339            {
290340               floppy_drive_set_motor_state(floppy_get_device(space->machine, towns_selected_drive-1), data & 0x10);
291341               floppy_drive_set_ready_state(floppy_get_device(space->machine, towns_selected_drive-1), data & 0x10,0);
r5980r5981
753803   }
754804}
755805
806static READ8_HANDLER(towns_unknown_r)
807{
808   return 0x08;
809}
810
756811static ADDRESS_MAP_START(towns_mem, ADDRESS_SPACE_PROGRAM, 32)
757812  // memory map based on FM-Towns/Bochs (Bochs modified to emulate the FM-Towns)
758813  // may not be (and probably is not) correct
r5980r5981
822877  AM_RANGE(0x05e8,0x05ef) AM_READWRITE(towns_sys5e8_r, towns_sys5e8_w)
823878  // Keyboard (8042 MCU)
824879  AM_RANGE(0x0600,0x0607) AM_READWRITE8(towns_keyboard_r, towns_keyboard_w,0x00ff00ff)
880  // No idea what this is currently...
881  AM_RANGE(0x0c30,0x0c33) AM_READ8(towns_unknown_r,0x00ff0000)
825882  // CMOS
826883  AM_RANGE(0x3000,0x3fff) AM_READWRITE8(towns_cmos8_r, towns_cmos8_w,0x00ff00ff)
827884  // CRTC / Video (again)
r5980r5981
840897   towns_cmos = auto_alloc_array(machine,UINT32,0x2000/(sizeof(UINT32)));
841898   towns_gfxvram = auto_alloc_array(machine,UINT8,0x200000);
842899   towns_txtvram = auto_alloc_array(machine,UINT8,0x8000);
900   towns_serial_rom = auto_alloc_array(machine,UINT8,256/8);
901   towns_init_serial_rom();
843902}
844903
845904static MACHINE_RESET( towns )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team