2022-04-13 21:25:28 +00:00
|
|
|
/*
|
|
|
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
2024-02-28 02:14:57 +00:00
|
|
|
Copyright (C) 2018-24 divingkatae and maximum
|
2022-04-13 21:25:28 +00:00
|
|
|
(theweirdo) spatium
|
|
|
|
|
|
|
|
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** ATI Mach64 GX definitions. */
|
|
|
|
|
|
|
|
#ifndef ATI_MACH64_GX_H
|
|
|
|
#define ATI_MACH64_GX_H
|
|
|
|
|
|
|
|
#include <devices/common/pci/pcidevice.h>
|
|
|
|
#include <devices/video/displayid.h>
|
|
|
|
#include <devices/video/videoctrl.h>
|
2024-04-20 07:53:32 +00:00
|
|
|
#include <devices/video/atimach64defs.h>
|
2022-04-13 21:25:28 +00:00
|
|
|
|
|
|
|
#include <cinttypes>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
class AtiMach64Gx : public PCIDevice, public VideoCtrlBase {
|
|
|
|
public:
|
|
|
|
AtiMach64Gx();
|
|
|
|
~AtiMach64Gx() = default;
|
|
|
|
|
2022-07-17 03:44:19 +00:00
|
|
|
static std::unique_ptr<HWComponent> create() {
|
|
|
|
return std::unique_ptr<AtiMach64Gx>(new AtiMach64Gx());
|
|
|
|
}
|
|
|
|
|
2023-04-10 20:19:55 +00:00
|
|
|
// PCI device methods
|
2022-04-13 21:25:28 +00:00
|
|
|
bool supports_io_space(void) {
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
2023-04-10 20:19:55 +00:00
|
|
|
// I/O space access methods
|
2022-04-13 21:25:28 +00:00
|
|
|
bool pci_io_read(uint32_t offset, uint32_t size, uint32_t* res);
|
|
|
|
bool pci_io_write(uint32_t offset, uint32_t value, uint32_t size);
|
|
|
|
|
2024-02-28 23:51:56 +00:00
|
|
|
// HWComponent methods
|
|
|
|
int device_postinit();
|
|
|
|
|
2023-04-10 20:19:55 +00:00
|
|
|
// MMIODevice methods
|
2022-04-13 21:25:28 +00:00
|
|
|
uint32_t read(uint32_t rgn_start, uint32_t offset, int size);
|
|
|
|
void write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void notify_bar_change(int bar_num);
|
2024-02-28 02:14:57 +00:00
|
|
|
const char* get_reg_name(uint32_t reg_offset);
|
|
|
|
const char* rgb514_get_reg_name(uint32_t reg_offset);
|
2024-02-28 05:27:56 +00:00
|
|
|
bool io_access_allowed(uint32_t offset);
|
2023-04-10 20:19:55 +00:00
|
|
|
uint32_t read_reg(uint32_t reg_offset, uint32_t size);
|
|
|
|
void write_reg(uint32_t reg_offset, uint32_t value, uint32_t size);
|
2024-02-28 09:22:47 +00:00
|
|
|
void crtc_update();
|
2022-04-13 21:25:28 +00:00
|
|
|
void rgb514_write_reg(uint8_t reg_addr, uint8_t value);
|
|
|
|
void rgb514_write_ind_reg(uint8_t reg_addr, uint8_t value);
|
2024-02-28 06:09:00 +00:00
|
|
|
void verbose_pixel_format(int crtc_index);
|
2024-02-28 23:51:56 +00:00
|
|
|
void draw_hw_cursor(uint8_t *dst_buf, int dst_pitch);
|
|
|
|
void get_cursor_position(int& x, int& y);
|
2022-04-13 21:25:28 +00:00
|
|
|
|
|
|
|
private:
|
2024-02-28 05:19:54 +00:00
|
|
|
void change_one_bar(uint32_t &aperture, uint32_t aperture_size, uint32_t aperture_new, int bar_num);
|
|
|
|
|
2023-04-10 20:19:55 +00:00
|
|
|
uint32_t regs[256] = {}; // internal registers
|
2022-04-13 21:25:28 +00:00
|
|
|
|
|
|
|
int vram_size;
|
2024-02-28 05:19:54 +00:00
|
|
|
|
|
|
|
// main aperture (16MB)
|
|
|
|
const uint32_t aperture_count = 1;
|
|
|
|
const uint32_t aperture_size[1] = { 0x1000000 };
|
|
|
|
const uint32_t aperture_flag[1] = { 0 };
|
|
|
|
uint32_t aperture_base[1] = { 0 };
|
|
|
|
|
2024-04-20 07:53:32 +00:00
|
|
|
uint32_t config_cntl[2] = { 2, 0 };
|
|
|
|
uint32_t mm_regs_offset = MM_REGS_0_OFF;
|
2022-04-13 21:25:28 +00:00
|
|
|
|
|
|
|
// RGB514 RAMDAC state
|
2024-04-16 08:55:19 +00:00
|
|
|
uint8_t dac_idx_lo = 0;
|
|
|
|
uint8_t dac_idx_hi = 0;
|
|
|
|
uint8_t clut_index = 0;
|
|
|
|
uint8_t comp_index = 0;
|
|
|
|
uint8_t clut_color[3] = {0};
|
|
|
|
uint8_t dac_regs[256] = {0};
|
2022-04-13 21:25:28 +00:00
|
|
|
|
|
|
|
std::unique_ptr<DisplayID> disp_id;
|
|
|
|
std::unique_ptr<uint8_t[]> vram_ptr;
|
|
|
|
};
|
|
|
|
|
2023-04-10 20:19:55 +00:00
|
|
|
#endif // ATI_MACH64_GX_H
|