Previous 15994 Revisions Next

r13914 Saturday 7th January, 2012 at 12:01:29 UTC by Wilbert Pol
rm380z: Split into driver, machine, and video files.
[src/mess]mess.mak
[src/mess/drivers]rm380z.c
[src/mess/includes]rm380z.h*
[src/mess/machine]rm380z.c*
[src/mess/video]rm380z.c*

src/mess/machine/rm380z.c
r0r13914
1
2/* 
3
4RM 380Z machine
5
6*/
7
8#include "emu.h"
9#include "cpu/z80/z80.h"
10#include "machine/ram.h"
11#include "imagedev/flopdrv.h"
12#include "machine/terminal.h"
13#include "machine/wd17xx.h"
14#include "includes/rm380z.h"
15
16
17WRITE8_MEMBER( rm380z_state::port_write )
18{
19   switch ( offset )
20   {
21   case 0x00:      // PORT0
22      //printf("write of [%x] to FBFC\n",data);
23      m_port0 = data;
24      if (data&0x01)
25      {
26         //printf("WARNING: bit0 of port0 reset\n");
27         m_port0_kbd=0;
28      }
29      config_memory_map();
30      break;
31
32   case 0x01:      // screen line counter (?)
33      printf("write of [%x] to FBFD at PC [%x]\n",data,cpu_get_pc(machine().device("maincpu")));
34      m_fbfd=data;
35      break;
36
37   case 0x02:      // something related to screen position
38      //printf("write of [%x] to FBFE\n",data);
39      m_fbfe=data;
40      break;
41
42   case 0x03:      // user I/O port
43      //printf("write of [%x] to FBFF\n",data);
44      //logerror("%s: Write %02X to user I/O port\n", machine().describe_context(), data );
45      break;
46   }
47}
48
49READ8_MEMBER( rm380z_state::port_read )
50{
51   UINT8 data = 0xFF;
52
53   switch ( offset )
54   {
55   case 0x00:      // PORT0
56      //m_port0_kbd=getKeyboard();
57      data = m_port0_kbd;
58      //if (m_port0_kbd!=0) m_port0_kbd=0;
59      //m_port0_kbd=0;
60      //printf("read of port0 (kbd) at [%f] from PC [%x]\n",machine().time().as_double(),cpu_get_pc(machine().device("maincpu")));
61      break;
62 
63   case 0x01:      // "counter" (?)
64      //printf("%s: Read from counter FBFD\n", machine().describe_context());
65      data = 0x00;
66      break;
67
68   case 0x02:      // PORT1
69      data = m_port1;
70      break;
71
72   case 0x03:      // user port
73      //printf("%s: Read from user port\n", machine().describe_context());
74      break;
75   }
76
77   return data;
78}
79
80#define LINE_SUBDIVISION 40
81#define TIMER_SPEED 50*100*LINE_SUBDIVISION
82
83//
84// this simulates line+frame blanking
85// according to the System manual, "frame blanking bit (bit 6) of port1 becomes high
86// for about 4.5 milliseconds every 20 milliseconds"
87//
88
89static TIMER_CALLBACK(static_vblank_timer)
90{
91   //printf("timer callback called at [%f]\n",machine.time().as_double());
92
93   rm380z_state *state = machine.driver_data<rm380z_state>();
94   
95   state->m_rasterlineCtr++;
96   state->m_rasterlineCtr%=(100*LINE_SUBDIVISION);
97   
98   if (state->m_rasterlineCtr>=((100-22)*LINE_SUBDIVISION))
99   {
100      // frame blanking
101      state->m_port1=0x41;
102   }
103   else
104   {
105      state->m_port1=0x00;
106   }
107
108   if ((state->m_rasterlineCtr%LINE_SUBDIVISION)==0) state->m_port1|=0x80; // line blanking
109}
110
111//
112// ports c0-cf are related to the floppy disc controller
113// c0-c3: wd1771
114// c4-c8: disk drive port0
115//
116// CP/M booting:
117// from the service manual: "the B command reads a sector from drive 0, track 0, sector 1 into memory
118// at 0x0080 to 0x00FF, then jumps to it if there is no error."
119//
120
121/*
122WRITE8_MEMBER( rm380z_state::rm380z_io_w )
123{
124   UINT8 portnum=offset&0xff;
125   device_t *fdc = machine().device("wd1771");
126   
127   //printf("port write of [%x] at [%x] from PC [%x]\n",data,portnum,cpu_get_pc(machine().device("maincpu")));
128   
129   if (portnum==0xc0)
130   {
131      wd17xx_command_w(fdc, 0, data);
132      //printf("wrote command [%x] to floppy disk\n",data);
133   }
134   else if (portnum==0xc1)
135   {
136      wd17xx_track_w(fdc, 0, data);
137      //printf("wrote track data [%x] to floppy disk\n",data);
138   }
139   else if (portnum==0xc2)
140   {
141      wd17xx_sector_w(fdc, 0, data);
142      //printf("wrote sector data [%x] to floppy disk\n",data);
143   }
144   else if (portnum==0xc3)
145   {
146      wd17xx_data_w(fdc, 0, data);
147      //printf("wrote data [%x] to floppy disk\n",data);
148   }
149   else if (portnum==0xc4)
150   {
151      //printf("disk drive port0 write [%x]\n",data);
152     
153      // drive port0
154      if (data&0x01)
155      {
156         // drive select bit 0
157         wd17xx_set_drive(fdc,0);
158      }
159     
160      if (data&0x08)
161      {
162         // motor on
163      }
164     
165      // "MSEL (dir/side select bit)
166      if (data&0x20)
167      {
168         wd17xx_set_side(fdc,1);
169      }
170      else
171      {
172         wd17xx_set_side(fdc,0);
173      }
174     
175      // set drive en- (?)
176      if (data&0x40)
177      {
178      }
179   }
180}
181
182READ8_MEMBER( rm380z_state::rm380z_io_r )
183{
184   UINT8 retval=0;
185   UINT8 portnum=offset&0xff;
186   device_t *fdc = machine().device("wd1771");
187
188   //printf("port read at [%x] from PC [%x]\n",portnum,cpu_get_pc(machine().device("maincpu")));
189
190   if (portnum==0xc0)
191   {
192      retval=wd17xx_status_r(fdc,0);
193      //printf("disk drive status read is [%x]\n",retval);
194   }
195   else if (portnum==0xc1)
196   {
197      retval=wd17xx_track_r(fdc, 0);
198      //printf("disk drive track read is [%x]\n",retval);
199   }
200   else if (portnum==0xc2)
201   {
202      retval=wd17xx_sector_r(fdc, 0);
203      //printf("disk drive sector read is [%x]\n",retval);
204   }
205   else if (portnum==0xc3)
206   {
207      retval=wd17xx_data_r(fdc, 0);
208      //printf("disk drive data read [%x] at PC [%x]\n",retval,cpu_get_pc(machine().device("maincpu")));
209   }
210   else if (portnum==0xc9)
211   {
212      return 0x01;
213   }
214   else if (portnum==0xcc)
215   {
216      // CTC (?)
217      return 0x00;
218   }
219   else
220   {
221      printf("Unknown system port read [%x] PC [%x]\n",portnum,cpu_get_pc(machine().device("maincpu")));
222      return 0x00;
223   }
224
225   return retval;
226}
227*/
228
229WRITE8_MEMBER( rm380z_state::disk_0_control )
230{
231   device_t *fdc = machine().device("wd1771");
232   
233   printf("disk drive port0 write [%x]\n",data);
234   
235   // drive port0
236   if (data&0x01)
237   {
238      // drive select bit 0
239      wd17xx_set_drive(fdc,0);
240   }
241   
242   if (data&0x08)
243   {
244      // motor on
245   }
246   
247   // "MSEL (dir/side select bit)
248   if (data&0x20)
249   {
250      wd17xx_set_side(fdc,1);
251   }
252   else
253   {
254      wd17xx_set_side(fdc,0);
255   }
256   
257   // set drive en- (?)
258   if (data&0x40)
259   {
260   }
261}
262
263WRITE8_MEMBER( rm380z_state::keyboard_put )
264{
265   m_port0_kbd = data;
266}
267
268void rm380z_state::machine_reset()
269{
270   m_port0=0x00;
271   m_port0_kbd=0x00;
272   m_port1=0x00;
273   m_fbfd=0x00;
274   m_fbfe=0x00;
275   m_old_fbfd=0x00;
276   
277   m_rasterlineCtr=0;
278
279   memset(m_mainVideoram,0,0x600);   
280   memset(m_vramattribs,0,0x600);
281   memset(m_vramchars,0,0x600);
282   memset(m_vram,0,0x600);
283   
284   config_memory_map();
285
286   machine().scheduler().timer_pulse(attotime::from_hz(TIMER_SPEED), FUNC(static_vblank_timer));
287     
288   wd17xx_reset(machine().device("wd1771"));
289}
290
291void rm380z_state::config_memory_map()
292{
293   address_space *program = m_maincpu->space(AS_PROGRAM);
294   UINT8 *rom = machine().region(MAINCPU_TAG)->base();
295   UINT8* m_ram_p = m_messram->pointer();
296
297   if ( PORTS_ENABLED_HIGH )
298   {
299      program->install_ram( 0x0000, 0xDFFF, m_ram_p );
300   }
301   else
302   {
303      program->install_rom( 0x0000, 0x0FFF, rom );
304      program->install_readwrite_handler(0x1BFC, 0x1BFF,read8_delegate(FUNC(rm380z_state::port_read), this),write8_delegate(FUNC(rm380z_state::port_write), this)   );
305      program->install_rom( 0x1C00, 0x1DFF, rom + 0x1400 );
306      program->install_ram( 0x4000, 0xDFFF, m_ram_p );
307   }
308}
src/mess/video/rm380z.c
r0r13914
1
2/*
3
4RM 380Z video code
5
6*/
7
8#include "emu.h"
9#include "cpu/z80/z80.h"
10#include "machine/ram.h"
11#include "imagedev/flopdrv.h"
12#include "machine/terminal.h"
13#include "machine/wd17xx.h"
14#include "includes/rm380z.h"
15
16
17UINT8 rm380z_state::decode_videoram_char(UINT8 ch1,UINT8 ch2)
18{
19   if ((ch1>0x0f)&&(ch1<0x80))
20   {
21      return ch1;
22   }
23   else if ((ch2>0x0f)&&(ch2<0x80))
24   {
25      return ch2;
26   }
27   else if ( ((ch1==0x04)&&(ch2==0x80)) || ((ch1==0x80)&&(ch2==0x04)) )
28   {
29      // blank out ?
30      return 0x80;
31   }
32//   else if (ch1==0x80)
33//   {
34//      // blank out
35//      return 0x20;
36//   }
37   else if ((ch1==0)&&(ch2==8))
38   {
39      // cursor
40      return 0x7f;
41   }
42   else if ((ch1==0)&&(ch2==0))
43   {
44      // delete char (?)
45      return 0x20;
46   }
47   else if ((ch1==4)&&(ch2==4))
48   {
49      // reversed cursor?
50      return 0x20;
51   }
52   else if ((ch1==4)&&(ch2==8))
53   {
54      // normal cursor
55      return 0x7f;
56   }
57   else
58   {
59      //printf("unhandled character combination [%x][%x]\n",ch1,ch2);
60   }
61   
62   return 0;
63}
64
65// after ctrl-L (clear screen?): routine at EBBD is executed
66// EB30??? next line?
67// memory at FF02 seems to hold the line counter (same as FBFD)
68
69WRITE8_MEMBER( rm380z_state::videoram_write )
70{
71   rm380z_state *state = machine().driver_data<rm380z_state>();
72 
73   //printf("vramw [%x][%x] port0 [%x] fbfd [%x] PC [%x]\n",offset,data,state->m_port0,m_fbfd,cpu_get_pc(machine().device("maincpu")));
74   
75   if (m_old_fbfd>m_fbfd)
76   {
77      printf("WARN: fbfd wrapped\n");
78   }
79   m_old_fbfd=m_fbfd;
80
81   int lineAdder=(m_fbfd&0x1f)*0x40;
82   int realA=offset+lineAdder;
83
84   // we suppose videoram is being written as character/attribute couple
85   // fbfc 6th bit set=attribute, unset=char
86
87   if (!(state->m_port0&0x40))
88   {
89      m_vramchars[realA%0x600]=data;
90   }
91   else
92   {
93      m_vramattribs[realA%0x600]=data;
94   }
95
96   UINT8 curch=decode_videoram_char(m_vramchars[realA],m_vramattribs[realA]);
97   state->m_vram[realA%0x600]=curch;
98
99   state->m_mainVideoram[offset]=data;
100}
101
102READ8_MEMBER( rm380z_state::videoram_read )
103{
104   rm380z_state *state = machine().driver_data<rm380z_state>();
105   //printf("read from videoram at [%x]\n",offset);   
106   //return state->m_vram[offset];
107   return state->m_mainVideoram[offset];
108}
109
110static void putChar(int charnum,int x,int y,UINT16* pscr,unsigned char* chsb)
111{
112   if ((charnum>0)&&(charnum<=0x7f))
113   {
114      int basex=chdimx*(charnum/ncy);
115      int basey=chdimy*(charnum%ncy);
116     
117      int inix=x*chdimx;
118      int iniy=y*chdimx*screencols*chdimy;
119     
120      for (int r=0;r<chdimy;r++)
121      {
122         for (int c=0;c<chdimx;c++)
123         {
124            pscr[(inix+c)+(iniy+(r*chdimx*screencols))]=(chsb[((basey+r)*(chdimx*ncx))+(basex+c)])==0xff?0:1;
125         }
126      }
127   }
128}
129
130void rm380z_state::update_screen(bitmap_t &bitmap)
131{
132   unsigned char* pChar=machine().region("gfx")->base();
133   UINT16* scrptr = &bitmap.pix16(0);
134
135   for (int row=0;row<screenrows;row++)
136   {
137      for (int col=0;col<screencols;col++)
138      {
139         unsigned char curchar=m_vram[(row*64)+col];
140         putChar(curchar,col,row,scrptr,pChar);         
141      }
142   }
143}
src/mess/includes/rm380z.h
r0r13914
1
2/*
3
4Research Machines RM 380Z
5
6*/
7
8#ifndef RM380Z_H_
9#define RM380Z_H_
10
11//
12//
13//
14
15#define MAINCPU_TAG      "maincpu"
16#define PORTS_ENABLED_HIGH   ( m_port0 & 0x80 )
17#define PORTS_ENABLED_LOW   ( ( m_port0 & 0x80 ) == 0x00 )
18
19#define chdimx 5
20#define chdimy 9
21#define ncx 8
22#define ncy 16
23#define screencols 40
24#define screenrows 24
25
26//
27//
28//
29
30
31class rm380z_state : public driver_device
32{
33private:
34   
35   UINT8 decode_videoram_char(UINT8 ch1,UINT8 ch2);
36   
37protected:
38   virtual void machine_reset();
39
40public:
41
42   UINT8 m_port0;
43   UINT8 m_port0_kbd;
44   UINT8 m_port1;
45   UINT8 m_fbfd;
46   UINT8 m_fbfe;
47
48   UINT8   m_vram[0x600];
49   UINT8 m_mainVideoram[0x600];
50
51   UINT8   m_vramchars[0x600];
52   UINT8   m_vramattribs[0x600];
53
54   int m_rasterlineCtr;
55   emu_timer* m_vblankTimer;
56   int m_old_fbfd;
57
58   required_device<cpu_device> m_maincpu;
59   required_device<ram_device> m_messram;
60   optional_device<device_t> m_fdc;
61
62   rm380z_state(const machine_config &mconfig, device_type type, const char *tag): driver_device(mconfig, type, tag),
63      m_maincpu(*this, MAINCPU_TAG),
64      m_messram(*this, RAM_TAG),
65      m_fdc(*this, "wd1771")
66   {
67   }
68
69   DECLARE_WRITE8_MEMBER( port_write );
70   DECLARE_READ8_MEMBER( port_read );
71
72   DECLARE_READ8_MEMBER( main_read );
73   DECLARE_WRITE8_MEMBER( main_write );
74
75   DECLARE_READ8_MEMBER( videoram_read );
76   DECLARE_WRITE8_MEMBER( videoram_write );
77
78   //DECLARE_READ8_MEMBER(rm380z_io_r);
79   //DECLARE_WRITE8_MEMBER(rm380z_io_w);
80
81   DECLARE_WRITE8_MEMBER(disk_0_control);
82   
83   DECLARE_WRITE8_MEMBER( keyboard_put );
84
85   void config_memory_map();
86   int keyboard_decode();
87   void update_screen(bitmap_t &bitmap);
88};
89
90
91#endif
src/mess/mess.mak
r13913r13914
13481348   $(MESS_AUDIO)/vp595.o      \
13491349
13501350$(MESSOBJ)/rm.a:            \
1351   $(MESS_DRIVERS)/rm380z.o   \
1352   $(MESS_MACHINE)/rm380z.o   \
1353   $(MESS_VIDEO)/rm380z.o      \
13511354   $(MESS_DRIVERS)/rmnimbus.o   \
13521355   $(MESS_MACHINE)/rmnimbus.o  \
13531356   $(MESS_VIDEO)/rmnimbus.o    \
r13913r13914
18001803   $(MESS_DRIVERS)/ptcsol.o   \
18011804   $(MESS_DRIVERS)/pv9234.o   \
18021805   $(MESS_DRIVERS)/qtsbc.o      \
1803   $(MESS_DRIVERS)/rm380z.o   \
18041806   $(MESS_DRIVERS)/rvoice.o   \
18051807   $(MESS_DRIVERS)/sacstate.o   \
18061808   $(MESS_DRIVERS)/sage2.o      \
src/mess/drivers/rm380z.c
r13913r13914
11
22/*
33
4Research Machines RM-380Z
5microcomputer produced by Research Machines Limited
4Research Machines 380Z (aka "RML 380Z" or "RM 380Z")
5Microcomputer produced by Research Machines Limited, Oxford, UK
661978-1985
7MESS driver by judge, friol
7MESS driver by Wilbert Pol and friol
8Driver started on 22/12/2011
89
910===
1011
11Memory map:
12Memory map from sevice manual:
1213
130x0000-0x0fff - COS ROM (in page 0)/RAM (in page 1)
140x1c00-0x1dff - additional ROM (?)
150x4000-0xbc00 - RAM page0
160xE000-0xEFFF - COS ROM mirror
170xF000-0xF5FF - video ram
180xf600-0xf9ff - ROM (?)
190xfa00-0xffff - RAM
14PAGE SEL bit in PORT0 set to 0:
2015
210xfbfc - port0
220xfbfd - "scroll" register in COS 4.0 (?)
16  0000-3BFF - CPU RAM row 1 (15KB!)
17  3C00-7BFF - CPU RAM row 2 (16KB)
18  7C00-BBFF - Add-on RAM row 1 or HRG RAM (16KB)
19  BC00-DFFF - Add-on RAM row 2 (9KB!)
20  E000-EFFF - ROM (COS)
21  F000-F5FF - VUD and HRG Video RAM
22  F600-F9FF - ROM (monitor extension)
23  FA00-FAFF - Reserved, RAM?
24  FB00-FBFF - Memory-mapped ports (FBFC-FBFF)
25  FC00-FFFF - RAM
2326
27PAGE SEL bit in PORT0 set to 1:
28  0000-0FFF - ROM (COS mirror from E000)
29  1B00-1BFF - Memory-mapped ports (1BFC-1BFF)
30  1C00-1DFF - ROM
31  4000-7FFF - CPU RAM row 1 (16KB!, this RAM normally appears at 0000)
32  8000-BFFF - ???
33  C000-DFFF - ???
34  E000-EFFF - ROM (COS)
35  F000-F5FF - VDU and HRG Video RAM
36  F600-F9FF - ROM (monitor extension)
37  FA00-FAFF - Reserved, RAM?
38  FB00-FBFF - Memory-mapped ports (FBFC-FBFF)
39  FC00-FFFF - RAM
40
4140x24 - 6 pixels wide (5 + spacing), 9 pixels high = 240x216
42Video input clock is 4MHz (8MHz/2)
43
2444According to the manuals, VDU-1 chargen is Texas 74LS262.
2545
2646===
2747
28COS 4.0 disassembly
48Notes on COS 4.0 disassembly:
2949
3050- routine at 0xe438 is called at startup in COS 4.0 and it sets the RST vectors in RAM
3151- routine at 0xe487 finds "top" of system RAM and stores it in 0x0006 and 0x000E
r13913r13914
3656
3757#define ADDRESS_MAP_MODERN
3858
39
4059#include "emu.h"
4160#include "cpu/z80/z80.h"
61#include "machine/ram.h"
4262#include "imagedev/flopdrv.h"
4363#include "machine/terminal.h"
4464#include "machine/wd17xx.h"
65#include "includes/rm380z.h"
4566
4667
47#define PORTS_ENABLED_HIGH   ( m_port0 & 0x80 )
48#define PORTS_ENABLED_LOW   ( ( m_port0 & 0x80 ) == 0x00 )
49
50//
51//
52//
53
54class rm380z_state : public driver_device
55{
56private:
57   
58   UINT8 decode_videoram_char(UINT8 ch1,UINT8 ch2);
59   
60protected:
61   virtual void machine_reset();
62
63public:
64
65   UINT8 m_port0;
66   UINT8 m_port0_kbd;
67   UINT8 m_port1;
68   UINT8 m_fbfd;
69   UINT8 *m_cos_rom;
70
71   int m_ksampler;
72
73   UINT8   m_vram[0x600];
74   UINT8 m_mainVideoram[0x600];
75
76   UINT8   m_vramchars[0x600];
77   UINT8   m_vramattribs[0x600];
78
79   UINT8 m_mainram[0x10000];
80   
81   int m_rasterlineCtr;
82   emu_timer* m_vblankTimer;
83   int m_old_fbfd;
84
85   required_device<cpu_device> m_maincpu;
86   optional_device<device_t> m_fdc;
87
88   rm380z_state(const machine_config &mconfig, device_type type, const char *tag): driver_device(mconfig, type, tag),
89      m_maincpu(*this, "maincpu"),
90      m_fdc(*this, "wd1771")
91   {
92   }
93
94   DECLARE_READ8_MEMBER( port_fbfc_read );
95   DECLARE_WRITE8_MEMBER( port_fbfc_write );
96
97   DECLARE_READ8_MEMBER( main_read );
98   DECLARE_WRITE8_MEMBER( main_write );
99
100   DECLARE_READ8_MEMBER( videoram_read );
101   DECLARE_WRITE8_MEMBER( videoram_write );
102
103   DECLARE_WRITE8_MEMBER(disk_0_control);
104
105   DECLARE_WRITE8_MEMBER( keyboard_put );
106
107};
108
109
110WRITE8_MEMBER( rm380z_state::port_fbfc_write )
111{
112   switch ( offset )
113   {
114   case 0x00:      // PORT0
115      //printf("write of [%x] to FBFC\n",data);
116      m_port0 = data;
117      if (data&0x01)
118      {
119         //printf("WARNING: bit0 of port0 reset\n");
120         m_port0_kbd=0;
121      }
122      break;
123
124   case 0x01:      // screen line counter (?)
125      //printf("write of [%x] to FBFD\n",data&0x1f);
126      m_fbfd=data&0x1f;
127      break;
128
129   case 0x02:      // PORT1
130      //printf("write of [%x] to FBFE\n",data);
131      break;
132
133   case 0x03:      // user I/O port
134      //printf("write of [%x] to FBFF\n",data);
135      //logerror("%s: Write %02X to user I/O port\n", machine().describe_context(), data );
136      break;
137   }
138}
139READ8_MEMBER( rm380z_state::port_fbfc_read )
140{
141   UINT8 data = 0xFF;
142
143   switch ( offset )
144   {
145   case 0x00:      // PORT0
146      //m_port0_kbd=getKeyboard();
147      data = m_port0_kbd;
148      //if (m_port0_kbd!=0) m_port0_kbd=0;
149      //m_port0_kbd=0;
150      //printf("read of port0 (kbd) at [%f] from PC [%x]\n",machine().time().as_double(),cpu_get_pc(machine().device("maincpu")));
151      break;
152
153   case 0x01:      // "counter" (?)
154      printf("%s: Read from counter FBFD\n", machine().describe_context());
155      data = 0x00;
156      break;
157
158   case 0x02:      // PORT1
159      data = m_port1;
160      break;
161
162   case 0x03:      // user port
163      printf("%s: Read from user port\n", machine().describe_context());
164      break;
165   }
166
167   return data;
168}
169
170#define LINE_SUBDIVISION 40
171#define TIMER_SPEED 50*100*LINE_SUBDIVISION
172
173//
174// this simulates line+frame blanking
175// according to the System manual, "frame blanking bit (bit 6) of port1 becomes high
176// for about 4.5 milliseconds every 20 milliseconds"
177//
178
179static TIMER_CALLBACK(static_vblank_timer)
180{
181   //printf("timer callback called at [%f]\n",machine.time().as_double());
182
183   rm380z_state *state = machine.driver_data<rm380z_state>();
184   
185   state->m_rasterlineCtr++;
186   state->m_rasterlineCtr%=(100*LINE_SUBDIVISION);
187   
188   if (state->m_rasterlineCtr>=((100-22)*LINE_SUBDIVISION))
189   {
190      // frame blanking
191      state->m_port1=0x41;
192   }
193   else
194   {
195      state->m_port1=0x00;
196   }
197
198   if ((state->m_rasterlineCtr%LINE_SUBDIVISION)==0) state->m_port1|=0x80; // line blanking
199
200   //     
201   // poll keyboard at fixed intervals, otherwise keys get pressed too fast
202   //
203   
204   state->m_ksampler++;
205   if (state->m_ksampler>(4*100*LINE_SUBDIVISION))
206   {
207      state->m_ksampler=0;
208   }
209}
210
211void rm380z_state::machine_reset()
212{
213   m_port0=0x00;
214   m_port0_kbd=0x00;
215   m_port1=0x00;
216   m_fbfd=0x00;
217   m_old_fbfd=0x00;
218   
219   m_rasterlineCtr=0;
220   m_ksampler=0;
221   
222   memset(m_vramattribs,0,0x600);
223   memset(m_vramchars,0,0x600);
224   
225   m_cos_rom=machine().region("maincpu")->base();
226
227   machine().scheduler().timer_pulse(attotime::from_hz(TIMER_SPEED), FUNC(static_vblank_timer));
228     
229   wd17xx_reset(machine().device("wd1771"));
230}
231
232//
233
234WRITE8_MEMBER( rm380z_state::main_write )
235{
236   rm380z_state *state = machine().driver_data<rm380z_state>();
237
238   if ( PORTS_ENABLED_LOW )
239   {
240      if ((offset>=0x1bfc)&&(offset<=0x1bff))
241      {
242         state->port_fbfc_write(space,offset-0x1bfc,data);
243         return;
244      }
245
246      if ((offset>=0x0000)&&(offset<0x1000))
247      {
248         // ROM
249         printf("ERROR: write on rom at [%x]\n",offset);
250         return;
251      }
252      else if ((offset>=0x1000)&&(offset<0x4000))
253      {
254         // ?
255         printf("WARNING: unhandled write page0 at [%x]\n",offset);
256         return;
257      }     
258      else if ((offset>=0x4000)&&(offset<0xBC00))
259      {
260         state->m_mainram[offset-0x4000]=data;
261         return;
262      }
263   }
264   else
265   {
266      if ((offset==0x000e)||(offset==0x000f))
267      {
268         printf("WARNING: writing [%x] at 0x000f at PC [%x]\n",data,cpu_get_pc(machine().device("maincpu")));
269      }
270
271      //if ((offset>=0x0000)&&(offset<0x7c00))
272      if ((offset>=0x0000)&&(offset<0xdf00))
273      {
274         // RAM
275         state->m_mainram[offset]=data;
276         return;
277      }
278   }
279   
280   //printf("ERROR: unhandled default write at [%x] of [%x]\n",offset,data);
281}
282
283READ8_MEMBER( rm380z_state::main_read )
284{
285   rm380z_state *state = machine().driver_data<rm380z_state>();
286
287   if ( PORTS_ENABLED_LOW )
288   {
289      if ((offset>=0x1bfc)&&(offset<=0x1bff))
290      {
291         return state->port_fbfc_read(space,offset-0x1bfc);
292      }
293
294      if ((offset>=0x0000)&&(offset<0x1000))
295      {
296         // ROM
297         return state->m_cos_rom[offset+ 0xe000];
298      }
299      else if ((offset>=0x1c00)&&(offset<=0x1dff))
300      {
301         return m_cos_rom[offset];
302      }
303      else if ((offset>=0x1000)&&(offset<0x4000))
304      {
305         // ?
306         //printf("WARNING: unhandled read page0 at [%x]\n",offset);
307         return 0xff;
308      }     
309      else if ((offset>=0x4000)&&(offset<0xBC00))
310      {
311         return state->m_mainram[offset-0x4000];
312      }
313   }
314   else
315   {
316      //if ((offset>=0x0000)&&(offset<0x7c00))
317      if ((offset>=0x0000)&&(offset<0xdf00))
318      {
319         // ROM
320         return state->m_mainram[offset];
321      }
322   }
323
324   //printf("ERROR: unhandled default read at [%x]\n",offset);   
325   return 0xff;
326}
327
328//
329
330UINT8 rm380z_state::decode_videoram_char(UINT8 ch1,UINT8 ch2)
331{
332   if ((ch1>0x0f)&&(ch1<0x80))
333   {
334      return ch1;
335   }
336   else if ((ch2>0x0f)&&(ch2<0x80))
337   {
338      return ch2;
339   }
340   else if (ch1==0x80)
341   {
342      // "blank"?
343      return 0x80;
344   }
345   else if ((ch1==0)&&(ch2==8))
346   {
347      // cursor
348      return 0x7f;
349   }
350   else if ((ch1==0)&&(ch2==0))
351   {
352      return 0x20;
353   }
354   else if ((ch1==4)&&(ch2==4))
355   {
356      // reversed cursor?
357      return 0x20;
358   }
359   else if ((ch1==4)&&(ch2==8))
360   {
361      // normal cursor
362      return 0x7f;
363   }
364   else
365   {
366      //printf("unhandled character combination [%x][%x]\n",ch1,ch2);
367   }
368   
369   return 0;
370}
371
372WRITE8_MEMBER( rm380z_state::videoram_write )
373{
374   rm380z_state *state = machine().driver_data<rm380z_state>();
375
376   //printf("vramw [%x][%x] port0 [%x] fbfd [%x]\n",offset,data,state->m_port0,m_fbfd);
377   
378   if (m_old_fbfd>m_fbfd)
379   {
380      printf("WARN: fbfd wrapped\n");
381   }
382   m_old_fbfd=m_fbfd;
383   
384   int lineAdder=(m_fbfd&0x1f)*0x40;
385   int realA=offset+lineAdder;
386
387   // we suppose videoram is being written as character/attribute couple
388   // fbfc 6th bit set=attribute, unset=char
389
390   if (!(state->m_port0&0x40))
391   {
392      m_vramchars[realA%0x600]=data;
393   }
394   else
395   {
396      m_vramattribs[realA%0x600]=data;
397   }
398
399   UINT8 curch=decode_videoram_char(m_vramchars[realA],m_vramattribs[realA]);
400   state->m_vram[realA%0x600]=curch;
401
402   state->m_mainVideoram[offset]=data;
403}
404
405READ8_MEMBER( rm380z_state::videoram_read )
406{
407   rm380z_state *state = machine().driver_data<rm380z_state>();
408   //printf("read from videoram at [%x]\n",offset);   
409   //return state->m_vram[offset];
410   return state->m_mainVideoram[offset];
411}
412
413//
414// ports c0-cf are related to the floppy disc controller
415// c0-c3: wd1771
416// c4-c8: disk drive port0
417// code at f7df writes 2f to c0
418// code at e526 reads from c1
419//
420// the manual says: "the B command reads a sector from drive 0, track 0, sector 1 into memory
421// at 0x0080 to 0x00FF, then jumps to it if there is no error.
422//
423
424
425WRITE8_MEMBER( rm380z_state::disk_0_control )
426{
427   device_t *fdc = machine().device("wd1771");
428   
429   printf("disk drive port0 write [%x]\n",data);
430   
431   // drive port0
432   if (data&0x01)
433   {
434      // drive select bit 0
435      wd17xx_set_drive(fdc,0);
436   }
437   
438   if (data&0x08)
439   {
440      // motor on
441   }
442   
443   // "MSEL (dir/side select bit)
444   if (data&0x20)
445   {
446      wd17xx_set_side(fdc,1);
447   }
448   else
449   {
450      wd17xx_set_side(fdc,0);
451   }
452   
453   // set drive en- (?)
454   if (data&0x40)
455   {
456   }
457}
458
45968static ADDRESS_MAP_START(rm380z_mem, AS_PROGRAM, 8, rm380z_state)
460   AM_RANGE( 0x0000, 0xdfff ) AM_READWRITE(main_read,main_write)
461   AM_RANGE( 0xe000, 0xefff ) AM_ROM
69   AM_RANGE( 0xe000, 0xefff ) AM_ROM AM_REGION(MAINCPU_TAG, 0)
46270   AM_RANGE( 0xf000, 0xf5ff ) AM_READWRITE(videoram_read,videoram_write)
463   AM_RANGE( 0xf600, 0xf9ff ) AM_ROM /* Extra ROM space for COS4.0 */
71   AM_RANGE( 0xf600, 0xf9ff ) AM_ROM AM_REGION(MAINCPU_TAG, 0x1000)      /* Extra ROM space for COS4.0 */
46472   AM_RANGE( 0xfa00, 0xfbfb ) AM_RAM
465   AM_RANGE( 0xfbfc, 0xfbff ) AM_READWRITE( port_fbfc_read, port_fbfc_write )
73   AM_RANGE( 0xfbfc, 0xfbff ) AM_READWRITE( port_read, port_write )
46674   AM_RANGE( 0xfc00, 0xffff ) AM_RAM
46775ADDRESS_MAP_END
46876
469// ports c0-c3 are related to the floppy disk controller
470// which seems to be based on WD1771 from the documentation
471// (n.b.: this is not working properly, need to get real fdc mapping)
472
47377static ADDRESS_MAP_START( rm380z_io , AS_IO, 8, rm380z_state)
47478   ADDRESS_MAP_GLOBAL_MASK(0xff)
79   //AM_RANGE(0x0000, 0xffff) AM_READWRITE(rm380z_io_r, rm380z_io_w)
47580   AM_RANGE(0xc0, 0xc0) AM_DEVREADWRITE_LEGACY("wd1771", wd17xx_status_r, wd17xx_command_w)
47681   AM_RANGE(0xc1, 0xc1) AM_DEVREADWRITE_LEGACY("wd1771", wd17xx_track_r, wd17xx_track_w)
47782   AM_RANGE(0xc2, 0xc2) AM_DEVREADWRITE_LEGACY("wd1771", wd17xx_sector_r, wd17xx_sector_w)
r13913r13914
48085   AM_RANGE(0xcc, 0xcc) AM_NOP // CTC (?)
48186ADDRESS_MAP_END
48287
88static GENERIC_TERMINAL_INTERFACE( terminal_intf )
89{
90   DEVCB_DRIVER_MEMBER(rm380z_state, keyboard_put)
91};
48392
48493INPUT_PORTS_START( rm380z )
48594INPUT_PORTS_END
r13913r13914
48897//
48998//
49099
491#define chdimx 5
492#define chdimy 9
493#define ncx 8
494#define ncy 16
495#define screencols 40
496#define screenrows 24
497
498static void putChar(int charnum,int x,int y,UINT16* pscr,unsigned char* chsb)
499{
500   if ((charnum>0)&&(charnum<=0x7f))
501   {
502      int basex=chdimx*(charnum/ncy);
503      int basey=chdimy*(charnum%ncy);
504     
505      int inix=x*chdimx;
506      int iniy=y*chdimx*screencols*chdimy;
507     
508      for (int r=0;r<chdimy;r++)
509      {
510         for (int c=0;c<chdimx;c++)
511         {
512            pscr[(inix+c)+(iniy+(r*chdimx*screencols))]=(chsb[((basey+r)*(chdimx*ncx))+(basex+c)])==0xff?0:1;
513         }
514      }
515   }
516}
517
518static SCREEN_UPDATE( rm380z )
519{
520   rm380z_state *state = screen.machine().driver_data<rm380z_state>();
521
522   unsigned char* pChar=screen.machine().region("gfx")->base();
523   UINT16* scrptr = &bitmap.pix16(0, 0);
524
525   for (int row=0;row<screenrows;row++)
526   {
527      for (int col=0;col<screencols;col++)
528      {
529         unsigned char curchar=state->m_vram[(row*64)+col];
530         putChar(curchar,col,row,scrptr,pChar);         
531      }
532   }
533
534   return 0;
535}
536
537
538WRITE8_MEMBER( rm380z_state::keyboard_put )
539{
540   m_port0_kbd = data;
541}
542
543
544static GENERIC_TERMINAL_INTERFACE( terminal_intf )
545{
546   DEVCB_DRIVER_MEMBER(rm380z_state, keyboard_put)
547};
548
549
550100static const floppy_interface rm380z_floppy_interface =
551101{
552102   DEVCB_NULL,
r13913r13914
560110   NULL
561111};
562112
113static SCREEN_UPDATE( rm380z )
114{
115   rm380z_state *state = screen.machine().driver_data<rm380z_state>();
116   state->update_screen(bitmap);
117   return 0;
118}
563119
564120static MACHINE_CONFIG_START( rm380z, rm380z_state )
565121   /* basic machine hardware */
r13913r13914
578134   MCFG_PALETTE_LENGTH(2)
579135   MCFG_PALETTE_INIT(black_and_white)
580136
137   /* RAM configurations */
138   MCFG_RAM_ADD(RAM_TAG)
139   MCFG_RAM_DEFAULT_SIZE("56K")
140
581141   /* floppy disk */
582142   MCFG_FD1771_ADD("wd1771", default_wd17xx_interface)
583143   MCFG_LEGACY_FLOPPY_DRIVE_ADD(FLOPPY_0, rm380z_floppy_interface)
584
144   
145   /* keyboard */
585146   MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, terminal_intf)
147
586148MACHINE_CONFIG_END
587149
588150/* ROM definition */
589151ROM_START( rm380z )
590   ROM_REGION( 0x10000, "maincpu", 0 )
591   ROM_LOAD( "cos40b-m_1c00-1dff.bin", 0x1c00, 0x0200, CRC(0f759f44) SHA1(9689c1c1faa62c56def999cbedbbb0c8d928dcff))
592   ROM_LOAD( "cos40b-m.bin",          0xe000, 0x1000, CRC(1f0b3a5c) SHA1(0b29cb2a3b7eaa3770b34f08c4fd42844f42700f))
593   ROM_LOAD( "cos40b-m_f600-f9ff.bin", 0xf600, 0x0400, CRC(e3397d9d) SHA1(490a0c834b0da392daf782edc7d51ca8f0668b1a))
152   ROM_REGION( 0x10000, MAINCPU_TAG, 0 )
153   ROM_LOAD( "cos40b-m.bin", 0x0000, 0x1000, CRC(1f0b3a5c) SHA1(0b29cb2a3b7eaa3770b34f08c4fd42844f42700f))
154   ROM_LOAD( "cos40b-m_f600-f9ff.bin", 0x1000, 0x400, CRC(e3397d9d) SHA1(490a0c834b0da392daf782edc7d51ca8f0668b1a))
155   ROM_LOAD( "cos40b-m_1c00-1dff.bin", 0x1400, 0x200, CRC(0f759f44) SHA1(9689c1c1faa62c56def999cbedbbb0c8d928dcff))
156   // chargen ROM is undumped, afaik
594157   ROM_REGION( 0x1680, "gfx", 0 )
595   ROM_LOAD( "ch3.raw", 0x0000, 0x1680, CRC(e0b10221) SHA1(95304ccad9a7af49d79a349feb2bc23035f90abc))
158   ROM_LOAD( "ch3.raw", 0x0000, 0x1680, BAD_DUMP CRC(e0b10221) SHA1(95304ccad9a7af49d79a349feb2bc23035f90abc))
596159ROM_END
597160
598161/* Driver */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team