Previous 15994 Revisions Next

r12358 Thursday 28th July, 2011 at 03:53:30 UTC by Robbbert
TRS80 - Modernised. Fixed descenders on Model 1. Removed notes about Model II.
[src/mess/drivers]trs80.c
[src/mess/includes]trs80.h
[src/mess/machine]trs80.c
[src/mess/video]trs80.c

src/mess/machine/trs80.c
r12357r12358
55  Functions to emulate general aspects of the machine (RAM, ROM, interrupts,
66  I/O ports)
77
8MAX_LUMPS   192      crude storage units - don't know much about it
9MAX_GRANULES   8      lumps consisted of granules.. aha
10MAX_SECTORS    5      and granules of sectors
11
812***************************************************************************/
913
10/* Core includes */
11#include "emu.h"
12#include "machine/ctronics.h"
13#include "machine/ay31015.h"
14#include "sound/speaker.h"
1514#include "includes/trs80.h"
1615
17/* Components */
18#include "cpu/z80/z80.h"
19#include "machine/wd17xx.h"
2016
21/* Devices */
22#include "imagedev/cassette.h"
23#include "imagedev/flopdrv.h"
24
25
26#ifdef MAME_DEBUG
27#define VERBOSE 1
28#else
29#define VERBOSE 0
30#endif
31
32#define LOG(x)   do { if (VERBOSE) logerror x; } while (0)
33
34
3517#define IRQ_M1_RTC      0x80   /* RTC on Model I */
3618#define IRQ_M1_FDC      0x40   /* FDC on Model I */
3719#define IRQ_M4_RTC      0x04   /* RTC on Model 4 */
3820#define CASS_RISE      0x01   /* high speed cass on Model III/4) */
3921#define CASS_FALL      0x02   /* high speed cass on Model III/4) */
40
41#define MAX_LUMPS   192      /* crude storage units - don't know much about it */
42#define MAX_GRANULES   8      /* lumps consisted of granules.. aha */
43#define MAX_SECTORS    5      /* and granules of sectors */
44
4522#define MODEL4_MASTER_CLOCK 20275200
4623
4724
r12357r12358
8663 *************************************/
8764
8865
89READ8_HANDLER( trs80m4_e0_r )
66READ8_MEMBER( trs80_state::trs80m4_e0_r )
9067{
91   trs80_state *state = space->machine().driver_data<trs80_state>();
9268/* Indicates which devices are interrupting - d6..d3 not emulated.
9369    Whenever an interrupt occurs, this port is immediately read
9470    to find out which device requires service. Lowest-numbered
r12357r12358
10379    d1 Cass 1500 baud Falling
10480    d0 Cass 1500 baud Rising */
10581
106   cputag_set_input_line(space->machine(), "maincpu", 0, CLEAR_LINE);
107   return ~(state->m_mask & state->m_irq);
82   cputag_set_input_line(machine(), "maincpu", 0, CLEAR_LINE);
83   return ~(m_mask & m_irq);
10884}
10985
110READ8_HANDLER( trs80m4_e4_r )
86READ8_MEMBER( trs80_state::trs80m4_e4_r )
11187{
112   trs80_state *state = space->machine().driver_data<trs80_state>();
11388/* Indicates which devices are interrupting - d6..d5 not emulated.
11489    Whenever an NMI occurs, this port is immediately read
11590    to find out which device requires service. Lowest-numbered
r12357r12358
12095    d6 status of Motor Timeout (0=true)
12196    d5 status of Reset signal (0=true - this will reboot the computer) */
12297
123   cputag_set_input_line(space->machine(), "maincpu", INPUT_LINE_NMI, CLEAR_LINE);
98   cputag_set_input_line(machine(), "maincpu", INPUT_LINE_NMI, CLEAR_LINE);
12499
125   return ~(state->m_nmi_mask & state->m_nmi_data);
100   return ~(m_nmi_mask & m_nmi_data);
126101}
127102
128READ8_HANDLER( trs80m4_e8_r )
103READ8_MEMBER( trs80_state::trs80m4_e8_r )
129104{
130105/* not emulated
131106    d7 Clear-to-Send (CTS), Pin 5
r12357r12358
138113   return 0;
139114}
140115
141READ8_HANDLER( trs80m4_ea_r )
116READ8_MEMBER( trs80_state::trs80m4_ea_r )
142117{
143   trs80_state *state = space->machine().driver_data<trs80_state>();
144118/* UART Status Register
145119    d7 Data Received ('1'=condition true)
146120    d6 Transmitter Holding Register empty ('1'=condition true)
r12357r12358
150124    d2..d0 Not used */
151125
152126   UINT8 data=7;
153   ay31015_set_input_pin( state->m_ay31015, AY31015_SWE, 0 );
154   data |= ay31015_get_output_pin( state->m_ay31015, AY31015_TBMT ) ? 0x40 : 0;
155   data |= ay31015_get_output_pin( state->m_ay31015, AY31015_DAV  ) ? 0x80 : 0;
156   data |= ay31015_get_output_pin( state->m_ay31015, AY31015_OR   ) ? 0x20 : 0;
157   data |= ay31015_get_output_pin( state->m_ay31015, AY31015_FE   ) ? 0x10 : 0;
158   data |= ay31015_get_output_pin( state->m_ay31015, AY31015_PE   ) ? 0x08 : 0;
159   ay31015_set_input_pin( state->m_ay31015, AY31015_SWE, 1 );
127   ay31015_set_input_pin( m_ay31015, AY31015_SWE, 0 );
128   data |= ay31015_get_output_pin( m_ay31015, AY31015_TBMT ) ? 0x40 : 0;
129   data |= ay31015_get_output_pin( m_ay31015, AY31015_DAV  ) ? 0x80 : 0;
130   data |= ay31015_get_output_pin( m_ay31015, AY31015_OR   ) ? 0x20 : 0;
131   data |= ay31015_get_output_pin( m_ay31015, AY31015_FE   ) ? 0x10 : 0;
132   data |= ay31015_get_output_pin( m_ay31015, AY31015_PE   ) ? 0x08 : 0;
133   ay31015_set_input_pin( m_ay31015, AY31015_SWE, 1 );
160134
161135   return data;
162136}
163137
164READ8_HANDLER( trs80m4_eb_r )
138READ8_MEMBER( trs80_state::trs80m4_eb_r )
165139{
166   trs80_state *state = space->machine().driver_data<trs80_state>();
167140/* UART received data */
168   UINT8 data = ay31015_get_received_data( state->m_ay31015 );
169   ay31015_set_input_pin( state->m_ay31015, AY31015_RDAV, 0 );
170   ay31015_set_input_pin( state->m_ay31015, AY31015_RDAV, 1 );
141   UINT8 data = ay31015_get_received_data( m_ay31015 );
142   ay31015_set_input_pin( m_ay31015, AY31015_RDAV, 0 );
143   ay31015_set_input_pin( m_ay31015, AY31015_RDAV, 1 );
171144   return data;
172145}
173146
174READ8_HANDLER( trs80m4_ec_r )
147READ8_MEMBER( trs80_state::trs80m4_ec_r )
175148{
176   trs80_state *state = space->machine().driver_data<trs80_state>();
177149/* Reset the RTC interrupt */
178   state->m_irq &= ~IRQ_M4_RTC;
150   m_irq &= ~IRQ_M4_RTC;
179151   return 0;
180152}
181153
182READ8_HANDLER( sys80_f9_r )
154READ8_MEMBER( trs80_state::sys80_f9_r )
183155{
184   trs80_state *state = space->machine().driver_data<trs80_state>();
185156/* UART Status Register - d6..d4 not emulated
186157    d7 Transmit buffer empty (inverted)
187158    d6 CTS pin
r12357r12358
193164    d0 Data Available */
194165
195166   UINT8 data=70;
196   ay31015_set_input_pin( state->m_ay31015, AY31015_SWE, 0 );
197   data |= ay31015_get_output_pin( state->m_ay31015, AY31015_TBMT ) ? 0 : 0x80;
198   data |= ay31015_get_output_pin( state->m_ay31015, AY31015_DAV  ) ? 0x01 : 0;
199   data |= ay31015_get_output_pin( state->m_ay31015, AY31015_OR   ) ? 0x02 : 0;
200   data |= ay31015_get_output_pin( state->m_ay31015, AY31015_FE   ) ? 0x04 : 0;
201   data |= ay31015_get_output_pin( state->m_ay31015, AY31015_PE   ) ? 0x08 : 0;
202   ay31015_set_input_pin( state->m_ay31015, AY31015_SWE, 1 );
167   ay31015_set_input_pin( m_ay31015, AY31015_SWE, 0 );
168   data |= ay31015_get_output_pin( m_ay31015, AY31015_TBMT ) ? 0 : 0x80;
169   data |= ay31015_get_output_pin( m_ay31015, AY31015_DAV  ) ? 0x01 : 0;
170   data |= ay31015_get_output_pin( m_ay31015, AY31015_OR   ) ? 0x02 : 0;
171   data |= ay31015_get_output_pin( m_ay31015, AY31015_FE   ) ? 0x04 : 0;
172   data |= ay31015_get_output_pin( m_ay31015, AY31015_PE   ) ? 0x08 : 0;
173   ay31015_set_input_pin( m_ay31015, AY31015_SWE, 1 );
203174
204175   return data;
205176}
206177
207READ8_HANDLER( lnw80_fe_r )
178READ8_MEMBER( trs80_state::lnw80_fe_r )
208179{
209   trs80_state *state = space->machine().driver_data<trs80_state>();
210   return ((state->m_mode & 0x78) >> 3) | 0xf0;
180   return ((m_mode & 0x78) >> 3) | 0xf0;
211181}
212182
213READ8_HANDLER( trs80_ff_r )
183READ8_MEMBER( trs80_state::trs80_ff_r )
214184{
215   trs80_state *state = space->machine().driver_data<trs80_state>();
216185/* ModeSel and cassette data
217186    d7 cassette data from tape
218187    d2 modesel setting */
219188
220   UINT8 data = (~state->m_mode & 1) << 5;
221   return data | state->m_cassette_data;
189   UINT8 data = (~m_mode & 1) << 5;
190   return data | m_cassette_data;
222191}
223192
224READ8_HANDLER( trs80m4_ff_r )
193READ8_MEMBER( trs80_state::trs80m4_ff_r )
225194{
226   trs80_state *state = space->machine().driver_data<trs80_state>();
227195/* Return of cassette data stream from tape
228196    d7 Low-speed data
229197    d6..d1 info from write of port EC
230198    d0 High-speed data */
231199
232   state->m_irq &= 0xfc;   /* clear cassette interrupts */
200   m_irq &= 0xfc;   /* clear cassette interrupts */
233201
234   return state->m_port_ec | state->m_cassette_data;
202   return m_port_ec | m_cassette_data;
235203}
236204
237205
238WRITE8_HANDLER( trs80m4_84_w )
206WRITE8_MEMBER( trs80_state::trs80m4_84_w )
239207{
240   trs80_state *state = space->machine().driver_data<trs80_state>();
241208/* Hi-res graphics control - d6..d4 not emulated
242209    d7 Page Control
243210    d6 Fix upper memory
r12357r12358
249216    d0 Select bit 0 */
250217
251218   /* get address space instead of io space */
252   address_space *mem = space->machine().device("maincpu")->memory().space(AS_PROGRAM);
253   UINT8 *base = space->machine().region("maincpu")->base();
219   address_space *mem = m_maincpu->memory().space(AS_PROGRAM);
220   UINT8 *base = machine().region("maincpu")->base();
254221
255   state->m_mode = (state->m_mode & 0x73) | (data & 0x8c);
222   m_mode = (m_mode & 0x73) | (data & 0x8c);
256223
257   state->m_model4 &= 0xce;
258   state->m_model4 |= (data & 3) << 4;
224   m_model4 &= 0xce;
225   m_model4 |= (data & 3) << 4;
259226
260227   switch (data & 3)
261228   {
262229      case 0:   /* normal operation */
263230
264         if (state->m_model4 & 4)   /* Model 4P gets RAM while Model 4 gets ROM */
231         if (m_model4 & 4)   /* Model 4P gets RAM while Model 4 gets ROM */
265232         {
266            if (state->m_model4 & 8)
267               memory_set_bankptr(space->machine(), "bank1", base);
233            if (m_model4 & 8)
234               memory_set_bankptr(machine(), "bank1", base);
268235            else
269               memory_set_bankptr(space->machine(), "bank1", base + 0x10000);
236               memory_set_bankptr(machine(), "bank1", base + 0x10000);
270237
271            memory_set_bankptr(space->machine(), "bank2", base + 0x11000);
272            memory_set_bankptr(space->machine(), "bank4", base + 0x137ea);
238            memory_set_bankptr(machine(), "bank2", base + 0x11000);
239            memory_set_bankptr(machine(), "bank4", base + 0x137ea);
273240         }
274241         else
275242         {
276            memory_set_bankptr(space->machine(), "bank1", base);
277            memory_set_bankptr(space->machine(), "bank2", base + 0x01000);
278            memory_set_bankptr(space->machine(), "bank4", base + 0x037ea);
243            memory_set_bankptr(machine(), "bank1", base);
244            memory_set_bankptr(machine(), "bank2", base + 0x01000);
245            memory_set_bankptr(machine(), "bank4", base + 0x037ea);
279246         }
280247
281         memory_set_bankptr(space->machine(), "bank7", base + 0x14000);
282         memory_set_bankptr(space->machine(), "bank8", base + 0x1f400);
283         memory_set_bankptr(space->machine(), "bank9", base + 0x1f800);
284         memory_set_bankptr(space->machine(), "bank11", base + 0x05000);
285         memory_set_bankptr(space->machine(), "bank12", base + 0x06000);
286         memory_set_bankptr(space->machine(), "bank14", base + 0x09000);
287         memory_set_bankptr(space->machine(), "bank15", base + 0x0a000);
288         memory_set_bankptr(space->machine(), "bank17", base + 0x14000);
289         memory_set_bankptr(space->machine(), "bank18", base + 0x1f400);
290         memory_set_bankptr(space->machine(), "bank19", base + 0x1f800);
291         mem->install_legacy_readwrite_handler (0x37e8, 0x37e9, FUNC(trs80_printer_r), FUNC(trs80_printer_w));   /* 3 & 13 */
292         mem->install_legacy_read_handler (0x3800, 0x3bff, FUNC(trs80_keyboard_r));   /* 5 */
293         mem->install_legacy_readwrite_handler (0x3c00, 0x3fff, FUNC(trs80_videoram_r), FUNC(trs80_videoram_w));   /* 6 & 16 */
248         memory_set_bankptr(machine(), "bank7", base + 0x14000);
249         memory_set_bankptr(machine(), "bank8", base + 0x1f400);
250         memory_set_bankptr(machine(), "bank9", base + 0x1f800);
251         memory_set_bankptr(machine(), "bank11", base + 0x05000);
252         memory_set_bankptr(machine(), "bank12", base + 0x06000);
253         memory_set_bankptr(machine(), "bank14", base + 0x09000);
254         memory_set_bankptr(machine(), "bank15", base + 0x0a000);
255         memory_set_bankptr(machine(), "bank17", base + 0x14000);
256         memory_set_bankptr(machine(), "bank18", base + 0x1f400);
257         memory_set_bankptr(machine(), "bank19", base + 0x1f800);
258         mem->install_readwrite_handler (0x37e8, 0x37e9, read8_delegate(FUNC(trs80_state::trs80_printer_r), this), write8_delegate(FUNC(trs80_state::trs80_printer_w), this));   /* 3 & 13 */
259         mem->install_read_handler (0x3800, 0x3bff, read8_delegate(FUNC(trs80_state::trs80_keyboard_r), this));   /* 5 */
260         mem->install_readwrite_handler (0x3c00, 0x3fff, read8_delegate(FUNC(trs80_state::trs80_videoram_r), this), write8_delegate(FUNC(trs80_state::trs80_videoram_w), this));   /* 6 & 16 */
294261         break;
295262
296263      case 1:   /* write-only ram backs up the rom */
297264
298         if (state->m_model4 & 4)   /* Model 4P gets RAM while Model 4 gets ROM */
265         if (m_model4 & 4)   /* Model 4P gets RAM while Model 4 gets ROM */
299266         {
300            if (state->m_model4 & 8)
301               memory_set_bankptr(space->machine(), "bank1", base);
267            if (m_model4 & 8)
268               memory_set_bankptr(machine(), "bank1", base);
302269            else
303               memory_set_bankptr(space->machine(), "bank1", base + 0x10000);
270               memory_set_bankptr(machine(), "bank1", base + 0x10000);
304271
305            memory_set_bankptr(space->machine(), "bank2", base + 0x11000);
306            memory_set_bankptr(space->machine(), "bank3", base + 0x137e8);
307            memory_set_bankptr(space->machine(), "bank4", base + 0x137ea);
272            memory_set_bankptr(machine(), "bank2", base + 0x11000);
273            memory_set_bankptr(machine(), "bank3", base + 0x137e8);
274            memory_set_bankptr(machine(), "bank4", base + 0x137ea);
308275         }
309276         else
310277         {
311            memory_set_bankptr(space->machine(), "bank1", base);
312            memory_set_bankptr(space->machine(), "bank2", base + 0x01000);
313            memory_set_bankptr(space->machine(), "bank3", base + 0x037e8);
314            memory_set_bankptr(space->machine(), "bank4", base + 0x037ea);
278            memory_set_bankptr(machine(), "bank1", base);
279            memory_set_bankptr(machine(), "bank2", base + 0x01000);
280            memory_set_bankptr(machine(), "bank3", base + 0x037e8);
281            memory_set_bankptr(machine(), "bank4", base + 0x037ea);
315282         }
316283
317         memory_set_bankptr(space->machine(), "bank7", base + 0x14000);
318         memory_set_bankptr(space->machine(), "bank8", base + 0x1f400);
319         memory_set_bankptr(space->machine(), "bank9", base + 0x1f800);
320         memory_set_bankptr(space->machine(), "bank11", base + 0x10000);
321         memory_set_bankptr(space->machine(), "bank12", base + 0x11000);
322         memory_set_bankptr(space->machine(), "bank13", base + 0x137e8);
323         memory_set_bankptr(space->machine(), "bank14", base + 0x137ea);
324         memory_set_bankptr(space->machine(), "bank15", base + 0x0a000);
325         memory_set_bankptr(space->machine(), "bank17", base + 0x14000);
326         memory_set_bankptr(space->machine(), "bank18", base + 0x1f400);
327         memory_set_bankptr(space->machine(), "bank19", base + 0x1f800);
328         mem->install_legacy_read_handler (0x3800, 0x3bff, FUNC(trs80_keyboard_r));   /* 5 */
329         mem->install_legacy_readwrite_handler (0x3c00, 0x3fff, FUNC(trs80_videoram_r), FUNC(trs80_videoram_w));   /* 6 & 16 */
284         memory_set_bankptr(machine(), "bank7", base + 0x14000);
285         memory_set_bankptr(machine(), "bank8", base + 0x1f400);
286         memory_set_bankptr(machine(), "bank9", base + 0x1f800);
287         memory_set_bankptr(machine(), "bank11", base + 0x10000);
288         memory_set_bankptr(machine(), "bank12", base + 0x11000);
289         memory_set_bankptr(machine(), "bank13", base + 0x137e8);
290         memory_set_bankptr(machine(), "bank14", base + 0x137ea);
291         memory_set_bankptr(machine(), "bank15", base + 0x0a000);
292         memory_set_bankptr(machine(), "bank17", base + 0x14000);
293         memory_set_bankptr(machine(), "bank18", base + 0x1f400);
294         memory_set_bankptr(machine(), "bank19", base + 0x1f800);
295         mem->install_read_handler (0x3800, 0x3bff, read8_delegate(FUNC(trs80_state::trs80_keyboard_r), this));   /* 5 */
296         mem->install_readwrite_handler (0x3c00, 0x3fff, read8_delegate(FUNC(trs80_state::trs80_videoram_r), this), write8_delegate(FUNC(trs80_state::trs80_videoram_w), this));   /* 6 & 16 */
330297         break;
331298
332299      case 2:   /* keyboard and video are moved to high memory, and the rest is ram */
333         memory_set_bankptr(space->machine(), "bank1", base + 0x10000);
334         memory_set_bankptr(space->machine(), "bank2", base + 0x11000);
335         memory_set_bankptr(space->machine(), "bank3", base + 0x137e8);
336         memory_set_bankptr(space->machine(), "bank4", base + 0x137ea);
337         memory_set_bankptr(space->machine(), "bank5", base + 0x13800);
338         memory_set_bankptr(space->machine(), "bank6", base + 0x13c00);
339         memory_set_bankptr(space->machine(), "bank7", base + 0x14000);
340         memory_set_bankptr(space->machine(), "bank11", base + 0x10000);
341         memory_set_bankptr(space->machine(), "bank12", base + 0x11000);
342         memory_set_bankptr(space->machine(), "bank13", base + 0x137e8);
343         memory_set_bankptr(space->machine(), "bank14", base + 0x137ea);
344         memory_set_bankptr(space->machine(), "bank15", base + 0x13800);
345         memory_set_bankptr(space->machine(), "bank16", base + 0x13c00);
346         memory_set_bankptr(space->machine(), "bank17", base + 0x14000);
347         memory_set_bankptr(space->machine(), "bank18", base + 0x0a000);
348         mem->install_legacy_read_handler (0xf400, 0xf7ff, FUNC(trs80_keyboard_r));   /* 8 */
349         mem->install_legacy_readwrite_handler (0xf800, 0xffff, FUNC(trs80_videoram_r), FUNC(trs80_videoram_w));   /* 9 & 19 */
350         state->m_model4++;
300         memory_set_bankptr(machine(), "bank1", base + 0x10000);
301         memory_set_bankptr(machine(), "bank2", base + 0x11000);
302         memory_set_bankptr(machine(), "bank3", base + 0x137e8);
303         memory_set_bankptr(machine(), "bank4", base + 0x137ea);
304         memory_set_bankptr(machine(), "bank5", base + 0x13800);
305         memory_set_bankptr(machine(), "bank6", base + 0x13c00);
306         memory_set_bankptr(machine(), "bank7", base + 0x14000);
307         memory_set_bankptr(machine(), "bank11", base + 0x10000);
308         memory_set_bankptr(machine(), "bank12", base + 0x11000);
309         memory_set_bankptr(machine(), "bank13", base + 0x137e8);
310         memory_set_bankptr(machine(), "bank14", base + 0x137ea);
311         memory_set_bankptr(machine(), "bank15", base + 0x13800);
312         memory_set_bankptr(machine(), "bank16", base + 0x13c00);
313         memory_set_bankptr(machine(), "bank17", base + 0x14000);
314         memory_set_bankptr(machine(), "bank18", base + 0x0a000);
315         mem->install_read_handler (0xf400, 0xf7ff, read8_delegate(FUNC(trs80_state::trs80_keyboard_r), this));   /* 8 */
316         mem->install_readwrite_handler (0xf800, 0xffff, read8_delegate(FUNC(trs80_state::trs80_videoram_r), this), write8_delegate(FUNC(trs80_state::trs80_videoram_w), this));   /* 9 & 19 */
317         m_model4++;
351318         break;
352319
353320      case 3:   /* 64k of ram */
354         memory_set_bankptr(space->machine(), "bank1", base + 0x10000);
355         memory_set_bankptr(space->machine(), "bank2", base + 0x11000);
356         memory_set_bankptr(space->machine(), "bank3", base + 0x137e8);
357         memory_set_bankptr(space->machine(), "bank4", base + 0x137ea);
358         memory_set_bankptr(space->machine(), "bank5", base + 0x13800);
359         memory_set_bankptr(space->machine(), "bank6", base + 0x13c00);
360         memory_set_bankptr(space->machine(), "bank7", base + 0x14000);
361         memory_set_bankptr(space->machine(), "bank8", base + 0x1f400);
362         memory_set_bankptr(space->machine(), "bank9", base + 0x1f800);
363         memory_set_bankptr(space->machine(), "bank11", base + 0x10000);
364         memory_set_bankptr(space->machine(), "bank12", base + 0x11000);
365         memory_set_bankptr(space->machine(), "bank13", base + 0x137e8);
366         memory_set_bankptr(space->machine(), "bank14", base + 0x137ea);
367         memory_set_bankptr(space->machine(), "bank15", base + 0x13800);
368         memory_set_bankptr(space->machine(), "bank16", base + 0x13c00);
369         memory_set_bankptr(space->machine(), "bank17", base + 0x14000);
370         memory_set_bankptr(space->machine(), "bank18", base + 0x1f400);
371         memory_set_bankptr(space->machine(), "bank19", base + 0x1f800);
321         memory_set_bankptr(machine(), "bank1", base + 0x10000);
322         memory_set_bankptr(machine(), "bank2", base + 0x11000);
323         memory_set_bankptr(machine(), "bank3", base + 0x137e8);
324         memory_set_bankptr(machine(), "bank4", base + 0x137ea);
325         memory_set_bankptr(machine(), "bank5", base + 0x13800);
326         memory_set_bankptr(machine(), "bank6", base + 0x13c00);
327         memory_set_bankptr(machine(), "bank7", base + 0x14000);
328         memory_set_bankptr(machine(), "bank8", base + 0x1f400);
329         memory_set_bankptr(machine(), "bank9", base + 0x1f800);
330         memory_set_bankptr(machine(), "bank11", base + 0x10000);
331         memory_set_bankptr(machine(), "bank12", base + 0x11000);
332         memory_set_bankptr(machine(), "bank13", base + 0x137e8);
333         memory_set_bankptr(machine(), "bank14", base + 0x137ea);
334         memory_set_bankptr(machine(), "bank15", base + 0x13800);
335         memory_set_bankptr(machine(), "bank16", base + 0x13c00);
336         memory_set_bankptr(machine(), "bank17", base + 0x14000);
337         memory_set_bankptr(machine(), "bank18", base + 0x1f400);
338         memory_set_bankptr(machine(), "bank19", base + 0x1f800);
372339         break;
373340   }
374341}
375342
376WRITE8_HANDLER( trs80m4_90_w )
343WRITE8_MEMBER( trs80_state::trs80m4_90_w )
377344{
378   trs80_state *state = space->machine().driver_data<trs80_state>();
379   speaker_level_w(state->m_speaker, ~data & 1);
345   speaker_level_w(m_speaker, ~data & 1);
380346}
381347
382WRITE8_HANDLER( trs80m4p_9c_w )      /* model 4P only - swaps the ROM with read-only RAM */
348WRITE8_MEMBER( trs80_state::trs80m4p_9c_w )      /* model 4P only - swaps the ROM with read-only RAM */
383349{
384   trs80_state *state = space->machine().driver_data<trs80_state>();
385350   /* Meaning of model4 variable:
386351        d5..d4 memory mode (as described in section above)
387352        d3 rom switch (1=enabled) only effective in mode0 and 1
r12357r12358
389354        d1 this is a Model 4
390355        d0 Video banking exists yes/no (1=not banked) */
391356
392   /* get address space instead of io space */
393   //address_space *mem = space->machine().device("maincpu")->memory().space(AS_PROGRAM);
357   m_model4 &= 0xf7;
358   m_model4 |= (data << 3);
394359
395   state->m_model4 &= 0xf7;
396   state->m_model4 |= (data << 3);
397
398   if ((state->m_model4) && (~state->m_model4 & 0x20))
360   if ((m_model4) && (~m_model4 & 0x20))
399361   {
400      switch (state->m_model4 & 8)
362      switch (m_model4 & 8)
401363      {
402364         case 0:      /* Read-only RAM replaces rom */
403            memory_set_bankptr(space->machine(), "bank1", space->machine().region("maincpu")->base() + 0x10000);
365            memory_set_bankptr(machine(), "bank1", machine().region("maincpu")->base() + 0x10000);
404366            break;
405367         case 8:      /* Normal setup - rom enabled */
406            memory_set_bankptr(space->machine(), "bank1", space->machine().region("maincpu")->base());
368            memory_set_bankptr(machine(), "bank1", machine().region("maincpu")->base());
407369            break;
408370      }
409371   }
410372}
411373
412WRITE8_HANDLER( trs80m4_e0_w )
374WRITE8_MEMBER( trs80_state::trs80m4_e0_w )
413375{
414   trs80_state *state = space->machine().driver_data<trs80_state>();
415376/* Interrupt settings - which devices are allowed to interrupt - bits align with read of E0
416377    d6 Enable Rec Err
417378    d5 Enable Rec Data
r12357r12358
421382    d1 C fall Int
422383    d0 C Rise Int */
423384
424   state->m_mask = data;
385   m_mask = data;
425386}
426387
427WRITE8_HANDLER( trs80m4_e4_w )
388WRITE8_MEMBER( trs80_state::trs80m4_e4_w )
428389{
429   trs80_state *state = space->machine().driver_data<trs80_state>();
430390/* Disk to NMI interface
431391    d7 1=enable disk INTRQ to generate NMI
432392    d6 1=enable disk Motor Timeout to generate NMI */
433393
434   state->m_nmi_mask = data;
394   m_nmi_mask = data;
435395}
436396
437WRITE8_HANDLER( trs80m4_e8_w )
397WRITE8_MEMBER( trs80_state::trs80m4_e8_w )
438398{
439   trs80_state *state = space->machine().driver_data<trs80_state>();
440399/* d1 when '1' enables control register load (see below) */
441400
442   state->m_reg_load = data & 2;
401   m_reg_load = data & 2;
443402}
444403
445WRITE8_HANDLER( trs80m4_e9_w )
404WRITE8_MEMBER( trs80_state::trs80m4_e9_w )
446405{
447   trs80_state *state = space->machine().driver_data<trs80_state>();
448406/* UART set baud rate. Rx = bits 0..3, Tx = bits 4..7
449407    00h    50
450408    11h    75
r12357r12358
464422    FFh    19200 */
465423
466424   static const int baud_clock[]={ 800, 1200, 1760, 2152, 2400, 4800, 9600, 19200, 28800, 32000, 38400, 57600, 76800, 115200, 153600, 307200 };
467   ay31015_set_receiver_clock( state->m_ay31015, baud_clock[data & 0x0f]);
468   ay31015_set_transmitter_clock( state->m_ay31015, baud_clock[data>>4]);
425   ay31015_set_receiver_clock( m_ay31015, baud_clock[data & 0x0f]);
426   ay31015_set_transmitter_clock( m_ay31015, baud_clock[data>>4]);
469427}
470428
471WRITE8_HANDLER( trs80m4_ea_w )
429WRITE8_MEMBER( trs80_state::trs80m4_ea_w )
472430{
473   trs80_state *state = space->machine().driver_data<trs80_state>();
474   if (state->m_reg_load)
431   if (m_reg_load)
475432
476433/* d2..d0 not emulated
477434    d7 Even Parity Enable ('1'=even, '0'=odd)
r12357r12358
486443    d0 Data-Terminal-Ready (DTR), pin 20 */
487444
488445   {
489      ay31015_set_input_pin( state->m_ay31015, AY31015_CS, 0 );
490      ay31015_set_input_pin( state->m_ay31015, AY31015_NB1, ( data & 0x40 ) ? 1 : 0 );
491      ay31015_set_input_pin( state->m_ay31015, AY31015_NB2, ( data & 0x20 ) ? 1 : 0 );
492      ay31015_set_input_pin( state->m_ay31015, AY31015_TSB, ( data & 0x10 ) ? 1 : 0 );
493      ay31015_set_input_pin( state->m_ay31015, AY31015_EPS, ( data & 0x80 ) ? 1 : 0 );
494      ay31015_set_input_pin( state->m_ay31015, AY31015_NP,  ( data & 0x08 ) ? 1 : 0 );
495      ay31015_set_input_pin( state->m_ay31015, AY31015_CS, 1 );
446      ay31015_set_input_pin( m_ay31015, AY31015_CS, 0 );
447      ay31015_set_input_pin( m_ay31015, AY31015_NB1, ( data & 0x40 ) ? 1 : 0 );
448      ay31015_set_input_pin( m_ay31015, AY31015_NB2, ( data & 0x20 ) ? 1 : 0 );
449      ay31015_set_input_pin( m_ay31015, AY31015_TSB, ( data & 0x10 ) ? 1 : 0 );
450      ay31015_set_input_pin( m_ay31015, AY31015_EPS, ( data & 0x80 ) ? 1 : 0 );
451      ay31015_set_input_pin( m_ay31015, AY31015_NP,  ( data & 0x08 ) ? 1 : 0 );
452      ay31015_set_input_pin( m_ay31015, AY31015_CS, 1 );
496453   }
497454   else
498455   {
r12357r12358
509466   }
510467}
511468
512WRITE8_HANDLER( trs80m4_eb_w )
469WRITE8_MEMBER( trs80_state::trs80m4_eb_w )
513470{
514   trs80_state *state = space->machine().driver_data<trs80_state>();
515   ay31015_set_transmit_data( state->m_ay31015, data );
471   ay31015_set_transmit_data( m_ay31015, data );
516472}
517473
518WRITE8_HANDLER( trs80m4_ec_w )
474WRITE8_MEMBER( trs80_state::trs80m4_ec_w )
519475{
520   trs80_state *state = space->machine().driver_data<trs80_state>();
521476/* Hardware settings - d5..d4 not emulated
522477    d6 CPU fast (1=4MHz, 0=2MHz)
523478    d5 1=Enable Video Wait
r12357r12358
526481    d2 Mode Select (0=64 chars, 1=32chars)
527482    d1 Cassette Motor (1=On) */
528483
529   space->machine().device("maincpu")->set_unscaled_clock(data & 0x40 ? MODEL4_MASTER_CLOCK/5 : MODEL4_MASTER_CLOCK/10);
484   m_maincpu->set_unscaled_clock(data & 0x40 ? MODEL4_MASTER_CLOCK/5 : MODEL4_MASTER_CLOCK/10);
530485
531   state->m_mode = (state->m_mode & 0xde) | ((data & 4) ? 1 : 0) | ((data & 8) ? 0x20 : 0);
486   m_mode = (m_mode & 0xde) | ((data & 4) ? 1 : 0) | ((data & 8) ? 0x20 : 0);
532487
533   state->m_cass->change_state(( data & 2 ) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR );
488   m_cass->change_state(( data & 2 ) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR );
534489
535   state->m_port_ec = data & 0x7e;
490   m_port_ec = data & 0x7e;
536491}
537492
538WRITE8_HANDLER( trs80m4_f4_w )
493WRITE8_MEMBER( trs80_state::trs80m4_f4_w )
539494{
540   trs80_state *state = space->machine().driver_data<trs80_state>();
541495/* Selection of drive and parameters - d6..d5 not emulated.
542496 A write also causes the selected drive motor to turn on for about 3 seconds.
543497 When the motor turns off, the drive is deselected.
r12357r12358
564518   if (data & 8)
565519      drive = 3;
566520
567   state->m_head = (data & 16) ? 1 : 0;
521   m_head = (data & 16) ? 1 : 0;
568522
569523   if (drive < 4)
570524   {
571      wd17xx_set_drive(state->m_fdc,drive);
572      wd17xx_set_side(state->m_fdc,state->m_head);
525      wd17xx_set_drive(m_fdc,drive);
526      wd17xx_set_side(m_fdc,m_head);
573527   }
574528
575   wd17xx_dden_w(state->m_fdc, !BIT(data, 7));
529   wd17xx_dden_w(m_fdc, !BIT(data, 7));
576530
577531   /* CLEAR_LINE means to turn motors on */
578   floppy_mon_w(floppy_get_device(space->machine(), 0), (data & 0x0f) ? CLEAR_LINE : ASSERT_LINE);
579   floppy_mon_w(floppy_get_device(space->machine(), 1), (data & 0x0f) ? CLEAR_LINE : ASSERT_LINE);
580   floppy_mon_w(floppy_get_device(space->machine(), 2), (data & 0x0f) ? CLEAR_LINE : ASSERT_LINE);
581   floppy_mon_w(floppy_get_device(space->machine(), 3), (data & 0x0f) ? CLEAR_LINE : ASSERT_LINE);
532   floppy_mon_w(floppy_get_device(machine(), 0), (data & 0x0f) ? CLEAR_LINE : ASSERT_LINE);
533   floppy_mon_w(floppy_get_device(machine(), 1), (data & 0x0f) ? CLEAR_LINE : ASSERT_LINE);
534   floppy_mon_w(floppy_get_device(machine(), 2), (data & 0x0f) ? CLEAR_LINE : ASSERT_LINE);
535   floppy_mon_w(floppy_get_device(machine(), 3), (data & 0x0f) ? CLEAR_LINE : ASSERT_LINE);
582536}
583537
584WRITE8_HANDLER( sys80_f8_w )
538WRITE8_MEMBER( trs80_state::sys80_f8_w )
585539{
586540/* not emulated
587541    d2 reset UART (XR pin)
r12357r12358
589543    d0 RTS */
590544}
591545
592WRITE8_HANDLER( sys80_fe_w )
546WRITE8_MEMBER( trs80_state::sys80_fe_w )
593547{
594   trs80_state *state = space->machine().driver_data<trs80_state>();
595548/* not emulated
596549    d4 select internal or external cassette player */
597550
598   state->m_tape_unit = (data & 0x10) ? 2 : 1;
551   m_tape_unit = (data & 0x10) ? 2 : 1;
599552}
600553
601554/* lnw80 can switch out all the devices, roms and video ram to be replaced by graphics ram. */
602WRITE8_HANDLER( lnw80_fe_w )
555WRITE8_MEMBER( trs80_state::lnw80_fe_w )
603556{
604   trs80_state *state = space->machine().driver_data<trs80_state>();
605557/* lnw80 video options
606558    d3 bankswitch lower 16k between roms and hires ram (1=hires)
607559    d2 enable colour    \
r12357r12358
609561    d0 inverse video (entire screen) */
610562
611563   /* get address space instead of io space */
612   address_space *mem = space->machine().device("maincpu")->memory().space(AS_PROGRAM);
564   address_space *mem = m_maincpu->memory().space(AS_PROGRAM);
613565
614   state->m_mode = (state->m_mode & 0x87) | ((data & 0x0f) << 3);
566   m_mode = (m_mode & 0x87) | ((data & 0x0f) << 3);
615567
616568   if (data & 8)
617569   {
618570      mem->unmap_readwrite (0x0000, 0x3fff);
619      mem->install_legacy_readwrite_handler (0x0000, 0x3fff, FUNC(trs80_gfxram_r), FUNC(trs80_gfxram_w));
571      mem->install_readwrite_handler (0x0000, 0x3fff, read8_delegate(FUNC(trs80_state::trs80_gfxram_r), this), write8_delegate(FUNC(trs80_state::trs80_gfxram_w), this));
620572   }
621573   else
622574   {
623575      mem->unmap_readwrite (0x0000, 0x3fff);
624576      mem->install_read_bank (0x0000, 0x2fff, "bank1");
625      memory_set_bankptr(space->machine(), "bank1", space->machine().region("maincpu")->base());
626      mem->install_legacy_readwrite_handler (0x37e0, 0x37e3, FUNC(trs80_irq_status_r), FUNC(trs80_motor_w));
627      mem->install_legacy_readwrite_handler (0x37e8, 0x37eb, FUNC(trs80_printer_r), FUNC(trs80_printer_w));
628      mem->install_legacy_readwrite_handler (*state->m_fdc, 0x37ec, 0x37ec, FUNC(trs80_wd179x_r), FUNC(wd17xx_command_w));
629      mem->install_legacy_readwrite_handler (*state->m_fdc, 0x37ed, 0x37ed, FUNC(wd17xx_track_r), FUNC(wd17xx_track_w));
630      mem->install_legacy_readwrite_handler (*state->m_fdc, 0x37ee, 0x37ee, FUNC(wd17xx_sector_r), FUNC(wd17xx_sector_w));
631      mem->install_legacy_readwrite_handler (*state->m_fdc, 0x37ef, 0x37ef, FUNC(wd17xx_data_r), FUNC(wd17xx_data_w));
632      mem->install_legacy_read_handler (0x3800, 0x38ff, 0, 0x0300, FUNC(trs80_keyboard_r));
633      mem->install_legacy_readwrite_handler (0x3c00, 0x3fff, FUNC(trs80_videoram_r), FUNC(trs80_videoram_w));
577      memory_set_bankptr(machine(), "bank1", machine().region("maincpu")->base());
578      mem->install_readwrite_handler (0x37e0, 0x37e3, read8_delegate(FUNC(trs80_state::trs80_irq_status_r), this), write8_delegate(FUNC(trs80_state::trs80_motor_w), this));
579      mem->install_readwrite_handler (0x37e8, 0x37eb, read8_delegate(FUNC(trs80_state::trs80_printer_r), this), write8_delegate(FUNC(trs80_state::trs80_printer_w), this));
580      mem->install_read_handler (0x37ec, 0x37ec, read8_delegate(FUNC(trs80_state::trs80_wd179x_r), this));
581      mem->install_legacy_write_handler (*m_fdc, 0x37ec, 0x37ec, FUNC(wd17xx_command_w));
582      mem->install_legacy_readwrite_handler (*m_fdc, 0x37ed, 0x37ed, FUNC(wd17xx_track_r), FUNC(wd17xx_track_w));
583      mem->install_legacy_readwrite_handler (*m_fdc, 0x37ee, 0x37ee, FUNC(wd17xx_sector_r), FUNC(wd17xx_sector_w));
584      mem->install_legacy_readwrite_handler (*m_fdc, 0x37ef, 0x37ef, FUNC(wd17xx_data_r), FUNC(wd17xx_data_w));
585      mem->install_read_handler (0x3800, 0x38ff, 0, 0x0300, read8_delegate(FUNC(trs80_state::trs80_keyboard_r), this));
586      mem->install_readwrite_handler (0x3c00, 0x3fff, read8_delegate(FUNC(trs80_state::trs80_videoram_r), this), write8_delegate(FUNC(trs80_state::trs80_videoram_w), this));
634587   }
635588}
636589
637WRITE8_HANDLER( trs80_ff_w )
590WRITE8_MEMBER( trs80_state::trs80_ff_w )
638591{
639   trs80_state *state = space->machine().driver_data<trs80_state>();
640592/* Standard output port of Model I
641593    d3 ModeSel bit
642594    d2 Relay
r12357r12358
644596
645597   static const double levels[4] = { 0.0, -1.0, 0.0, 1.0 };
646598
647   state->m_cass->change_state(( data & 4 ) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR );
648   state->m_cass->output(levels[data & 3]);
649   state->m_cassette_data &= ~0x80;
599   m_cass->change_state(( data & 4 ) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR );
600   m_cass->output(levels[data & 3]);
601   m_cassette_data &= ~0x80;
650602
651   state->m_mode = (state->m_mode & 0xfe) | ((data & 8) >> 3);
603   m_mode = (m_mode & 0xfe) | ((data & 8) >> 3);
652604
653605   /* Speaker for System-80 MK II - only sounds if relay is off */
654606   if (~data & 4)
655      speaker_level_w(state->m_speaker, data & 3);
607      speaker_level_w(m_speaker, data & 3);
656608}
657609
658WRITE8_HANDLER( trs80m4_ff_w )
610WRITE8_MEMBER( trs80_state::trs80m4_ff_w )
659611{
660   trs80_state *state = space->machine().driver_data<trs80_state>();
661612/* Cassette port
662613    d1, d0 Cassette output */
663614
664615   static const double levels[4] = { 0.0, -1.0, 0.0, 1.0 };
665   state->m_cass->output(levels[data & 3]);
666   state->m_cassette_data &= ~0x80;
616   m_cass->output(levels[data & 3]);
617   m_cassette_data &= ~0x80;
667618}
668619
669620
r12357r12358
744695
745696
746697/*************************************
747 *                   *
748 *      Memory handlers      *
749 *                   *
698 *                                   *
699 *      Memory handlers              *
700 *                                   *
750701 *************************************/
751702
752READ8_DEVICE_HANDLER (trs80_wd179x_r)
703READ8_MEMBER( trs80_state::trs80_wd179x_r )
753704{
754   if (input_port_read(device->machine(), "CONFIG") & 0x80)
755      return wd17xx_status_r(device, offset);
756   else
757      return 0xff;
705   UINT8 data = 0xff;
706   if (BIT(input_port_read(machine(), "CONFIG"), 7))
707      data = wd17xx_status_r(m_fdc, offset);
708
709   return data;
758710}
759711
760READ8_HANDLER ( trs80_printer_r )
712READ8_MEMBER( trs80_state::trs80_printer_r )
761713{
762   trs80_state *state = space->machine().driver_data<trs80_state>();
763714   /* Bit 7 - 1 = Busy; 0 = Not Busy
764715       Bit 6 - 1 = Out of Paper; 0 = Paper
765716       Bit 5 - 1 = Printer selected; 0 = Printer not selected
r12357r12358
767718       Bits 3..0 - Not used */
768719
769720   UINT8 data = 0;
770   data |= centronics_busy_r(state->m_printer) << 7;
771   data |= centronics_pe_r(state->m_printer) << 6;
772   data |= centronics_vcc_r(state->m_printer) << 5;
773   data |= centronics_fault_r(state->m_printer) << 4;
721   data |= centronics_busy_r(m_printer) << 7;
722   data |= centronics_pe_r(m_printer) << 6;
723   data |= centronics_vcc_r(m_printer) << 5;
724   data |= centronics_fault_r(m_printer) << 4;
774725
775726   return data;
776727}
777728
778WRITE8_HANDLER( trs80_printer_w )
729WRITE8_MEMBER( trs80_state::trs80_printer_w )
779730{
780   trs80_state *state = space->machine().driver_data<trs80_state>();
781   centronics_strobe_w(state->m_printer, 1);
782   centronics_data_w(state->m_printer, 0, data);
783   centronics_strobe_w(state->m_printer, 0);
731   centronics_strobe_w(m_printer, 1);
732   centronics_data_w(m_printer, 0, data);
733   centronics_strobe_w(m_printer, 0);
784734}
785735
786WRITE8_HANDLER( trs80_cassunit_w )
736WRITE8_MEMBER( trs80_state::trs80_cassunit_w )
787737{
788   trs80_state *state = space->machine().driver_data<trs80_state>();
789738/* not emulated
790    01 for unit 1 (default
739    01 for unit 1 (default)
791740    02 for unit 2 */
792741
793   state->m_tape_unit = data;
742   m_tape_unit = data;
794743}
795744
796READ8_HANDLER( trs80_irq_status_r )
745READ8_MEMBER( trs80_state::trs80_irq_status_r )
797746{
798   trs80_state *state = space->machine().driver_data<trs80_state>();
799747/* (trs80l2) Whenever an interrupt occurs, 37E0 is read to see what devices require service.
800748    d7 = RTC
801749    d6 = FDC
r12357r12358
803751    All interrupting devices are serviced in a single interrupt. There is a mask byte,
804752    which is dealt with by the DOS. We take the opportunity to reset the cpu INT line. */
805753
806   int result = state->m_irq;
807   cputag_set_input_line(space->machine(), "maincpu", 0, CLEAR_LINE);
808   state->m_irq = 0;
754   int result = m_irq;
755   cputag_set_input_line(machine(), "maincpu", 0, CLEAR_LINE);
756   m_irq = 0;
809757   return result;
810758}
811759
812760
813WRITE8_HANDLER( trs80_motor_w )
761WRITE8_MEMBER( trs80_state::trs80_motor_w )
814762{
815   trs80_state *state = space->machine().driver_data<trs80_state>();
816763   UINT8 drive = 255;
817764
818   LOG(("trs80 motor_w $%02X\n", data));
819
820765   switch (data)
821766   {
822767   case 1:
823768      drive = 0;
824      state->m_head = 0;
769      m_head = 0;
825770      break;
826771   case 2:
827772      drive = 1;
828      state->m_head = 0;
773      m_head = 0;
829774      break;
830775   case 4:
831776      drive = 2;
832      state->m_head = 0;
777      m_head = 0;
833778      break;
834779   case 8:
835780      drive = 3;
836      state->m_head = 0;
781      m_head = 0;
837782      break;
838783   /* These 3 combinations aren't official. Some manufacturers of double-sided disks
839784        used drive select 4 to indicate the other side. */
840785   case 9:
841786      drive = 0;
842      state->m_head = 1;
787      m_head = 1;
843788      break;
844789   case 10:
845790      drive = 1;
846      state->m_head = 1;
791      m_head = 1;
847792      break;
848793   case 12:
849794      drive = 2;
850      state->m_head = 1;
795      m_head = 1;
851796      break;
852797   }
853798
854799   if (drive > 3)
855800   {   /* Turn motors off */
856      floppy_mon_w(floppy_get_device(space->machine(), 0), ASSERT_LINE);
857      floppy_mon_w(floppy_get_device(space->machine(), 1), ASSERT_LINE);
858      floppy_mon_w(floppy_get_device(space->machine(), 2), ASSERT_LINE);
859      floppy_mon_w(floppy_get_device(space->machine(), 3), ASSERT_LINE);
801      floppy_mon_w(floppy_get_device(machine(), 0), ASSERT_LINE);
802      floppy_mon_w(floppy_get_device(machine(), 1), ASSERT_LINE);
803      floppy_mon_w(floppy_get_device(machine(), 2), ASSERT_LINE);
804      floppy_mon_w(floppy_get_device(machine(), 3), ASSERT_LINE);
860805      return;
861806   }
862807
863   wd17xx_set_drive(state->m_fdc,drive);
864   wd17xx_set_side(state->m_fdc,state->m_head);
808   wd17xx_set_drive(m_fdc,drive);
809   wd17xx_set_side(m_fdc,m_head);
865810
866811   /* Turn motors on */
867   floppy_mon_w(floppy_get_device(space->machine(), 0), CLEAR_LINE);
868   floppy_mon_w(floppy_get_device(space->machine(), 1), CLEAR_LINE);
869   floppy_mon_w(floppy_get_device(space->machine(), 2), CLEAR_LINE);
870   floppy_mon_w(floppy_get_device(space->machine(), 3), CLEAR_LINE);
812   floppy_mon_w(floppy_get_device(machine(), 0), CLEAR_LINE);
813   floppy_mon_w(floppy_get_device(machine(), 1), CLEAR_LINE);
814   floppy_mon_w(floppy_get_device(machine(), 2), CLEAR_LINE);
815   floppy_mon_w(floppy_get_device(machine(), 3), CLEAR_LINE);
871816}
872817
873818/*************************************
874819 *      Keyboard         *
875820 *************************************/
876READ8_HANDLER( trs80_keyboard_r )
821READ8_MEMBER( trs80_state::trs80_keyboard_r )
877822{
878823   UINT8 result = 0;
879824
880825   if (offset & 1)
881      result |= input_port_read(space->machine(), "LINE0");
826      result |= input_port_read(machine(), "LINE0");
882827   if (offset & 2)
883      result |= input_port_read(space->machine(), "LINE1");
828      result |= input_port_read(machine(), "LINE1");
884829   if (offset & 4)
885      result |= input_port_read(space->machine(), "LINE2");
830      result |= input_port_read(machine(), "LINE2");
886831   if (offset & 8)
887      result |= input_port_read(space->machine(), "LINE3");
832      result |= input_port_read(machine(), "LINE3");
888833   if (offset & 16)
889      result |= input_port_read(space->machine(), "LINE4");
834      result |= input_port_read(machine(), "LINE4");
890835   if (offset & 32)
891      result |= input_port_read(space->machine(), "LINE5");
836      result |= input_port_read(machine(), "LINE5");
892837   if (offset & 64)
893      result |= input_port_read(space->machine(), "LINE6");
838      result |= input_port_read(machine(), "LINE6");
894839   if (offset & 128)
895      result |= input_port_read(space->machine(), "LINE7");
840      result |= input_port_read(machine(), "LINE7");
896841
897842   return result;
898843}
r12357r12358
911856
912857   state->m_cassette_data_timer = machine.scheduler().timer_alloc(FUNC(cassette_data_callback));
913858   state->m_cassette_data_timer->adjust( attotime::zero, 0, attotime::from_hz(11025) );
914   state->m_printer = machine.device("centronics");
915   state->m_ay31015 = machine.device("tr1602");
916   state->m_cass = machine.device<cassette_image_device>(CASSETTE_TAG);
917   state->m_speaker = machine.device(SPEAKER_TAG);
918   state->m_fdc = machine.device("wd179x");
919859}
920860
921861MACHINE_RESET( trs80 )
r12357r12358
927867MACHINE_RESET( trs80m4 )
928868{
929869   trs80_state *state = machine.driver_data<trs80_state>();
930   address_space *mem = machine.device("maincpu")->memory().space(AS_PROGRAM);
870   address_space *mem = state->m_maincpu->memory().space(AS_PROGRAM);
931871   state->m_cassette_data = 0;
932872
933873   mem->install_read_bank (0x0000, 0x0fff, "bank1");
r12357r12358
949889   mem->install_write_bank (0x4000, 0xf3ff, "bank17");
950890   mem->install_write_bank (0xf400, 0xf7ff, "bank18");
951891   mem->install_write_bank (0xf800, 0xffff, "bank19");
952   trs80m4p_9c_w(mem, 0, 1);   /* Enable the ROM */
953   trs80m4_84_w(mem, 0, 0);   /* switch in devices at power-on */
892   state->trs80m4p_9c_w(*mem, 0, 1);   /* Enable the ROM */
893   state->trs80m4_84_w(*mem, 0, 0);   /* switch in devices at power-on */
954894}
955895
956896MACHINE_RESET( lnw80 )
957897{
958898   trs80_state *state = machine.driver_data<trs80_state>();
959   address_space *space = machine.device("maincpu")->memory().space(AS_PROGRAM);
899   address_space *space = state->m_maincpu->memory().space(AS_PROGRAM);
960900   state->m_cassette_data = 0;
961901   state->m_reg_load = 1;
962   lnw80_fe_w(space, 0, 0);
902   state->lnw80_fe_w(*space, 0, 0);
963903}
964904
src/mess/includes/trs80.h
r12357r12358
77#ifndef TRS80_H_
88#define TRS80_H_
99
10#include "emu.h"
11#include "cpu/z80/z80.h"
12#include "sound/speaker.h"
13#include "sound/wave.h"
14#include "machine/ay31015.h"
15#include "machine/ctronics.h"
16#include "machine/wd17xx.h"
17#include "imagedev/cassette.h"
18#include "imagedev/flopdrv.h"
1019#include "imagedev/snapquik.h"
11#include "imagedev/cassette.h"
12#include "machine/wd17xx.h"
20#include "formats/trs_cas.h"
21#include "formats/trs_cmd.h"
22#include "formats/trs_dsk.h"
1323
24
1425#define FW 6
1526#define FH 12
1627
17
1828class trs80_state : public driver_device
1929{
2030public:
2131   trs80_state(const machine_config &mconfig, device_type type, const char *tag)
22      : driver_device(mconfig, type, tag) { }
32      : driver_device(mconfig, type, tag),
33   m_maincpu(*this, "maincpu"),
34   m_printer(*this, "centronics"),
35   m_ay31015(*this, "tr1602"),
36   m_fdc(*this, "wd179x"),
37   m_speaker(*this, SPEAKER_TAG),
38   m_cass(*this, CASSETTE_TAG)
39   { }
2340
24   UINT8 *m_videoram;
41   required_device<cpu_device> m_maincpu;
42   optional_device<device_t> m_printer;
43   optional_device<device_t> m_ay31015;
44   optional_device<device_t> m_fdc;
45   required_device<device_t> m_speaker;
46   required_device<cassette_image_device> m_cass;
47   DECLARE_WRITE8_MEMBER ( trs80_ff_w );
48   DECLARE_WRITE8_MEMBER ( lnw80_fe_w );
49   DECLARE_WRITE8_MEMBER ( sys80_fe_w );
50   DECLARE_WRITE8_MEMBER ( sys80_f8_w );
51   DECLARE_WRITE8_MEMBER ( trs80m4_ff_w );
52   DECLARE_WRITE8_MEMBER ( trs80m4_f4_w );
53   DECLARE_WRITE8_MEMBER ( trs80m4_ec_w );
54   DECLARE_WRITE8_MEMBER ( trs80m4_eb_w );
55   DECLARE_WRITE8_MEMBER ( trs80m4_ea_w );
56   DECLARE_WRITE8_MEMBER ( trs80m4_e9_w );
57   DECLARE_WRITE8_MEMBER ( trs80m4_e8_w );
58   DECLARE_WRITE8_MEMBER ( trs80m4_e4_w );
59   DECLARE_WRITE8_MEMBER ( trs80m4_e0_w );
60   DECLARE_WRITE8_MEMBER ( trs80m4p_9c_w );
61   DECLARE_WRITE8_MEMBER ( trs80m4_90_w );
62   DECLARE_WRITE8_MEMBER ( trs80m4_84_w );
63   DECLARE_READ8_MEMBER ( lnw80_fe_r );
64   DECLARE_READ8_MEMBER ( trs80_ff_r );
65   DECLARE_READ8_MEMBER ( sys80_f9_r );
66   DECLARE_READ8_MEMBER ( trs80m4_ff_r );
67   DECLARE_READ8_MEMBER ( trs80m4_ec_r );
68   DECLARE_READ8_MEMBER ( trs80m4_eb_r );
69   DECLARE_READ8_MEMBER ( trs80m4_ea_r );
70   DECLARE_READ8_MEMBER ( trs80m4_e8_r );
71   DECLARE_READ8_MEMBER ( trs80m4_e4_r );
72   DECLARE_READ8_MEMBER ( trs80m4_e0_r );
73   DECLARE_READ8_MEMBER( trs80_irq_status_r );
74   DECLARE_READ8_MEMBER( trs80_printer_r );
75   DECLARE_WRITE8_MEMBER( trs80_printer_w );
76   DECLARE_WRITE8_MEMBER( trs80_cassunit_w );
77   DECLARE_WRITE8_MEMBER( trs80_motor_w );
78   DECLARE_READ8_MEMBER( trs80_keyboard_r );
79   DECLARE_WRITE8_MEMBER ( trs80m4_88_w );
80   DECLARE_READ8_MEMBER( trs80_videoram_r );
81   DECLARE_WRITE8_MEMBER( trs80_videoram_w );
82   DECLARE_READ8_MEMBER( trs80_gfxram_r );
83   DECLARE_WRITE8_MEMBER( trs80_gfxram_w );
84   DECLARE_READ8_MEMBER (trs80_wd179x_r);
85   const UINT8 *m_p_chargen;
86   UINT8 *m_p_videoram;
87   UINT8 *m_p_gfxram;
2588   UINT8 m_model4;
26   UINT8 *m_gfxram;
2789   UINT8 m_mode;
2890   UINT8 m_irq;
2991   UINT8 m_mask;
r12357r12358
41103#endif
42104   UINT8 m_cassette_data;
43105   emu_timer *m_cassette_data_timer;
44   device_t *m_printer;
45   device_t *m_ay31015;
46   cassette_image_device *m_cass;
47   device_t *m_speaker;
48   device_t *m_fdc;
49106   double m_old_cassette_val;
50107   UINT16 m_start_address;
51108   UINT8 m_crtc_reg;
r12357r12358
62119MACHINE_RESET( trs80m4 );
63120MACHINE_RESET( lnw80 );
64121
65WRITE8_HANDLER ( trs80_ff_w );
66WRITE8_HANDLER ( lnw80_fe_w );
67WRITE8_HANDLER ( sys80_fe_w );
68WRITE8_HANDLER ( sys80_f8_w );
69WRITE8_HANDLER ( trs80m4_ff_w );
70WRITE8_HANDLER ( trs80m4_f4_w );
71WRITE8_HANDLER ( trs80m4_ec_w );
72WRITE8_HANDLER ( trs80m4_eb_w );
73WRITE8_HANDLER ( trs80m4_ea_w );
74WRITE8_HANDLER ( trs80m4_e9_w );
75WRITE8_HANDLER ( trs80m4_e8_w );
76WRITE8_HANDLER ( trs80m4_e4_w );
77WRITE8_HANDLER ( trs80m4_e0_w );
78WRITE8_HANDLER ( trs80m4p_9c_w );
79WRITE8_HANDLER ( trs80m4_90_w );
80WRITE8_HANDLER ( trs80m4_84_w );
81READ8_HANDLER ( lnw80_fe_r );
82READ8_HANDLER ( trs80_ff_r );
83READ8_HANDLER ( sys80_f9_r );
84READ8_HANDLER ( trs80m4_ff_r );
85READ8_HANDLER ( trs80m4_ec_r );
86READ8_HANDLER ( trs80m4_eb_r );
87READ8_HANDLER ( trs80m4_ea_r );
88READ8_HANDLER ( trs80m4_e8_r );
89READ8_HANDLER ( trs80m4_e4_r );
90READ8_HANDLER ( trs80m4_e0_r );
91122
92123INTERRUPT_GEN( trs80_rtc_interrupt );
93124INTERRUPT_GEN( trs80_fdc_interrupt );
94125
95READ8_HANDLER( trs80_irq_status_r );
96126
97READ8_HANDLER( trs80_printer_r );
98WRITE8_HANDLER( trs80_printer_w );
99127
100WRITE8_HANDLER( trs80_cassunit_w );
101WRITE8_HANDLER( trs80_motor_w );
102
103READ8_HANDLER( trs80_keyboard_r );
104READ8_DEVICE_HANDLER (trs80_wd179x_r);
105
106
107128/*----------- defined in video/trs80.c -----------*/
108129
109130VIDEO_START( trs80 );
r12357r12358
113134SCREEN_UPDATE( radionic );
114135SCREEN_UPDATE( trs80m4 );
115136
116WRITE8_HANDLER ( trs80m4_88_w );
117137
118READ8_HANDLER( trs80_videoram_r );
119WRITE8_HANDLER( trs80_videoram_w );
120READ8_HANDLER( trs80_gfxram_r );
121WRITE8_HANDLER( trs80_gfxram_w );
122
123138PALETTE_INIT( lnw80 );
124139
125140
src/mess/video/trs80.c
r12357r12358
55  Functions to emulate the video hardware of the TRS80.
66
77***************************************************************************/
8#include "emu.h"
8
99#include "includes/trs80.h"
1010
11/* Bit assignment for "trs80_mode"
11/* Bit assignment for "state->m_mode"
1212    d7 Page select
1313    d6 LNW80 switch to graphics ram
1414    d5 LNW80 colour or monochrome (1=colour)
r12357r12358
1919    d0 80/64 or 40/32 characters per line (1=32) */
2020
2121
22WRITE8_HANDLER( trs80m4_88_w )
22WRITE8_MEMBER( trs80_state::trs80m4_88_w )
2323{
24   trs80_state *state = space->machine().driver_data<trs80_state>();
2524/* This is for the programming of the CRTC registers.
2625    However this CRTC is mask-programmed, and only the
2726    start address register can be used. The cursor and
r12357r12358
3029    Therefore it is easier to use normal
3130    coding rather than the mc6845 device. */
3231
33   if (!offset) state->m_crtc_reg = data & 0x1f;
32   if (!offset) m_crtc_reg = data & 0x1f;
3433
35   if (offset) switch (state->m_crtc_reg)
34   if (offset) switch (m_crtc_reg)
3635   {
3736      case 12:
38         state->m_start_address = (state->m_start_address & 0x00ff) | (data << 8);
37         m_start_address = (m_start_address & 0x00ff) | (data << 8);
3938         break;
4039      case 13:
41         state->m_start_address = (state->m_start_address & 0xff00) | data;
40         m_start_address = (m_start_address & 0xff00) | data;
4241   }
4342}
4443
r12357r12358
4645VIDEO_START( trs80 )
4746{
4847   trs80_state *state = machine.driver_data<trs80_state>();
48   state->m_p_chargen = machine.region("chargen")->base();
4949   state->m_size_store = 0xff;
5050   state->m_mode &= 2;
5151}
r12357r12358
5555SCREEN_UPDATE( trs80 )
5656{
5757   trs80_state *state = screen->machine().driver_data<trs80_state>();
58   UINT8 *videoram = state->m_videoram;
5958   UINT8 y,ra,chr,gfx,gfxbit;
6059   UINT16 sy=0,ma=0,x;
61   UINT8 *FNT = screen->machine().region("gfx1")->base();
62   UINT8 cols = (state->m_mode & 1) ? 32 : 64;
63   UINT8 skip = (state->m_mode & 1) ? 2 : 1;
60   UINT8 cols = BIT(state->m_mode, 0) ? 32 : 64;
61   UINT8 skip = BIT(state->m_mode, 0) ? 2 : 1;
6462
6563   if (state->m_mode != state->m_size_store)
6664   {
6765      state->m_size_store = state->m_mode & 1;
68      screen->set_visible_area(0, cols*FW-1, 0, 16*FH-1);
66      screen->set_visible_area(0, cols*6-1, 0, 16*12-1);
6967   }
7068
7169   for (y = 0; y < 16; y++)
7270   {
73      for (ra = 0; ra < FH; ra++)
71      for (ra = 0; ra < 12; ra++)
7472      {
7573         UINT16 *p = BITMAP_ADDR16(bitmap, sy++, 0);
7674
7775         for (x = ma; x < ma + 64; x+=skip)
7876         {
79            chr = videoram[x];
77            chr = state->m_p_videoram[x];
8078
8179            if (chr & 0x80)
8280            {
83               gfxbit = 1<<((ra & 0x0c)>>1);
81               gfxbit = (ra & 0x0c)>>1;
8482               /* Display one line of a lores character (6 pixels) */
85               *p++ = ( chr & gfxbit ) ? 1 : 0;
86               *p++ = ( chr & gfxbit ) ? 1 : 0;
87               *p++ = ( chr & gfxbit ) ? 1 : 0;
88               gfxbit <<= 1;
89               *p++ = ( chr & gfxbit ) ? 1 : 0;
90               *p++ = ( chr & gfxbit ) ? 1 : 0;
91               *p++ = ( chr & gfxbit ) ? 1 : 0;
83               *p++ = BIT(chr, gfxbit);
84               *p++ = BIT(chr, gfxbit);
85               *p++ = BIT(chr, gfxbit);
86               gfxbit++;
87               *p++ = BIT(chr, gfxbit);
88               *p++ = BIT(chr, gfxbit);
89               *p++ = BIT(chr, gfxbit);
9290            }
9391            else
9492            {
95               if ((state->m_mode & 2) && (chr < 32)) chr+=64;
93               if (BIT(state->m_mode, 1) & (chr < 32)) chr+=64;
9694
97               /* get pattern of pixels for that character scanline */
98               if (ra < 8)
99                  gfx = FNT[(chr<<3) | ra ];
95               // if g,j,p,q,y; lower the descender
96               if ((chr==0x2c)||(chr==0x3b)||(chr==0x67)||(chr==0x6a)||(chr==0x70)||(chr==0x71)||(chr==0x79))
97               {
98                  if ((ra < 10) && (ra > 1))
99                     gfx = state->m_p_chargen[(chr<<3) | (ra-2) ];
100                  else
101                     gfx = 0;
102               }
100103               else
101                  gfx = 0;
104               {
105                  if (ra < 8)
106                     gfx = state->m_p_chargen[(chr<<3) | ra ];
107                  else
108                     gfx = 0;
109               }
102110
103111               /* Display a scanline of a character (6 pixels) */
104               *p++ = ( gfx & 0x20 ) ? 1 : 0;
105               *p++ = ( gfx & 0x10 ) ? 1 : 0;
106               *p++ = ( gfx & 0x08 ) ? 1 : 0;
107               *p++ = ( gfx & 0x04 ) ? 1 : 0;
108               *p++ = ( gfx & 0x02 ) ? 1 : 0;
109               *p++ = ( gfx & 0x01 ) ? 1 : 0;
112               *p++ = BIT(gfx, 5);
113               *p++ = BIT(gfx, 4);
114               *p++ = BIT(gfx, 3);
115               *p++ = BIT(gfx, 2);
116               *p++ = BIT(gfx, 1);
117               *p++ = BIT(gfx, 0);
110118            }
111119         }
112120      }
r12357r12358
119127SCREEN_UPDATE( trs80m4 )
120128{
121129   trs80_state *state = screen->machine().driver_data<trs80_state>();
122   UINT8 *videoram = state->m_videoram;
123130   UINT8 y,ra,chr,gfx,gfxbit;
124131   UINT16 sy=0,ma=0,x;
125   UINT8 *FNT = screen->machine().region("gfx1")->base();
126132   UINT8 skip=1;
127   UINT8 cols = (state->m_mode & 4) ? 80 : 64;
128   UINT8 rows = (state->m_mode & 4) ? 24 : 16;
129   UINT8 lines = (state->m_mode & 4) ? 10 : 12;
133   UINT8 cols = BIT(state->m_mode, 2) ? 80 : 64;
134   UINT8 rows = BIT(state->m_mode, 2) ? 24 : 16;
135   UINT8 lines = BIT(state->m_mode, 2) ? 10 : 12;
130136   UINT8 s_cols = cols;
131   UINT8 mask = (state->m_mode & 0x20) ? 0xff : 0xbf;   /* Select Japanese or extended chars */
137   UINT8 mask = BIT(state->m_mode, 5) ? 0xff : 0xbf;   /* Select Japanese or extended chars */
132138
133139   if (state->m_mode & 1)
134140   {
r12357r12358
150156
151157         for (x = ma; x < ma + cols; x+=skip)
152158         {
153            chr = videoram[x+state->m_start_address];
159            chr = state->m_p_videoram[x+state->m_start_address];
154160
155161            if (((chr & 0xc0) == 0xc0) && (~state->m_mode & 8))
156162            {
157163               if (ra < 8)
158                  gfx = FNT[((chr&mask)<<3) | ra ];
164                  gfx = state->m_p_chargen[((chr&mask)<<3) | ra ];
159165               else
160166                  gfx = 0;
161167
162               *p++ = ( gfx & 0x80 ) ? 1 : 0;
163               *p++ = ( gfx & 0x40 ) ? 1 : 0;
164               *p++ = ( gfx & 0x20 ) ? 1 : 0;
165               *p++ = ( gfx & 0x10 ) ? 1 : 0;
166               *p++ = ( gfx & 0x08 ) ? 1 : 0;
167               *p++ = ( gfx & 0x04 ) ? 1 : 0;
168               *p++ = ( gfx & 0x02 ) ? 1 : 0;
169               *p++ = ( gfx & 0x01 ) ? 1 : 0;
168               *p++ = BIT(gfx, 7);
169               *p++ = BIT(gfx, 6);
170               *p++ = BIT(gfx, 5);
171               *p++ = BIT(gfx, 4);
172               *p++ = BIT(gfx, 3);
173               *p++ = BIT(gfx, 2);
174               *p++ = BIT(gfx, 1);
175               *p++ = BIT(gfx, 0);
170176            }
171177            else
172178            if ((chr & 0x80) && (~state->m_mode & 8))
173179            {
174               gfxbit = 1<<((ra & 0x0c)>>1);
180               gfxbit = (ra & 0x0c)>>1;
175181               /* Display one line of a lores character */
176               *p++ = ( chr & gfxbit ) ? 1 : 0;
177               *p++ = ( chr & gfxbit ) ? 1 : 0;
178               *p++ = ( chr & gfxbit ) ? 1 : 0;
179               *p++ = ( chr & gfxbit ) ? 1 : 0;
180               gfxbit <<= 1;
181               *p++ = ( chr & gfxbit ) ? 1 : 0;
182               *p++ = ( chr & gfxbit ) ? 1 : 0;
183               *p++ = ( chr & gfxbit ) ? 1 : 0;
184               *p++ = ( chr & gfxbit ) ? 1 : 0;
182               *p++ = BIT(chr, gfxbit);
183               *p++ = BIT(chr, gfxbit);
184               *p++ = BIT(chr, gfxbit);
185               *p++ = BIT(chr, gfxbit);
186               gfxbit++;
187               *p++ = BIT(chr, gfxbit);
188               *p++ = BIT(chr, gfxbit);
189               *p++ = BIT(chr, gfxbit);
190               *p++ = BIT(chr, gfxbit);
185191            }
186192            else
187193            {
188194               /* get pattern of pixels for that character scanline */
189195               if (ra < 8)
190                  gfx = FNT[((chr&0x7f)<<3) | ra ];
196                  gfx = state->m_p_chargen[((chr&0x7f)<<3) | ra ];
191197               else
192198                  gfx = 0;
193199
194200               /* if inverse mode, and bit 7 set, invert gfx */
195               if ((state->m_mode & 8) && (chr & 0x80))
201               if (BIT(state->m_mode, 3) & BIT(chr, 7))
196202                  gfx ^= 0xff;
197203
198204               /* Display a scanline of a character */
199               *p++ = ( gfx & 0x80 ) ? 1 : 0;
200               *p++ = ( gfx & 0x40 ) ? 1 : 0;
201               *p++ = ( gfx & 0x20 ) ? 1 : 0;
202               *p++ = ( gfx & 0x10 ) ? 1 : 0;
203               *p++ = ( gfx & 0x08 ) ? 1 : 0;
204               *p++ = ( gfx & 0x04 ) ? 1 : 0;
205               *p++ = ( gfx & 0x02 ) ? 1 : 0;
206               *p++ = ( gfx & 0x01 ) ? 1 : 0;
205               *p++ = BIT(gfx, 7);
206               *p++ = BIT(gfx, 6);
207               *p++ = BIT(gfx, 5);
208               *p++ = BIT(gfx, 4);
209               *p++ = BIT(gfx, 3);
210               *p++ = BIT(gfx, 2);
211               *p++ = BIT(gfx, 1);
212               *p++ = BIT(gfx, 0);
207213            }
208214         }
209215      }
r12357r12358
216222SCREEN_UPDATE( ht1080z )
217223{
218224   trs80_state *state = screen->machine().driver_data<trs80_state>();
219   UINT8 *videoram = state->m_videoram;
220225   UINT8 y,ra,chr,gfx,gfxbit;
221226   UINT16 sy=0,ma=0,x;
222   UINT8 *FNT = screen->machine().region("gfx1")->base();
223   UINT8 cols = (state->m_mode & 1) ? 32 : 64;
224   UINT8 skip = (state->m_mode & 1) ? 2 : 1;
227   UINT8 cols = BIT(state->m_mode, 0) ? 32 : 64;
228   UINT8 skip = BIT(state->m_mode, 0) ? 2 : 1;
225229
226230   if (state->m_mode != state->m_size_store)
227231   {
228232      state->m_size_store = state->m_mode & 1;
229      screen->set_visible_area(0, cols*FW-1, 0, 16*FH-1);
233      screen->set_visible_area(0, cols*6-1, 0, 16*12-1);
230234   }
231235
232236   for (y = 0; y < 16; y++)
233237   {
234      for (ra = 0; ra < FH; ra++)
238      for (ra = 0; ra < 12; ra++)
235239      {
236240         UINT16 *p = BITMAP_ADDR16(bitmap, sy++, 0);
237241
238242         for (x = ma; x < ma + 64; x+=skip)
239243         {
240            chr = videoram[x];
244            chr = state->m_p_videoram[x];
241245
242246            if (chr & 0x80)
243247            {
244               gfxbit = 1<<((ra & 0x0c)>>1);
248               gfxbit = (ra & 0x0c)>>1;
245249               /* Display one line of a lores character (6 pixels) */
246               *p++ = ( chr & gfxbit ) ? 1 : 0;
247               *p++ = ( chr & gfxbit ) ? 1 : 0;
248               *p++ = ( chr & gfxbit ) ? 1 : 0;
249               gfxbit <<= 1;
250               *p++ = ( chr & gfxbit ) ? 1 : 0;
251               *p++ = ( chr & gfxbit ) ? 1 : 0;
252               *p++ = ( chr & gfxbit ) ? 1 : 0;
250               *p++ = BIT(chr, gfxbit);
251               *p++ = BIT(chr, gfxbit);
252               *p++ = BIT(chr, gfxbit);
253               gfxbit++;
254               *p++ = BIT(chr, gfxbit);
255               *p++ = BIT(chr, gfxbit);
256               *p++ = BIT(chr, gfxbit);
253257            }
254258            else
255259            {
256260               if ((state->m_mode & 2) && (chr < 32)) chr+=64;
257261
258262               /* get pattern of pixels for that character scanline */
259               gfx = FNT[(chr<<4) | ra ];
263               gfx = state->m_p_chargen[(chr<<4) | ra ];
260264
261265               /* Display a scanline of a character (6 pixels) */
262               *p++ = ( gfx & 0x80 ) ? 1 : 0;
263               *p++ = ( gfx & 0x40 ) ? 1 : 0;
264               *p++ = ( gfx & 0x20 ) ? 1 : 0;
265               *p++ = ( gfx & 0x10 ) ? 1 : 0;
266               *p++ = ( gfx & 0x08 ) ? 1 : 0;
266               *p++ = BIT(gfx, 7);
267               *p++ = BIT(gfx, 6);
268               *p++ = BIT(gfx, 5);
269               *p++ = BIT(gfx, 4);
270               *p++ = BIT(gfx, 3);
267271               *p++ = 0;   /* fix for ht108064 */
268272            }
269273         }
r12357r12358
277281SCREEN_UPDATE( lnw80 )
278282{
279283   trs80_state *state = screen->machine().driver_data<trs80_state>();
280   UINT8 *videoram = state->m_videoram;
281284   static const UINT16 rows[] = { 0, 0x200, 0x100, 0x300, 1, 0x201, 0x101, 0x301 };
282285   UINT8 chr,gfx,gfxbit,bg=7,fg=0;
283286   UINT16 sy=0,ma=0,x,y,ra;
284   UINT8 *FNT = screen->machine().region("gfx1")->base();
285   UINT8 cols = (state->m_mode & 0x10) ? 80 : 64;
287   UINT8 cols = BIT(state->m_mode, 4) ? 80 : 64;
286288
287289   /* Although the OS can select 32-character mode, it is not supported by hardware */
288290   if (state->m_mode != state->m_size_store)
289291   {
290292      state->m_size_store = state->m_mode & 0x10;
291      screen->set_visible_area(0, cols*FW-1, 0, 16*FH-1);
293      screen->set_visible_area(0, cols*6-1, 0, 16*12-1);
292294   }
293295
294296   if (state->m_mode & 8)
r12357r12358
302304      case 0:               // MODE 0
303305         for (y = 0; y < 16; y++)
304306         {
305            for (ra = 0; ra < FH; ra++)
307            for (ra = 0; ra < 12; ra++)
306308            {
307309               UINT16 *p = BITMAP_ADDR16(bitmap, sy++, 0);
308310
309311               for (x = ma; x < ma + 64; x++)
310312               {
311                  chr = videoram[x];
313                  chr = state->m_p_videoram[x];
312314
313315                  if (chr & 0x80)
314316                  {
315                     gfxbit = 1<<((ra & 0x0c)>>1);
317                     gfxbit = (ra & 0x0c)>>1;
316318                     /* Display one line of a lores character (6 pixels) */
317                     *p++ = ( chr & gfxbit ) ? fg : bg;
318                     *p++ = ( chr & gfxbit ) ? fg : bg;
319                     *p++ = ( chr & gfxbit ) ? fg : bg;
320                     gfxbit <<= 1;
321                     *p++ = ( chr & gfxbit ) ? fg : bg;
322                     *p++ = ( chr & gfxbit ) ? fg : bg;
323                     *p++ = ( chr & gfxbit ) ? fg : bg;
319                     *p++ = BIT(chr, gfxbit) ? fg : bg;
320                     *p++ = BIT(chr, gfxbit) ? fg : bg;
321                     *p++ = BIT(chr, gfxbit) ? fg : bg;
322                     gfxbit++;
323                     *p++ = BIT(chr, gfxbit) ? fg : bg;
324                     *p++ = BIT(chr, gfxbit) ? fg : bg;
325                     *p++ = BIT(chr, gfxbit) ? fg : bg;
324326                  }
325327                  else
326328                  {
327329                     /* get pattern of pixels for that character scanline */
328330                     if (ra < 8)
329                        gfx = FNT[(chr<<1) | rows[ra] ];
331                        gfx = state->m_p_chargen[(chr<<1) | rows[ra] ];
330332                     else
331333                        gfx = 0;
332334
333335                     /* Display a scanline of a character (6 pixels) */
334                     *p++ = ( gfx & 0x04 ) ? fg : bg;
335                     *p++ = ( gfx & 0x02 ) ? fg : bg;
336                     *p++ = ( gfx & 0x40 ) ? fg : bg;
337                     *p++ = ( gfx & 0x80 ) ? fg : bg;
338                     *p++ = ( gfx & 0x20 ) ? fg : bg;
339                     *p++ = ( gfx & 0x08 ) ? fg : bg;
336                     *p++ = BIT(gfx, 2) ? fg : bg;
337                     *p++ = BIT(gfx, 1) ? fg : bg;
338                     *p++ = BIT(gfx, 6) ? fg : bg;
339                     *p++ = BIT(gfx, 7) ? fg : bg;
340                     *p++ = BIT(gfx, 5) ? fg : bg;
341                     *p++ = BIT(gfx, 3) ? fg : bg;
340342                  }
341343               }
342344            }
r12357r12358
353355
354356               for (x = 0; x < 0x40; x++)
355357               {
356                  gfx = state->m_gfxram[ y | x | ra];
358                  gfx = state->m_p_gfxram[ y | x | ra];
357359                  /* Display 6 pixels in normal region */
358                  *p++ = ( gfx & 0x01 ) ? fg : bg;
359                  *p++ = ( gfx & 0x02 ) ? fg : bg;
360                  *p++ = ( gfx & 0x04 ) ? fg : bg;
361                  *p++ = ( gfx & 0x08 ) ? fg : bg;
362                  *p++ = ( gfx & 0x10 ) ? fg : bg;
363                  *p++ = ( gfx & 0x20 ) ? fg : bg;
360                  *p++ = BIT(gfx, 0) ? fg : bg;
361                  *p++ = BIT(gfx, 1) ? fg : bg;
362                  *p++ = BIT(gfx, 2) ? fg : bg;
363                  *p++ = BIT(gfx, 3) ? fg : bg;
364                  *p++ = BIT(gfx, 4) ? fg : bg;
365                  *p++ = BIT(gfx, 5) ? fg : bg;
364366               }
365367
366368               for (x = 0; x < 0x10; x++)
367369               {
368                  gfx = state->m_gfxram[ 0x3000 | x | (ra & 0xc00) | ((ra & 0x3000) >> 8)];
370                  gfx = state->m_p_gfxram[ 0x3000 | x | (ra & 0xc00) | ((ra & 0x3000) >> 8)];
369371                  /* Display 6 pixels in extended region */
370                  *p++ = ( gfx & 0x01 ) ? fg : bg;
371                  *p++ = ( gfx & 0x02 ) ? fg : bg;
372                  *p++ = ( gfx & 0x04 ) ? fg : bg;
373                  *p++ = ( gfx & 0x08 ) ? fg : bg;
374                  *p++ = ( gfx & 0x10 ) ? fg : bg;
375                  *p++ = ( gfx & 0x20 ) ? fg : bg;
372                  *p++ = BIT(gfx, 0) ? fg : bg;
373                  *p++ = BIT(gfx, 1) ? fg : bg;
374                  *p++ = BIT(gfx, 2) ? fg : bg;
375                  *p++ = BIT(gfx, 3) ? fg : bg;
376                  *p++ = BIT(gfx, 4) ? fg : bg;
377                  *p++ = BIT(gfx, 5) ? fg : bg;
376378               }
377379            }
378380         }
r12357r12358
389391
390392               for (x = 0; x < 0x40; x++)
391393               {
392                  gfx = state->m_gfxram[ y | x | ra];
394                  gfx = state->m_p_gfxram[ y | x | ra];
393395                  /* Display 6 pixels in normal region */
394396                  fg = (gfx & 0x38) >> 3;
395397                  *p++ = fg;
r12357r12358
416418
417419               for (x = 0; x < 0x40; x++)
418420               {
419                  gfx = state->m_gfxram[ y | x | ra];
420                  fg = (videoram[ 0x3c00 | x | y ] & 0x38) >> 3;
421                  gfx = state->m_p_gfxram[ y | x | ra];
422                  fg = (state->m_p_videoram[ 0x3c00 | x | y ] & 0x38) >> 3;
421423                  /* Display 6 pixels in normal region */
422                  *p++ = ( gfx & 0x01 ) ? fg : bg;
423                  *p++ = ( gfx & 0x02 ) ? fg : bg;
424                  *p++ = ( gfx & 0x04 ) ? fg : bg;
425                  fg = videoram[ 0x3c00 | x | y ] & 0x07;
426                  *p++ = ( gfx & 0x08 ) ? fg : bg;
427                  *p++ = ( gfx & 0x10 ) ? fg : bg;
428                  *p++ = ( gfx & 0x20 ) ? fg : bg;
424                  *p++ = BIT(gfx, 0) ? fg : bg;
425                  *p++ = BIT(gfx, 1) ? fg : bg;
426                  *p++ = BIT(gfx, 2) ? fg : bg;
427                  fg = state->m_p_videoram[ 0x3c00 | x | y ] & 0x07;
428                  *p++ = BIT(gfx, 3) ? fg : bg;
429                  *p++ = BIT(gfx, 4) ? fg : bg;
430                  *p++ = BIT(gfx, 5) ? fg : bg;
429431               }
430432
431433               for (x = 0; x < 0x10; x++)
432434               {
433                  gfx = state->m_gfxram[ 0x3000 | x | (ra & 0xc00) | ((ra & 0x3000) >> 8)];
434                  fg = (state->m_gfxram[ 0x3c00 | x | y ] & 0x38) >> 3;
435                  gfx = state->m_p_gfxram[ 0x3000 | x | (ra & 0xc00) | ((ra & 0x3000) >> 8)];
436                  fg = (state->m_p_gfxram[ 0x3c00 | x | y ] & 0x38) >> 3;
435437                  /* Display 6 pixels in extended region */
436                  *p++ = ( gfx & 0x01 ) ? fg : bg;
437                  *p++ = ( gfx & 0x02 ) ? fg : bg;
438                  *p++ = ( gfx & 0x04 ) ? fg : bg;
439                  fg = state->m_gfxram[ 0x3c00 | x | y ] & 0x07;
440                  *p++ = ( gfx & 0x08 ) ? fg : bg;
441                  *p++ = ( gfx & 0x10 ) ? fg : bg;
442                  *p++ = ( gfx & 0x20 ) ? fg : bg;
438                  *p++ = BIT(gfx, 0) ? fg : bg;
439                  *p++ = BIT(gfx, 1) ? fg : bg;
440                  *p++ = BIT(gfx, 2) ? fg : bg;
441                  fg = state->m_p_gfxram[ 0x3c00 | x | y ] & 0x07;
442                  *p++ = BIT(gfx, 3) ? fg : bg;
443                  *p++ = BIT(gfx, 4) ? fg : bg;
444                  *p++ = BIT(gfx, 5) ? fg : bg;
443445               }
444446            }
445447         }
r12357r12358
452454SCREEN_UPDATE( radionic )
453455{
454456   trs80_state *state = screen->machine().driver_data<trs80_state>();
455   UINT8 *videoram = state->m_videoram;
456457   UINT8 y,ra,chr,gfx;
457458   UINT16 sy=0,ma=0,x;
458   UINT8 *FNT = screen->machine().region("gfx1")->base();
459   UINT8 cols = (state->m_mode & 1) ? 32 : 64;
460   UINT8 skip = (state->m_mode & 1) ? 2 : 1;
459   UINT8 cols = BIT(state->m_mode, 0) ? 32 : 64;
460   UINT8 skip = BIT(state->m_mode, 0) ? 2 : 1;
461461
462462   if (state->m_mode != state->m_size_store)
463463   {
r12357r12358
473473
474474         for (x = ma; x < ma + 64; x+=skip)
475475         {
476            chr = videoram[x];
476            chr = state->m_p_videoram[x];
477477
478478            /* get pattern of pixels for that character scanline */
479            gfx = FNT[(chr<<3) | (ra & 7) | (ra & 8) << 8];
479            gfx = state->m_p_chargen[(chr<<3) | (ra & 7) | (ra & 8) << 8];
480480
481481            /* Display a scanline of a character (8 pixels) */
482            *p++ = ( gfx & 0x01 ) ? 1 : 0;
483            *p++ = ( gfx & 0x02 ) ? 1 : 0;
484            *p++ = ( gfx & 0x04 ) ? 1 : 0;
485            *p++ = ( gfx & 0x08 ) ? 1 : 0;
486            *p++ = ( gfx & 0x10 ) ? 1 : 0;
487            *p++ = ( gfx & 0x20 ) ? 1 : 0;
488            *p++ = ( gfx & 0x40 ) ? 1 : 0;
489            *p++ = ( gfx & 0x80 ) ? 1 : 0;
482            *p++ = BIT(gfx, 0);
483            *p++ = BIT(gfx, 1);
484            *p++ = BIT(gfx, 2);
485            *p++ = BIT(gfx, 3);
486            *p++ = BIT(gfx, 4);
487            *p++ = BIT(gfx, 5);
488            *p++ = BIT(gfx, 6);
489            *p++ = BIT(gfx, 7);
490490         }
491491      }
492492      ma+=64;
r12357r12358
499499  Write to video ram
500500***************************************************************************/
501501
502READ8_HANDLER( trs80_videoram_r )
502READ8_MEMBER( trs80_state::trs80_videoram_r )
503503{
504   trs80_state *state = space->machine().driver_data<trs80_state>();
505   UINT8 *videoram = state->m_videoram;
506   if ((state->m_mode & 0x80) && (~state->m_model4 & 1)) offset |= 0x400;
507   return videoram[offset];
504   if ((m_mode & 0x80) && (~m_model4 & 1)) offset |= 0x400;
505   return m_p_videoram[offset];
508506}
509507
510WRITE8_HANDLER( trs80_videoram_w )
508WRITE8_MEMBER( trs80_state::trs80_videoram_w )
511509{
512   trs80_state *state = space->machine().driver_data<trs80_state>();
513   UINT8 *videoram = state->m_videoram;
514   if ((state->m_mode & 0x80) && (~state->m_model4 & 1)) offset |= 0x400;
515   videoram[offset] = data;
510   if ((m_mode & 0x80) && (~m_model4 & 1)) offset |= 0x400;
511   m_p_videoram[offset] = data;
516512}
517513
518514
r12357r12358
520516  Write to graphics ram
521517***************************************************************************/
522518
523READ8_HANDLER( trs80_gfxram_r )
519READ8_MEMBER( trs80_state::trs80_gfxram_r )
524520{
525   trs80_state *state = space->machine().driver_data<trs80_state>();
526   return state->m_gfxram[offset];
521   return m_p_gfxram[offset];
527522}
528523
529WRITE8_HANDLER( trs80_gfxram_w )
524WRITE8_MEMBER( trs80_state::trs80_gfxram_w )
530525{
531   trs80_state *state = space->machine().driver_data<trs80_state>();
532   state->m_gfxram[offset] = data;
526   m_p_gfxram[offset] = data;
533527}
534528
535529
src/mess/drivers/trs80.c
r12357r12358
8989    - 90-93 write sound (optional)
9090    - 80-8F hires graphics (optional)
9191
92About the Model II - this runs a boostrap rom, and boots a floppy. The rom is then bankswitched
93out, and RAM takes its place. There is no rom basic, and no cassette support. Display sizes are
9480x24 and 40x24. It could have 32k or 64k RAM. 2x RS-232C ports. 1x Parallel printer port. 1x
95Expansion interface for more floppy drives. The drives use 8-inch floppies holding 0.5mb of data.
96It was extremely expensive, non-standard, and not many were sold. A rom dump does not seem to exist.
97
9892About the ht1080z - This was made for schools in Hungary. Each comes with a BASIC extension roms
9993        which activated Hungarian features. To activate - start emulation - enter SYSTEM
10094        Enter /12288 and the extensions will be installed and you are returned to READY.
r12357r12358
138132There don't seem to be any JV1 boot disks for Model III/4.
139133
140134***************************************************************************/
135#define ADDRESS_MAP_MODERN
141136
142/* Core includes */
143#include "emu.h"
144#include "cpu/z80/z80.h"
145#include "sound/wave.h"
146#include "machine/ctronics.h"
147#include "machine/ay31015.h"
148137#include "includes/trs80.h"
149138
150/* Components */
151#include "machine/wd17xx.h"
152#include "sound/speaker.h"
153139
154/* Devices */
155#include "imagedev/flopdrv.h"
156#include "formats/trs_dsk.h"
157#include "imagedev/cassette.h"
158#include "formats/trs_cas.h"
159#include "formats/trs_cmd.h"
160
161
162static ADDRESS_MAP_START( trs80_map, AS_PROGRAM, 8 )
140static ADDRESS_MAP_START( trs80_map, AS_PROGRAM, 8, trs80_state )
163141   AM_RANGE(0x0000, 0x0fff) AM_ROM
164142   AM_RANGE(0x3800, 0x38ff) AM_READ(trs80_keyboard_r)
165   AM_RANGE(0x3c00, 0x3fff) AM_READWRITE(trs80_videoram_r, trs80_videoram_w) AM_BASE_MEMBER(trs80_state, m_videoram)
143   AM_RANGE(0x3c00, 0x3fff) AM_READWRITE(trs80_videoram_r, trs80_videoram_w) AM_BASE(m_p_videoram)
166144   AM_RANGE(0x4000, 0x7fff) AM_RAM
167145ADDRESS_MAP_END
168146
169static ADDRESS_MAP_START( trs80_io, AS_IO, 8 )
147static ADDRESS_MAP_START( trs80_io, AS_IO, 8, trs80_state )
170148   ADDRESS_MAP_GLOBAL_MASK(0xff)
171149   AM_RANGE(0xff, 0xff) AM_READWRITE(trs80_ff_r, trs80_ff_w)
172150ADDRESS_MAP_END
173151
174static ADDRESS_MAP_START( model1_map, AS_PROGRAM, 8 )
152static ADDRESS_MAP_START( model1_map, AS_PROGRAM, 8, trs80_state )
175153   AM_RANGE(0x0000, 0x377f) AM_ROM   // sys80,ht1080 needs up to 375F
176154   AM_RANGE(0x37de, 0x37de) AM_READWRITE(sys80_f9_r, sys80_f8_w)
177155   AM_RANGE(0x37df, 0x37df) AM_READWRITE(trs80m4_eb_r, trs80m4_eb_w)
178156   AM_RANGE(0x37e0, 0x37e3) AM_READWRITE(trs80_irq_status_r, trs80_motor_w)
179157   AM_RANGE(0x37e4, 0x37e7) AM_WRITE(trs80_cassunit_w)
180158   AM_RANGE(0x37e8, 0x37eb) AM_READWRITE(trs80_printer_r, trs80_printer_w)
181   AM_RANGE(0x37ec, 0x37ec) AM_DEVREADWRITE("wd179x", trs80_wd179x_r, wd17xx_command_w)
182   AM_RANGE(0x37ed, 0x37ed) AM_DEVREADWRITE("wd179x", wd17xx_track_r, wd17xx_track_w)
183   AM_RANGE(0x37ee, 0x37ee) AM_DEVREADWRITE("wd179x", wd17xx_sector_r, wd17xx_sector_w)
184   AM_RANGE(0x37ef, 0x37ef) AM_DEVREADWRITE("wd179x", wd17xx_data_r, wd17xx_data_w)
159   AM_RANGE(0x37ec, 0x37ec) AM_READ(trs80_wd179x_r)
160   AM_RANGE(0x37ec, 0x37ec) AM_DEVWRITE_LEGACY("wd179x", wd17xx_command_w)
161   AM_RANGE(0x37ed, 0x37ed) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_track_r, wd17xx_track_w)
162   AM_RANGE(0x37ee, 0x37ee) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_sector_r, wd17xx_sector_w)
163   AM_RANGE(0x37ef, 0x37ef) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_data_r, wd17xx_data_w)
185164   AM_RANGE(0x3800, 0x38ff) AM_MIRROR(0x300) AM_READ(trs80_keyboard_r)
186   AM_RANGE(0x3c00, 0x3fff) AM_READWRITE(trs80_videoram_r, trs80_videoram_w) AM_BASE_MEMBER(trs80_state, m_videoram)
165   AM_RANGE(0x3c00, 0x3fff) AM_READWRITE(trs80_videoram_r, trs80_videoram_w) AM_BASE(m_p_videoram)
187166   AM_RANGE(0x4000, 0xffff) AM_RAM
188167ADDRESS_MAP_END
189168
190static ADDRESS_MAP_START( model1_io, AS_IO, 8 )
169static ADDRESS_MAP_START( model1_io, AS_IO, 8, trs80_state )
191170   ADDRESS_MAP_GLOBAL_MASK(0xff)
192171   AM_RANGE(0xff, 0xff) AM_READWRITE(trs80_ff_r, trs80_ff_w)
193172ADDRESS_MAP_END
194173
195static ADDRESS_MAP_START( sys80_io, AS_IO, 8 )
174static ADDRESS_MAP_START( sys80_io, AS_IO, 8, trs80_state )
196175   ADDRESS_MAP_GLOBAL_MASK(0xff)
197176   AM_RANGE(0xf8, 0xf8) AM_READWRITE(trs80m4_eb_r, sys80_f8_w)
198177   AM_RANGE(0xf9, 0xf9) AM_READWRITE(sys80_f9_r, trs80m4_eb_w)
r12357r12358
201180   AM_RANGE(0xff, 0xff) AM_READWRITE(trs80_ff_r, trs80_ff_w)
202181ADDRESS_MAP_END
203182
204static ADDRESS_MAP_START( lnw80_map, AS_PROGRAM, 8 )
183static ADDRESS_MAP_START( lnw80_map, AS_PROGRAM, 8, trs80_state )
205184   AM_RANGE(0x4000, 0xffff) AM_RAM
206185ADDRESS_MAP_END
207186
208static ADDRESS_MAP_START( lnw80_io, AS_IO, 8 )
187static ADDRESS_MAP_START( lnw80_io, AS_IO, 8, trs80_state )
209188   ADDRESS_MAP_GLOBAL_MASK(0xff)
210189   AM_RANGE(0xe8, 0xe8) AM_READWRITE(trs80m4_e8_r, trs80m4_e8_w)
211190   AM_RANGE(0xe9, 0xe9) AM_READ_PORT("E9")
r12357r12358
215194   AM_RANGE(0xff, 0xff) AM_READWRITE(trs80_ff_r, trs80_ff_w)
216195ADDRESS_MAP_END
217196
218static ADDRESS_MAP_START( model3_map, AS_PROGRAM, 8 )
197static ADDRESS_MAP_START( model3_map, AS_PROGRAM, 8, trs80_state )
219198ADDRESS_MAP_END
220199
221static ADDRESS_MAP_START( model3_io, AS_IO, 8 )
200static ADDRESS_MAP_START( model3_io, AS_IO, 8, trs80_state )
222201   ADDRESS_MAP_GLOBAL_MASK(0xff)
223202   AM_RANGE(0xe0, 0xe3) AM_READWRITE(trs80m4_e0_r, trs80m4_e0_w)
224203   AM_RANGE(0xe4, 0xe4) AM_READWRITE(trs80m4_e4_r, trs80m4_e4_w)
r12357r12358
227206   AM_RANGE(0xea, 0xea) AM_READWRITE(trs80m4_ea_r, trs80m4_ea_w)
228207   AM_RANGE(0xeb, 0xeb) AM_READWRITE(trs80m4_eb_r, trs80m4_eb_w)
229208   AM_RANGE(0xec, 0xef) AM_READWRITE(trs80m4_ec_r, trs80m4_ec_w)
230   AM_RANGE(0xf0, 0xf0) AM_DEVREADWRITE("wd179x", trs80_wd179x_r, wd17xx_command_w)
231   AM_RANGE(0xf1, 0xf1) AM_DEVREADWRITE("wd179x", wd17xx_track_r, wd17xx_track_w)
232   AM_RANGE(0xf2, 0xf2) AM_DEVREADWRITE("wd179x", wd17xx_sector_r, wd17xx_sector_w)
233   AM_RANGE(0xf3, 0xf3) AM_DEVREADWRITE("wd179x", wd17xx_data_r, wd17xx_data_w)
209   AM_RANGE(0xf0, 0xf0) AM_READ(trs80_wd179x_r)
210   AM_RANGE(0xf0, 0xf0) AM_DEVWRITE_LEGACY("wd179x", wd17xx_command_w)
211   AM_RANGE(0xf1, 0xf1) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_track_r, wd17xx_track_w)
212   AM_RANGE(0xf2, 0xf2) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_sector_r, wd17xx_sector_w)
213   AM_RANGE(0xf3, 0xf3) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_data_r, wd17xx_data_w)
234214   AM_RANGE(0xf4, 0xf4) AM_WRITE(trs80m4_f4_w)
235215   AM_RANGE(0xf8, 0xfb) AM_READWRITE(trs80_printer_r, trs80_printer_w)
236216   AM_RANGE(0xfc, 0xff) AM_READWRITE(trs80m4_ff_r, trs80m4_ff_w)
237217ADDRESS_MAP_END
238218
239static ADDRESS_MAP_START( model4_io, AS_IO, 8 )
219static ADDRESS_MAP_START( model4_io, AS_IO, 8, trs80_state )
240220   ADDRESS_MAP_GLOBAL_MASK(0xff)
241221   AM_RANGE(0x84, 0x87) AM_WRITE(trs80m4_84_w)
242222   AM_RANGE(0x88, 0x89) AM_WRITE(trs80m4_88_w)
r12357r12358
248228   AM_RANGE(0xea, 0xea) AM_READWRITE(trs80m4_ea_r, trs80m4_ea_w)
249229   AM_RANGE(0xeb, 0xeb) AM_READWRITE(trs80m4_eb_r, trs80m4_eb_w)
250230   AM_RANGE(0xec, 0xef) AM_READWRITE(trs80m4_ec_r, trs80m4_ec_w)
251   AM_RANGE(0xf0, 0xf0) AM_DEVREADWRITE("wd179x", trs80_wd179x_r, wd17xx_command_w)
252   AM_RANGE(0xf1, 0xf1) AM_DEVREADWRITE("wd179x", wd17xx_track_r, wd17xx_track_w)
253   AM_RANGE(0xf2, 0xf2) AM_DEVREADWRITE("wd179x", wd17xx_sector_r, wd17xx_sector_w)
254   AM_RANGE(0xf3, 0xf3) AM_DEVREADWRITE("wd179x", wd17xx_data_r, wd17xx_data_w)
231   AM_RANGE(0xf0, 0xf0) AM_READ(trs80_wd179x_r)
232   AM_RANGE(0xf0, 0xf0) AM_DEVWRITE_LEGACY("wd179x", wd17xx_command_w)
233   AM_RANGE(0xf1, 0xf1) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_track_r, wd17xx_track_w)
234   AM_RANGE(0xf2, 0xf2) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_sector_r, wd17xx_sector_w)
235   AM_RANGE(0xf3, 0xf3) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_data_r, wd17xx_data_w)
255236   AM_RANGE(0xf4, 0xf4) AM_WRITE(trs80m4_f4_w)
256237   AM_RANGE(0xf8, 0xfb) AM_READWRITE(trs80_printer_r, trs80_printer_w)
257238   AM_RANGE(0xfc, 0xff) AM_READWRITE(trs80m4_ff_r, trs80m4_ff_w)
258239ADDRESS_MAP_END
259240
260static ADDRESS_MAP_START( model4p_io, AS_IO, 8 )
241static ADDRESS_MAP_START( model4p_io, AS_IO, 8, trs80_state )
261242   ADDRESS_MAP_GLOBAL_MASK(0xff)
262243   AM_RANGE(0x84, 0x87) AM_WRITE(trs80m4_84_w)
263244   AM_RANGE(0x88, 0x89) AM_WRITE(trs80m4_88_w)
r12357r12358
270251   AM_RANGE(0xea, 0xea) AM_READWRITE(trs80m4_ea_r, trs80m4_ea_w)
271252   AM_RANGE(0xeb, 0xeb) AM_READWRITE(trs80m4_eb_r, trs80m4_eb_w)
272253   AM_RANGE(0xec, 0xef) AM_READWRITE(trs80m4_ec_r, trs80m4_ec_w)
273   AM_RANGE(0xf0, 0xf0) AM_DEVREADWRITE("wd179x", trs80_wd179x_r, wd17xx_command_w)
274   AM_RANGE(0xf1, 0xf1) AM_DEVREADWRITE("wd179x", wd17xx_track_r, wd17xx_track_w)
275   AM_RANGE(0xf2, 0xf2) AM_DEVREADWRITE("wd179x", wd17xx_sector_r, wd17xx_sector_w)
276   AM_RANGE(0xf3, 0xf3) AM_DEVREADWRITE("wd179x", wd17xx_data_r, wd17xx_data_w)
254   AM_RANGE(0xf0, 0xf0) AM_READ(trs80_wd179x_r)
255   AM_RANGE(0xf0, 0xf0) AM_DEVWRITE_LEGACY("wd179x", wd17xx_command_w)
256   AM_RANGE(0xf1, 0xf1) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_track_r, wd17xx_track_w)
257   AM_RANGE(0xf2, 0xf2) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_sector_r, wd17xx_sector_w)
258   AM_RANGE(0xf3, 0xf3) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_data_r, wd17xx_data_w)
277259   AM_RANGE(0xf4, 0xf4) AM_WRITE(trs80m4_f4_w)
278260   AM_RANGE(0xf8, 0xfb) AM_READWRITE(trs80_printer_r, trs80_printer_w)
279261   AM_RANGE(0xfc, 0xff) AM_READWRITE(trs80m4_ff_r, trs80m4_ff_w)
r12357r12358
502484};
503485
504486static GFXDECODE_START(trs80)
505   GFXDECODE_ENTRY( "gfx1", 0, trs80_charlayout, 0, 1 )
487   GFXDECODE_ENTRY( "chargen", 0, trs80_charlayout, 0, 1 )
506488GFXDECODE_END
507489
508490static GFXDECODE_START(ht1080z)
509   GFXDECODE_ENTRY( "gfx1", 0, ht1080z_charlayout, 0, 1 )
491   GFXDECODE_ENTRY( "chargen", 0, ht1080z_charlayout, 0, 1 )
510492GFXDECODE_END
511493
512494static GFXDECODE_START(trs80m4)
513   GFXDECODE_ENTRY( "gfx1", 0, trs80m4_charlayout, 0, 1 )
495   GFXDECODE_ENTRY( "chargen", 0, trs80m4_charlayout, 0, 1 )
514496GFXDECODE_END
515497
516498static GFXDECODE_START(lnw80)
517   GFXDECODE_ENTRY( "gfx1", 0, lnw80_charlayout, 0, 4 )
499   GFXDECODE_ENTRY( "chargen", 0, lnw80_charlayout, 0, 4 )
518500GFXDECODE_END
519501
520502static GFXDECODE_START(radionic)
521   GFXDECODE_ENTRY( "gfx1", 0, radionic_charlayout, 0, 1 )
503   GFXDECODE_ENTRY( "chargen", 0, radionic_charlayout, 0, 1 )
522504GFXDECODE_END
523505
524506
r12357r12358
603585   MCFG_CENTRONICS_ADD("centronics", standard_centronics)
604586   MCFG_AY31015_ADD( "tr1602", trs80_ay31015_config )
605587MACHINE_CONFIG_END
606#if 0
607static MACHINE_CONFIG_DERIVED( model2, model1 )
608MACHINE_CONFIG_END
609#endif
610588
611589static MACHINE_CONFIG_DERIVED( model3, model1 )
612590   MCFG_CPU_MODIFY( "maincpu" )
r12357r12358
678656   ROM_REGION(0x10000, "maincpu",0)
679657   ROM_LOAD("level1.rom",   0x0000, 0x1000, CRC(70d06dff) SHA1(20d75478fbf42214381e05b14f57072f3970f765))
680658
681   ROM_REGION(0x00400, "gfx1",0)
659   ROM_REGION(0x00400, "chargen",0)
682660   ROM_LOAD("trs80m1.chr",  0x0000, 0x0400, CRC(0033f2b9) SHA1(0d2cd4197d54e2e872b515bbfdaa98efe502eda7))
683661ROM_END
684662
r12357r12358
693671   ROMX_LOAD("trs80alt.z34",0x1000, 0x1000, CRC(6c791c2d) SHA1(2a38e0a248f6619d38f1a108eea7b95761cf2aee), ROM_BIOS(2))
694672   ROMX_LOAD("trs80alt.zl2",0x2000, 0x1000, CRC(55b3ad13) SHA1(6279f6a68f927ea8628458b278616736f0b3c339), ROM_BIOS(2))
695673
696   ROM_REGION(0x00400, "gfx1",0)
674   ROM_REGION(0x00400, "chargen",0)
697675   ROM_LOAD("trs80m1.chr",  0x0000, 0x0400, CRC(0033f2b9) SHA1(0d2cd4197d54e2e872b515bbfdaa98efe502eda7))
698676ROM_END
699677
r12357r12358
707685   ROM_CONTINUE(0x3000, 0x600)
708686   ROM_IGNORE(0x200)
709687
710   ROM_REGION(0x01000, "gfx1",0)
688   ROM_REGION(0x01000, "chargen",0)
711689   ROM_LOAD("trschar.bin",  0x0000, 0x1000, CRC(02e767b6) SHA1(c431fcc6bd04ce2800ca8c36f6f8aeb2f91ce9f7))
712690ROM_END
713691
r12357r12358
719697   /* This rom turns the system80 into the "blue label" version. SYSTEM then /12288 to activate. */
720698   ROM_LOAD("sys80.ext",    0x3000, 0x0800, CRC(2a851e33) SHA1(dad21ec60973eb66e499fe0ecbd469118826a715))
721699
722   ROM_REGION(0x00400, "gfx1",0)
700   ROM_REGION(0x00400, "chargen",0)
723701   ROM_LOAD("trs80m1.chr",  0x0000, 0x0400, CRC(0033f2b9) SHA1(0d2cd4197d54e2e872b515bbfdaa98efe502eda7))
724702ROM_END
725703
r12357r12358
732710   ROM_LOAD("lnw_c.bin",    0x2000, 0x0800, CRC(2ba025d7) SHA1(232efbe23c3f5c2c6655466ebc0a51cf3697be9b))
733711   ROM_LOAD("lnw_c1.bin",   0x2800, 0x0800, CRC(ed547445) SHA1(20102de89a3ee4a65366bc2d62be94da984a156b))
734712
735   ROM_REGION(0x00800, "gfx1",0)
713   ROM_REGION(0x00800, "chargen",0)
736714   ROM_LOAD("lnw_chr.bin",  0x0000, 0x0800, CRC(c89b27df) SHA1(be2a009a07e4378d070002a558705e9a0de59389))
737715
738716   ROM_REGION(0x04400, "gfx2",0)
r12357r12358
772750   ROM_SYSTEM_BIOS(3, "trs80m3_l1", "Level 1 bios")
773751   ROMX_LOAD("8040032.u104", 0x0000, 0x1000, CRC(6418d641) SHA1(f823ab6ceb102588d27e5f5c751e31175289291c), ROM_BIOS(4) ) // Label: "8040032 // (M) QQ8028 // SCM91616P"; Silkscreen: "TANDY // (C) '80"; (Level 1 bios)
774752
775   ROM_REGION(0x00800, "gfx1",0)   /* correct for later systems; the trs80m3_l1 bios uses the non-a version of this rom, dump is pending */
753   ROM_REGION(0x00800, "chargen",0)   /* correct for later systems; the trs80m3_l1 bios uses the non-a version of this rom, dump is pending */
776754   ROM_LOAD("8044316.u36", 0x0000, 0x0800, NO_DUMP) // Label: "(M) // SCM91665P // 8044316 // QQ8029" ('no-letter' revision)
777755   ROM_LOAD("8044316a.u36", 0x0000, 0x0800, CRC(444c8b60) SHA1(c52ee41439bd5e57c3b113ebfd61c951e2af4446)) // Label: "Tandy (C) 81 // 8044316A // 8206" (rev A)
778756ROM_END
r12357r12358
782760   ROM_REGION(0x20000, "maincpu",0)
783761   ROM_LOAD("trs80m4.rom",  0x0000, 0x3800, BAD_DUMP CRC(1a92d54d) SHA1(752555fdd0ff23abc9f35c6e03d9d9b4c0e9677b)) // should be split into 3 roms, roms A, B, C, exactly like trs80m3; in fact, roms A and B are shared between both systems.
784762
785   ROM_REGION(0x00800, "gfx1",0)
763   ROM_REGION(0x00800, "chargen",0)
786764   ROM_LOAD("8044316a.u36", 0x0000, 0x0800, CRC(444c8b60) SHA1(c52ee41439bd5e57c3b113ebfd61c951e2af4446)) // according to parts catalog, this is the correct rom for both model 3 and 4
787765ROM_END
788766
r12357r12358
793771   ROM_SYSTEM_BIOS(1, "trs80m4p_hack", "Disk loader hack")
794772   ROMX_LOAD("trs80m4p_loader_hack.rom", 0x0000, 0x01f8, CRC(7ff336f4) SHA1(41184f5240b4b54f3804f5a22b4d78bbba52ed1d), ROM_BIOS(2))
795773
796   ROM_REGION(0x00800, "gfx1",0)
774   ROM_REGION(0x00800, "chargen",0)
797775   ROM_LOAD("8049007.u103", 0x0000, 0x0800, CRC(1ac44bea) SHA1(c9426ab2b2aa5380dc97a7b9c048ccd1bbde92ca)) // Label: "SCM95987P // 8049007 // TANDY (C) 1983 // 8447" at location U103 (may be located at U43 on some pcb revisions)
798776ROM_END
799777
r12357r12358
802780   ROM_LOAD("ht1080z.rom",  0x0000, 0x3000, CRC(2bfef8f7) SHA1(7a350925fd05c20a3c95118c1ae56040c621be8f))
803781   ROM_LOAD("sys80.ext",    0x3000, 0x0800, CRC(2a851e33) SHA1(dad21ec60973eb66e499fe0ecbd469118826a715))
804782
805   ROM_REGION(0x00800, "gfx1",0)
783   ROM_REGION(0x00800, "chargen",0)
806784   ROM_LOAD("ht1080z.chr",  0x0000, 0x0800, CRC(e8c59d4f) SHA1(a15f30a543e53d3e30927a2e5b766fcf80f0ae31))
807785ROM_END
808786
r12357r12358
811789   ROM_LOAD("ht1080z.rom",  0x0000, 0x3000, CRC(2bfef8f7) SHA1(7a350925fd05c20a3c95118c1ae56040c621be8f))
812790   ROM_LOAD("ht1080z2.ext", 0x3000, 0x0800, CRC(07415ac6) SHA1(b08746b187946e78c4971295c0aefc4e3de97115))
813791
814   ROM_REGION(0x00800, "gfx1",0)
792   ROM_REGION(0x00800, "chargen",0)
815793   ROM_LOAD("ht1080z2.chr", 0x0000, 0x0800, CRC(6728f0ab) SHA1(1ba949f8596f1976546f99a3fdcd3beb7aded2c5))
816794ROM_END
817795
r12357r12358
820798   ROM_LOAD("ht108064.rom", 0x0000, 0x3000, CRC(48985a30) SHA1(e84cf3121f9e0bb9e1b01b095f7a9581dcfaaae4))
821799   ROM_LOAD("ht108064.ext", 0x3000, 0x0800, CRC(fc12bd28) SHA1(0da93a311f99ec7a1e77486afe800a937778e73b))
822800
823   ROM_REGION(0x00800, "gfx1",0)
801   ROM_REGION(0x00800, "chargen",0)
824802   ROM_LOAD("ht108064.chr", 0x0000, 0x0800, CRC(e76b73a4) SHA1(6361ee9667bf59d50059d09b0baf8672fdb2e8af))
825803ROM_END
826804
r12357r12358
843821   trs80_state *state = machine.driver_data<trs80_state>();
844822   state->m_mode = 0;
845823   state->m_model4 = 2;
846   state->m_videoram = machine.region("maincpu")->base()+0x4000;
824   state->m_p_videoram = machine.region("maincpu")->base()+0x4000;
847825}
848826
849827static DRIVER_INIT( trs80m4p )
r12357r12358
851829   trs80_state *state = machine.driver_data<trs80_state>();
852830   state->m_mode = 0;
853831   state->m_model4 = 4;
854   state->m_videoram = machine.region("maincpu")->base()+0x4000;
832   state->m_p_videoram = machine.region("maincpu")->base()+0x4000;
855833}
856834
857835static DRIVER_INIT( lnw80 )
r12357r12358
859837   trs80_state *state = machine.driver_data<trs80_state>();
860838   state->m_mode = 0;
861839   state->m_model4 = 0;
862   state->m_gfxram = machine.region("gfx2")->base();
863   state->m_videoram = machine.region("gfx2")->base()+0x4000;
840   state->m_p_gfxram = machine.region("gfx2")->base();
841   state->m_p_videoram = machine.region("gfx2")->base()+0x4000;
864842}
865843
866/*    YEAR  NAME      PARENT  COMPAT  MACHINE     INPUT    INIT  COMPANY  FULLNAME */
867COMP( 1977, trs80,    0,      0,   trs80,    trs80,   trs80,    "Tandy Radio Shack",  "TRS-80 Model I (Level I Basic)" , 0 )
868COMP( 1978, trs80l2,  trs80,   0,   model1,   trs80,   trs80l2,  "Tandy Radio Shack",  "TRS-80 Model I (Level II Basic)" , 0 )
869COMP( 1983, radionic, trs80,   0,   radionic, trs80,   trs80,    "Komtek",  "Radionic" , 0 )
870COMP( 1980, sys80,    trs80,   0,   sys80,    trs80,   trs80l2,  "EACA Computers Ltd","System-80" , 0 )
871COMP( 1981, lnw80,    trs80,   0,   lnw80,    trs80m3, lnw80,    "LNW Research","LNW-80", 0 )
872COMP( 1980, trs80m3,  trs80,   0,   model3,   trs80m3, trs80m4,  "Tandy Radio Shack",  "TRS-80 Model III", 0 )
873COMP( 1980, trs80m4,  trs80,   0,   model4,   trs80m3, trs80m4,  "Tandy Radio Shack",  "TRS-80 Model 4", 0 )
874COMP( 1983, trs80m4p, trs80,   0,   model4p,  trs80m3, trs80m4p, "Tandy Radio Shack",  "TRS-80 Model 4P", 0 )
875COMP( 1983, ht1080z,  trs80,   0,   ht1080z,  trs80,   trs80l2,  "Hiradastechnika Szovetkezet",  "HT-1080Z Series I" , 0 )
876COMP( 1984, ht1080z2, trs80,   0,   ht1080z,  trs80,   trs80l2,  "Hiradastechnika Szovetkezet",  "HT-1080Z Series II" , 0 )
877COMP( 1985, ht108064, trs80,   0,   ht1080z,  trs80,   trs80,    "Hiradastechnika Szovetkezet",  "HT-1080Z/64" , 0 )
844/*    YEAR  NAME      PARENT  COMPAT  MACHINE     INPUT    INIT         COMPANY           FULLNAME */
845COMP( 1977, trs80,    0,      0,      trs80,      trs80,   trs80,    "Tandy Radio Shack", "TRS-80 Model I (Level I Basic)", 0 )
846COMP( 1978, trs80l2,  trs80,  0,      model1,     trs80,   trs80l2,  "Tandy Radio Shack", "TRS-80 Model I (Level II Basic)", 0 )
847COMP( 1983, radionic, trs80,  0,      radionic,   trs80,   trs80,    "Komtek", "Radionic", 0 )
848COMP( 1980, sys80,    trs80,  0,      sys80,      trs80,   trs80l2,  "EACA Computers Ltd", "System-80", 0 )
849COMP( 1981, lnw80,    trs80,  0,      lnw80,      trs80m3, lnw80,    "LNW Research", "LNW-80", 0 )
850COMP( 1980, trs80m3,  trs80,  0,      model3,     trs80m3, trs80m4,  "Tandy Radio Shack", "TRS-80 Model III", 0 )
851COMP( 1980, trs80m4,  trs80,  0,      model4,     trs80m3, trs80m4,  "Tandy Radio Shack", "TRS-80 Model 4", 0 )
852COMP( 1983, trs80m4p, trs80,  0,      model4p,    trs80m3, trs80m4p, "Tandy Radio Shack", "TRS-80 Model 4P", 0 )
853COMP( 1983, ht1080z,  trs80,  0,      ht1080z,    trs80,   trs80l2,  "Hiradastechnika Szovetkezet", "HT-1080Z Series I", 0 )
854COMP( 1984, ht1080z2, trs80,  0,      ht1080z,    trs80,   trs80l2,  "Hiradastechnika Szovetkezet", "HT-1080Z Series II", 0 )
855COMP( 1985, ht108064, trs80,  0,      ht1080z,    trs80,   trs80,    "Hiradastechnika Szovetkezet", "HT-1080Z/64", 0 )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team