Skip to content

Commit

Permalink
DMD: fix LibPinMame, fix WhiteStar error
Browse files Browse the repository at this point in the history
  • Loading branch information
vbousquet committed Sep 9, 2024
1 parent 7ece2f8 commit 3de7ec9
Show file tree
Hide file tree
Showing 12 changed files with 309 additions and 478 deletions.
2 changes: 1 addition & 1 deletion src/wpc/alvgdmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,6 @@ static INTERRUPT_GEN(dmd32_firq2) {

PINMAME_VIDEO_UPDATE(alvgdmd_update) {
core_dmd_update_pwm(&dmdlocals.pwm_state);
video_update_core_dmd(bitmap, cliprect, layout);
core_dmd_video_update(bitmap, cliprect, layout, &dmdlocals.pwm_state);
return 0;
}
4 changes: 2 additions & 2 deletions src/wpc/capcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ PINMAME_VIDEO_UPDATE(cc_dmd128x32) {
*line++ = 0;
RAM+=16;
}
video_update_core_dmd(bitmap, cliprect, layout);
core_dmd_video_update(bitmap, cliprect, layout, NULL);
return 0;
}

Expand Down Expand Up @@ -993,7 +993,7 @@ PINMAME_VIDEO_UPDATE(cc_dmd256x64) {
}
RAM+=16;
}
video_update_core_dmd(bitmap, cliprect, layout);
core_dmd_video_update(bitmap, cliprect, layout, NULL);
return 0;
}

Expand Down
692 changes: 259 additions & 433 deletions src/wpc/core.c

Large diffs are not rendered by default.

34 changes: 20 additions & 14 deletions src/wpc/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ typedef struct core_dispLayout core_tLCDLayout, *core_ptLCDLayout;

#define PINMAME_VIDEO_UPDATE(name) int (name)(struct mame_bitmap *bitmap, const struct rectangle *cliprect, const struct core_dispLayout *layout)
typedef int (*ptPinMAMEvidUpdate)(struct mame_bitmap *bitmap, const struct rectangle *cliprect, const struct core_dispLayout *layout);
extern void video_update_core_dmd(struct mame_bitmap *bitmap, const struct rectangle *cliprect, const struct core_dispLayout *layout);

/*----------------------
/ WPC driver constants
Expand Down Expand Up @@ -599,19 +598,25 @@ INLINE void core_zero_cross(void) { coreGlobals.lastACZeroCrossTimeStamp = timer

/*-- DMD PWM integration --*/
typedef struct {
int width; // DMD width
int height; // DMD height
int revByte; // Is bitset reversed ?
int rawFrameSize; // Size of a raw DMD frame in bytes (width * height / 8)
UINT8* rawFrames; // Buffer for incoming raw frames
UINT16* shadedFrame; // Shaded frame computed from raw frames
int nextFrame; // Position in circular buffer to store next raw frame
int nFrames; // Number of frames to store and consider to create shades (depends on hardware refresh frequency and used PWM patterns)
int raw_combiner; // Enum (see CORE_DMD_PWM_COMBINER_...) that defines how to combine bitplane to create multi plane raw frame for colorization plugin
int fir_size; // Selected filter (depends on hardware refresh frequency and number of stored frames)
UINT16* fir_weights; // Selected filter (depends on hardware refresh frequency and number of stored frames)
unsigned int fir_sum; // Sum of filter weights
unsigned int frame_index; // Raw frame index
// Definition initialized at startup using 'core_dmd_pwm_init' then unmutable
int width; // DMD width
int height; // DMD height
int revByte; // Is bitset reversed ?
int frameSize; // Size of a DMD frame in bytes (width * height)
int rawFrameSize; // Size of a raw DMD frame in bytes (width * height / 8)
int nFrames; // Number of frames to store and consider to create shades (depends on hardware refresh frequency and used PWM patterns)
int raw_combiner; // CORE_DMD_PWM_COMBINER_... enum that defines how to combine bitplanes to create multi plane raw frame for colorization plugin
int fir_size; // Selected filter (depends on hardware refresh frequency and number of stored frames)
UINT16* fir_weights; // Selected filter (depends on hardware refresh frequency and number of stored frames)
unsigned int fir_sum; // Sum of filter weights
// Data acquisition, feeded by the driver through 'core_dmd_submit_frame'
UINT8* rawFrames; // Buffer for incoming raw frames
int nextFrame; // Position in circular buffer to store next raw frame
UINT16* shadedFrame; // Shaded frame computed from raw frames
unsigned int frame_index; // Raw frame index
// Integrated data, computed by 'core_dmd_update_pwm'
UINT8* bitplaneFrame; // DMD: bitplane frame built up from raw rasterized frames (depends on each driver, stable result that can be used for post processing like colorization, ...)
UINT8* luminanceFrame; // DMD: linear luminance computed from PWM frames, for rendering (result may change and can't be considered as stable accross PinMame builds)
} core_tDMDPWMState;

#define CORE_DMD_PWM_FILTER_DE_128x16 0
Expand All @@ -633,6 +638,7 @@ extern void core_dmd_pwm_init(core_tDMDPWMState* dmd_state, const int width, con
extern void core_dmd_pwm_exit(core_tDMDPWMState* dmd_state);
extern void core_dmd_submit_frame(core_tDMDPWMState* dmd_state, const UINT8* frame, const int ntimes);
extern void core_dmd_update_pwm(core_tDMDPWMState* dmd_state);
extern void core_dmd_video_update(struct mame_bitmap *bitmap, const struct rectangle *cliprect, const struct core_dispLayout *layout, core_tDMDPWMState* dmd_state);

extern void core_sound_throttle_adj(int sIn, int *sOut, int buffersize, double samplerate);

Expand Down
9 changes: 4 additions & 5 deletions src/wpc/dedmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ MACHINE_DRIVER_END
RA0 - A9 => used to toggle between frame while rasterizing each row
MA8..12 - A10..14
- RA0 is also wired to ROWCLOCK, therefore row is advanced once every 2 rasterized rows
- The start address can be either 0x2000 or 0x2100 (i.e. MA13 is always set), with CURSOR always being defined on 0x2000 / row 0, which led
- The start address is usually either 0x2000 or 0x2100 (i.e. with MA13 set), with CURSOR always being defined on one of these / row 0, which led
to guess that CURSOR signal is used to generate FIRQ (frame IRQ to CPU, trigerring some animation update). Results looks good but this would
be nice to check this assumption on real hardware.
*/
Expand All @@ -110,7 +110,6 @@ static void dmd32_vblank(int which) {
// Store 2 next rasterized frame, as the CRTC is setup to render 2 contiguous full frames for each VBLANK
unsigned int base = crtc6845_start_address_r(0); // MA0..13
assert((base & 0x00FF) == 0x0000); // As the mapping of lowest 8 bits is not implemented (would need complex data copy and does not seem to be used by any game)
assert((base & 0x2000) == 0x2000); // As the implementation supposed this to be always true
assert(crtc6845_rasterized_height_r(0) == 64); // As the implementation requires this to be always true
unsigned int src = /*((base >> 3) & 0x000F) | ((base << 1) & 0x0100) |*/ ((base << 2) & 0x7C00);
core_dmd_submit_frame(&dmdlocals.pwm_state, dmd32RAM + src, 2); // First frame has been displayed 2/3 of the time (500kHz row clock)
Expand Down Expand Up @@ -210,7 +209,7 @@ PINMAME_VIDEO_UPDATE(dedmd32_update) {
}
#endif
core_dmd_update_pwm(&dmdlocals.pwm_state);
video_update_core_dmd(bitmap, cliprect, layout);
core_dmd_video_update(bitmap, cliprect, layout, &dmdlocals.pwm_state);
return 0;
}

Expand Down Expand Up @@ -316,7 +315,7 @@ static void dmd64_vblank(int which) {

PINMAME_VIDEO_UPDATE(dedmd64_update) {
core_dmd_update_pwm(&dmdlocals.pwm_state);
video_update_core_dmd(bitmap, cliprect, layout);
core_dmd_video_update(bitmap, cliprect, layout, &dmdlocals.pwm_state);
return 0;
}

Expand Down Expand Up @@ -557,6 +556,6 @@ static void dmd16_setbank(int bit, int value) {
/*-- update display --*/
PINMAME_VIDEO_UPDATE(dedmd16_update) {
core_dmd_update_pwm(&dmdlocals.pwm_state);
video_update_core_dmd(bitmap, cliprect, layout);
core_dmd_video_update(bitmap, cliprect, layout, &dmdlocals.pwm_state);
return 0;
}
2 changes: 1 addition & 1 deletion src/wpc/gts3dmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extern GTS3_DMDlocals GTS3_dmdlocals[2];
int gts3_dmd128x32(int which, struct mame_bitmap* bitmap, const struct rectangle* cliprect, const struct core_dispLayout* layout)
{
core_dmd_update_pwm(&GTS3_dmdlocals[which].pwm_state);
video_update_core_dmd(bitmap, cliprect, layout);
core_dmd_video_update(bitmap, cliprect, layout, &GTS3_dmdlocals[which].pwm_state);
return 0;
}

Expand Down
20 changes: 10 additions & 10 deletions src/wpc/sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ static MEMORY_READ32_START(sam_readmem)
{ 0x01100000, 0x011FFFFF, samswitch_r }, //Various Input Signals
{ 0x02000000, 0x020FFFFF, MRA32_RAM }, //U9 Boot Flash Eprom
{ 0x02100000, 0x0211FFFF, MRA32_RAM }, //nvram_r }, //U11 NVRAM (128K)
{ 0x02400000, 0x024000FF, samio_r }, //I/O Related
{ 0x02400000, 0x024000FF, samio_r }, //I/O Related
{ 0x03000000, 0x030000FF, MRA32_RAM }, //USB Related
{ 0x04000000, 0x047FFFFF, MRA32_RAM }, //1st 8MB of Flash ROM U44 Mapped here
{ 0x04800000, 0x04FFFFFF, MRA32_BANK1 }, //Banked Access to Flash ROM U44 (including 1st 8MB ALSO!)
Expand Down Expand Up @@ -1143,7 +1143,7 @@ static MEMORY_WRITE32_START(sam_writemem)
{ 0x01080000, 0x0109EFFF, MWA32_RAM }, //U13 RAM - DMD Data for output
{ 0x0109F000, 0x010FFFFF, samxilinx_w }, //U13 RAM - Sound Data for output
{ 0x01100000, 0x01FFFFFF, samdmdram_w }, //Various Output Signals
{ 0x02100000, 0x0211FFFF, MWA32_RAM, &nvram }, //U11 NVRAM (128K) 0x02100000,0x0211ffff
{ 0x02100000, 0x0211FFFF, MWA32_RAM, &nvram }, //U11 NVRAM (128K) 0x02100000,0x0211ffff
{ 0x02200000, 0x022fffff, sam_io2_w }, //LE versions: more I/O stuff (mostly LED lamps)
{ 0x02400000, 0x02FFFFFF, sambank_w }, //I/O Related
{ 0x03000000, 0x030000FF, MWA32_RAM }, //USB Related
Expand Down Expand Up @@ -1743,10 +1743,10 @@ static void sam_transmit_serial(int usartno, data8_t *data, int size)
}


/********************/
/* VBLANK Section */
/********************/
static INTERRUPT_GEN(sam_vblank) {
/******************************/
/* Interface update Section */
/******************************/
static INTERRUPT_GEN(sam_interface_update) {
/*-------------------------------
/ copy local data to interface
/--------------------------------*/
Expand Down Expand Up @@ -1814,7 +1814,7 @@ static MACHINE_DRIVER_START(sam1)
MDRV_CPU_ADD(AT91, SAM_CPUFREQ) // AT91R40008
MDRV_CPU_MEMORY(sam_readmem, sam_writemem)
MDRV_CPU_PORTS(sam_readport, sam_writeport)
MDRV_CPU_VBLANK_INT(sam_vblank, 1)
MDRV_CPU_VBLANK_INT(sam_interface_update, 1)
MDRV_CPU_PERIODIC_INT(sam_irq, SAM_IRQFREQ)
MDRV_CORE_INIT_RESET_STOP(sam, sam1, sam)
MDRV_DIPS(8)
Expand Down Expand Up @@ -1883,7 +1883,7 @@ static PINMAME_VIDEO_UPDATE(samdmd_update) {
}
}

video_update_core_dmd(bitmap, cliprect, layout);
core_dmd_video_update(bitmap, cliprect, layout, NULL);
return 0;
}

Expand All @@ -1905,7 +1905,7 @@ static PINMAME_VIDEO_UPDATE(samminidmd_update) {
coreGlobals.drawSeg[5*dmd_x + 35*dmd_y + ii] = bits;
}
if (!pmoptions.dmd_only)
video_update_core_dmd(bitmap, cliprect, layout);
core_dmd_video_update(bitmap, cliprect, layout, NULL);
return 0;
}

Expand All @@ -1925,7 +1925,7 @@ static PINMAME_VIDEO_UPDATE(samminidmd2_update) {
coreGlobals.drawSeg[ii] = bits;
}
if (!pmoptions.dmd_only)
video_update_core_dmd(bitmap, cliprect, layout);
core_dmd_video_update(bitmap, cliprect, layout, NULL);
return 0;
}

Expand Down
6 changes: 3 additions & 3 deletions src/wpc/sam_original.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ static PINMAME_VIDEO_UPDATE(sam1_dmd32_update) {
}
}
}
video_update_core_dmd(bitmap, cliprect, dotCol, layout);
core_dmd_video_update(bitmap, cliprect, dotCol, layout, NULL);

return 0;
}
Expand Down Expand Up @@ -1031,7 +1031,7 @@ static PINMAME_VIDEO_UPDATE(sam1_minidmd_update) {
*seg++ = bits;
}
if (!pmoptions.dmd_only)
video_update_core_dmd(bitmap, cliprect, dotCol, layout);
core_dmd_video_update(bitmap, cliprect, dotCol, layout, NULL);
return 0;
}

Expand Down Expand Up @@ -1071,7 +1071,7 @@ static PINMAME_VIDEO_UPDATE(sam1_minidmd2_update) {
| (dotCol[3][ii] ? 4 : 0) | (dotCol[4][ii] ? 2 : 0) | (dotCol[5][ii] ? 1 : 0);
}
if (!pmoptions.dmd_only)
video_update_core_dmd(bitmap, cliprect, dotCol, layout);
core_dmd_video_update(bitmap, cliprect, dotCol, layout, NULL);
return 0;
}

Expand Down
10 changes: 5 additions & 5 deletions src/wpc/se.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ PINMAME_VIDEO_UPDATE(seminidmd1_update) {
*seg++ = bits;
}
if (!pmoptions.dmd_only)
video_update_core_dmd(bitmap, cliprect, layout);
core_dmd_video_update(bitmap, cliprect, layout, NULL);
return 0;
}
// MINI DMD Type 1 (Ripley's) (3 x 5x7)
Expand All @@ -919,7 +919,7 @@ PINMAME_VIDEO_UPDATE(seminidmd1s_update) {
*seg++ = bits;
}
if (!pmoptions.dmd_only)
video_update_core_dmd(bitmap, cliprect, layout);
core_dmd_video_update(bitmap, cliprect, layout, NULL);
return 0;
}
// MINI DMD Type 2 (Monopoly) (15x7)
Expand All @@ -943,7 +943,7 @@ PINMAME_VIDEO_UPDATE(seminidmd2_update) {
*seg++ = bits;
}
if (!pmoptions.dmd_only)
video_update_core_dmd(bitmap, cliprect, layout);
core_dmd_video_update(bitmap, cliprect, layout, NULL);
return 0;
}
// MINI DMD Type 3 (RCT) (21x5)
Expand All @@ -968,7 +968,7 @@ PINMAME_VIDEO_UPDATE(seminidmd3_update) {
*seg++ = bits;
}
if (!pmoptions.dmd_only)
video_update_core_dmd(bitmap, cliprect, layout);
core_dmd_video_update(bitmap, cliprect, layout, NULL);
return 0;
}
// 3-Color MINI DMD Type 4 (Simpsons) (14x10)
Expand Down Expand Up @@ -1000,7 +1000,7 @@ PINMAME_VIDEO_UPDATE(seminidmd4_update) {
*seg++ = bits2;
}
if (!pmoptions.dmd_only)
video_update_core_dmd(bitmap, cliprect, layout);
core_dmd_video_update(bitmap, cliprect, layout, NULL);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/wpc/sleic.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,6 @@ PINMAME_VIDEO_UPDATE(sleic_dmd_update) {
*line = 0;
}

video_update_core_dmd(bitmap, cliprect, layout);
core_dmd_video_update(bitmap, cliprect, layout, NULL);
return 0;
}
4 changes: 2 additions & 2 deletions src/wpc/spinb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,7 @@ PINMAME_VIDEO_UPDATE(SPINBdmd_update) {
}
*line = 0;
}
video_update_core_dmd(bitmap, cliprect, layout);
core_dmd_video_update(bitmap, cliprect, layout, NULL);
return 0;
}

Expand Down Expand Up @@ -1524,7 +1524,7 @@ PINMAME_VIDEO_UPDATE(SPINBdmd_update) {
}
*line = 0;
}
video_update_core_dmd(bitmap, cliprect, layout);
core_dmd_video_update(bitmap, cliprect, layout, NULL);
return 0;

}
Expand Down
2 changes: 1 addition & 1 deletion src/wpc/wpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@ static void wpc_dmd_hsync(int param) {

int wpcdmd_update(int height, struct mame_bitmap* bitmap, const struct rectangle* cliprect, const struct core_dispLayout* layout) {
core_dmd_update_pwm(&dmdlocals.pwm_state);
video_update_core_dmd(bitmap, cliprect, layout);
core_dmd_video_update(bitmap, cliprect, layout, &dmdlocals.pwm_state);
return 0;
}

Expand Down

0 comments on commit 3de7ec9

Please sign in to comment.