src/mess/machine/rm380z.c
| r14027 | r14028 | |
| 18 | 18 | |
| 19 | 19 | PORT0 write in COS 4.0B/M: |
| 20 | 20 | |
| 21 | | bit0: 1=reset keyboard latch |
| 21 | bit0: 1=reset keyboard latch (?) |
| 22 | 22 | bit1: ? |
| 23 | 23 | bit2: ? |
| 24 | 24 | bit3: ? |
| r14027 | r14028 | |
| 33 | 33 | { |
| 34 | 34 | switch ( offset ) |
| 35 | 35 | { |
| 36 | | case 0x00: // PORT0 |
| 37 | | //printf("write of [%x] to FBFC at PC [%x]\n",data,cpu_get_pc(machine().device("maincpu"))); |
| 36 | case 0xFC: // PORT0 |
| 37 | //printf("FBFCw[%2.2x] FBFD [%2.2x] FBFE [%2.2x] PC [%4.4x] writenum [%4.4x]\n",data,m_fbfd,m_fbfe,cpu_get_pc(machine().device("maincpu")),writenum); |
| 38 | 38 | m_port0 = data; |
| 39 | 39 | if (data&0x01) |
| 40 | 40 | { |
| 41 | 41 | //printf("WARNING: bit0 of port0 reset\n"); |
| 42 | 42 | m_port0_kbd=0; |
| 43 | 43 | } |
| 44 | m_port1&=~0x01; //? |
| 45 | |
| 44 | 46 | config_videomode(); |
| 45 | 47 | config_memory_map(); |
| 46 | 48 | break; |
| 47 | 49 | |
| 48 | | case 0x01: // screen line counter (?) |
| 49 | | //printf("write of [%x] to FBFD at PC [%x] FBFE [%x]\n",data,cpu_get_pc(machine().device("maincpu")),m_fbfe); |
| 50 | case 0xFD: // screen line counter (?) |
| 51 | //printf("FBFC [%2.2x] FBFDw[%2.2x] FBFE [%2.2x] PC [%4.4x] writenum [%4.4x]\n",m_port0,data,m_fbfe,cpu_get_pc(machine().device("maincpu")),writenum); |
| 52 | |
| 53 | m_old_old_fbfd=m_old_fbfd; |
| 54 | m_old_fbfd=m_fbfd; |
| 50 | 55 | m_fbfd=data; |
| 56 | |
| 57 | writenum++; |
| 58 | |
| 59 | check_scroll_register(); |
| 60 | |
| 51 | 61 | break; |
| 52 | 62 | |
| 53 | | case 0x02: // something related to screen position |
| 54 | | //printf("write of [%x] to FBFE\n",data); |
| 63 | case 0xFE: // line on screen to write to divided by 2 |
| 64 | //printf("FBFC [%2.2x] FBFD [%2.2x] FBFEw[%2.2x] PC [%4.4x] writenum [%4.4x]\n",m_port0,m_fbfd,data,cpu_get_pc(machine().device("maincpu")),writenum); |
| 55 | 65 | m_fbfe=data; |
| 56 | 66 | break; |
| 57 | 67 | |
| 58 | | case 0x03: // user I/O port |
| 68 | case 0xFF: // user I/O port |
| 59 | 69 | //printf("write of [%x] to FBFF\n",data); |
| 60 | 70 | //logerror("%s: Write %02X to user I/O port\n", machine().describe_context(), data ); |
| 61 | 71 | break; |
| 72 | |
| 73 | default: |
| 74 | printf("unknown port [%2.2x] write of [%2.2x]\n",offset,data); |
| 62 | 75 | } |
| 63 | 76 | } |
| 64 | 77 | |
| r14027 | r14028 | |
| 68 | 81 | |
| 69 | 82 | switch ( offset ) |
| 70 | 83 | { |
| 71 | | case 0x00: // PORT0 |
| 84 | case 0xFC: // PORT0 |
| 72 | 85 | //m_port0_kbd=getKeyboard(); |
| 73 | 86 | data = m_port0_kbd; |
| 74 | 87 | //if (m_port0_kbd!=0) m_port0_kbd=0; |
| 75 | 88 | //m_port0_kbd=0; |
| 76 | | //printf("read of port0 (kbd) at [%f] from PC [%x]\n",machine().time().as_double(),cpu_get_pc(machine().device("maincpu"))); |
| 89 | //printf("read of port0 (kbd) from PC [%x]\n",cpu_get_pc(machine().device("maincpu"))); |
| 77 | 90 | break; |
| 78 | 91 | |
| 79 | | case 0x01: // "counter" (?) |
| 92 | case 0xFD: // "counter" (?) |
| 80 | 93 | //printf("%s: Read from counter FBFD\n", machine().describe_context()); |
| 81 | 94 | data = 0x00; |
| 82 | 95 | break; |
| 83 | 96 | |
| 84 | | case 0x02: // PORT1 |
| 97 | case 0xFE: // PORT1 |
| 85 | 98 | data = m_port1; |
| 99 | //printf("read of port1 from PC [%x]\n",cpu_get_pc(machine().device("maincpu"))); |
| 86 | 100 | break; |
| 87 | 101 | |
| 88 | | case 0x03: // user port |
| 102 | case 0xFF: // user port |
| 89 | 103 | //printf("%s: Read from user port\n", machine().describe_context()); |
| 90 | 104 | break; |
| 105 | |
| 106 | default: |
| 107 | printf("read from unknown port [%2.2x]\n",offset); |
| 91 | 108 | } |
| 92 | 109 | |
| 93 | 110 | return data; |
| 94 | 111 | } |
| 95 | 112 | |
| 96 | | #define LINE_SUBDIVISION 40 |
| 97 | | #define TIMER_SPEED 50*100*LINE_SUBDIVISION |
| 113 | WRITE8_MEMBER( rm380z_state::port_write_1b00 ) |
| 114 | { |
| 115 | address_space *program = m_maincpu->space(AS_PROGRAM); |
| 116 | port_write(*program,offset+0xfc,data); |
| 117 | } |
| 98 | 118 | |
| 119 | READ8_MEMBER( rm380z_state::port_read_1b00 ) |
| 120 | { |
| 121 | address_space *program = m_maincpu->space(AS_PROGRAM); |
| 122 | return port_read(*program,offset+0xfc); |
| 123 | } |
| 124 | |
| 125 | READ8_MEMBER( rm380z_state::hiram_read ) |
| 126 | { |
| 127 | return hiram[offset]; |
| 128 | } |
| 129 | |
| 130 | WRITE8_MEMBER( rm380z_state::hiram_write ) |
| 131 | { |
| 132 | hiram[offset]=data; |
| 133 | } |
| 134 | |
| 135 | READ8_MEMBER( rm380z_state::rm380z_portlow_r ) |
| 136 | { |
| 137 | return 0xff; |
| 138 | } |
| 139 | |
| 140 | WRITE8_MEMBER( rm380z_state::rm380z_portlow_w ) |
| 141 | { |
| 142 | //printf("port write [%x] [%x] at PC [%x]\n",offset,data,cpu_get_pc(machine().device("maincpu"))); |
| 143 | } |
| 144 | |
| 145 | READ8_MEMBER( rm380z_state::rm380z_porthi_r ) |
| 146 | { |
| 147 | return 0xff; |
| 148 | } |
| 149 | |
| 150 | WRITE8_MEMBER( rm380z_state::rm380z_porthi_w ) |
| 151 | { |
| 152 | //printf("port write [%x] [%x]\n",offset+0xc5,data); |
| 153 | } |
| 154 | |
| 155 | |
| 156 | #define LINE_SUBDIVISION 82 |
| 157 | #define HORZ_LINES 100 |
| 158 | #define TIMER_SPEED 50*HORZ_LINES*LINE_SUBDIVISION |
| 159 | |
| 99 | 160 | // |
| 100 | 161 | // this simulates line+frame blanking |
| 101 | 162 | // according to the System manual, "frame blanking bit (bit 6) of port1 becomes high |
| r14027 | r14028 | |
| 109 | 170 | rm380z_state *state = machine.driver_data<rm380z_state>(); |
| 110 | 171 | |
| 111 | 172 | state->m_rasterlineCtr++; |
| 112 | | state->m_rasterlineCtr%=(100*LINE_SUBDIVISION); |
| 173 | state->m_rasterlineCtr%=(HORZ_LINES*LINE_SUBDIVISION); |
| 113 | 174 | |
| 114 | | if (state->m_rasterlineCtr>=((100-22)*LINE_SUBDIVISION)) |
| 175 | // frame blanking |
| 176 | if (state->m_rasterlineCtr>=((HORZ_LINES-22)*LINE_SUBDIVISION)) |
| 115 | 177 | { |
| 116 | | // frame blanking |
| 117 | | state->m_port1=0x41; |
| 178 | state->m_port1|=0x40; |
| 118 | 179 | } |
| 119 | 180 | else |
| 120 | 181 | { |
| 121 | | state->m_port1=0x00; |
| 182 | state->m_port1&=~0x40; |
| 122 | 183 | } |
| 123 | 184 | |
| 124 | | if ((state->m_rasterlineCtr%LINE_SUBDIVISION)==0) state->m_port1|=0x80; // line blanking |
| 185 | // line blanking |
| 186 | if ((state->m_rasterlineCtr%LINE_SUBDIVISION)>80) |
| 187 | { |
| 188 | state->m_port1|=0x80; |
| 189 | } |
| 190 | else |
| 191 | { |
| 192 | state->m_port1&=~0x80; |
| 193 | } |
| 125 | 194 | } |
| 126 | 195 | |
| 196 | WRITE8_MEMBER( rm380z_state::keyboard_put ) |
| 197 | { |
| 198 | m_port0_kbd = data; |
| 199 | m_port1|=0x01; |
| 200 | } |
| 201 | |
| 127 | 202 | // |
| 128 | 203 | // ports c0-cf are related to the floppy disc controller |
| 129 | 204 | // c0-c3: wd1771 |
| r14027 | r14028 | |
| 158 | 233 | // motor on |
| 159 | 234 | } |
| 160 | 235 | |
| 161 | | // "MSEL (dir/side select bit) |
| 236 | // "MSEL (dir/side select bit)" |
| 162 | 237 | if (data&0x20) |
| 163 | 238 | { |
| 164 | 239 | wd17xx_set_side(fdc,1); |
| r14027 | r14028 | |
| 174 | 249 | } |
| 175 | 250 | } |
| 176 | 251 | |
| 177 | | WRITE8_MEMBER( rm380z_state::keyboard_put ) |
| 178 | | { |
| 179 | | //printf("pressed [%x]\n",data); |
| 180 | | //if (data==0x60) data=0x1d; // remap ESC |
| 181 | | m_port0_kbd = data; |
| 182 | | } |
| 183 | | |
| 184 | 252 | void rm380z_state::machine_reset() |
| 185 | 253 | { |
| 186 | 254 | m_port0=0x00; |
| r14027 | r14028 | |
| 189 | 257 | m_fbfd=0x00; |
| 190 | 258 | m_fbfe=0x00; |
| 191 | 259 | m_old_fbfd=0x00; |
| 192 | | maxrow=0; |
| 193 | | m_pageAdder=0; |
| 260 | m_old_old_fbfd=0x00; |
| 261 | writenum=0; |
| 262 | |
| 194 | 263 | m_videomode=RM380Z_VIDEOMODE_80COL; |
| 195 | 264 | m_old_videomode=m_videomode; |
| 196 | | |
| 197 | 265 | m_rasterlineCtr=0; |
| 198 | 266 | |
| 199 | | // note: from COS 4.0 videos, RAM seems to have garbage at the beginning |
| 200 | | memset(m_mainVideoram,0,0x600); |
| 267 | // note: from COS 4.0 videos, screen seems to show garbage at the beginning |
| 268 | memset(m_mainVideoram,0,RM380Z_VIDEORAM_SIZE); |
| 201 | 269 | |
| 202 | 270 | memset(m_vramattribs,0,RM380Z_SCREENSIZE); |
| 203 | 271 | memset(m_vramchars,0,RM380Z_SCREENSIZE); |
| 204 | 272 | memset(m_vram,0,RM380Z_SCREENSIZE); |
| 205 | | |
| 273 | |
| 206 | 274 | config_memory_map(); |
| 207 | | |
| 208 | 275 | machine().scheduler().timer_pulse(attotime::from_hz(TIMER_SPEED), FUNC(static_vblank_timer)); |
| 276 | wd17xx_reset(machine().device("wd1771")); |
| 209 | 277 | |
| 210 | | wd17xx_reset(machine().device("wd1771")); |
| 278 | init_graphic_chars(); |
| 211 | 279 | } |
| 212 | 280 | |
| 213 | 281 | void rm380z_state::config_memory_map() |
| r14027 | r14028 | |
| 223 | 291 | else |
| 224 | 292 | { |
| 225 | 293 | program->install_rom( 0x0000, 0x0FFF, rom ); |
| 226 | | program->install_readwrite_handler(0x1BFC, 0x1BFF,read8_delegate(FUNC(rm380z_state::port_read), this),write8_delegate(FUNC(rm380z_state::port_write), this) ); |
| 294 | program->install_readwrite_handler(0x1BFC, 0x1BFF,read8_delegate(FUNC(rm380z_state::port_read_1b00), this),write8_delegate(FUNC(rm380z_state::port_write_1b00), this) ); |
| 227 | 295 | program->install_rom( 0x1C00, 0x1DFF, rom + 0x1400 ); |
| 228 | 296 | program->install_ram( 0x4000, 0xDFFF, m_ram_p ); |
| 229 | 297 | } |
src/mess/video/rm380z.c
| r14027 | r14028 | |
| 14 | 14 | #include "includes/rm380z.h" |
| 15 | 15 | |
| 16 | 16 | |
| 17 | void rm380z_state::put_point(int charnum,int x,int y,int col) |
| 18 | { |
| 19 | int mx=3; |
| 20 | if (y==6) mx=4; |
| 21 | |
| 22 | for (int r=y;r<(y+mx);r++) |
| 23 | { |
| 24 | for (int c=x;c<(x+3);c++) |
| 25 | { |
| 26 | m_graphic_chars[charnum][c+(r*(RM380Z_CHDIMX+1))]=col; |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | void rm380z_state::init_graphic_chars() |
| 32 | { |
| 33 | for (int c=0;c<0x3f;c++) |
| 34 | { |
| 35 | if (c&0x01) put_point(c,0,0,1); |
| 36 | else put_point(c,0,0,0); |
| 37 | |
| 38 | if (c&0x02) put_point(c,3,0,1); |
| 39 | else put_point(c,3,0,0); |
| 40 | |
| 41 | if (c&0x04) put_point(c,0,3,1); |
| 42 | else put_point(c,0,3,0); |
| 43 | |
| 44 | if (c&0x08) put_point(c,3,3,1); |
| 45 | else put_point(c,3,3,0); |
| 46 | |
| 47 | if (c&0x10) put_point(c,0,6,1); |
| 48 | else put_point(c,0,6,0); |
| 49 | |
| 50 | if (c&0x20) put_point(c,3,6,1); |
| 51 | else put_point(c,3,6,0); |
| 52 | } |
| 53 | } |
| 54 | |
| 17 | 55 | void rm380z_state::config_videomode() |
| 18 | 56 | { |
| 19 | 57 | if (m_port0&0x20) |
| r14027 | r14028 | |
| 30 | 68 | if (m_old_videomode!=m_videomode) |
| 31 | 69 | { |
| 32 | 70 | m_old_videomode=m_videomode; |
| 33 | | memset(m_vram,0x20,RM380Z_SCREENSIZE); |
| 34 | | memset(m_vramchars,0x20,RM380Z_SCREENSIZE); |
| 35 | | memset(m_vramattribs,0x00,RM380Z_SCREENSIZE); |
| 36 | | maxrow=0; |
| 37 | | m_pageAdder=0; |
| 38 | 71 | } |
| 39 | 72 | } |
| 40 | 73 | |
| r14027 | r14028 | |
| 131 | 164 | } |
| 132 | 165 | } |
| 133 | 166 | |
| 167 | void rm380z_state::check_scroll_register() |
| 168 | { |
| 169 | UINT8 r[3]; |
| 170 | |
| 171 | r[0]=m_old_old_fbfd; |
| 172 | r[1]=m_old_fbfd; |
| 173 | r[2]=m_fbfd; |
| 174 | |
| 175 | if ( ((r[1]&0x20)==0) && ((r[2]&0x20)==0) ) |
| 176 | { |
| 177 | // it's a scroll command |
| 178 | |
| 179 | if (r[2]>r[1]) |
| 180 | { |
| 181 | scroll_videoram(); |
| 182 | } |
| 183 | else if ((r[2]==0x00)&&(r[1]==0x17)) |
| 184 | { |
| 185 | // wrap-scroll |
| 186 | scroll_videoram(); |
| 187 | } |
| 188 | |
| 189 | } |
| 190 | } |
| 191 | |
| 134 | 192 | // after ctrl-L (clear screen?): routine at EBBD is executed |
| 135 | 193 | // EB30??? next line? |
| 136 | 194 | // memory at FF02 seems to hold the line counter (same as FBFD) |
| r14027 | r14028 | |
| 143 | 201 | { |
| 144 | 202 | rm380z_state *state = machine().driver_data<rm380z_state>(); |
| 145 | 203 | |
| 146 | | //printf("vramw [%x][%x] port0 [%x] fbfd [%x] fbfe [%x] PC [%x]\n",offset,data,state->m_port0,m_fbfd,m_fbfe,cpu_get_pc(machine().device("maincpu"))); |
| 147 | | //printf("maxrow is [%x]\n",maxrow); |
| 148 | | |
| 204 | //printf("vramw [%2.2x][%2.2x] port0 [%2.2x] fbfd [%2.2x] fbfe [%2.2x] PC [%4.4x]\n",offset,data,state->m_port0,m_fbfd,m_fbfe,cpu_get_pc(machine().device("maincpu"))); |
| 205 | |
| 149 | 206 | int lineWidth=0x80; |
| 150 | 207 | if (m_videomode==RM380Z_VIDEOMODE_40COL) |
| 151 | 208 | { |
| 152 | 209 | lineWidth=0x40; |
| 153 | 210 | } |
| 154 | | |
| 155 | | if (m_old_fbfd>m_fbfd) |
| 156 | | { |
| 157 | | //printf("WARN: fbfd wrapped\n"); |
| 158 | | m_pageAdder+=(0x18*lineWidth); |
| 159 | | } |
| 160 | | m_old_fbfd=m_fbfd; |
| 161 | | |
| 162 | | // |
| 163 | | |
| 211 | |
| 164 | 212 | int rowadder=(m_fbfe&0x0f)*2; |
| 165 | | int fbfdadder=m_fbfd&0x1f; |
| 213 | if (m_videomode==RM380Z_VIDEOMODE_40COL) rowadder=0; // FBFE register is not used in VDU-40 |
| 166 | 214 | |
| 167 | | int lineAdder=(rowadder+fbfdadder)*lineWidth; |
| 168 | | int realA=offset+lineAdder+m_pageAdder; |
| 215 | int lineAdder=rowadder*lineWidth; |
| 216 | int realA=(offset+lineAdder); |
| 169 | 217 | |
| 170 | | if ((realA/lineWidth)>maxrow) |
| 171 | | { |
| 172 | | maxrow=realA/lineWidth; |
| 173 | | //printf("setting new maxrow [%x]\n",maxrow); |
| 174 | | if (maxrow>0x17) |
| 175 | | { |
| 176 | | //printf("ok, scrolling videoram\n"); |
| 177 | | scroll_videoram(); |
| 178 | | } |
| 179 | | } |
| 180 | | |
| 181 | | int scrollsub=0; |
| 182 | | if (maxrow>0x17) |
| 183 | | { |
| 184 | | scrollsub=(maxrow-0x17)*lineWidth; |
| 185 | | } |
| 186 | | realA-=scrollsub; |
| 187 | | |
| 188 | 218 | // we suppose videoram is being written as character/attribute couple |
| 189 | 219 | // fbfc 6th bit set=attribute, unset=char |
| 190 | 220 | |
| r14027 | r14028 | |
| 205 | 235 | READ8_MEMBER( rm380z_state::videoram_read ) |
| 206 | 236 | { |
| 207 | 237 | rm380z_state *state = machine().driver_data<rm380z_state>(); |
| 208 | | //printf("read from videoram at [%x]\n",offset); |
| 209 | | //return state->m_vram[offset]; |
| 210 | 238 | return state->m_mainVideoram[offset]; |
| 211 | 239 | } |
| 212 | 240 | |
| 213 | 241 | void rm380z_state::putChar(int charnum,int attribs,int x,int y,UINT16* pscr,unsigned char* chsb,int vmode) |
| 214 | 242 | { |
| 215 | | // bool attrDim=false; |
| 243 | //bool attrDim=false; |
| 216 | 244 | bool attrRev=false; |
| 217 | 245 | bool attrUnder=false; |
| 218 | 246 | |
| 219 | 247 | if (attribs&0x02) attrUnder=true; |
| 220 | | // if (attribs&0x04) attrDim=true; |
| 248 | //if (attribs&0x04) attrDim=true; |
| 221 | 249 | if (attribs&0x08) attrRev=true; |
| 222 | 250 | |
| 223 | 251 | if ((charnum>0)&&(charnum<=0x7f)) |
| 224 | 252 | { |
| 253 | // normal chars (base set) |
| 254 | |
| 225 | 255 | if (vmode==RM380Z_VIDEOMODE_80COL) |
| 226 | 256 | { |
| 227 | 257 | int basex=RM380Z_CHDIMX*(charnum/RM380Z_NCY); |
| 228 | 258 | int basey=RM380Z_CHDIMY*(charnum%RM380Z_NCY); |
| 229 | 259 | |
| 230 | 260 | int inix=x*(RM380Z_CHDIMX+1); |
| 231 | | int iniy=y*(RM380Z_CHDIMX+1)*RM380Z_SCREENCOLS*RM380Z_CHDIMY; |
| 261 | int iniy=y*(RM380Z_CHDIMX+1)*RM380Z_SCREENCOLS*(RM380Z_CHDIMY+1); |
| 232 | 262 | |
| 233 | 263 | for (int r=0;r<RM380Z_CHDIMY;r++) |
| 234 | 264 | { |
| r14027 | r14028 | |
| 276 | 306 | int basey=RM380Z_CHDIMY*(charnum%RM380Z_NCY); |
| 277 | 307 | |
| 278 | 308 | int inix=(x*(RM380Z_CHDIMX+1)*2); |
| 279 | | int iniy=y*(RM380Z_CHDIMX+1)*(RM380Z_SCREENCOLS)*RM380Z_CHDIMY; |
| 309 | int iniy=y*(RM380Z_CHDIMX+1)*(RM380Z_SCREENCOLS)*(RM380Z_CHDIMY+1); |
| 280 | 310 | |
| 281 | 311 | for (int r=0;r<RM380Z_CHDIMY;r++) |
| 282 | 312 | { |
| r14027 | r14028 | |
| 322 | 352 | } |
| 323 | 353 | } |
| 324 | 354 | } |
| 355 | else |
| 356 | { |
| 357 | // graphic chars: 0x80-0xbf is "dimmed", 0xc0-0xff is full bright |
| 358 | if (vmode==RM380Z_VIDEOMODE_80COL) |
| 359 | { |
| 360 | int inix=x*(RM380Z_CHDIMX+1); |
| 361 | int iniy=y*(RM380Z_CHDIMX+1)*RM380Z_SCREENCOLS*(RM380Z_CHDIMY+1); |
| 362 | |
| 363 | for (int r=0;r<(RM380Z_CHDIMY+1);r++) |
| 364 | { |
| 365 | for (int c=0;c<RM380Z_CHDIMX;c++) |
| 366 | { |
| 367 | pscr[(inix+c)+(iniy+(r*(RM380Z_CHDIMX+1)*RM380Z_SCREENCOLS))]=m_graphic_chars[charnum&0x3f][c+(r*(RM380Z_CHDIMX+1))]; |
| 368 | } |
| 369 | } |
| 370 | } |
| 371 | else |
| 372 | { |
| 373 | int inix=(x*(RM380Z_CHDIMX+1)*2); |
| 374 | int iniy=y*(RM380Z_CHDIMX+1)*(RM380Z_SCREENCOLS)*(RM380Z_CHDIMY+1); |
| 375 | |
| 376 | for (int r=0;r<RM380Z_CHDIMY;r++) |
| 377 | { |
| 378 | for (int c=0;c<(RM380Z_CHDIMX*2);c+=2) |
| 379 | { |
| 380 | pscr[(inix+c)+(iniy+(r*(RM380Z_CHDIMX+1)*(RM380Z_SCREENCOLS)))]=m_graphic_chars[charnum&0x3f][(c/2)+(r*(RM380Z_CHDIMX+1))]; |
| 381 | pscr[(inix+c+1)+(iniy+(r*(RM380Z_CHDIMX+1)*(RM380Z_SCREENCOLS)))]=m_graphic_chars[charnum&0x3f][(c/2)+(r*(RM380Z_CHDIMX+1))]; |
| 382 | } |
| 383 | } |
| 384 | } |
| 385 | } |
| 325 | 386 | } |
| 326 | 387 | |
| 327 | 388 | void rm380z_state::update_screen(bitmap_ind16 &bitmap) |
| r14027 | r14028 | |
| 329 | 390 | unsigned char* pChar=machine().region("gfx")->base(); |
| 330 | 391 | UINT16* scrptr = &bitmap.pix16(0); |
| 331 | 392 | |
| 332 | | memset(scrptr,0,(RM380Z_SCREENCOLS*(RM380Z_CHDIMX+1))*(RM380Z_SCREENROWS*RM380Z_CHDIMY)*2); |
| 393 | // blank screen |
| 394 | memset(scrptr,0,(RM380Z_SCREENCOLS*(RM380Z_CHDIMX+1))*(RM380Z_SCREENROWS*(RM380Z_CHDIMY+1))*2); |
| 333 | 395 | |
| 334 | 396 | int lineWidth=0x80; |
| 335 | 397 | int ncols=80; |
| r14027 | r14028 | |
| 347 | 409 | UINT8 curch,attribs; |
| 348 | 410 | decode_videoram_char((row*lineWidth)+col,curch,attribs); |
| 349 | 411 | putChar(curch,attribs,col,row,scrptr,pChar,m_videomode); |
| 350 | | |
| 351 | | //putChar(0x4f,10,10,scrptr,pChar,RM380Z_VIDEOMODE_40COL); |
| 352 | 412 | } |
| 353 | 413 | } |
| 354 | 414 | } |
src/mess/includes/rm380z.h
| r14027 | r14028 | |
| 25 | 25 | #define RM380Z_NCY 16 |
| 26 | 26 | #define RM380Z_SCREENCOLS 80 |
| 27 | 27 | #define RM380Z_SCREENROWS 24 |
| 28 | |
| 29 | #define RM380Z_VIDEORAM_SIZE 0x600 |
| 28 | 30 | #define RM380Z_SCREENSIZE 0x1200 |
| 29 | 31 | |
| 32 | |
| 30 | 33 | // |
| 31 | 34 | // |
| 32 | 35 | // |
| r14027 | r14028 | |
| 36 | 39 | { |
| 37 | 40 | private: |
| 38 | 41 | |
| 42 | void put_point(int charnum,int x,int y,int col); |
| 43 | void init_graphic_chars(); |
| 44 | |
| 39 | 45 | void putChar(int charnum,int attribs,int x,int y,UINT16* pscr,unsigned char* chsb,int vmode); |
| 40 | 46 | void decode_videoram_char(int pos,UINT8& chr,UINT8& attrib); |
| 41 | 47 | void scroll_videoram(); |
| 42 | 48 | void config_videomode(); |
| 49 | void check_scroll_register(); |
| 43 | 50 | |
| 51 | int writenum; |
| 52 | |
| 44 | 53 | protected: |
| 45 | 54 | virtual void machine_reset(); |
| 46 | 55 | |
| r14027 | r14028 | |
| 52 | 61 | UINT8 m_fbfd; |
| 53 | 62 | UINT8 m_fbfe; |
| 54 | 63 | |
| 55 | | UINT8 m_mainVideoram[0x600]; |
| 64 | UINT8 m_graphic_chars[0x80][(RM380Z_CHDIMX+1)*(RM380Z_CHDIMY+1)]; |
| 56 | 65 | |
| 66 | UINT8 m_mainVideoram[RM380Z_VIDEORAM_SIZE]; |
| 57 | 67 | UINT8 m_vramchars[RM380Z_SCREENSIZE]; |
| 58 | 68 | UINT8 m_vramattribs[RM380Z_SCREENSIZE]; |
| 59 | 69 | UINT8 m_vram[RM380Z_SCREENSIZE]; |
| 60 | 70 | |
| 61 | 71 | int m_rasterlineCtr; |
| 62 | 72 | emu_timer* m_vblankTimer; |
| 73 | |
| 63 | 74 | int m_old_fbfd; |
| 64 | | int maxrow; // maximum row where the code wrote to videoram |
| 65 | | int m_pageAdder; // pages to add (incremented by one page when FBFD wraps) |
| 75 | int m_old_old_fbfd; |
| 66 | 76 | |
| 67 | 77 | int m_videomode; |
| 68 | 78 | int m_old_videomode; |
| 69 | | |
| 79 | |
| 70 | 80 | required_device<cpu_device> m_maincpu; |
| 71 | 81 | required_device<ram_device> m_messram; |
| 72 | 82 | optional_device<device_t> m_fdc; |
| r14027 | r14028 | |
| 80 | 90 | |
| 81 | 91 | DECLARE_WRITE8_MEMBER( port_write ); |
| 82 | 92 | DECLARE_READ8_MEMBER( port_read ); |
| 93 | DECLARE_WRITE8_MEMBER( port_write_1b00 ); |
| 94 | DECLARE_READ8_MEMBER( port_read_1b00 ); |
| 83 | 95 | |
| 84 | 96 | DECLARE_READ8_MEMBER( main_read ); |
| 85 | 97 | DECLARE_WRITE8_MEMBER( main_write ); |
| r14027 | r14028 | |
| 87 | 99 | DECLARE_READ8_MEMBER( videoram_read ); |
| 88 | 100 | DECLARE_WRITE8_MEMBER( videoram_write ); |
| 89 | 101 | |
| 102 | UINT8 hiram[0x1000]; |
| 103 | DECLARE_READ8_MEMBER( hiram_read ); |
| 104 | DECLARE_WRITE8_MEMBER( hiram_write ); |
| 105 | |
| 106 | DECLARE_READ8_MEMBER( rm380z_portlow_r ); |
| 107 | DECLARE_WRITE8_MEMBER( rm380z_portlow_w ); |
| 108 | DECLARE_READ8_MEMBER( rm380z_porthi_r ); |
| 109 | DECLARE_WRITE8_MEMBER( rm380z_porthi_w ); |
| 110 | |
| 90 | 111 | DECLARE_WRITE8_MEMBER(disk_0_control); |
| 91 | 112 | |
| 92 | 113 | DECLARE_WRITE8_MEMBER( keyboard_put ); |
src/mess/drivers/rm380z.c
| r14027 | r14028 | |
| 3 | 3 | Research Machines 380Z (aka "RML 380Z" or "RM 380Z") |
| 4 | 4 | Microcomputer produced by Research Machines Limited, Oxford, UK |
| 5 | 5 | 1978-1985 |
| 6 | | MESS driver by Wilbert Pol and friol |
| 6 | MESS driver by Wilbert Pol and friol (dantonag (at) gmail.com) |
| 7 | 7 | Driver started on 22/12/2011 |
| 8 | 8 | |
| 9 | 9 | === |
| r14027 | r14028 | |
| 17 | 17 | 7C00-BBFF - Add-on RAM row 1 or HRG RAM (16KB) |
| 18 | 18 | BC00-DFFF - Add-on RAM row 2 (9KB!) |
| 19 | 19 | E000-EFFF - ROM (COS) |
| 20 | | F000-F5FF - VUD and HRG Video RAM |
| 20 | F000-F5FF - VDU and HRG Video RAM |
| 21 | 21 | F600-F9FF - ROM (monitor extension) |
| 22 | 22 | FA00-FAFF - Reserved, RAM? |
| 23 | 23 | FB00-FBFF - Memory-mapped ports (FBFC-FBFF) |
| r14027 | r14028 | |
| 37 | 37 | FB00-FBFF - Memory-mapped ports (FBFC-FBFF) |
| 38 | 38 | FC00-FFFF - RAM |
| 39 | 39 | |
| 40 | | 40x24 - 6 pixels wide (5 + spacing), 9 pixels high = 240x216 |
| 41 | | Video input clock is 4MHz (8MHz/2) |
| 40 | Video resolution (not confirmed): |
| 41 | 80x24 - 6 pixels wide (5 + spacing), 10 pixels high (9 + spacing) = 480x240 |
| 42 | Video input clock is 16MHz |
| 42 | 43 | |
| 43 | 44 | According to the manuals, VDU-1 chargen is Texas 74LS262. |
| 44 | 45 | |
| r14027 | r14028 | |
| 51 | 52 | - 0xeca0 - outputs a string (null terminated) to screen (?) |
| 52 | 53 | - 0xff18 - does char output to screen (char in A?) |
| 53 | 54 | |
| 55 | === |
| 56 | |
| 57 | TODO: |
| 58 | |
| 59 | - Properly implement "backwards" or "last 4 lines" scrolling |
| 60 | - Properly implement dimming and graphic chars (>0x80) |
| 61 | - Understand why any write to disk command fails with "bad sector" |
| 62 | - Understand why ctrl-U (blinking cursor) in COS 4.0 stops keyboard input from working |
| 63 | - Get a reliable ROM dump and charset ROM dump |
| 64 | |
| 54 | 65 | */ |
| 55 | 66 | |
| 56 | 67 | #define ADDRESS_MAP_MODERN |
| r14027 | r14028 | |
| 68 | 79 | AM_RANGE( 0xe000, 0xefff ) AM_ROM AM_REGION(RM380Z_MAINCPU_TAG, 0) |
| 69 | 80 | AM_RANGE( 0xf000, 0xf5ff ) AM_READWRITE(videoram_read,videoram_write) |
| 70 | 81 | AM_RANGE( 0xf600, 0xf9ff ) AM_ROM AM_REGION(RM380Z_MAINCPU_TAG, 0x1000) /* Extra ROM space for COS4.0 */ |
| 71 | | AM_RANGE( 0xfa00, 0xfbfb ) AM_RAM |
| 72 | | AM_RANGE( 0xfbfc, 0xfbff ) AM_READWRITE( port_read, port_write ) |
| 73 | | AM_RANGE( 0xfc00, 0xffff ) AM_RAM |
| 82 | AM_RANGE( 0xfa00, 0xfaff ) AM_RAM |
| 83 | AM_RANGE( 0xfb00, 0xfbff ) AM_READWRITE( port_read, port_write ) |
| 84 | AM_RANGE( 0xfc00, 0xffff ) AM_READWRITE(hiram_read,hiram_write) |
| 74 | 85 | ADDRESS_MAP_END |
| 75 | 86 | |
| 76 | 87 | static ADDRESS_MAP_START( rm380z_io , AS_IO, 8, rm380z_state) |
| 77 | 88 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 78 | | //AM_RANGE(0x0000, 0xffff) AM_READWRITE(rm380z_io_r, rm380z_io_w) |
| 89 | AM_RANGE(0x00, 0xbf) AM_READWRITE(rm380z_portlow_r, rm380z_portlow_w) |
| 79 | 90 | AM_RANGE(0xc0, 0xc0) AM_DEVREADWRITE_LEGACY("wd1771", wd17xx_status_r, wd17xx_command_w) |
| 80 | 91 | AM_RANGE(0xc1, 0xc1) AM_DEVREADWRITE_LEGACY("wd1771", wd17xx_track_r, wd17xx_track_w) |
| 81 | 92 | AM_RANGE(0xc2, 0xc2) AM_DEVREADWRITE_LEGACY("wd1771", wd17xx_sector_r, wd17xx_sector_w) |
| 82 | 93 | AM_RANGE(0xc3, 0xc3) AM_DEVREADWRITE_LEGACY("wd1771", wd17xx_data_r, wd17xx_data_w) |
| 83 | 94 | AM_RANGE(0xc4, 0xc4) AM_WRITE(disk_0_control) |
| 84 | | AM_RANGE(0xcc, 0xcc) AM_NOP // CTC (?) |
| 95 | AM_RANGE(0xc5, 0xff) AM_READWRITE(rm380z_porthi_r, rm380z_porthi_w) |
| 85 | 96 | ADDRESS_MAP_END |
| 86 | | |
| 97 | |
| 87 | 98 | static GENERIC_TERMINAL_INTERFACE( terminal_intf ) |
| 88 | 99 | { |
| 89 | 100 | DEVCB_DRIVER_MEMBER(rm380z_state, keyboard_put) |
| r14027 | r14028 | |
| 105 | 116 | DEVCB_NULL, |
| 106 | 117 | DEVCB_NULL, |
| 107 | 118 | DEVCB_NULL, |
| 108 | | FLOPPY_STANDARD_5_25_DSSD, |
| 119 | FLOPPY_STANDARD_5_25_SSSD, |
| 109 | 120 | LEGACY_FLOPPY_OPTIONS_NAME(default), |
| 110 | 121 | NULL, |
| 111 | 122 | NULL |
| r14027 | r14028 | |
| 129 | 140 | MCFG_SCREEN_REFRESH_RATE(50) |
| 130 | 141 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) |
| 131 | 142 | // according to videos and pictures of the real hardware, chars are spaced of at least 1 pixel |
| 132 | | MCFG_SCREEN_SIZE((RM380Z_SCREENCOLS*(RM380Z_CHDIMX+1)), (RM380Z_SCREENROWS*RM380Z_CHDIMY)) |
| 133 | | MCFG_SCREEN_VISIBLE_AREA(0, (RM380Z_SCREENCOLS*(RM380Z_CHDIMX+1))-1, 0, (RM380Z_SCREENROWS*RM380Z_CHDIMY)-1) |
| 143 | // and there is at least 1 pixel between each row of characters |
| 144 | MCFG_SCREEN_SIZE((RM380Z_SCREENCOLS*(RM380Z_CHDIMX+1)), (RM380Z_SCREENROWS*(RM380Z_CHDIMY+1))) |
| 145 | MCFG_SCREEN_VISIBLE_AREA(0, (RM380Z_SCREENCOLS*(RM380Z_CHDIMX+1))-1, 0, (RM380Z_SCREENROWS*(RM380Z_CHDIMY+1))-1) |
| 146 | |
| 134 | 147 | MCFG_SCREEN_UPDATE_STATIC(rm380z) |
| 135 | 148 | MCFG_PALETTE_LENGTH(2) |
| 136 | 149 | MCFG_PALETTE_INIT(black_and_white) |
| r14027 | r14028 | |
| 151 | 164 | /* ROM definition */ |
| 152 | 165 | ROM_START( rm380z ) |
| 153 | 166 | ROM_REGION( 0x10000, RM380Z_MAINCPU_TAG, 0 ) |
| 154 | | ROM_LOAD( "cos40b-m.bin", 0x0000, 0x1000, CRC(1f0b3a5c) SHA1(0b29cb2a3b7eaa3770b34f08c4fd42844f42700f)) |
| 155 | | ROM_LOAD( "cos40b-m_f600-f9ff.bin", 0x1000, 0x400, CRC(e3397d9d) SHA1(490a0c834b0da392daf782edc7d51ca8f0668b1a)) |
| 156 | | ROM_LOAD( "cos40b-m_1c00-1dff.bin", 0x1400, 0x200, CRC(0f759f44) SHA1(9689c1c1faa62c56def999cbedbbb0c8d928dcff)) |
| 167 | // ROM_LOAD( "cos34e-m.bin", 0x0000, 0x1000, CRC(20e2ddf4) SHA1(3177b28793d5a348c94fd0ae6393d74e2e9a8662)) |
| 168 | // I'm not sure of how those roms have been dumped. I don't know if those are good dumps or not. |
| 169 | ROM_LOAD( "cos40b-m.bin", 0x0000, 0x1000, BAD_DUMP CRC(1f0b3a5c) SHA1(0b29cb2a3b7eaa3770b34f08c4fd42844f42700f)) |
| 170 | ROM_LOAD( "cos40b-m_f600-f9ff.bin", 0x1000, 0x400, BAD_DUMP CRC(e3397d9d) SHA1(490a0c834b0da392daf782edc7d51ca8f0668b1a)) |
| 171 | ROM_LOAD( "cos40b-m_1c00-1dff.bin", 0x1400, 0x200, BAD_DUMP CRC(0f759f44) SHA1(9689c1c1faa62c56def999cbedbbb0c8d928dcff)) |
| 157 | 172 | // chargen ROM is undumped, afaik |
| 158 | 173 | ROM_REGION( 0x1680, "gfx", 0 ) |
| 159 | 174 | ROM_LOAD( "ch3.raw", 0x0000, 0x1680, BAD_DUMP CRC(c223622b) SHA1(185ef24896419d7ff46f71a760ac217de3811684)) |