Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug viewers #277

Merged
merged 6 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ find_package(OpenAL REQUIRED)
include_directories(${OPENAL_INCLUDE_DIR})

if(${PCEM_DISPLAY_ENGINE} STREQUAL "wxWidgets")
find_package(wxWidgets REQUIRED COMPONENTS core base xrc)
find_package(wxWidgets REQUIRED COMPONENTS core base xrc adv)
include(${wxWidgets_USE_FILE})
set(DISPLAY_ENGINE_LIBRARIES ${wxWidgets_LIBRARIES})
endif()
Expand Down
12 changes: 8 additions & 4 deletions includes/private/cpu/x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ typedef union MMX_REG {
float f[2];
} MMX_REG;

struct {
typedef struct cpu_state_t {
x86reg regs[8];

uint8_t tag[8];
Expand Down Expand Up @@ -113,7 +113,9 @@ struct {
uint16_t flags, eflags;

uint32_t smbase;
} cpu_state;
} cpu_state_t;

extern cpu_state_t cpu_state;

#define cpu_state_offset(MEMBER) ((uintptr_t)&cpu_state.MEMBER - (uintptr_t)&cpu_state - 128)

Expand Down Expand Up @@ -318,12 +320,14 @@ void cyrix_write_seg_descriptor(uint32_t addr, x86seg *seg);
#define SMHR_VALID (1 << 0)
#define SMHR_ADDR_MASK (0xfffffffc)

struct {
typedef struct cyrix_t {
struct {
uint32_t base;
uint64_t size;
} arr[8];
uint32_t smhr;
} cyrix;
} cyrix_t;

extern cyrix_t cyrix;

#endif /* _X86_H_ */
48 changes: 24 additions & 24 deletions includes/private/ibm.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
#define readflash_get(offset, drive) ((readflash & (1 << ((offset) + (drive)))) != 0)

/*Memory*/
uint8_t *ram;
extern uint8_t *ram;

uint32_t rammask;
extern uint32_t rammask;

int readlookup[256], readlookupp[256];
uintptr_t *readlookup2;
int readlnext;
int writelookup[256], writelookupp[256];
uintptr_t *writelookup2;
int writelnext;
extern int readlookup[256], readlookupp[256];
extern uintptr_t *readlookup2;
extern int readlnext;
extern int writelookup[256], writelookupp[256];
extern uintptr_t *writelookup2;
extern int writelnext;

extern int mmu_perm;

Expand Down Expand Up @@ -104,7 +104,7 @@ typedef struct PIT {
void (*set_out_funcs[3])(int new_out, int old_out);
} PIT;

PIT pit, pit2;
extern PIT pit, pit2;
void setpitclock(float clock);

float pit_timer0_freq();
Expand All @@ -130,15 +130,15 @@ typedef struct dma_t {
uint16_t io_addr;
} dma_t;

dma_t dma[8];
extern dma_t dma[8];

/*PPI*/
typedef struct PPI {
int s2;
uint8_t pa, pb;
} PPI;

PPI ppi;
extern PPI ppi;

/*PIC*/
typedef struct PIC {
Expand All @@ -149,15 +149,15 @@ typedef struct PIC {
uint8_t level_sensitive;
} PIC;

PIC pic, pic2;
extern PIC pic, pic2;
extern int pic_intpending;

char discfns[2][256];
int driveempty[2];
extern char discfns[2][256];
extern int driveempty[2];

#define PCJR (romset == ROM_IBMPCJR)

int GAMEBLASTER, GUS, SSI2001, voodoo_enabled;
extern int GAMEBLASTER, GUS, SSI2001, voodoo_enabled;
extern int AMSTRAD, AT, is386, PCI, TANDY, MCA;

enum {
Expand Down Expand Up @@ -267,8 +267,8 @@ enum {

extern int romspresent[ROM_MAX];

int hasfpu;
int romset;
extern int hasfpu;
extern int romset;

enum {
GFX_BUILTIN = -1,
Expand Down Expand Up @@ -326,12 +326,12 @@ enum {

extern int gfx_present[GFX_MAX];

int gfxcard;
extern int gfxcard;

int cpuspeed;
extern int cpuspeed;

/*Video*/
int readflash;
extern int readflash;
extern int egareads, egawrites;
extern int vid_resize;
extern int vid_api;
Expand All @@ -340,12 +340,12 @@ extern int winsizex, winsizey;
extern int changeframecount;

/*Sound*/
int ppispeakon;
extern int ppispeakon;
extern uint64_t CGACONST;
extern uint64_t MDACONST;
extern uint64_t VGACONST1, VGACONST2;
extern uint64_t RTCCONST;
int gated, speakval, speakon;
extern int gated, speakval, speakon;

/*Sound Blaster*/
#define SADLIB 1 /*No DSP*/
Expand All @@ -367,10 +367,10 @@ typedef struct {
int tracks;
} PcemHDC;

PcemHDC hdc[7];
extern PcemHDC hdc[7];

/*Keyboard*/
int keybsenddelay;
extern int keybsenddelay;

/*CD-ROM*/
extern int cdrom_drive;
Expand Down
4 changes: 2 additions & 2 deletions includes/private/memory/mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ void mem_write_nulll(uint32_t addr, uint32_t val, void *p);

FILE *romfopen(char *fn, char *mode);

mem_mapping_t bios_mapping[8];
mem_mapping_t bios_high_mapping[9];
extern mem_mapping_t bios_mapping[8];
extern mem_mapping_t bios_high_mapping[9];

extern mem_mapping_t ram_high_mapping;
extern mem_mapping_t ram_remapped_mapping;
Expand Down
3 changes: 3 additions & 0 deletions includes/private/video/vid_voodoo_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ typedef struct voodoo_t {
unsigned int vertex_next_age;
int num_verticies;
int cull_pingpong;
int in_strip;

int flush;

Expand Down Expand Up @@ -463,6 +464,8 @@ typedef struct voodoo_t {
uint8_t *vram, *changedvram;

void *p;

int viewer_active;
} voodoo_t;

typedef struct voodoo_set_t {
Expand Down
64 changes: 64 additions & 0 deletions includes/private/wx-ui/viewer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#ifndef _VIEWER_H_
#define _VIEWER_H_

#ifdef __cplusplus
extern "C" {
#endif

typedef struct viewer_t
{
void *(*open)(void *parent, void *p, const char *title);
} viewer_t;

void viewer_reset();
void viewer_add(char *title, viewer_t *viewer, void *p);
void viewer_open(void *hwnd, int id);
void viewer_remove(void *viewer);
void viewer_update(viewer_t *viewer, void *p);
void viewer_call(viewer_t *viewer, void *p, void (*func)(void *v, void *param), void *param);
void viewer_close_all();
void viewer_notify_pause();
void viewer_notify_resume();
void update_viewers_menu(void *menu);

extern viewer_t viewer_font;
extern viewer_t viewer_palette;
extern viewer_t viewer_palette_16;
extern viewer_t viewer_voodoo;
extern viewer_t viewer_vram;

#define IDM_VIEWER 1600
#define IDM_VIEWER_MAX 1700

#ifdef __cplusplus
}


class Viewer: public wxFrame
{
public:
void *p;

Viewer(wxWindow *parent, wxString title, wxSize size, void *p)
: wxFrame(parent, wxID_ANY, title, wxPoint(50, 50), size, wxDEFAULT_FRAME_STYLE),
p(p)
{
SetClientSize(size);
}

virtual ~Viewer()
{
}

virtual void NotifyPause()
{
}

virtual void NotifyResume()
{
}
};

#endif

#endif
18 changes: 18 additions & 0 deletions includes/private/wx-ui/viewer_voodoo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef _VIEWER_VOODOO_H_
#define _VIEWER_VOODOO_H_

#ifdef __cplusplus
extern "C" {
#endif

void voodoo_viewer_swap_buffer(void *v, void *param);
void voodoo_viewer_queue_triangle(void *v, void *param);
void voodoo_viewer_begin_strip(void *v, void *param);
void voodoo_viewer_end_strip(void *v, void *param);
void voodoo_viewer_use_texture(void *v, void *param);

#ifdef __cplusplus
}
#endif

#endif
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/video/video.cmake)

if(${PCEM_DISPLAY_ENGINE} STREQUAL "wxWidgets")
include(${CMAKE_CURRENT_SOURCE_DIR}/wx-ui/wx-ui.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/wx-ui/viewers/viewers.cmake)
endif()
if(${PCEM_DISPLAY_ENGINE} STREQUAL "Qt")
message(FATAL_ERROR "Qt Mode is not yet implemented.")
Expand Down
3 changes: 3 additions & 0 deletions src/cpu/386_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include "x86_flags.h"
#include "codegen.h"

cpu_state_t cpu_state;
cyrix_t cyrix;

x86seg gdt, ldt, idt, tr;

uint32_t cr2, cr3, cr4;
Expand Down
2 changes: 2 additions & 0 deletions src/cpu/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ static int cpu_turbo = 1;
int isa_cycles;
int has_vlb;
static uint8_t ccr0, ccr1, ccr2, ccr3, ccr4, ccr5, ccr6;
int hasfpu;
int cpuspeed;

OpFn *x86_dynarec_opcodes;
OpFn *x86_dynarec_opcodes_0f;
Expand Down
2 changes: 2 additions & 0 deletions src/floppy/fdd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "fdc.h"
#include "fdd.h"

char discfns[2][256];

static struct {
int type;

Expand Down
2 changes: 2 additions & 0 deletions src/hdd/hdd.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <pcem/devices.h>
#include <pcem/defines.h>

PcemHDC hdc[7];

extern HDD_CONTROLLER *hdd_controllers[HDDCONTROLLERS_MAX];
char hdd_controller_name[16];

Expand Down
11 changes: 10 additions & 1 deletion src/memory/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ void (*smram_disable)(void);
int mmuflush = 0;
int mmu_perm = 4;

int readlookup[256], readlookupp[256];
uintptr_t *readlookup2;
int readlnext;
int writelookup[256], writelookupp[256];
uintptr_t *writelookup2;
int writelnext;

uint32_t rammask;

int mem_addr_is_ram(uint32_t addr) {
mem_mapping_t *mapping = read_mapping[addr >> 14];

Expand Down Expand Up @@ -1161,7 +1170,7 @@ void mem_mapping_remove(mem_mapping_t *mapping)
dest = dest->next;
}
prev->next = mapping->next;

mem_mapping_recalc(mapping->base, mapping->size);
}

Expand Down
2 changes: 2 additions & 0 deletions src/models/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "video.h"
#include "x86.h"

dma_t dma[8];

static uint8_t dmaregs[16];
static uint8_t dma16regs[16];
static uint8_t dmapages[16];
Expand Down
2 changes: 2 additions & 0 deletions src/models/pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "pit.h"
#include "video.h"

PIC pic, pic2;

int intclear;
int keywaiting = 0;
int pic_intpending;
Expand Down
3 changes: 3 additions & 0 deletions src/models/pit.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#include "timer.h"
#include "video.h"
#include "model.h"

PIT pit, pit2;

/*B0 to 40, two writes to 43, then two reads - value does not change!*/
/*B4 to 40, two writes to 43, then two reads - value _does_ change!*/
// Tyrian writes 4300 or 17512
Expand Down
Loading
Loading