Skip to content

Commit

Permalink
Merge pull request #4677 from nanshiki/pc98gdcstatus
Browse files Browse the repository at this point in the history
Fixed to set the drawing bit of the GDC status.
  • Loading branch information
joncampbell123 authored Dec 18, 2023
2 parents 92628d6 + 49f9145 commit 5c9579d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
4 changes: 4 additions & 0 deletions include/pc98_gdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ struct PC98_GDC_state {
bool doublescan; /* 200-line as 400-line */

bool dbg_ev_partition;

double drawing_end;
int dot_count;
uint8_t drawing_status;
};

typedef union pc98_tile egc_quad[4];
Expand Down
17 changes: 7 additions & 10 deletions src/hardware/vga_pc98_gdc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ PC98_GDC_state::PC98_GDC_state() {
horizontal_back_porch_width = 0;
vertical_front_porch_width = 0;
vertical_back_porch_width = 0;
drawing_status = 0;
reset_fifo();
reset_rfifo();
draw_reset();
Expand Down Expand Up @@ -656,16 +657,12 @@ uint8_t PC98_GDC_state::read_status(void) {
if (rfifo_has_content())
ret |= 0x01; // data ready
else if (fifo_read == fifo_write) {
#if 0 // THIS IS CAUSING SEVERE PERFORMANCE ISSUES, DISABLED!
// According to
// [http://hackipedia.org/browse.cgi/Computer/Platform/PC%2c%20NEC%20PC%2d98/Collections/Undocumented%209801%2c%209821%20Volume%202%20%28webtech.co.jp%29/io%5fdisp%2etxt]
// bit 3 (0x08) is supposed to indicate when the GDC is drawing. Perhaps the contributer who's
// pull request added this found a PC-98 game that failed to run without it. Re-enable when a
// higher performance implementation is possible. Also, recent commits in 2022 added actual
// GDC drawing functionality, so perhaps this should mirror that too?
initRand();
if (rand()%20<1) ret |= 0x08;
#endif
if(drawing_status) {
if(PIC_FullIndex() > drawing_end) {
drawing_status = 0;
}
ret |= drawing_status;
}
}

return ret;
Expand Down
10 changes: 9 additions & 1 deletion src/hardware/vga_pc98_gdc_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "logging.h"
#include "pc98_gdc.h"
#include "pc98_gdc_const.h"
#include "pic.h"
#include <math.h>

/* do not issue CPU-side I/O here -- this code emulates functions that the GDC itself carries out, not on the CPU */
Expand Down Expand Up @@ -191,7 +192,8 @@ void PC98_GDC_state::draw_dot(uint16_t x, uint16_t y) {
// The GDC is documented to issue 16-bit read/modify/write when drawing, so
// that's what this code should do. Additionally, drawing with 8-bit memio
// and EGC causes minor artifacts.
if ((pc98_gdc_vramop & 0xE) == 0xA || (pc98_gdc_vramop & 0xE) == 0xE) {
// NOTE: It seems that the same behavior as EGC is required for GRCG+RMW.
if ((pc98_gdc_vramop & 0xE) == 0xA || (pc98_gdc_vramop & 0xC) == 0xC) {
if(dot) {
// REPLACE. COMPLEMENT or SET
if(draw.mode == 0x00 || draw.mode == 0x01 || draw.mode == 0x03) {
Expand Down Expand Up @@ -219,6 +221,7 @@ void PC98_GDC_state::draw_dot(uint16_t x, uint16_t y) {
}
}
}
dot_count++;
}

void PC98_GDC_state::pset(void) {
Expand Down Expand Up @@ -450,6 +453,7 @@ void PC98_GDC_state::box(void) {
}

void PC98_GDC_state::exec(uint8_t command) {
dot_count = 0;
switch(draw.ope & 0xf8) {
case 0x00:
pset();
Expand All @@ -473,4 +477,8 @@ void PC98_GDC_state::exec(uint8_t command) {
break;
}
draw_reset();
// GDC status drawing bit
drawing_status = 0x08;
// uPD7220's 1-dot drawing time is 800ns
drawing_end = PIC_FullIndex() + (0.0008 * dot_count);
}

0 comments on commit 5c9579d

Please sign in to comment.