From 3a77b631b453229f6feeb7e50087b508f2fb2766 Mon Sep 17 00:00:00 2001 From: starfrost013 Date: Sat, 1 Feb 2025 22:30:46 +0000 Subject: [PATCH] Write the pullers and some graphics object skeletons. --- .../86box/nv/classes/vid_nv3_classes.h | 62 +++++++++++++- src/include/86box/nv/vid_nv3.h | 15 ++-- .../nv3/classes/nv3_class_001_beta_factor.c | 23 ++++- src/video/nv/nv3/classes/nv3_class_002_rop.c | 23 ++++- .../nv/nv3/classes/nv3_class_003_chroma_key.c | 23 ++++- .../nv/nv3/classes/nv3_class_004_plane_mask.c | 23 ++++- .../nv3_class_005_clipping_rectangle.c | 22 ++++- .../nv/nv3/classes/nv3_class_006_pattern.c | 23 ++++- .../nv/nv3/classes/nv3_class_007_rectangle.c | 23 ++++- .../nv/nv3/classes/nv3_class_008_point.c | 23 ++++- src/video/nv/nv3/classes/nv3_class_009_line.c | 23 ++++- src/video/nv/nv3/classes/nv3_class_00a_lin.c | 24 +++++- .../nv/nv3/classes/nv3_class_00b_triangle.c | 23 ++++- .../classes/nv3_class_00c_win95_gdi_text.c | 23 ++++- src/video/nv/nv3/classes/nv3_class_00d_m2mf.c | 23 ++++- .../nv3_class_00e_scaled_image_from_mem.c | 23 ++++- src/video/nv/nv3/classes/nv3_class_010_blit.c | 23 ++++- .../nv/nv3/classes/nv3_class_011_image.c | 23 ++++- .../nv/nv3/classes/nv3_class_012_bitmap.c | 24 +++++- .../classes/nv3_class_014_transfer2memory.c | 24 +++++- .../nv3_class_015_stretched_image_from_cpu.c | 25 +++++- .../nv3_class_017_d3d5_tri_zeta_buffer.c | 23 ++++- .../classes/nv3_class_018_point_zeta_buffer.c | 23 ++++- .../classes/nv3_class_01c_image_in_memory.c | 23 ++++- src/video/nv/nv3/classes/nv3_class_names.c | 1 - .../nv/nv3/classes/nv3_class_shared_methods.c | 35 ++++++++ src/video/nv/nv3/subsystems/nv3_pfifo.c | 85 +++++++++++++++++-- src/video/nv/nv3/subsystems/nv3_pramdac.c | 5 +- src/video/nv/nv3/subsystems/nv3_pramin.c | 16 ++-- 29 files changed, 683 insertions(+), 46 deletions(-) create mode 100644 src/video/nv/nv3/classes/nv3_class_shared_methods.c diff --git a/src/include/86box/nv/classes/vid_nv3_classes.h b/src/include/86box/nv/classes/vid_nv3_classes.h index afe3fe18d..b794e43b9 100644 --- a/src/include/86box/nv/classes/vid_nv3_classes.h +++ b/src/include/86box/nv/classes/vid_nv3_classes.h @@ -50,7 +50,7 @@ typedef struct nv3_class_ctx_switch_method_s uint32_t data; uint16_t instance; - uint8_t channel_id : 6; + uint8_t channel : 6; uint16_t reserved : 9; bool reset_if_volatile; // ???? } set_notify_ctx_dma; // Set notifier context for DMA (context switch) @@ -1085,5 +1085,63 @@ typedef struct nv3_object_class_01C uint8_t reserved3[0x1C3F]; } nv3_image_in_memory_t; +// See envytools. This is where we finally end up after this mess, it allows parameters to be passed to the methods. +typedef struct nv3_grobj_s +{ + uint32_t grobj_0; + uint32_t grobj_1; + uint32_t grobj_2; + uint32_t grobj_3; +} nv3_grobj_t; // TODO: PATCHCORDS!!!! TO LINK ALL OF THIS TOGETHER!!! -#pragma pack(pop) // return packing to whatever it was before this disaster \ No newline at end of file +#pragma pack(pop) // return packing to whatever it was before this disaster + +// Class methods +void nv3_generic_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_001_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_002_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_003_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_004_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_005_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_006_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_007_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_008_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_008_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_009_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_00a_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_00b_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_00c_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_00d_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_00e_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_010_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_011_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_012_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_014_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_015_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_017_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_018_method(uint32_t method_id, nv3_grobj_t grobj); +void nv3_class_01c_method(uint32_t method_id, nv3_grobj_t grobj); + +// This area is used for holding universal representations of the U* registers... +extern struct nv3_object_class_001 nv3_beta_factor; +extern struct nv3_object_class_002 nv3_rop; +extern struct nv3_object_class_003 nv3_chroma_key; +extern struct nv3_object_class_004 nv3_plane_mask; +extern struct nv3_object_class_005 nv3_clipping_rectangle; +extern struct nv3_object_class_006 nv3_pattern; +extern struct nv3_object_class_007 nv3_triangle; +extern struct nv3_object_class_008 nv3_point; +extern struct nv3_object_class_009 nv3_line; +extern struct nv3_object_class_00a nv3_lin; +extern struct nv3_object_class_00b nv3_triangle; +extern struct nv3_object_class_00c nv3_win95_gdi_text; +extern struct nv3_object_class_00d nv3_m2mf; +extern struct nv3_object_class_00e nv3_scaled_image_from_memory; +extern struct nv3_object_class_010 nv3_blit; +extern struct nv3_object_class_011 nv3_image; +extern struct nv3_object_class_012 nv3_bitmap; +extern struct nv3_object_class_014 nv3_transfer2memory; +extern struct nv3_object_class_015 nv3_stretched_image_from_cpu; +extern struct nv3_object_class_017 nv3_d3d5_tri; +extern struct nv3_object_class_018 nv3_point_zeta_buffer; +extern struct nv3_object_class_01c nv3_image_in_memory; \ No newline at end of file diff --git a/src/include/86box/nv/vid_nv3.h b/src/include/86box/nv/vid_nv3.h index 651693257..275671f4f 100644 --- a/src/include/86box/nv/vid_nv3.h +++ b/src/include/86box/nv/vid_nv3.h @@ -41,7 +41,7 @@ extern const device_config_t nv3_config[]; #define NV3_DMA_CHANNELS 8 #define NV3_DMA_SUBCHANNELS_PER_CHANNEL 8 -#define NV3_86BOX_TIMER_SYSTEM_FIX_QUOTIENT 10 // The amount by which we have to ration out the memory clock because it's not fast enough... +#define NV3_86BOX_TIMER_SYSTEM_FIX_QUOTIENT 1 // The amount by which we have to ration out the memory clock because it's not fast enough... // Multiply by this value to get the real clock speed. #define NV3_LAST_VALID_GRAPHICS_OBJECT_ID 0x1F @@ -298,7 +298,7 @@ extern const device_config_t nv3_config[]; //todo: merge stuff #define NV3_PFIFO_CACHE1_PULLER_CONTROL_ENABLED 0 #define NV3_PFIFO_CACHE1_PULLER_CONTROL_HASH_FAILURE 4 -#define NV3_PFIFO_CACHE1_PULLER_CONTROL_SOFTWARE_METHOD 8 // 0=software, 1=hardware +#define NV3_PFIFO_CACHE1_PULLER_CONTROL_SOFTWARE_METHOD 8 // 0=software, 1=hardware #define NV3_PFIFO_CACHE1_PULLER_STATE1 0x3250 #define NV3_PFIFO_CACHE1_PULLER_CTX_IS_DIRTY 4 #define NV3_PFIFO_CACHE1_GET 0x3270 @@ -792,7 +792,7 @@ typedef struct nv3_pfifo_cache_s bool access_enabled; // Can we even access this cache? uint8_t put_address; // Trigger a DMA into the value you put here. uint8_t get_address; // Trigger a DMA from the value you put here into where you were going. - uint8_t channel_id; // The DMA channel ID of this cache. + uint8_t channel; // The DMA channel ID of this cache. uint32_t status; uint32_t puller_control; uint32_t control; @@ -821,7 +821,7 @@ typedef struct nv3_pfifo_cache_s typedef struct nv3_pfifo_cache_entry_s { - uint8_t subchannel_id : 3; + uint8_t subchannel : 3; uint16_t method : 11; // method id depending on class (offset from entry channel start in ramin) uint32_t data; // is this the context @@ -845,7 +845,7 @@ typedef struct nv3_pfifo_s nv3_pfifo_cache_t cache0_settings; nv3_pfifo_cache_t cache1_settings; - nv3_pfifo_cache_entry_t cache0_entries[1]; + nv3_pfifo_cache_entry_t cache0_entry; // It only has 1 entry nv3_pfifo_cache_entry_t cache1_entries[NV3_PFIFO_CACHE1_SIZE_MAX]; // ONLY 32 USED ON REVISION A/B CARDS @@ -1080,7 +1080,7 @@ typedef struct nv3_ramin_context_s struct { bool reserved : 1; - uint8_t channel_id : 7; + uint8_t channel : 7; bool is_rendering : 1; uint8_t class_id : 7; uint16_t ramin_offset; @@ -1238,6 +1238,9 @@ bool nv3_ramin_arbitrate_write(uint32_t address, uint32_t value); / // RAMIN functions uint32_t nv3_ramht_hash(uint32_t name, uint32_t channel); bool nv3_ramin_find_object(uint32_t name, uint32_t cache_num, uint32_t channel_id, uint32_t subchannel_id); +#ifndef RELEASE_BUILD +void nv3_debug_ramin_print_context_info(uint32_t name, nv3_ramin_context_t context); +#endif uint32_t nv3_ramfc_read(uint32_t address); void nv3_ramfc_write(uint32_t address, uint32_t value); diff --git a/src/video/nv/nv3/classes/nv3_class_001_beta_factor.c b/src/video/nv/nv3/classes/nv3_class_001_beta_factor.c index 2f9cdb066..b6b97ee3a 100644 --- a/src/video/nv/nv3/classes/nv3_class_001_beta_factor.c +++ b/src/video/nv/nv3/classes/nv3_class_001_beta_factor.c @@ -13,4 +13,25 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_001 beta_factor; + +void nv3_class_001_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_002_rop.c b/src/video/nv/nv3/classes/nv3_class_002_rop.c index e3256d699..747d4b017 100644 --- a/src/video/nv/nv3/classes/nv3_class_002_rop.c +++ b/src/video/nv/nv3/classes/nv3_class_002_rop.c @@ -13,4 +13,25 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_002 nv3_rop; + +void nv3_class_002_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_003_chroma_key.c b/src/video/nv/nv3/classes/nv3_class_003_chroma_key.c index 188f5f94e..08f854529 100644 --- a/src/video/nv/nv3/classes/nv3_class_003_chroma_key.c +++ b/src/video/nv/nv3/classes/nv3_class_003_chroma_key.c @@ -13,4 +13,25 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_003 nv3_chroma_key; + +void nv3_class_003_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_004_plane_mask.c b/src/video/nv/nv3/classes/nv3_class_004_plane_mask.c index 0797819d7..0388bc35a 100644 --- a/src/video/nv/nv3/classes/nv3_class_004_plane_mask.c +++ b/src/video/nv/nv3/classes/nv3_class_004_plane_mask.c @@ -13,4 +13,25 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_004 nv3_plane_mask; + +void nv3_class_004_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_005_clipping_rectangle.c b/src/video/nv/nv3/classes/nv3_class_005_clipping_rectangle.c index c675be6e8..01f395040 100644 --- a/src/video/nv/nv3/classes/nv3_class_005_clipping_rectangle.c +++ b/src/video/nv/nv3/classes/nv3_class_005_clipping_rectangle.c @@ -13,4 +13,24 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_005 nv3_clipping_rectangle; + +void nv3_class_005_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_006_pattern.c b/src/video/nv/nv3/classes/nv3_class_006_pattern.c index d75307a24..282557b95 100644 --- a/src/video/nv/nv3/classes/nv3_class_006_pattern.c +++ b/src/video/nv/nv3/classes/nv3_class_006_pattern.c @@ -13,4 +13,25 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_006 nv3_pattern; + +void nv3_class_006_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_007_rectangle.c b/src/video/nv/nv3/classes/nv3_class_007_rectangle.c index 513f19496..3d378df91 100644 --- a/src/video/nv/nv3/classes/nv3_class_007_rectangle.c +++ b/src/video/nv/nv3/classes/nv3_class_007_rectangle.c @@ -13,4 +13,25 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_007 nv3_rectangle; + +void nv3_class_007_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_008_point.c b/src/video/nv/nv3/classes/nv3_class_008_point.c index 92561591a..55fae702c 100644 --- a/src/video/nv/nv3/classes/nv3_class_008_point.c +++ b/src/video/nv/nv3/classes/nv3_class_008_point.c @@ -13,4 +13,25 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_008 nv3_point; + +void nv3_class_008_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_009_line.c b/src/video/nv/nv3/classes/nv3_class_009_line.c index d10501558..cd0a8b768 100644 --- a/src/video/nv/nv3/classes/nv3_class_009_line.c +++ b/src/video/nv/nv3/classes/nv3_class_009_line.c @@ -13,4 +13,25 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_009 nv3_line; + +void nv3_class_009_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_00a_lin.c b/src/video/nv/nv3/classes/nv3_class_00a_lin.c index 372a56e92..4f44d4e80 100644 --- a/src/video/nv/nv3/classes/nv3_class_00a_lin.c +++ b/src/video/nv/nv3/classes/nv3_class_00a_lin.c @@ -13,4 +13,26 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_00a nv3_lin; + +void nv3_class_00a_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_00b_triangle.c b/src/video/nv/nv3/classes/nv3_class_00b_triangle.c index 1b8c23f03..4c668c275 100644 --- a/src/video/nv/nv3/classes/nv3_class_00b_triangle.c +++ b/src/video/nv/nv3/classes/nv3_class_00b_triangle.c @@ -13,4 +13,25 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_00b nv3_triangle; + +void nv3_class_00b_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_00c_win95_gdi_text.c b/src/video/nv/nv3/classes/nv3_class_00c_win95_gdi_text.c index 9c58cf250..d0116b910 100644 --- a/src/video/nv/nv3/classes/nv3_class_00c_win95_gdi_text.c +++ b/src/video/nv/nv3/classes/nv3_class_00c_win95_gdi_text.c @@ -13,4 +13,25 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_00c nv3_win95_gdi_text; + +void nv3_class_00c_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_00d_m2mf.c b/src/video/nv/nv3/classes/nv3_class_00d_m2mf.c index 0b6c48cc1..a121abcde 100644 --- a/src/video/nv/nv3/classes/nv3_class_00d_m2mf.c +++ b/src/video/nv/nv3/classes/nv3_class_00d_m2mf.c @@ -13,4 +13,25 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_00d nv3_m2mf; + +void nv3_class_00d_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_00e_scaled_image_from_mem.c b/src/video/nv/nv3/classes/nv3_class_00e_scaled_image_from_mem.c index 6e90a552a..a3daae7fc 100644 --- a/src/video/nv/nv3/classes/nv3_class_00e_scaled_image_from_mem.c +++ b/src/video/nv/nv3/classes/nv3_class_00e_scaled_image_from_mem.c @@ -13,4 +13,25 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_00e nv3_scaled_image_from_mem; + +void nv3_class_00e_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_010_blit.c b/src/video/nv/nv3/classes/nv3_class_010_blit.c index 5e6f19aff..2bcdc2234 100644 --- a/src/video/nv/nv3/classes/nv3_class_010_blit.c +++ b/src/video/nv/nv3/classes/nv3_class_010_blit.c @@ -13,4 +13,25 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_010 nv3_blit; + +void nv3_class_010_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_011_image.c b/src/video/nv/nv3/classes/nv3_class_011_image.c index 3334b4185..9a2f73486 100644 --- a/src/video/nv/nv3/classes/nv3_class_011_image.c +++ b/src/video/nv/nv3/classes/nv3_class_011_image.c @@ -13,4 +13,25 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_011 nv3_image; + +void nv3_class_011_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_012_bitmap.c b/src/video/nv/nv3/classes/nv3_class_012_bitmap.c index b5c62f5f4..f2d49f6b0 100644 --- a/src/video/nv/nv3/classes/nv3_class_012_bitmap.c +++ b/src/video/nv/nv3/classes/nv3_class_012_bitmap.c @@ -13,4 +13,26 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_012 nv3_bitmap; + +void nv3_class_012_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_014_transfer2memory.c b/src/video/nv/nv3/classes/nv3_class_014_transfer2memory.c index c4b97a98a..ada899cf6 100644 --- a/src/video/nv/nv3/classes/nv3_class_014_transfer2memory.c +++ b/src/video/nv/nv3/classes/nv3_class_014_transfer2memory.c @@ -13,4 +13,26 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_014 nv3_transfer2memory; + +void nv3_class_014_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_015_stretched_image_from_cpu.c b/src/video/nv/nv3/classes/nv3_class_015_stretched_image_from_cpu.c index 951d77bce..c0a4f492f 100644 --- a/src/video/nv/nv3/classes/nv3_class_015_stretched_image_from_cpu.c +++ b/src/video/nv/nv3/classes/nv3_class_015_stretched_image_from_cpu.c @@ -6,11 +6,32 @@ * * This file is part of the 86Box distribution. * - * NV3: Methods for class 0x15 (stretched image to memory) + * NV3: Methods for class 0x15 (stretched image from cpu to memory) * * * * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_014 nv3_stretched_image_from_cpu; + +void nv3_class_015_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_017_d3d5_tri_zeta_buffer.c b/src/video/nv/nv3/classes/nv3_class_017_d3d5_tri_zeta_buffer.c index 4e0463104..b45ef8968 100644 --- a/src/video/nv/nv3/classes/nv3_class_017_d3d5_tri_zeta_buffer.c +++ b/src/video/nv/nv3/classes/nv3_class_017_d3d5_tri_zeta_buffer.c @@ -13,4 +13,25 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_017 nv3_d3d5_tri; + +void nv3_class_017_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_018_point_zeta_buffer.c b/src/video/nv/nv3/classes/nv3_class_018_point_zeta_buffer.c index 0440c39fe..23e09904f 100644 --- a/src/video/nv/nv3/classes/nv3_class_018_point_zeta_buffer.c +++ b/src/video/nv/nv3/classes/nv3_class_018_point_zeta_buffer.c @@ -13,4 +13,25 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_018 nv3_d3d5_point_zeta_buffer; + +void nv3_class_018_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_01c_image_in_memory.c b/src/video/nv/nv3/classes/nv3_class_01c_image_in_memory.c index daea3e0bb..a0e454fd4 100644 --- a/src/video/nv/nv3/classes/nv3_class_01c_image_in_memory.c +++ b/src/video/nv/nv3/classes/nv3_class_01c_image_in_memory.c @@ -13,4 +13,25 @@ * Authors: Connor Hyde, I need a better email address ;^) * * Copyright 2024-2025 Connor Hyde - */ \ No newline at end of file + */ + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +struct nv3_object_class_01c nv3_image_in_memory; + +void nv3_class_01c_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/classes/nv3_class_names.c b/src/video/nv/nv3/classes/nv3_class_names.c index 3604d147b..e05ddc1eb 100644 --- a/src/video/nv/nv3/classes/nv3_class_names.c +++ b/src/video/nv/nv3/classes/nv3_class_names.c @@ -64,5 +64,4 @@ const char* nv3_class_names[] = "NV3 INVALID class 0x1D", "NV3 INVALID class 0x1E", "NV3 INVALID class 0x1F", - }; diff --git a/src/video/nv/nv3/classes/nv3_class_shared_methods.c b/src/video/nv/nv3/classes/nv3_class_shared_methods.c new file mode 100644 index 000000000..e336168c6 --- /dev/null +++ b/src/video/nv/nv3/classes/nv3_class_shared_methods.c @@ -0,0 +1,35 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * NV3: Methods shared across multiple classes + * + * + * + * Authors: Connor Hyde, I need a better email address ;^) + * + * Copyright 2024-2025 Connor Hyde + */ + +#include +#include +#include +#include +#include <86Box/86box.h> +#include <86Box/device.h> +#include <86Box/mem.h> +#include <86box/pci.h> +#include <86Box/rom.h> +#include <86Box/video.h> +#include <86Box/nv/vid_nv.h> +#include <86Box/nv/vid_nv3.h> +#include <86box/nv/classes/vid_nv3_classes.h> + +void nv3_generic_method(uint32_t method_id, nv3_grobj_t grobj) +{ + +} \ No newline at end of file diff --git a/src/video/nv/nv3/subsystems/nv3_pfifo.c b/src/video/nv/nv3/subsystems/nv3_pfifo.c index b9e7e4cdd..a83d055cf 100644 --- a/src/video/nv/nv3/subsystems/nv3_pfifo.c +++ b/src/video/nv/nv3/subsystems/nv3_pfifo.c @@ -152,10 +152,10 @@ uint32_t nv3_pfifo_read(uint32_t address) ret = nv3->pfifo.cache1_settings.access_enabled; break; case NV3_PFIFO_CACHE0_PUSH_CHANNEL_ID: - ret = nv3->pfifo.cache0_settings.channel_id; + ret = nv3->pfifo.cache0_settings.channel; break; case NV3_PFIFO_CACHE1_PUSH_CHANNEL_ID: - ret = nv3->pfifo.cache1_settings.channel_id; + ret = nv3->pfifo.cache1_settings.channel; break; case NV3_PFIFO_CACHE0_STATUS: uint32_t ret = 0x00; @@ -351,10 +351,10 @@ void nv3_pfifo_write(uint32_t address, uint32_t value) nv3->pfifo.cache1_settings.access_enabled = value; break; case NV3_PFIFO_CACHE0_PUSH_CHANNEL_ID: - nv3->pfifo.cache0_settings.channel_id = value; + nv3->pfifo.cache0_settings.channel = value; break; case NV3_PFIFO_CACHE1_PUSH_CHANNEL_ID: - nv3->pfifo.cache1_settings.channel_id = value; + nv3->pfifo.cache1_settings.channel = value; break; // CACHE0_STATUS and CACHE1_STATUS are not writable case NV3_PFIFO_CACHE0_METHOD: @@ -441,7 +441,38 @@ void nv3_pfifo_cache0_pull() if (nv3->pfifo.cache0_settings.put_address == nv3->pfifo.cache0_settings.get_address) return; - // There is only one entry + // There is only one entry for cache0 + uint16_t current_channel = nv3->pfifo.cache0_settings.channel; + uint32_t current_subchannel = nv3->pfifo.cache0_entry.subchannel; + uint32_t current_name = nv3->pfifo.cache0_entry.data; + uint32_t current_method = nv3->pfifo.cache0_entry.method; + + // i.e. there is no method in cache0, so we have to find the object. + if (!current_method) + { + if (!nv3_ramin_find_object(current_name, 0, current_channel, current_subchannel)) + return; // interrupt was fired, and we went to ramro + } + + uint32_t current_context = nv3->pfifo.cache0_settings.context[0]; // only 1 entry for CACHE0 so basically ignore the other context entries? + + // Tell the CPU if we found a software method + if (current_context & 0x800000) + { + nv3->pfifo.cache0_settings.puller_control |= NV3_PFIFO_CACHE0_PULLER_CONTROL_SOFTWARE_METHOD; + nv3->pfifo.cache0_settings.puller_control &= ~NV3_PFIFO_CACHE0_PULLER_CONTROL_ENABLED; + nv3_pfifo_interrupt(NV3_PFIFO_INTR_CACHE_ERROR, true); + } + + // Is this needed? + nv3->pfifo.cache0_settings.get_address ^= 0x04; + + #ifndef RELEASE_BUILD + nv_log("NV3: ***** SUBMITTING GRAPHICS COMMANDS CURRENTLY UNIMPLEMENTED - CACHE0 PULLED ****** Contextual information below\n"); + + nv3_debug_ramin_print_context_info(current_name, *(nv3_ramin_context_t*)current_context); + #endif + } void nv3_pfifo_cache1_push() @@ -458,6 +489,50 @@ void nv3_pfifo_cache1_pull() // Do nothing if there is nothing in cache1 to pull if (nv3->pfifo.cache1_settings.put_address == nv3->pfifo.cache1_settings.get_address) return; + + // There is only one entry for cache0 + uint32_t get_address = nv3->pfifo.cache1_settings.get_address >> 2; // 32 bit aligned probably + + uint16_t current_channel = nv3->pfifo.cache1_settings.channel; + uint32_t current_subchannel = nv3->pfifo.cache1_entries[get_address].subchannel; + uint32_t current_name = nv3->pfifo.cache1_entries[get_address].data; + uint32_t current_method = nv3->pfifo.cache1_entries[get_address].method; + + // i.e. there is no method in cache0, so we have to find the object. + if (!current_method) + { + if (!nv3_ramin_find_object(current_name, 0, current_channel, current_subchannel)) + return; // interrupt was fired, and we went to ramro + } + + uint32_t current_context = nv3->pfifo.cache0_settings.context[0]; // only 1 entry for CACHE0 so basically ignore the other context entries? + + // Tell the CPU if we found a software method + if (current_context & 0x800000) + { + nv3->pfifo.cache0_settings.puller_control |= NV3_PFIFO_CACHE0_PULLER_CONTROL_SOFTWARE_METHOD; + nv3->pfifo.cache0_settings.puller_control &= ~NV3_PFIFO_CACHE0_PULLER_CONTROL_ENABLED; + nv3_pfifo_interrupt(NV3_PFIFO_INTR_CACHE_ERROR, true); + } + + // start by incrementing + uint32_t next_get_address = nv3_pfifo_cache1_gray2normal(get_address) + 1; + + if (nv3->nvbase.gpu_revision >= NV3_BOOT_REG_REV_C00) // RIVA 128ZX# + next_get_address &= NV3_PFIFO_CACHE1_SIZE_REV_C; + else + next_get_address &= NV3_PFIFO_CACHE1_SIZE_REV_AB; + + // Is this needed? + nv3->pfifo.cache0_settings.get_address = nv3_pfifo_cache1_normal2gray(next_get_address) << 2; + + #ifndef RELEASE_BUILD + nv_log("NV3: ***** SUBMITTING GRAPHICS COMMANDS CURRENTLY UNIMPLEMENTED - CACHE1 PULLED ****** Contextual information below\n"); + + nv3_debug_ramin_print_context_info(current_name, *(nv3_ramin_context_t*)current_context); + #endif + + //Todo: finish it } bool nv3_pfifo_cache1_is_free() diff --git a/src/video/nv/nv3/subsystems/nv3_pramdac.c b/src/video/nv/nv3/subsystems/nv3_pramdac.c index 9c44105b9..f913e2917 100644 --- a/src/video/nv/nv3/subsystems/nv3_pramdac.c +++ b/src/video/nv/nv3/subsystems/nv3_pramdac.c @@ -49,16 +49,19 @@ void nv3_pramdac_init() } // Polls the pixel clock. -// This updates the 2D/3D engine PGRAPH void nv3_pramdac_pixel_clock_poll(double real_time) { // TODO: ???? } // Polls the memory clock. +// This updates the 2D/3D engine PGRAPH, PTIMER and more void nv3_pramdac_memory_clock_poll(double real_time) { nv3_ptimer_tick(real_time); + + nv3_pfifo_cache0_pull(); + nv3_pfifo_cache1_pull(); // TODO: UPDATE PGRAPH! } diff --git a/src/video/nv/nv3/subsystems/nv3_pramin.c b/src/video/nv/nv3/subsystems/nv3_pramin.c index d9ab438d7..3730765ab 100644 --- a/src/video/nv/nv3/subsystems/nv3_pramin.c +++ b/src/video/nv/nv3/subsystems/nv3_pramin.c @@ -347,7 +347,7 @@ bool nv3_ramin_arbitrate_write(uint32_t address, uint32_t value) } // THIS IS THE MOST IMPORTANT FUNCTION! -bool nv3_ramin_find_object(uint32_t name, uint32_t cache_num, uint32_t channel_id, uint32_t subchannel_id) +bool nv3_ramin_find_object(uint32_t name, uint32_t cache_num, uint32_t channel, uint32_t subchannel) { // TODO: WRITE IT!!! // Set the number of entries to search based on the ramht size (2*(size+1)) @@ -358,7 +358,7 @@ bool nv3_ramin_find_object(uint32_t name, uint32_t cache_num, uint32_t channel_i uint32_t ramht_base = ((nv3->pfifo.ramht_config >> NV3_PFIFO_CONFIG_RAMHT_BASE_ADDRESS) & 0x0F) << NV3_PFIFO_CONFIG_RAMHT_BASE_ADDRESS; uint32_t ramht_cur_address = ramht_base; - nv_log("NV3: Beginning search for graphics object at RAMHT base=0x%04x, Cache%d, channel=%d, subchannel=%d)", name, cache_num, channel_id, subchannel_id); + nv_log("NV3: Beginning search for graphics object at RAMHT base=0x%04x, Cache%d, channel=%d, subchannel=%d)", name, cache_num, channel, subchannel); bool found_object = false; @@ -376,7 +376,7 @@ bool nv3_ramin_find_object(uint32_t name, uint32_t cache_num, uint32_t channel_i // see if the object is in the right channel if (found_obj_name == name - && obj_context_struct.channel_id == channel_id) + && obj_context_struct.channel == channel) { found_object = true; break; @@ -421,8 +421,8 @@ bool nv3_ramin_find_object(uint32_t name, uint32_t cache_num, uint32_t channel_i fatal("NV3: Invalid graphics object class ID name=0x%04x type=%04x, interpreted by pgraph as: %04x (Contact starfrost)", name, obj_context_struct.class_id, obj_context_struct.class_id & 0x1F); } - else if (obj_context_struct.channel_id > NV3_DMA_CHANNELS) - fatal("NV3: Super fucked up graphics object. Contact starfrost with the error string: DMA Channel ID=%d, it should be 0-8", obj_context_struct.channel_id); + else if (obj_context_struct.channel > NV3_DMA_CHANNELS) + fatal("NV3: Super fucked up graphics object. Contact starfrost with the error string: DMA Channel ID=%d, it should be 0-8", obj_context_struct.channel); // Illegal accesses sent to RAMRO, so ignore here // TODO: SEND THESE TO RAMRO!!!!! @@ -442,9 +442,9 @@ bool nv3_ramin_find_object(uint32_t name, uint32_t cache_num, uint32_t channel_i bool is_software = false; if (!cache_num) - is_software = (nv3->pfifo.cache0_settings.context[subchannel_id] & 0x800000); + is_software = (nv3->pfifo.cache0_settings.context[subchannel] & 0x800000); else - is_software = (nv3->pfifo.cache1_settings.context[subchannel_id] & 0x800000); + is_software = (nv3->pfifo.cache1_settings.context[subchannel] & 0x800000); // This isn't an error but it's sent as an interrupt so the drivers can sync if (is_software) @@ -487,7 +487,7 @@ void nv3_debug_ramin_print_context_info(uint32_t name, nv3_ramin_context_t conte nv_log("Name: 0x%04x", name); nv_log("Context:"); - nv_log("DMA Channel %d (0-7 valid)", context.channel_id); + nv_log("DMA Channel %d (0-7 valid)", context.channel); nv_log("Class ID: as repreesnted in ramin=%04x, Stupid 5 bit version (the actual id)=0x%04x (%s)", context.class_id, context.class_id & 0x1F, nv3_class_names[context.class_id & 0x1F]); nv_log("Render Engine %d (0=Software, also DMA? 1=Accelerated Renderer)", context.is_rendering);