diff options
| author | 2025-09-20 02:45:27 +1000 | |
|---|---|---|
| committer | 2025-09-20 02:45:27 +1000 | |
| commit | e6ec4dce4e840f736db7039a55714eec0775991b (patch) | |
| tree | d865b44a9f2cdb8ca7f24e15790fd8695a5e3af9 | |
| parent | 5b15aff4656cfa5612ad28d93d53a018b6fb66dd (diff) | |
-cpu/drcbearm64.cpp: Improved emulated memory access code:
* Generate optimised code for reads narrower than native width.
* Mask returned value to access size - the upper bits may not be cleared
(fixes Hyperstone E1 misbehaving on Windows arm64).
* Don't save emulated flags across CALLC - flags are clobbered anyway.
-adp/servicetastatur.cpp, toshiba/pasopia7.cpp: Cleanup, side effect
checks, fewer literal tags.
| -rw-r--r-- | src/devices/cpu/drcbearm64.cpp | 121 | ||||
| -rw-r--r-- | src/mame/adp/servicetastatur.cpp | 20 | ||||
| -rw-r--r-- | src/mame/toshiba/pasopia7.cpp | 377 |
3 files changed, 303 insertions, 215 deletions
diff --git a/src/devices/cpu/drcbearm64.cpp b/src/devices/cpu/drcbearm64.cpp index 392763e20ad..857192e10f5 100644 --- a/src/devices/cpu/drcbearm64.cpp +++ b/src/devices/cpu/drcbearm64.cpp @@ -505,7 +505,6 @@ private: struct near_state { uint64_t saved_fpcr; - uint32_t emulated_flags; }; struct memory_accessors @@ -623,6 +622,8 @@ private: arm::Mem emit_loadstore_address_setup(a64::Assembler &a, const a64::Gp &basereg, const be_parameter &indp, const uml::parameter &scalesizep) const; void emit_memaccess_setup(a64::Assembler &a, const be_parameter &addrp, const memory_accessors &accessors, const address_space::specific_access_info::side &side) const; + void emit_narrow_memaccess_setup(a64::Assembler &a, const be_parameter &addrp, const parameter &spacesizep, const memory_accessors &accessors, const address_space::specific_access_info::side &side) const; + void emit_narrow_memread(a64::Assembler &a, const be_parameter &addrp, const parameter &spacesizep, const memory_accessors &accessors) const; void emit_narrow_memwrite(a64::Assembler &a, const be_parameter &addrp, const parameter &spacesizep, const memory_accessors &accessors) const; void store_carry(a64::Assembler &a, bool inverted = false); @@ -1108,14 +1109,12 @@ void drcbe_arm64::emit_memaccess_setup(a64::Assembler &a, const be_parameter &ad // x8, x7 and potentially x6 clobbered } -void drcbe_arm64::emit_narrow_memwrite(a64::Assembler &a, const be_parameter &addrp, const parameter &spacesizep, const memory_accessors &accessors) const +void drcbe_arm64::emit_narrow_memaccess_setup(a64::Assembler &a, const be_parameter &addrp, const parameter &spacesizep, const memory_accessors &accessors, const address_space::specific_access_info::side &side) const { - // expects data in REG_PARAM3 and mask in REG_PARAM4 - address_space &space = *m_space[spacesizep.space()]; auto const addrreg = (accessors.no_mask || accessors.mask_simple) ? REG_PARAM2 : a64::x5; mov_reg_param(a, 4, addrreg, addrp); - get_imm_relative(a, a64::x8, uintptr_t(accessors.specific.write.dispatch)); + get_imm_relative(a, a64::x8, uintptr_t(side.dispatch)); // get the shift count for the data and offset in w7 int const shift = space.addr_shift() - 3; @@ -1180,8 +1179,55 @@ void drcbe_arm64::emit_narrow_memwrite(a64::Assembler &a, const be_parameter &ad } // apply this pointer displacement if necessary - if (accessors.specific.write.displacement) - a.add(REG_PARAM1, REG_PARAM1, accessors.specific.write.displacement); // assume less than 4K + if (side.displacement) + a.add(REG_PARAM1, REG_PARAM1, side.displacement); // assume less than 4K + + // load vtable pointer early if we'll need it + if (side.is_virtual) + a.ldr(a64::x8, a64::Mem(REG_PARAM1)); + + // adjusted dispatch table entry pointer in REG_PARAM1 + // masked address in REG_PARAM2 + // shift count in w7 + // vtable pointer in x8 if virtual + // x6 and potentially x8 and x5 clobbered +} + +void drcbe_arm64::emit_narrow_memread(a64::Assembler &a, const be_parameter &addrp, const parameter &spacesizep, const memory_accessors &accessors) const +{ + // expects mask in REG_PARAM3 + + emit_narrow_memaccess_setup(a, addrp, spacesizep, accessors, accessors.specific.read); + + // shift the mask + a.lsl(REG_PARAM3, REG_PARAM3, a64::x7); + + // stash the shift count - flags are clobbered anyway, so use the emulated flags register + a.mov(FLAGS_REG.w(), a64::w7); + + // call the read function + if (accessors.specific.read.is_virtual) + { + a.ldr(a64::x8, a64::Mem(a64::x8, accessors.specific.read.function)); // assume no more than 4096 vtable entries + a.blr(a64::x8); + } + else + { + call_arm_addr(a, (const void *)accessors.specific.read.function); + } + + // shift the result + if (accessors.specific.native_bytes <= 4) + a.lsr(REG_PARAM1.w(), REG_PARAM1.w(), FLAGS_REG.w()); + else + a.lsr(REG_PARAM1, REG_PARAM1, FLAGS_REG); +} + +void drcbe_arm64::emit_narrow_memwrite(a64::Assembler &a, const be_parameter &addrp, const parameter &spacesizep, const memory_accessors &accessors) const +{ + // expects data in REG_PARAM3 and mask in REG_PARAM4 + + emit_narrow_memaccess_setup(a, addrp, spacesizep, accessors, accessors.specific.write); // shift the data and mask a.lsl(REG_PARAM3, REG_PARAM3, a64::x7); @@ -1190,7 +1236,6 @@ void drcbe_arm64::emit_narrow_memwrite(a64::Assembler &a, const be_parameter &ad // call the write function if (accessors.specific.write.is_virtual) { - a.ldr(a64::x8, a64::Mem(REG_PARAM1)); a.ldr(a64::x8, a64::Mem(a64::x8, accessors.specific.write.function)); // assume no more than 4096 vtable entries a.blr(a64::x8); } @@ -1527,8 +1572,6 @@ drcbe_arm64::drcbe_arm64(drcuml_state &drcuml, device_t &device, drc_cache &cach , m_baseptr(cache.near() + 0x100) , m_near(*(near_state *)cache.alloc_near(sizeof(m_near))) { - m_near.emulated_flags = 0; - // create the log if (device.machine().options().drc_log_native()) { @@ -1629,7 +1672,7 @@ void drcbe_arm64::reset() get_imm_absolute(a, BASE_REG, uintptr_t(m_baseptr)); a.mrs(SCRATCH_REG1, a64::Predicate::SysReg::kFPCR); - emit_ldr_mem(a, FLAGS_REG.w(), &m_near.emulated_flags); + a.mov(FLAGS_REG, 0); emit_str_mem(a, SCRATCH_REG1, &m_near.saved_fpcr); a.emitArgsAssignment(frame, args); @@ -2206,14 +2249,10 @@ void drcbe_arm64::op_callc(a64::Assembler &a, const uml::instruction &inst) Label skip; emit_skip(a, inst.condition(), skip); - emit_str_mem(a, FLAGS_REG.w(), &m_near.emulated_flags); - get_imm_relative(a, REG_PARAM1, (uintptr_t)paramp.memory()); get_imm_relative(a, TEMP_REG1, (uintptr_t)funcp.cfunc()); a.blr(TEMP_REG1); - emit_ldr_mem(a, FLAGS_REG.w(), &m_near.emulated_flags); - if (inst.condition() != uml::COND_ALWAYS) a.bind(skip); @@ -2676,6 +2715,11 @@ void drcbe_arm64::op_read(a64::Assembler &a, const uml::instruction &inst) else call_arm_addr(a, (const void *)accessors.specific.read.function); } + else if (have_specific && ((1 << spacesizep.size()) < accessors.specific.native_bytes)) + { + a.mov(REG_PARAM3, make_bitmask<uint64_t>(8 << spacesizep.size())); + emit_narrow_memread(a, addrp, spacesizep, accessors); + } else { mov_reg_param(a, 4, REG_PARAM2, addrp); @@ -2702,7 +2746,26 @@ void drcbe_arm64::op_read(a64::Assembler &a, const uml::instruction &inst) } } - mov_param_reg(a, inst.size(), dstp, REG_PARAM1); + const a64::Gp dstreg = dstp.select_register(REG_PARAM1, inst.size()); + if (spacesizep.size() == SIZE_BYTE) + { + a.and_(dstreg, select_register(REG_PARAM1, inst.size()), 0x000000ff); + mov_param_reg(a, inst.size(), dstp, dstreg); + } + else if (spacesizep.size() == SIZE_WORD) + { + a.and_(dstreg, select_register(REG_PARAM1, inst.size()), 0x0000ffff); + mov_param_reg(a, inst.size(), dstp, dstreg); + } + else if ((spacesizep.size() == SIZE_DWORD) && (inst.size() == 8)) + { + a.mov(dstreg.w(), REG_PARAM1.w()); + mov_param_reg(a, inst.size(), dstp, dstreg); + } + else + { + mov_param_reg(a, inst.size(), dstp, REG_PARAM1); + } } void drcbe_arm64::op_readm(a64::Assembler &a, const uml::instruction &inst) @@ -2737,6 +2800,11 @@ void drcbe_arm64::op_readm(a64::Assembler &a, const uml::instruction &inst) call_arm_addr(a, (const void *)accessors.specific.read.function); } } + else if (have_specific && ((1 << spacesizep.size()) < accessors.specific.native_bytes)) + { + mov_reg_param(a, inst.size(), REG_PARAM3, maskp); + emit_narrow_memread(a, addrp, spacesizep, accessors); + } else { mov_reg_param(a, 4, REG_PARAM2, addrp); @@ -2764,7 +2832,26 @@ void drcbe_arm64::op_readm(a64::Assembler &a, const uml::instruction &inst) } } - mov_param_reg(a, inst.size(), dstp, REG_PARAM1); + const a64::Gp dstreg = dstp.select_register(REG_PARAM1, inst.size()); + if (spacesizep.size() == SIZE_BYTE) + { + a.and_(dstreg, select_register(REG_PARAM1, inst.size()), 0x000000ff); + mov_param_reg(a, inst.size(), dstp, dstreg); + } + else if (spacesizep.size() == SIZE_WORD) + { + a.and_(dstreg, select_register(REG_PARAM1, inst.size()), 0x0000ffff); + mov_param_reg(a, inst.size(), dstp, dstreg); + } + else if ((spacesizep.size() == SIZE_DWORD) && (inst.size() == 8)) + { + a.mov(dstreg.w(), REG_PARAM1.w()); + mov_param_reg(a, inst.size(), dstp, dstreg); + } + else + { + mov_param_reg(a, inst.size(), dstp, REG_PARAM1); + } } void drcbe_arm64::op_write(a64::Assembler &a, const uml::instruction &inst) diff --git a/src/mame/adp/servicetastatur.cpp b/src/mame/adp/servicetastatur.cpp index 327333f1502..5d7d341e51b 100644 --- a/src/mame/adp/servicetastatur.cpp +++ b/src/mame/adp/servicetastatur.cpp @@ -83,7 +83,7 @@ public: m_io_keys(*this, "IN%u", 0U) { } - void servicet(machine_config &config); + void servicet(machine_config &config) ATTR_COLD; protected: virtual void machine_start() override ATTR_COLD; @@ -163,9 +163,9 @@ uint8_t servicet_state::port1_r() // Column-to-Row scanning: When columns (P1.0-P1.2) are driven HIGH for (int col = 0; col < 3; col++) { - if (m_port1 & (1 << col)) // Column is driven HIGH + if (BIT(m_port1, col)) // Column is driven HIGH { - uint8_t keys = m_io_keys[col]->read(); + uint8_t const keys = m_io_keys[col]->read(); data |= (keys & 0x70); // Mask to only row bits (4,5,6) } } @@ -173,13 +173,13 @@ uint8_t servicet_state::port1_r() // Row-to-Column scanning: When rows (P1.4-P1.6) are driven HIGH for (int row = 0; row < 3; row++) { - if (m_port1 & (1 << (row + 4))) // Row is driven HIGH (bits 4,5,6) + if (BIT(m_port1, row + 4)) // Row is driven HIGH (bits 4,5,6) { // Check all columns for this row for (int col = 0; col < 3; col++) { - uint8_t keys = m_io_keys[col]->read(); - if (keys & (1 << (row + 4))) // Key pressed in this row + uint8_t const keys = m_io_keys[col]->read(); + if (BIT(keys, row + 4)) // Key pressed in this row { data |= (1 << col); // Set corresponding column bit HIGH } @@ -199,7 +199,7 @@ uint8_t servicet_state::port3_r() { uint8_t data = m_port3; - uint8_t sda = m_i2cmem->read_sda(); + uint8_t const sda = m_i2cmem->read_sda(); // Clear bit 4 (SDA) and insert actual value from EEPROM data = (data & ~(1 << PORT_3_SDA)) | (sda ? (1 << PORT_3_SDA) : 0); @@ -254,8 +254,8 @@ void servicet_state::bus_w(offs_t offset, uint8_t data) if ((offset & 0x70) == 0x70) { // RS and RW are A1 and A0 - bool rs = BIT(offset, 1); - bool rw = BIT(offset, 0); + bool const rs = BIT(offset, 1); + bool const rw = BIT(offset, 0); if (!rw) { @@ -291,7 +291,7 @@ void servicet_state::servicet(machine_config &config) m_maincpu->port_out_cb<3>().set(FUNC(servicet_state::port3_w)); // I2C EEPROM: 24C16 (2KB) - connected to P3.4 (SDA) and P3.5 (SCL) - I2C_24C16(config, "eeprom"); + I2C_24C16(config, m_i2cmem); // LCD4002A screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_LCD)); diff --git a/src/mame/toshiba/pasopia7.cpp b/src/mame/toshiba/pasopia7.cpp index d38cfba1367..629acaa280b 100644 --- a/src/mame/toshiba/pasopia7.cpp +++ b/src/mame/toshiba/pasopia7.cpp @@ -47,6 +47,9 @@ #include "softlist_dev.h" #include "speaker.h" +//#define VERBOSE 1 +#include "logmacro.h" + namespace { @@ -76,12 +79,12 @@ public: , m_font_rom(*this, "font") { } - void p7_base(machine_config &config); - void p7_lcd(machine_config &config); - void p7_raster(machine_config &config); + void p7_base(machine_config &config) ATTR_COLD; + void p7_lcd(machine_config &config) ATTR_COLD; + void p7_raster(machine_config &config) ATTR_COLD; - void init_p7_lcd(); - void init_p7_raster(); + void init_p7_lcd() ATTR_COLD; + void init_p7_raster() ATTR_COLD; protected: virtual void machine_start() override ATTR_COLD; @@ -89,28 +92,28 @@ protected: virtual void video_start() override ATTR_COLD; private: - uint8_t vram_r(offs_t offset); - void vram_w(offs_t offset, uint8_t data); - void memory_ctrl_w(uint8_t data); - void ram_bank_w(offs_t offset, uint8_t data); - void pasopia7_6845_w(offs_t offset, uint8_t data); - uint8_t io_r(offs_t offset); - void io_w(offs_t offset, uint8_t data); - uint8_t fdc_r(offs_t offset); - void fdc_w(offs_t offset, uint8_t data); - uint8_t keyb_r(); - void mux_w(uint8_t data); - uint8_t crtc_portb_r(); - void screen_mode_w(uint8_t data); - void plane_reg_w(uint8_t data); - void video_attr_w(uint8_t data); - void video_misc_w(uint8_t data); - void nmi_mask_w(uint8_t data); - uint8_t unk_r(); - uint8_t nmi_reg_r(); - void nmi_reg_w(uint8_t data); - uint8_t nmi_porta_r(); - uint8_t nmi_portb_r(); + u8 vram_r(offs_t offset); + void vram_w(offs_t offset, u8 data); + void memory_ctrl_w(u8 data); + void ram_bank_w(offs_t offset, u8 data); + void pasopia7_6845_w(offs_t offset, u8 data); + u8 io_r(offs_t offset); + void io_w(offs_t offset, u8 data); + u8 fdc_r(offs_t offset); + void fdc_w(offs_t offset, u8 data); + u8 keyb_r(); + void mux_w(u8 data); + u8 crtc_portb_r(); + void screen_mode_w(u8 data); + void plane_reg_w(u8 data); + void video_attr_w(u8 data); + void video_misc_w(u8 data); + void nmi_mask_w(u8 data); + u8 unk_r(); + u8 nmi_reg_r(); + void nmi_reg_w(u8 data); + u8 nmi_porta_r(); + u8 nmi_portb_r(); void speaker_w(int state); TIMER_CALLBACK_MEMBER(pio_timer); void p7_lcd_palette(palette_device &palette) const; @@ -119,34 +122,35 @@ private: void pasopia7_io(address_map &map) ATTR_COLD; void pasopia7_mem(address_map &map) ATTR_COLD; - std::unique_ptr<uint8_t[]> m_work_ram; - std::unique_ptr<uint8_t[]> m_vram; - uint8_t m_vram_sel = 0; - uint8_t m_mio_sel = 0; - std::unique_ptr<uint8_t[]> m_p7_pal; - uint8_t m_bank_reg = 0; - uint8_t m_cursor_blink = 0; - uint8_t m_plane_reg = 0; - uint8_t m_attr_data = 0; - uint8_t m_attr_wrap = 0; - uint8_t m_attr_latch = 0; - uint8_t m_pal_sel = 0; - uint8_t m_x_width = 0; - uint8_t m_gfx_mode = 0; - uint8_t m_nmi_mask = 0; - uint8_t m_nmi_enable_reg = 0; - uint8_t m_nmi_trap = 0; - uint8_t m_nmi_reset = 0; - uint8_t m_screen_type = 0; + void fdc_irq(bool state); + void draw_cg4_line(bitmap_rgb32 &bitmap, int y, int yi, int width, int count); + void draw_tv_line(bitmap_rgb32 &bitmap, int y, int yi, int width, int count, int cursor_x); + void draw_mixed_line(bitmap_rgb32 &bitmap, int y, int yi, int width, int count, int cursor_x); + + std::unique_ptr<u8[]> m_work_ram; + std::unique_ptr<u8[]> m_vram; + u8 m_vram_sel = 0; + u8 m_mio_sel = 0; + std::unique_ptr<u8[]> m_p7_pal; + u8 m_bank_reg = 0; + u8 m_cursor_blink = 0; + u8 m_plane_reg = 0; + u8 m_attr_data = 0; + u8 m_attr_wrap = 0; + u8 m_attr_latch = 0; + u8 m_pal_sel = 0; + u8 m_x_width = 0; + u8 m_gfx_mode = 0; + u8 m_nmi_mask = 0; + u8 m_nmi_enable_reg = 0; + u8 m_nmi_trap = 0; + u8 m_nmi_reset = 0; + u8 m_screen_type = 0; void pasopia_nmi_trap(); - uint8_t m_mux_data = 0; + u8 m_mux_data = 0; u8 m_porta_2 = 0; bool m_spr_sw = false; emu_timer *m_pio_timer = nullptr; - void fdc_irq(bool state); - void draw_cg4_line(bitmap_rgb32 &bitmap,int y,int yi,int width,int count); - void draw_tv_line(bitmap_rgb32 &bitmap,int y,int yi,int width,int count,int cursor_x); - void draw_mixed_line(bitmap_rgb32 &bitmap,int y,int yi,int width,int count,int cursor_x); required_device<z80_device> m_maincpu; required_memory_bank_array<2> m_banks; @@ -166,7 +170,7 @@ private: required_device<cassette_image_device> m_cass; required_device<pasopia_pac2_slot_device> m_pac2; required_device<speaker_sound_device> m_speaker; - required_region_ptr<uint8_t> m_font_rom; + required_region_ptr<u8> m_font_rom; }; #define VDP_CLOCK 14.318181_MHz_XTAL / 16 @@ -174,14 +178,14 @@ private: void pasopia7_state::machine_start() { - m_work_ram = std::make_unique<uint8_t[]>(0x10000); + m_work_ram = std::make_unique<u8[]>(0x10000); std::fill(&m_work_ram[0], &m_work_ram[0x10000], 0xff); - m_vram = make_unique_clear<uint8_t[]>(0x10000); + m_vram = make_unique_clear<u8[]>(0x10000); - uint8_t *work_ram = m_work_ram.get(); - uint8_t *basic = memregion("basic")->base(); - uint8_t *bios = memregion("bios")->base(); + u8 *work_ram = m_work_ram.get(); + u8 *basic = memregion("basic")->base(); + u8 *bios = memregion("bios")->base(); // 0000-3FFF m_banks[0]->configure_entry(0, bios); m_banks[0]->configure_entry(1, basic); @@ -203,123 +207,121 @@ TIMER_CALLBACK_MEMBER( pasopia7_state::pio_timer ) void pasopia7_state::video_start() { - m_p7_pal = std::make_unique<uint8_t[]>(0x10); + m_p7_pal = std::make_unique<u8[]>(0x10); } -void pasopia7_state::draw_cg4_line(bitmap_rgb32 &bitmap,int y,int yi,int width,int count) +void pasopia7_state::draw_cg4_line(bitmap_rgb32 &bitmap, int y, int yi, int width, int count) { - for(int x=0;x<8*width;x+=8) + for (int x = 0; x < 8*width; x += 8) { - for(int xi=0;xi<8;xi++) + for (int xi = 0; xi < 8; xi++) { - int pen_b = (m_vram[count+yi+0x0000]>>(7-xi)) & 1; - int pen_r = (m_vram[count+yi+0x4000]>>(7-xi)) & 1; - int pen_g = 0;//(m_vram[count+yi+0x8000]>>(7-xi)) & 1; + int pen_b = BIT(m_vram[count + yi + 0x0000], 7 - xi); + int pen_r = BIT(m_vram[count + yi + 0x4000], 7 - xi); + int pen_g = 0;//(m_vram[count + yi + 0x8000], 7 - xi); int color = pen_g<<2 | pen_r<<1 | pen_b<<0; - bitmap.pix(y, x+xi) = m_palette->pen(color); + bitmap.pix(y, x + xi) = m_palette->pen(color); } - count+=8; + count += 8; } } -void pasopia7_state::draw_tv_line(bitmap_rgb32 &bitmap,int y,int yi,int width,int count,int cursor_x) +void pasopia7_state::draw_tv_line(bitmap_rgb32 &bitmap, int y, int yi, int width, int count, int cursor_x) { - for(int x=0;x<width;x++) + for (int x = 0; x < width; x++) { - int tile = m_vram[count+0x8000]; - int attr = m_vram[count+0xc000]; + int tile = m_vram[count + 0x8000]; + int attr = m_vram[count + 0xc000]; int color = attr & 7; - for(int xi=0;xi<8;xi++) + for (int xi = 0; xi < 8; xi++) { - int pen = ((m_font_rom[tile*8+yi]>>(7-xi)) & 1) ? color : 0; + int pen = BIT(m_font_rom[tile*8 + yi], 7 - xi) ? color : 0; - bitmap.pix(y, x*8+xi) = m_palette->pen(pen); + bitmap.pix(y, x*8 + xi) = m_palette->pen(pen); } // draw cursor - if(cursor_x == x) + if (cursor_x == x) { - for(int xc=0;xc<8;xc++) + for (int xc = 0; xc < 8; xc++) { - bitmap.pix(y, x*8+xc) = m_palette->pen(7); + bitmap.pix(y, x*8 + xc) = m_palette->pen(7); } } - count+=8; + count += 8; } } -void pasopia7_state::draw_mixed_line(bitmap_rgb32 &bitmap,int y,int yi,int width,int count,int cursor_x) +void pasopia7_state::draw_mixed_line(bitmap_rgb32 &bitmap, int y, int yi, int width, int count, int cursor_x) { - for(int x=0;x<width;x++) + for (int x = 0; x < width; x++) { - int tile = m_vram[count+0x8000]; - int attr = m_vram[count+0xc000+yi]; + int tile = m_vram[count + 0x8000]; + int attr = m_vram[count + 0xc000 + yi]; - if(attr & 0x80) + if (attr & 0x80) { - for(int xi=0;xi<8;xi++) + for (int xi = 0; xi < 8; xi++) { - int pen_b = (m_vram[count+yi+0x0000]>>(7-xi)) & 1; - int pen_r = (m_vram[count+yi+0x4000]>>(7-xi)) & 1; - int pen_g = (m_vram[count+yi+0x8000]>>(7-xi)) & 1; + int pen_b = BIT(m_vram[count + yi + 0x0000], 7 - xi); + int pen_r = BIT(m_vram[count + yi + 0x4000], 7 - xi); + int pen_g = BIT(m_vram[count + yi + 0x8000], 7 - xi); int pen = pen_g<<2 | pen_r<<1 | pen_b<<0; - bitmap.pix(y, x*8+xi) = m_palette->pen(pen); + bitmap.pix(y, x*8 + xi) = m_palette->pen(pen); } } else { int color = attr & 7; - for(int xi=0;xi<8;xi++) + for (int xi = 0; xi < 8; xi++) { - int pen = ((m_font_rom[tile*8+yi]>>(7-xi)) & 1) ? color : 0; + int pen = BIT(m_font_rom[tile*8 + yi], 7 - xi) ? color : 0; - bitmap.pix(y, x*8+xi) = m_palette->pen(pen); + bitmap.pix(y, x*8 + xi) = m_palette->pen(pen); } } // draw cursor - if(cursor_x == x) + if (cursor_x == x) { - for(int xc=0;xc<8;xc++) + for(int xc = 0; xc < 8; xc++) { - bitmap.pix(y, x*8+xc) = m_palette->pen(7); + bitmap.pix(y, x*8 + xc) = m_palette->pen(7); } } - count+=8; + count += 8; } } MC6845_UPDATE_ROW(pasopia7_state::update_row) { - if(m_gfx_mode) - draw_mixed_line(bitmap,y,ra,x_count,ma*8,cursor_x); + if (m_gfx_mode) + { + draw_mixed_line(bitmap, y, ra, x_count, ma * 8, cursor_x); + } else { - draw_cg4_line(bitmap,y,ra,x_count,ma*8); - draw_tv_line(bitmap,y,ra,x_count,ma*8,cursor_x); + draw_cg4_line(bitmap, y, ra, x_count, ma * 8); + draw_tv_line(bitmap, y, ra, x_count, ma * 8, cursor_x); } } -uint8_t pasopia7_state::vram_r(offs_t offset) +u8 pasopia7_state::vram_r(offs_t offset) { - uint8_t res; - if (m_vram_sel == 0) - { - return m_work_ram[offset+0x8000]; - } + return m_work_ram[offset + 0x8000]; if (m_pal_sel && (m_plane_reg & 0x70) == 0x00) return m_p7_pal[offset & 0xf]; - res = 0xff; + u8 res = 0xff; if ((m_plane_reg & 0x11) == 0x11) res &= m_vram[offset | 0x0000]; @@ -334,7 +336,7 @@ uint8_t pasopia7_state::vram_r(offs_t offset) return res; } -void pasopia7_state::vram_w(offs_t offset, uint8_t data) +void pasopia7_state::vram_w(offs_t offset, u8 data) { if (m_vram_sel) { @@ -361,7 +363,7 @@ void pasopia7_state::vram_w(offs_t offset, uint8_t data) } } -void pasopia7_state::memory_ctrl_w(uint8_t data) +void pasopia7_state::memory_ctrl_w(u8 data) { switch(data & 3) { @@ -386,18 +388,18 @@ void pasopia7_state::memory_ctrl_w(uint8_t data) // bank4 is always RAM -// logerror("%02x\n",m_vram_sel); + LOG("m_vram_sel=%02x\n", m_vram_sel); } /* writes always occurs to the RAM banks, even if the ROMs are selected. */ -void pasopia7_state::ram_bank_w(offs_t offset, uint8_t data) +void pasopia7_state::ram_bank_w(offs_t offset, u8 data) { m_work_ram[offset] = data; } -void pasopia7_state::pasopia7_6845_w(offs_t offset, uint8_t data) +void pasopia7_state::pasopia7_6845_w(offs_t offset, u8 data) { - if(offset == 0) + if (offset == 0) { m_crtc->address_w(data); } @@ -406,25 +408,25 @@ void pasopia7_state::pasopia7_6845_w(offs_t offset, uint8_t data) m_crtc->register_w(data); /* double pump the pixel clock if we are in 640 x 200 mode */ - if(m_screen_type == 1) // raster - m_crtc->set_unscaled_clock( (m_x_width) ? VDP_CLOCK*2 : VDP_CLOCK); + if (m_screen_type == 1) // raster + m_crtc->set_unscaled_clock(m_x_width ? (VDP_CLOCK * 2) : VDP_CLOCK); else // lcd - m_crtc->set_unscaled_clock( (m_x_width) ? LCD_CLOCK*2 : LCD_CLOCK); + m_crtc->set_unscaled_clock(m_x_width ? (LCD_CLOCK * 2) : LCD_CLOCK); } } void pasopia7_state::pasopia_nmi_trap() { - if(m_nmi_enable_reg) + if (m_nmi_enable_reg) { m_nmi_trap |= 2; - if(m_nmi_mask == 0) + if (m_nmi_mask == 0) m_maincpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); } } -[[maybe_unused]] uint8_t pasopia7_state::fdc_r(offs_t offset) +[[maybe_unused]] u8 pasopia7_state::fdc_r(offs_t offset) { switch(offset) { @@ -436,15 +438,15 @@ void pasopia7_state::pasopia_nmi_trap() return 0xff; } -void pasopia7_state::fdc_w(offs_t offset, uint8_t data) +void pasopia7_state::fdc_w(offs_t offset, u8 data) { - switch(offset) + switch (offset) { case 0: m_fdc->tc_w(false); break; case 2: m_fdc->tc_w(true); break; case 5: m_fdc->fifo_w(data); break; case 6: - if(data & 0x80) + if (data & 0x80) m_fdc->reset(); /* TODO */ m_floppy->mon_w(data & 0x40 ? CLEAR_LINE : ASSERT_LINE); @@ -453,44 +455,39 @@ void pasopia7_state::fdc_w(offs_t offset, uint8_t data) } -uint8_t pasopia7_state::io_r(offs_t offset) +u8 pasopia7_state::io_r(offs_t offset) { - if(m_mio_sel) + if (m_mio_sel) { address_space &ram_space = m_maincpu->space(AS_PROGRAM); - m_mio_sel = 0; + if (!machine().side_effects_disabled()) + m_mio_sel = 0; // hack: this is used for reading the keyboard data, we can fake it a little ... (modify fda4) return ram_space.read_byte(offset); } - u8 io_port = offset & 0xff; //trim down to 8-bit bus + const u8 io_port = offset & 0xff; //trim down to 8-bit bus - if(io_port >= 0x08 && io_port <= 0x0b) + if (io_port >= 0x08 && io_port <= 0x0b) return m_ppi0->read(io_port & 3); - else - if(io_port >= 0x0c && io_port <= 0x0f) + else if (io_port >= 0x0c && io_port <= 0x0f) return m_ppi1->read(io_port & 3); - else - if(io_port == 0x10) + else if (io_port == 0x10) return m_crtc->status_r(); - else - if(io_port == 0x11) + else if (io_port == 0x11) return m_crtc->register_r(); - else - if(io_port >= 0x18 && io_port <= 0x1b) + else if (io_port >= 0x18 && io_port <= 0x1b) return m_pac2->read(io_port & 3); - else - if(io_port >= 0x20 && io_port <= 0x23) + else if (io_port >= 0x20 && io_port <= 0x23) { - pasopia_nmi_trap(); + if (!machine().side_effects_disabled()) + pasopia_nmi_trap(); return m_ppi2->read(io_port & 3); } - else - if(io_port >= 0x28 && io_port <= 0x2b) + else if (io_port >= 0x28 && io_port <= 0x2b) return m_ctc->read(io_port & 3); - else - if(io_port >= 0x30 && io_port <= 0x33) + else if (io_port >= 0x30 && io_port <= 0x33) return m_pio->read(io_port & 3); // else if(io_port == 0x3a) { SN1 } // else if(io_port == 0x3b) { SN2 } @@ -500,15 +497,16 @@ uint8_t pasopia7_state::io_r(offs_t offset) // return fdc_r(offset & 7); // else { - logerror("(PC=%06x) Read i/o address %02x\n",m_maincpu->pc(),io_port); + if (!machine().side_effects_disabled()) + logerror("(PC=%06x) Read i/o address %02x\n", m_maincpu->pc(), io_port); } return 0xff; } -void pasopia7_state::io_w(offs_t offset, uint8_t data) +void pasopia7_state::io_w(offs_t offset, u8 data) { - if(m_mio_sel) + if (m_mio_sel) { address_space &ram_space = m_maincpu->space(AS_PROGRAM); m_mio_sel = 0; @@ -516,42 +514,37 @@ void pasopia7_state::io_w(offs_t offset, uint8_t data) return; } - u8 io_port = offset & 0xff; //trim down to 8-bit bus + const u8 io_port = offset & 0xff; //trim down to 8-bit bus - if(io_port >= 0x08 && io_port <= 0x0b) + if (io_port >= 0x08 && io_port <= 0x0b) m_ppi0->write(io_port & 3, data); else - if(io_port >= 0x0c && io_port <= 0x0f) + if (io_port >= 0x0c && io_port <= 0x0f) m_ppi1->write(io_port & 3, data); else - if(io_port >= 0x10 && io_port <= 0x11) + if (io_port >= 0x10 && io_port <= 0x11) pasopia7_6845_w(io_port-0x10, data); else - if(io_port >= 0x18 && io_port <= 0x1b) + if (io_port >= 0x18 && io_port <= 0x1b) m_pac2->write(io_port & 3, data); else - if(io_port >= 0x20 && io_port <= 0x23) + if (io_port >= 0x20 && io_port <= 0x23) { m_ppi2->write(io_port & 3, data); pasopia_nmi_trap(); } else - if(io_port >= 0x28 && io_port <= 0x2b) + if (io_port >= 0x28 && io_port <= 0x2b) m_ctc->write(io_port & 3, data); - else - if(io_port >= 0x30 && io_port <= 0x33) + else if (io_port >= 0x30 && io_port <= 0x33) m_pio->write(io_port & 3, data); - else - if(io_port == 0x3a) + else if (io_port == 0x3a) m_sn1->write(data); - else - if(io_port == 0x3b) + else if (io_port == 0x3b) m_sn2->write(data); - else - if(io_port == 0x3c) + else if (io_port == 0x3c) memory_ctrl_w(data); - else - if(io_port >= 0xe0 && io_port <= 0xe6) + else if (io_port >= 0xe0 && io_port <= 0xe6) fdc_w(offset & 7, data); else { @@ -563,8 +556,8 @@ void pasopia7_state::pasopia7_mem(address_map &map) { map.unmap_value_high(); map(0x0000, 0x7fff).w(FUNC(pasopia7_state::ram_bank_w)); - map(0x0000, 0x3fff).bankr("bank0"); - map(0x4000, 0x7fff).bankr("bank1"); + map(0x0000, 0x3fff).bankr(m_banks[0]); + map(0x4000, 0x7fff).bankr(m_banks[1]); map(0x8000, 0xbfff).rw(FUNC(pasopia7_state::vram_r), FUNC(pasopia7_state::vram_w)); map(0xc000, 0xffff).ram(); } @@ -618,19 +611,25 @@ static GFXDECODE_START( gfx_pasopia7 ) GFXDECODE_ENTRY( "font", 0x00000, p7_chars_8x8, 0, 0x10 ) GFXDECODE_END -uint8_t pasopia7_state::keyb_r() +u8 pasopia7_state::keyb_r() { u8 data = 0xff; - for (u8 j=0; j<3; j++) - if (BIT(m_mux_data, 4+j)) - for (u8 i=0; i<4; i++) + for (u8 j = 0; j < 3; j++) + { + if (BIT(m_mux_data, 4 + j)) + { + for (u8 i = 0; i < 4; i++) + { if (BIT(m_mux_data, i)) - data &= m_keyboard[j*4+i]->read(); + data &= m_keyboard[j*4 + i]->read(); + } + } + } return data; } -void pasopia7_state::mux_w(uint8_t data) +void pasopia7_state::mux_w(u8 data) { m_mux_data = data; } @@ -643,44 +642,44 @@ static const z80_daisy_config p7_daisy[] = { nullptr } }; -uint8_t pasopia7_state::crtc_portb_r() +u8 pasopia7_state::crtc_portb_r() { // --x- ---- vsync bit // ---x ---- hardcoded bit, defines if the system screen is raster (1) or LCD (0) // ---- x--- disp bit - uint8_t vdisp = (m_screen->vpos() < (m_screen_type ? 200 : 28)) ? 0x08 : 0x00; //TODO: check LCD vpos trigger - uint8_t vsync = vdisp ? 0x00 : 0x20; + u8 vdisp = (m_screen->vpos() < (m_screen_type ? 200 : 28)) ? 0x08 : 0x00; //TODO: check LCD vpos trigger + u8 vsync = vdisp ? 0x00 : 0x20; return 0x40 | (m_attr_latch & 0x87) | vsync | vdisp | (m_screen_type << 4); } -void pasopia7_state::screen_mode_w(uint8_t data) +void pasopia7_state::screen_mode_w(u8 data) { - if(data & 0x5f) + if (data & 0x5f) logerror("GFX MODE %02x\n",data); m_x_width = data & 0x20; m_gfx_mode = data & 0x80; -// logerror("%02x\n",m_gfx_mode); + LOG("m_gfx_mode=%02x\n", m_gfx_mode); } -void pasopia7_state::plane_reg_w(uint8_t data) +void pasopia7_state::plane_reg_w(u8 data) { //if(data & 0x11) //logerror("PLANE %02x\n",data); m_plane_reg = data; } -void pasopia7_state::video_attr_w(uint8_t data) +void pasopia7_state::video_attr_w(u8 data) { - //logerror("VIDEO ATTR %02x | TEXT_PAGE %02x\n",data & 0xf,data & 0x70); - m_attr_data = (data & 0x7) | ((data & 0x8)<<4); + LOG("VIDEO ATTR %02x | TEXT_PAGE %02x\n", data & 0xf, data & 0x70); + m_attr_data = (data & 0x7) | ((data & 0x8) << 4); } //#include "debugger.h" -void pasopia7_state::video_misc_w(uint8_t data) +void pasopia7_state::video_misc_w(u8 data) { /* --x- ---- blinking @@ -698,7 +697,7 @@ void pasopia7_state::video_misc_w(uint8_t data) //m_pal_sel = data & 0x02; } -void pasopia7_state::nmi_mask_w(uint8_t data) +void pasopia7_state::nmi_mask_w(u8 data) { /* --x- ---- tape motor @@ -706,9 +705,9 @@ void pasopia7_state::nmi_mask_w(uint8_t data) ---- --x- sound off ---- ---x reset NMI & trap */ -// logerror("SYSTEM MISC %02x\n",data); + LOG("SYSTEM MISC %02x\n",data); - if(data & 1) + if (data & 1) { m_nmi_reset &= ~4; m_nmi_trap &= ~2; @@ -722,18 +721,18 @@ void pasopia7_state::nmi_mask_w(uint8_t data) } /* TODO: investigate on these. */ -uint8_t pasopia7_state::unk_r() +u8 pasopia7_state::unk_r() { return 0xff;//machine().rand(); } -uint8_t pasopia7_state::nmi_reg_r() +u8 pasopia7_state::nmi_reg_r() { //logerror("C\n"); return 0xfc | m_bank_reg;//machine().rand(); } -void pasopia7_state::nmi_reg_w(uint8_t data) +void pasopia7_state::nmi_reg_w(u8 data) { /* x--- ---- NMI mask @@ -743,12 +742,12 @@ void pasopia7_state::nmi_reg_w(uint8_t data) m_nmi_enable_reg = data & 0x40; } -uint8_t pasopia7_state::nmi_porta_r() +u8 pasopia7_state::nmi_porta_r() { return 0xff; } -uint8_t pasopia7_state::nmi_portb_r() +u8 pasopia7_state::nmi_portb_r() { u8 data = (m_cass->input() > +0.04) ? 0x20 : 0; return 0xd9 | data | m_nmi_trap | m_nmi_reset; @@ -858,6 +857,7 @@ void pasopia7_state::p7_base(machine_config &config) void pasopia7_state::p7_raster(machine_config &config) { p7_base(config); + SCREEN(config, m_screen, SCREEN_TYPE_RASTER); m_screen->set_refresh_hz(60); m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */ @@ -879,6 +879,7 @@ void pasopia7_state::p7_raster(machine_config &config) void pasopia7_state::p7_lcd(machine_config &config) { p7_base(config); + SCREEN(config, m_screen, SCREEN_TYPE_LCD); m_screen->set_refresh_hz(60); m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */ @@ -935,7 +936,7 @@ void pasopia7_state::init_p7_lcd() m_pio_timer->adjust(attotime::from_hz(5000), 0, attotime::from_hz(5000)); } -} // Anonymous namespace +} // anonymous namespace /* Driver */ |
