apple2gs: rewritten driver using bankdev. [R. Belmont]

This commit is contained in:
arbee 2018-07-03 21:15:50 -04:00
parent 927623bb18
commit e019d58dfe
8 changed files with 5153 additions and 5927 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,395 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:R. Belmont
/***************************************************************************
includes/apple2.h
Include file to handle emulation of the Apple II series.
***************************************************************************/
#ifndef MAME_INCLUDES_APPLE2_H
#define MAME_INCLUDES_APPLE2_H
#include "cpu/m6502/m6502.h"
#include "cpu/m6502/m65c02.h"
#include "imagedev/cassette.h"
#include "machine/applefdc.h"
#include "machine/kb3600.h"
#include "machine/mos6551.h"
#include "machine/ram.h"
#include "machine/timer.h"
#include "sound/spkrdev.h"
#include "bus/a2bus/a2bus.h"
#include "bus/a2bus/a2eauxslot.h"
#include "bus/rs232/rs232.h"
#include "emupal.h"
#include "screen.h"
#define AUXSLOT_TAG "auxbus"
#define IIC_ACIA1_TAG "acia1"
#define IIC_ACIA2_TAG "acia2"
#define IICP_IWM_TAG "fdc"
#define LASER128_UDC_TAG "l128udc"
#define PRINTER_PORT_TAG "printer"
#define MODEM_PORT_TAG "modem"
/***************************************************************************
SOFTSWITCH VALUES
***************************************************************************/
#define VAR_80STORE 0x000001
#define VAR_RAMRD 0x000002
#define VAR_RAMWRT 0x000004
#define VAR_INTCXROM 0x000008
#define VAR_ALTZP 0x000010
#define VAR_SLOTC3ROM 0x000020
#define VAR_80COL 0x000040
#define VAR_ALTCHARSET 0x000080
#define VAR_TEXT 0x000100
#define VAR_MIXED 0x000200
#define VAR_PAGE2 0x000400
#define VAR_HIRES 0x000800
#define VAR_AN0 0x001000
#define VAR_AN1 0x002000
#define VAR_AN2 0x004000
#define VAR_AN3 0x008000
#define VAR_LCRAM 0x010000
#define VAR_LCRAM2 0x020000
#define VAR_LCWRITE 0x040000
#define VAR_ROMSWITCH 0x080000
#define VAR_TK2000RAM 0x100000 // ROM/RAM switch for TK2000
#define VAR_DHIRES VAR_AN3
/***************************************************************************
OTHER
***************************************************************************/
/* -----------------------------------------------------------------------
* New Apple II memory manager
* ----------------------------------------------------------------------- */
#define APPLE2_MEM_AUX 0x40000000
#define APPLE2_MEM_SLOT 0x80000000
#define APPLE2_MEM_ROM 0xC0000000
#define APPLE2_MEM_FLOATING 0xFFFFFFFF
#define APPLE2_MEM_MASK 0x00FFFFFF
enum machine_type_t
{
APPLE_II, // Apple II/II+
APPLE_IIE, // Apple IIe with aux slots
APPLE_IIGS, // Apple IIgs
APPLE_IIC, // Apple IIc
APPLE_IICPLUS, // Apple IIc+
TK2000, // Microdigital TK2000
TK3000, // Microdigital TK3000
LASER128, // Laser 128/128EX/128EX2
SPACE84, // "Space 84" with flipped text mode
LABA2P // lab equipment (?) II Plus with flipped text mode
};
enum bank_disposition_t
{
A2MEM_IO = 0, /* this is always handlers; never banked memory */
A2MEM_MONO = 1, /* this is a bank where read and write are always in unison */
A2MEM_DUAL = 2 /* this is a bank where read and write can go different places */
};
struct apple2_meminfo
{
uint32_t read_mem;
read8_delegate *read_handler;
uint32_t write_mem;
write8_delegate *write_handler;
};
struct apple2_memmap_entry
{
offs_t begin;
offs_t end;
void (*get_meminfo)(running_machine &machine, offs_t begin, offs_t end, apple2_meminfo *meminfo);
bank_disposition_t bank_disposition;
};
struct apple2_memmap_config
{
int first_bank;
uint8_t *auxmem;
uint32_t auxmem_length;
const apple2_memmap_entry *memmap;
};
class apple2_state : public driver_device
{
public:
apple2_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_screen(*this, "screen"),
m_ram(*this, RAM_TAG),
m_ay3600(*this, "ay3600"),
m_a2bus(*this, "a2bus"),
m_speaker(*this, "a2speaker"),
m_a2eauxslot(*this, AUXSLOT_TAG),
m_joy1x(*this, "joystick_1_x"),
m_joy1y(*this, "joystick_1_y"),
m_joy2x(*this, "joystick_2_x"),
m_joy2y(*this, "joystick_2_y"),
m_joybuttons(*this, "joystick_buttons"),
m_kbdrom(*this, "keyboard"),
m_kbspecial(*this, "keyb_special"),
m_kbrepeat(*this, "keyb_repeat"),
m_resetdip(*this, "reset_dip"),
m_sysconfig(*this, "a2_config"),
m_cassette(*this, "cassette"),
m_acia1(*this, IIC_ACIA1_TAG),
m_acia2(*this, IIC_ACIA2_TAG),
m_laserudc(*this, LASER128_UDC_TAG),
m_iicpiwm(*this, IICP_IWM_TAG)
{ }
required_device<cpu_device> m_maincpu;
required_device<screen_device> m_screen;
required_device<ram_device> m_ram;
required_device<ay3600_device> m_ay3600;
required_device<a2bus_device> m_a2bus;
required_device<speaker_sound_device> m_speaker;
optional_device<a2eauxslot_device> m_a2eauxslot;
optional_ioport m_joy1x, m_joy1y, m_joy2x, m_joy2y, m_joybuttons;
optional_memory_region m_kbdrom;
required_ioport m_kbspecial;
optional_ioport m_kbrepeat;
optional_ioport m_resetdip;
optional_ioport m_sysconfig;
optional_device<cassette_image_device> m_cassette;
optional_device<mos6551_device> m_acia1, m_acia2;
optional_device<applefdc_base_device> m_laserudc;
optional_device<iwm_device> m_iicpiwm;
uint32_t m_flags, m_flags_mask;
int32_t m_a2_cnxx_slot;
uint32_t m_a2_mask;
uint32_t m_a2_set;
int m_a2_speaker_state;
double m_joystick_x1_time;
double m_joystick_y1_time;
double m_joystick_x2_time;
double m_joystick_y2_time;
apple2_memmap_config m_mem_config;
std::unique_ptr<apple2_meminfo[]> m_current_meminfo;
int m_fdc_diskreg;
const uint8_t *m_a2_videoram, *m_a2_videoaux, *m_textgfx_data;
uint32_t m_a2_videomask, m_textgfx_datalen;
uint32_t m_old_a2;
int m_fgcolor;
int m_bgcolor;
int m_flash;
int m_alt_charset_value;
std::unique_ptr<uint16_t[]> m_hires_artifact_map;
std::unique_ptr<uint16_t[]> m_dhires_artifact_map;
bool m_monochrome_dhr;
int m_inh_slot;
int m_reset_flag;
uint8_t *m_rambase;
uint8_t *m_rom, *m_slot_ram;
uint32_t m_rom_length, m_slot_length;
machine_type_t m_machinetype;
device_a2eauxslot_card_interface *m_auxslotdevice;
uint16_t m_lastchar, m_strobe;
uint8_t m_transchar;
READ8_MEMBER(apple2_c0xx_r);
WRITE8_MEMBER(apple2_c0xx_w);
READ8_MEMBER(apple2_c080_r);
WRITE8_MEMBER(apple2_c080_w);
READ8_MEMBER ( apple2_c00x_r );
READ8_MEMBER ( apple2_c01x_r );
READ8_MEMBER ( apple2_c02x_r );
READ8_MEMBER ( apple2_c03x_r );
READ8_MEMBER ( apple2_c05x_r );
READ8_MEMBER ( apple2_c06x_r );
READ8_MEMBER ( apple2_c07x_r );
WRITE8_MEMBER ( apple2_c00x_w );
WRITE8_MEMBER ( apple2_c01x_w );
WRITE8_MEMBER ( apple2_c02x_w );
WRITE8_MEMBER ( apple2_c03x_w );
WRITE8_MEMBER ( apple2_c05x_w );
WRITE8_MEMBER ( apple2_c07x_w );
READ8_MEMBER ( apple2_mainram0000_r );
READ8_MEMBER ( apple2_mainram0200_r );
READ8_MEMBER ( apple2_mainram0400_r );
READ8_MEMBER ( apple2_mainram0800_r );
READ8_MEMBER ( apple2_mainram2000_r );
READ8_MEMBER ( apple2_mainram4000_r );
READ8_MEMBER ( apple2_mainramc000_r );
READ8_MEMBER ( apple2_mainramd000_r );
READ8_MEMBER ( apple2_mainrame000_r );
READ8_MEMBER ( apple2_auxram0000_r );
READ8_MEMBER ( apple2_auxram0200_r );
READ8_MEMBER ( apple2_auxram0400_r );
READ8_MEMBER ( apple2_auxram0800_r );
READ8_MEMBER ( apple2_auxram2000_r );
READ8_MEMBER ( apple2_auxram4000_r );
READ8_MEMBER ( apple2_auxramc000_r );
READ8_MEMBER ( apple2_auxramd000_r );
READ8_MEMBER ( apple2_auxrame000_r );
WRITE8_MEMBER ( apple2_mainram0000_w );
WRITE8_MEMBER ( apple2_mainram0200_w );
WRITE8_MEMBER ( apple2_mainram0400_w );
WRITE8_MEMBER ( apple2_mainram0800_w );
WRITE8_MEMBER ( apple2_mainram2000_w );
WRITE8_MEMBER ( apple2_mainram4000_w );
WRITE8_MEMBER ( apple2_mainramc000_w );
WRITE8_MEMBER ( apple2_mainramd000_w );
WRITE8_MEMBER ( apple2_mainrame000_w );
WRITE8_MEMBER ( apple2_auxram0000_w );
WRITE8_MEMBER ( apple2_auxram0200_w );
WRITE8_MEMBER ( apple2_auxram0400_w );
WRITE8_MEMBER ( apple2_auxram0800_w );
WRITE8_MEMBER ( apple2_auxram2000_w );
WRITE8_MEMBER ( apple2_auxram4000_w );
WRITE8_MEMBER ( apple2_auxramc000_w );
WRITE8_MEMBER ( apple2_auxramd000_w );
WRITE8_MEMBER ( apple2_auxrame000_w );
READ8_MEMBER ( apple2_c1xx_r );
WRITE8_MEMBER ( apple2_c1xx_w );
READ8_MEMBER ( apple2_c3xx_r );
WRITE8_MEMBER ( apple2_c3xx_w );
READ8_MEMBER ( apple2_c4xx_r );
WRITE8_MEMBER ( apple2_c4xx_w );
READ8_MEMBER ( apple2_c800_r );
WRITE8_MEMBER ( apple2_c800_w );
READ8_MEMBER ( apple2_ce00_r );
WRITE8_MEMBER ( apple2_ce00_w );
READ8_MEMBER ( apple2_inh_d000_r );
WRITE8_MEMBER ( apple2_inh_d000_w );
READ8_MEMBER ( apple2_inh_e000_r );
WRITE8_MEMBER ( apple2_inh_e000_w );
READ8_MEMBER(read_floatingbus);
READ8_MEMBER(apple2_cfff_r);
WRITE8_MEMBER(apple2_cfff_w);
void apple2_refresh_delegates();
int apple2_pressed_specialkey(uint8_t key);
void langcard_touch(offs_t offset);
read8_delegate read_delegates_master[4];
write8_delegate write_delegates_master[3];
write8_delegate write_delegates_0000[2];
write8_delegate write_delegates_0200[2];
write8_delegate write_delegates_0400[2];
write8_delegate write_delegates_0800[2];
write8_delegate write_delegates_2000[2];
write8_delegate write_delegates_4000[2];
write8_delegate write_delegates_c000[2];
write8_delegate write_delegates_d000[2];
write8_delegate write_delegates_e000[2];
read8_delegate read_delegates_0000[2];
read8_delegate read_delegates_0200[2];
read8_delegate read_delegates_0400[2];
read8_delegate read_delegates_0800[2];
read8_delegate read_delegates_2000[2];
read8_delegate read_delegates_4000[2];
read8_delegate read_delegates_c000[2];
read8_delegate read_delegates_d000[2];
read8_delegate read_delegates_e000[2];
read8_delegate rd_c000;
write8_delegate wd_c000;
read8_delegate rd_c080;
write8_delegate wd_c080;
read8_delegate rd_cfff;
write8_delegate wd_cfff;
read8_delegate rd_c800;
write8_delegate wd_c800;
read8_delegate rd_ce00;
write8_delegate wd_ce00;
read8_delegate rd_inh_d000;
write8_delegate wd_inh_d000;
read8_delegate rd_inh_e000;
write8_delegate wd_inh_e000;
DECLARE_MACHINE_START(apple2orig);
DECLARE_MACHINE_START(apple2e);
DECLARE_MACHINE_START(apple2c);
DECLARE_MACHINE_START(apple2cp);
DECLARE_MACHINE_START(tk2000);
DECLARE_MACHINE_START(tk3000);
DECLARE_MACHINE_START(laser128);
DECLARE_MACHINE_START(space84);
DECLARE_MACHINE_START(laba2p);
DECLARE_VIDEO_START(apple2);
DECLARE_PALETTE_INIT(apple2);
DECLARE_VIDEO_START(apple2p);
DECLARE_VIDEO_START(apple2e);
DECLARE_VIDEO_START(apple2c);
uint32_t screen_update_apple2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
TIMER_DEVICE_CALLBACK_MEMBER(apple2_interrupt);
DECLARE_WRITE_LINE_MEMBER(a2bus_irq_w);
DECLARE_WRITE_LINE_MEMBER(a2bus_nmi_w);
DECLARE_WRITE_LINE_MEMBER(a2bus_inh_w);
DECLARE_READ_LINE_MEMBER(ay3600_shift_r);
DECLARE_READ_LINE_MEMBER(ay3600_control_r);
DECLARE_WRITE_LINE_MEMBER(ay3600_data_ready_w);
DECLARE_WRITE_LINE_MEMBER(ay3600_iie_data_ready_w);
void apple2_update_memory_postload();
virtual void machine_reset() override;
void apple2_setup_memory(const apple2_memmap_config *config);
void apple2_update_memory();
inline uint32_t effective_a2();
uint32_t compute_video_address(int col, int row);
void adjust_begin_and_end_row(const rectangle &cliprect, int *beginrow, int *endrow);
inline void apple2_plot_text_character(bitmap_ind16 &bitmap, int xpos, int ypos, int xscale, uint32_t code,
const uint8_t *textgfx_data, uint32_t textgfx_datalen, uint32_t my_a2);
void apple2_text_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int page, int beginrow, int endrow);
void apple2_lores_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int page, int beginrow, int endrow);
void apple2_hires_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int page, int beginrow, int endrow);
void apple2_video_start(const uint8_t *vram, const uint8_t *aux_vram, uint32_t ignored_softswitches, int hires_modulo);
void apple2_setvar(uint32_t val, uint32_t mask);
uint8_t apple2_getfloatingbusvalue();
int apple2_fdc_has_35();
int apple2_fdc_has_525();
void apple2_iwm_setdiskreg(uint8_t data);
void apple2_init_common();
void apple2eplus_init_common(void *apple2cp_ce00_ram);
int8_t apple2_slotram_r(int slotnum, int offset);
int a2_no_ctrl_reset();
private:
// Laser 128EX2 slot 5 Apple Memory Expansion emulation vars
uint8_t m_exp_bankhior;
int m_exp_addrmask;
uint8_t m_exp_regs[0x10];
std::unique_ptr<uint8_t[]> m_exp_ram;
int m_exp_wptr, m_exp_liveptr;
};
/*----------- defined in drivers/apple2.c -----------*/
INPUT_PORTS_EXTERN( apple2ep );
/*----------- defined in machine/apple2.c -----------*/
extern const applefdc_interface apple2_fdc_interface;
#endif // MAME_INCLUDES_APPLE2_H

View File

@ -1,278 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:Nathan Woods,R. Belmont
/*****************************************************************************
*
* includes/apple2gs.h
*
* Apple IIgs
*
****************************************************************************/
#ifndef MAME_INCLUDES_APPLE2GS_H
#define MAME_INCLUDES_APPLE2GS_H
#define RUN_ADB_MICRO (0)
#include "includes/apple2.h"
#include "sound/es5503.h"
#include "machine/nvram.h"
#include "cpu/g65816/g65816.h"
#include "cpu/m6502/m5074x.h"
#include "machine/z80scc.h"
#include "emupal.h"
#define ADBMICRO_TAG "adbmicro"
#define SCC_TAG "scc"
#define RS232A_TAG "printer"
#define RS232B_TAG "modem"
// IIgs clocks as marked on the schematics
#define APPLE2GS_28M (XTAL(28'636'363)) // IIGS master clock
#define APPLE2GS_14M (APPLE2GS_28M/2)
#define APPLE2GS_7M (APPLE2GS_28M/4)
// screen dimensions
#define BORDER_LEFT (32)
#define BORDER_RIGHT (32)
#define BORDER_TOP (16) // (plus bottom)
// these are numbered as seen from the MCU
enum glu_reg_names
{
GLU_KEY_DATA = 0, // MCU W
GLU_COMMAND, // MCU R
GLU_MOUSEX, // MCU W
GLU_MOUSEY, // MCU W
GLU_KG_STATUS, // MCU R
GLU_ANY_KEY_DOWN, // MCU W
GLU_KEYMOD, // MCU W
GLU_DATA, // MCU W
GLU_C000, // 816 R
GLU_C010, // 816 RW
GLU_SYSSTAT // 816 R/(limited) W
};
enum glu_kg_status
{
KGS_ANY_KEY_DOWN = 0x01,
KGS_KEYSTROBE = 0x10,
KGS_DATA_FULL = 0x20,
KGS_COMMAND_FULL = 0x40,
KGS_MOUSEX_FULL = 0x80
};
enum apple2gs_clock_mode
{
CLOCKMODE_IDLE,
CLOCKMODE_TIME,
CLOCKMODE_INTERNALREGS,
CLOCKMODE_BRAM1,
CLOCKMODE_BRAM2
};
enum adbstate_t
{
ADBSTATE_IDLE,
ADBSTATE_INCOMMAND,
ADBSTATE_INRESPONSE
};
#define IRQ_KBD_SRQ 0x01
#define IRQ_ADB_DATA 0x02
#define IRQ_ADB_MOUSE 0x04
#define IRQ_VGC_SCANLINE 0x08
#define IRQ_VGC_SECOND 0x10
#define IRQ_INTEN_QSECOND 0x20
#define IRQ_INTEN_VBL 0x40
#define IRQ_DOC 0x80
#define IRQ_SLOT 0x100
void apple2gs_add_irq(running_machine &machine, uint16_t irq_mask);
void apple2gs_remove_irq(running_machine &machine, uint16_t irq_mask);
class apple2gs_state : public apple2_state
{
public:
apple2gs_state(const machine_config &mconfig, device_type type, const char *tag)
: apple2_state(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_es5503(*this, "es5503"),
m_fdc(*this, "fdc"),
m_scc(*this, "scc"),
#if RUN_ADB_MICRO
m_adbmicro(*this, ADBMICRO_TAG),
#endif
m_adb_mousex(*this, "adb_mouse_x"),
m_adb_mousey(*this, "adb_mouse_y"),
m_palette(*this, "palette")
{ }
required_device<g65816_device> m_maincpu;
required_device<es5503_device> m_es5503;
required_device<applefdc_base_device> m_fdc;
required_device<z80scc_device> m_scc;
#if RUN_ADB_MICRO
optional_device<m5074x_device> m_adbmicro;
#endif
required_ioport m_adb_mousex, m_adb_mousey;
required_device<palette_device> m_palette;
std::unique_ptr<uint8_t[]> m_slowmem;
uint8_t m_newvideo;
uint16_t m_bordercolor;
uint8_t m_vgcint;
uint8_t m_langsel;
uint8_t m_sltromsel;
uint8_t m_cyareg;
uint8_t m_inten;
uint8_t m_intflag;
uint8_t m_shadow;
uint16_t m_pending_irqs;
uint8_t m_mouse_x;
uint8_t m_mouse_y;
int8_t m_mouse_dx;
int8_t m_mouse_dy;
device_t *m_cur_slot6_image;
emu_timer *m_scanline_timer;
emu_timer *m_clock_timer;
emu_timer *m_qsecond_timer;
uint8_t m_clock_data;
uint8_t m_clock_control;
uint8_t m_clock_read;
uint8_t m_clock_reg1;
apple2gs_clock_mode m_clock_mode;
uint32_t m_clock_curtime;
seconds_t m_clock_curtime_interval;
uint8_t m_clock_bram[256];
#if !RUN_ADB_MICRO
adbstate_t m_adb_state;
uint8_t m_adb_command;
uint8_t m_adb_mode;
uint8_t m_adb_kmstatus;
uint8_t m_adb_latent_result;
int32_t m_adb_command_length;
int32_t m_adb_command_pos;
uint8_t m_adb_command_bytes[8];
uint8_t m_adb_response_bytes[8];
uint8_t m_adb_response_length;
int32_t m_adb_response_pos;
uint8_t m_adb_memory[0x100];
int m_adb_address_keyboard;
int m_adb_address_mouse;
#endif
uint8_t m_sndglu_ctrl;
int m_sndglu_addr;
int m_sndglu_dummy_read;
std::unique_ptr<bitmap_ind16> m_legacy_gfx;
bool m_is_rom3;
uint8_t m_echo_bank;
uint64_t m_last_adb_time;
int m_adb_dtime;
uint32_t m_a2_palette[16];
uint32_t m_shr_palette[256];
READ8_MEMBER( apple2gs_c0xx_r );
WRITE8_MEMBER( apple2gs_c0xx_w );
WRITE8_MEMBER( apple2gs_main0400_w );
WRITE8_MEMBER( apple2gs_aux0400_w );
WRITE8_MEMBER( apple2gs_main2000_w );
WRITE8_MEMBER( apple2gs_aux2000_w );
WRITE8_MEMBER( apple2gs_main4000_w );
WRITE8_MEMBER( apple2gs_aux4000_w );
uint8_t adb_read_datareg();
uint8_t adb_read_kmstatus();
void apple2gs_refresh_delegates();
write8_delegate write_delegates_2gs0400[2];
write8_delegate write_delegates_2gs2000[2];
write8_delegate write_delegates_2gs4000[2];
DECLARE_MACHINE_START(apple2gs);
DECLARE_MACHINE_RESET(apple2gs);
DECLARE_VIDEO_START(apple2gs);
DECLARE_PALETTE_INIT(apple2gs);
DECLARE_MACHINE_START(apple2gsr1);
DECLARE_MACHINE_START(apple2gscommon);
uint32_t screen_update_apple2gs(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
TIMER_CALLBACK_MEMBER(apple2gs_clock_tick);
TIMER_CALLBACK_MEMBER(apple2gs_qsecond_tick);
TIMER_CALLBACK_MEMBER(apple2gs_scanline_tick);
DECLARE_WRITE_LINE_MEMBER(a2bus_irq_w);
DECLARE_WRITE_LINE_MEMBER(a2bus_nmi_w);
DECLARE_WRITE_LINE_MEMBER(a2bus_inh_w);
DECLARE_READ8_MEMBER(apple2gs_read_vector);
// ADB MCU and ADB GLU stuff
#if RUN_ADB_MICRO
uint8_t m_glu_regs[8], m_glu_bus, m_glu_sysstat;
bool m_glu_mcu_read_kgs, m_glu_816_read_dstat, m_glu_mouse_read_stat, m_adb_line;
uint8_t keyglu_mcu_read(uint8_t offset);
void keyglu_mcu_write(uint8_t offset, uint8_t data);
uint8_t keyglu_816_read(uint8_t offset);
void keyglu_816_write(uint8_t offset, uint8_t data);
DECLARE_READ8_MEMBER(adbmicro_p0_in);
DECLARE_READ8_MEMBER(adbmicro_p1_in);
DECLARE_READ8_MEMBER(adbmicro_p2_in);
DECLARE_READ8_MEMBER(adbmicro_p3_in);
DECLARE_WRITE8_MEMBER(adbmicro_p0_out);
DECLARE_WRITE8_MEMBER(adbmicro_p1_out);
DECLARE_WRITE8_MEMBER(adbmicro_p2_out);
DECLARE_WRITE8_MEMBER(adbmicro_p3_out);
#endif
void process_clock();
const char *apple2gs_irq_name(uint16_t irq_mask);
void apple2gs_add_irq(uint16_t irq_mask);
void apple2gs_remove_irq(uint16_t irq_mask);
uint8_t adb_read_memory(uint32_t address);
void adb_write_memory(uint32_t address, uint8_t data);
void adb_set_mode(uint8_t mode);
void adb_set_config(uint8_t b1, uint8_t b2, uint8_t b3);
void adb_post_response(const uint8_t *bytes, size_t length);
void adb_post_response_1(uint8_t b);
void adb_post_response_2(uint8_t b1, uint8_t b2);
void adb_do_command();
void adb_write_datareg(uint8_t data);
void adb_write_kmstatus(uint8_t data);
uint8_t adb_read_mousedata();
int8_t seven_bit_diff(uint8_t v1, uint8_t v2);
void adb_check_mouse();
void apple2gs_set_scanint(uint8_t data);
int apple2gs_get_vpos();
uint8_t *apple2gs_getslotmem(offs_t address);
uint8_t apple2gs_xxCxxx_r(address_space &space, offs_t address);
void apple2gs_xxCxxx_w(address_space &space, offs_t address, uint8_t data);
void apple2gs_setup_memory();
DECLARE_READ8_MEMBER( gssnd_r );
DECLARE_WRITE8_MEMBER( gssnd_w );
DECLARE_READ8_MEMBER( apple2gs_00Cxxx_r );
DECLARE_READ8_MEMBER( apple2gs_01Cxxx_r );
DECLARE_READ8_MEMBER( apple2gs_E0Cxxx_r );
DECLARE_READ8_MEMBER( apple2gs_E1Cxxx_r );
DECLARE_WRITE8_MEMBER( apple2gs_00Cxxx_w );
DECLARE_WRITE8_MEMBER( apple2gs_01Cxxx_w );
DECLARE_WRITE8_MEMBER( apple2gs_E0Cxxx_w );
DECLARE_WRITE8_MEMBER( apple2gs_E1Cxxx_w );
DECLARE_WRITE8_MEMBER( apple2gs_Exxxxx_w );
DECLARE_WRITE8_MEMBER( apple2gs_E004xx_w );
DECLARE_WRITE8_MEMBER( apple2gs_E02xxx_w );
DECLARE_WRITE8_MEMBER( apple2gs_E104xx_w );
DECLARE_WRITE8_MEMBER( apple2gs_E12xxx_w );
DECLARE_WRITE8_MEMBER( apple2gs_slowmem_w );
DECLARE_READ8_MEMBER(apple2gs_bank_echo_r);
DECLARE_WRITE_LINE_MEMBER( apple2gs_doc_irq);
DECLARE_READ8_MEMBER(apple2gs_adc_read);
void apple2gs(machine_config &config);
void apple2gsr1(machine_config &config);
void apple2gs_map(address_map &map);
void vectors_map(address_map &map);
};
#endif // MAME_INCLUDES_APPLE2GS_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -193,7 +193,48 @@ inline void apple2_state::apple2_plot_text_character(bitmap_ind16 &bitmap, int x
}
}
void a2_video_device::plot_text_characterGS(bitmap_ind16 &bitmap, int xpos, int ypos, int xscale, uint32_t code,
const uint8_t *textgfx_data, uint32_t textgfx_datalen, int fg, int bg)
{
int x, y, i;
const uint8_t *chardata;
uint16_t color;
if (!m_altcharset)
{
if ((code >= 0x40) && (code <= 0x7f))
{
code &= 0x3f;
if (m_flash)
{
i = fg;
fg = bg;
bg = i;
}
}
}
else
{
code |= 0x100;
}
/* look up the character data */
chardata = &textgfx_data[(code * 8)];
for (y = 0; y < 8; y++)
{
for (x = 0; x < 7; x++)
{
color = (chardata[y] & (1 << x)) ? bg : fg;
for (i = 0; i < xscale; i++)
{
bitmap.pix16(ypos + y, xpos + (x * xscale) + i) = color;
}
}
}
}
/*-------------------------------------------------
apple2_text_draw - renders text (either 40
@ -1637,3 +1678,263 @@ PALETTE_INIT_MEMBER(a2_video_device, apple2)
{
palette.set_pen_colors(0, apple2_palette, ARRAY_LENGTH(apple2_palette));
}
uint32_t a2_video_device::screen_update_GS(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
const uint8_t *vram;
uint32_t *scanline;
uint8_t scb, b;
int col, palette;
uint32_t last_pixel = 0, pixel;
int beamy;
uint16_t *a2pixel;
beamy = cliprect.min_y;
if (m_newvideo & 0x80)
{
// in top or bottom border?
if ((beamy < BORDER_TOP) || (beamy >= 200+BORDER_TOP))
{
// don't draw past the bottom border
if (beamy >= 231+BORDER_TOP)
{
return 0;
}
scanline = &bitmap.pix32(beamy);
for (col = 0; col < BORDER_LEFT+BORDER_RIGHT+640; col++)
{
scanline[col] = m_GSborder_colors[m_GSborder];
}
}
else // regular screen area
{
int shrline = beamy - BORDER_TOP;
scb = m_aux_ptr[0x9D00 + shrline];
palette = ((scb & 0x0f) << 4);
vram = &m_aux_ptr[0x2000 + (shrline * 160)];
scanline = &bitmap.pix32(beamy);
// draw left and right borders
for (col = 0; col < BORDER_LEFT; col++)
{
scanline[col] = m_GSborder_colors[m_GSborder];
scanline[col+BORDER_LEFT+640] = m_GSborder_colors[m_GSborder];
}
if (scb & 0x80) // 640 mode
{
for (col = 0; col < 160; col++)
{
b = vram[col];
scanline[col * 4 + 0 + BORDER_LEFT] = m_shr_palette[palette + 0 + ((b >> 6) & 0x03)];
scanline[col * 4 + 1 + BORDER_LEFT] = m_shr_palette[palette + 4 + ((b >> 4) & 0x03)];
scanline[col * 4 + 2 + BORDER_LEFT] = m_shr_palette[palette + 8 + ((b >> 2) & 0x03)];
scanline[col * 4 + 3 + BORDER_LEFT] = m_shr_palette[palette + 12 + ((b >> 0) & 0x03)];
}
}
else // 320 mode
{
for (col = 0; col < 160; col++)
{
b = vram[col];
pixel = (b >> 4) & 0x0f;
if ((scb & 0x20) && !pixel)
pixel = last_pixel;
else
last_pixel = pixel;
pixel += palette;
scanline[col * 4 + 0 + BORDER_LEFT] = m_shr_palette[pixel];
scanline[col * 4 + 1 + BORDER_LEFT] = m_shr_palette[pixel];
b = vram[col];
pixel = (b >> 0) & 0x0f;
if ((scb & 0x20) && !pixel)
pixel = last_pixel;
else
last_pixel = pixel;
pixel += palette;
scanline[col * 4 + 2 + BORDER_LEFT] = m_shr_palette[pixel];
scanline[col * 4 + 3 + BORDER_LEFT] = m_shr_palette[pixel];
}
}
}
}
else
{
/* call legacy Apple II video rendering at scanline 0 to draw into the off-screen buffer */
if (beamy == 0)
{
rectangle new_cliprect(0, 559, 0, 191);
screen_update_GS_8bit(screen, *m_8bit_graphics, new_cliprect);
}
if ((beamy < (BORDER_TOP+4)) || (beamy >= (192+4+BORDER_TOP)))
{
if (beamy >= (231+BORDER_TOP))
{
return 0;
}
scanline = &bitmap.pix32(beamy);
for (col = 0; col < BORDER_LEFT+BORDER_RIGHT+640; col++)
{
scanline[col] = m_GSborder_colors[m_GSborder];
}
}
else
{
scanline = &bitmap.pix32(beamy);
// draw left and right borders
for (col = 0; col < BORDER_LEFT + 40; col++)
{
scanline[col] = m_GSborder_colors[m_GSborder];
scanline[col+BORDER_LEFT+600] = m_GSborder_colors[m_GSborder];
}
a2pixel = &m_8bit_graphics->pix16(beamy-(BORDER_TOP+4));
for (int x = 0; x < 560; x++)
{
scanline[40 + BORDER_LEFT + x] = m_GSborder_colors[*a2pixel++];
}
}
}
return 0;
}
uint32_t a2_video_device::screen_update_GS_8bit(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
bool old_page2 = m_page2;
// don't display page2 if 80store is set (we just saved the previous value, don't worry)
if (m_80store)
{
m_page2 = false;
}
// always update the flash timer here so it's smooth regardless of mode switches
m_flash = ((machine().time() * 4).seconds() & 1) ? true : false;
if (m_graphics)
{
if (m_hires)
{
if (m_mix)
{
if ((m_dhires) && (m_80col))
{
dhgr_update(screen, bitmap, cliprect, 0, 159);
}
else
{
hgr_update(screen, bitmap, cliprect, 0, 159);
}
text_updateGS(screen, bitmap, cliprect, 160, 191);
}
else
{
if ((m_dhires) && (m_80col))
{
dhgr_update(screen, bitmap, cliprect, 0, 191);
}
else
{
hgr_update(screen, bitmap, cliprect, 0, 191);
}
}
}
else // lo-res
{
if (m_mix)
{
if ((m_dhires) && (m_80col))
{
dlores_update(screen, bitmap, cliprect, 0, 159);
}
else
{
lores_update(screen, bitmap, cliprect, 0, 159);
}
text_updateGS(screen, bitmap, cliprect, 160, 191);
}
else
{
if ((m_dhires) && (m_80col))
{
dlores_update(screen, bitmap, cliprect, 0, 191);
}
else
{
lores_update(screen, bitmap, cliprect, 0, 191);
}
}
}
}
else
{
text_updateGS(screen, bitmap, cliprect, 0, 191);
}
m_page2 = old_page2;
return 0;
}
void a2_video_device::text_updateGS(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow)
{
int row, col;
uint32_t start_address;
uint32_t address;
uint8_t *aux_page = m_ram_ptr;
if (m_80col)
{
start_address = 0x400;
if (m_aux_ptr)
{
aux_page = m_aux_ptr;
}
}
else
{
start_address = m_page2 ? 0x800 : 0x400;
}
beginrow = std::max(beginrow, cliprect.min_y - (cliprect.min_y % 8));
endrow = std::min(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7);
for (row = beginrow; row <= endrow; row += 8)
{
if (m_80col)
{
for (col = 0; col < 40; col++)
{
/* calculate address */
address = start_address + ((((row/8) & 0x07) << 7) | (((row/8) & 0x18) * 5 + col));
plot_text_characterGS(bitmap, col * 14, row, 1, aux_page[address],
m_char_ptr, m_char_size, m_GSfg, m_GSbg);
plot_text_characterGS(bitmap, col * 14 + 7, row, 1, m_ram_ptr[address],
m_char_ptr, m_char_size, m_GSfg, m_GSbg);
}
}
else
{
for (col = 0; col < 40; col++)
{
/* calculate address */
address = start_address + ((((row/8) & 0x07) << 7) | (((row/8) & 0x18) * 5 + col));
plot_text_characterGS(bitmap, col * 14, row, 2, m_ram_ptr[address],
m_char_ptr, m_char_size, m_GSfg, m_GSbg);
}
}
}
}

View File

@ -11,6 +11,10 @@
#include "emupal.h"
#define BORDER_LEFT (32)
#define BORDER_RIGHT (32)
#define BORDER_TOP (16) // (plus bottom)
class a2_video_device :
public device_t
{
@ -29,8 +33,11 @@ public:
bool m_80col;
bool m_altcharset;
bool m_an2;
bool m_80store;
bool m_monohgr;
uint8_t m_GSfg, m_GSbg, m_GSborder, m_newvideo, m_monochrome;
uint32_t m_GSborder_colors[16], m_shr_palette[256];
std::unique_ptr<bitmap_ind16> m_8bit_graphics;
std::unique_ptr<uint16_t[]> m_hires_artifact_map;
std::unique_ptr<uint16_t[]> m_dhires_artifact_map;
@ -43,12 +50,16 @@ public:
void text_update_ultr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow);
void text_update_orig(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow);
void text_update_jplus(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow);
void text_updateGS(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow);
void lores_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow);
void dlores_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow);
void hgr_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow);
void hgr_update_tk2000(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow);
void dhgr_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int beginrow, int endrow);
uint32_t screen_update_GS(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
uint32_t screen_update_GS_8bit(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
protected:
virtual void device_reset() override;
virtual void device_start() override;
@ -58,6 +69,7 @@ private:
void plot_text_character_ultr(bitmap_ind16 &bitmap, int xpos, int ypos, int xscale, uint32_t code, const uint8_t *textgfx_data, uint32_t textgfx_datalen, int fg, int bg);
void plot_text_character_orig(bitmap_ind16 &bitmap, int xpos, int ypos, int xscale, uint32_t code, const uint8_t *textgfx_data, uint32_t textgfx_datalen, int fg, int bg);
void plot_text_character_jplus(bitmap_ind16 &bitmap, int xpos, int ypos, int xscale, uint32_t code, const uint8_t *textgfx_data, uint32_t textgfx_datalen, int fg, int bg);
void plot_text_characterGS(bitmap_ind16 &bitmap, int xpos, int ypos, int xscale, uint32_t code, const uint8_t *textgfx_data, uint32_t textgfx_datalen, int fg, int bg);
};
// device type definition

View File

@ -1,168 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:Nathan Woods,R. Belmont
/*********************************************************************
video/apple2gs.c
Apple IIgs video code
*********************************************************************/
#include "emu.h"
#include "includes/apple2.h"
#include "includes/apple2gs.h"
VIDEO_START_MEMBER(apple2gs_state,apple2gs)
{
m_bordercolor = 0;
apple2_video_start(m_slowmem.get(), m_slowmem.get()+0x10000, 0, 8);
m_legacy_gfx = std::make_unique<bitmap_ind16>(560, 192);
save_item(m_bordercolor, "BORDERCLR");
save_item(NAME(m_fgcolor));
save_item(NAME(m_bgcolor));
}
uint32_t apple2gs_state::screen_update_apple2gs(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
const uint8_t *vram;
uint32_t *scanline;
uint8_t scb, b;
int col, palette;
uint32_t last_pixel = 0, pixel;
int beamy;
uint16_t *a2pixel;
beamy = cliprect.min_y;
if (m_newvideo & 0x80)
{
// in top or bottom border?
if ((beamy < BORDER_TOP) || (beamy >= 200+BORDER_TOP))
{
// don't draw past the bottom border
if (beamy >= 231+BORDER_TOP)
{
return 0;
}
scanline = &bitmap.pix32(beamy);
for (col = 0; col < BORDER_LEFT+BORDER_RIGHT+640; col++)
{
scanline[col] = m_a2_palette[m_bordercolor];
}
}
else // regular screen area
{
int shrline = beamy - BORDER_TOP;
scb = m_slowmem[0x19D00 + shrline];
palette = ((scb & 0x0f) << 4);
vram = &m_slowmem[0x12000 + (shrline * 160)];
scanline = &bitmap.pix32(beamy);
// draw left and right borders
for (col = 0; col < BORDER_LEFT; col++)
{
scanline[col] = m_a2_palette[m_bordercolor];
scanline[col+BORDER_LEFT+640] = m_a2_palette[m_bordercolor];
}
if (scb & 0x80) // 640 mode
{
for (col = 0; col < 160; col++)
{
b = vram[col];
scanline[col * 4 + 0 + BORDER_LEFT] = m_shr_palette[palette + 0 + ((b >> 6) & 0x03)];
scanline[col * 4 + 1 + BORDER_LEFT] = m_shr_palette[palette + 4 + ((b >> 4) & 0x03)];
scanline[col * 4 + 2 + BORDER_LEFT] = m_shr_palette[palette + 8 + ((b >> 2) & 0x03)];
scanline[col * 4 + 3 + BORDER_LEFT] = m_shr_palette[palette + 12 + ((b >> 0) & 0x03)];
}
}
else // 320 mode
{
for (col = 0; col < 160; col++)
{
b = vram[col];
pixel = (b >> 4) & 0x0f;
if ((scb & 0x20) && !pixel)
pixel = last_pixel;
else
last_pixel = pixel;
pixel += palette;
scanline[col * 4 + 0 + BORDER_LEFT] = m_shr_palette[pixel];
scanline[col * 4 + 1 + BORDER_LEFT] = m_shr_palette[pixel];
b = vram[col];
pixel = (b >> 0) & 0x0f;
if ((scb & 0x20) && !pixel)
pixel = last_pixel;
else
last_pixel = pixel;
pixel += palette;
scanline[col * 4 + 2 + BORDER_LEFT] = m_shr_palette[pixel];
scanline[col * 4 + 3 + BORDER_LEFT] = m_shr_palette[pixel];
}
}
}
}
else
{
/* call legacy Apple II video rendering at scanline 0 to draw into the off-screen buffer */
if (beamy == 0)
{
// check if DHR should be monochrome 560x192
if (m_newvideo & 0x20)
{
m_monochrome_dhr = true;
}
else
{
m_monochrome_dhr = false;
}
rectangle new_cliprect(0, 559, 0, 191);
screen_update_apple2(screen, *m_legacy_gfx, new_cliprect);
}
if ((beamy < (BORDER_TOP+4)) || (beamy >= (192+4+BORDER_TOP)))
{
if (beamy >= (231+BORDER_TOP))
{
return 0;
}
scanline = &bitmap.pix32(beamy);
for (col = 0; col < BORDER_LEFT+BORDER_RIGHT+640; col++)
{
scanline[col] = m_a2_palette[m_bordercolor];
}
}
else
{
scanline = &bitmap.pix32(beamy);
// draw left and right borders
for (col = 0; col < BORDER_LEFT + 40; col++)
{
scanline[col] = m_a2_palette[m_bordercolor];
scanline[col+BORDER_LEFT+600] = m_a2_palette[m_bordercolor];
}
a2pixel = &m_legacy_gfx->pix16(beamy-(BORDER_TOP+4));
for (int x = 0; x < 560; x++)
{
scanline[40 + BORDER_LEFT + x] = m_a2_palette[*a2pixel++];
}
}
}
return 0;
}