|
|
| version 1.10, 2004/08/12 11:03:09 | version 1.19, 2008/06/02 20:07:31 |
|---|---|
| Line 1 | Line 1 |
| #include "compiler.h" | #include "compiler.h" |
| #include "z80core.h" | |
| #include "pccore.h" | #include "pccore.h" |
| #include "iocore.h" | #include "iocore.h" |
| #include "makescrn.h" | |
| // ---- 8255 PPI〜 | /* 8255 PPI〜 */ |
| static REG8 getportb(void) { | static REG8 getportb(void) { |
| REG8 ret; | REG8 ret; |
| UINT v; | REG8 ppib; |
| #if defined(MAINFRAMES_OLD) | |
| ret = cmt_test(); // | cmt_read(); // THUNDER BALL | SINT32 clock; |
| #endif | |
| v = pccore_getraster(NULL); | #if 0 |
| if (v < crtc.s.CRT_YL) { | |
| ret |= 0x80; // 1:DISP | |
| } | |
| if (subcpu.IBF) { | if (subcpu.IBF) { |
| subcpu.IBF = 0; | subcpu.IBF = 0; |
| ret |= 0x40; // 1:SUB-CPU BUSY | ret |= 0x40; /* 1:SUB-CPU BUSY */ |
| } | } |
| if (subcpu.OBF) { | if (subcpu.OBF) { |
| ret |= 0x20; // 1:SUB-CPU Data empty | ret |= 0x20; /* 1:SUB-CPU Data empty */ |
| } | } |
| if (memio.ram) { | #endif /* 0 */ |
| ret |= 0x10; // 1:RAM | |
| ppib = iocore.s.ppib; | |
| ret = ppib; | |
| /* ret |= cmt_test(); */ /* THUNDER BALL */ | |
| iocore.s.ppib = (UINT8)((ppib & (~0x40)) | 0x01); | |
| /* ret |= cmt_read(); */ | |
| #if defined(MAINFRAMES_OLD) | |
| clock = CPU_CLOCKCOUNT - iocore.e.framestartclock; | |
| if (clock < iocore.e.dispclock) { | |
| ret |= 0x80; /* 1:DISP */ | |
| } | } |
| #if 1 | |
| if (!(v < crtc.e.vs)) { | /* 実機の動きを見ると どうも 読み込んだらリセットされるようだ? */ |
| ret |= 0x04; // V-SYNC | /* 有効範囲が絞れるならそうすべき(VSYNCを取りこぼすソフトがある) */ |
| } | clock -= iocore.e.vsyncstart; |
| #else // ラプラステスト…VYSNCが長すぎるらしい | if ((clock >= 0) && (clock < iocore.e.vpulseclock)) { |
| if (v_cnt == crtc.e.vs) { | ret |= 0x04; /* 1:V-SYNC */ |
| ret |= 0x04; | |
| } | } |
| #endif | #endif |
| return(ret); | return(ret); |
| Line 41 static REG8 getportb(void) { | Line 51 static REG8 getportb(void) { |
| static void setportc(REG8 dat) { | static void setportc(REG8 dat) { |
| REG8 oldc; | REG8 modify; |
| UINT8 xl; | |
| oldc = ppi.portc; | modify = ppi.portc ^ dat; |
| if (crtc.s.TXT_XL == 40) { | |
| oldc |= 0x40; | |
| } | |
| else { | |
| oldc &= ~0x40; | |
| } | |
| ppi.portc = dat; | ppi.portc = dat; |
| /* cmt_write((REG8)(dat & 1)); */ | |
| // cmt_write((REG8)(dat & 1)); | if ((modify & 0x20) && (!(dat & 0x20))) { |
| if ((oldc & 0x20) && (!(dat & 0x20))) { | |
| iocore.s.mode = 1; | iocore.s.mode = 1; |
| /* TRACEOUT(("iocore.s.mode = 1")); */ | |
| } | } |
| xl = ((dat & 0x40)?40:80); | if (modify & 0x40) { |
| if (crtc.s.TXT_XL != xl) { | crtc_setwidth((REG8)(dat & 0x40)); |
| crtc.s.TXT_XL = (UINT8)xl; | |
| // crtc.s.GRP_XL = xl << 3; | |
| vrambank_patch(); | |
| scrnallflash = 1; | |
| } | } |
| } | } |
| // ---- | /* ---- */ |
| void IOOUTCALL ppi_o(UINT port, REG8 value) { | void IOOUTCALL ppi_o(UINT port, REG8 value) { |
| Line 108 REG8 IOINPCALL ppi_i(UINT port) { | Line 107 REG8 IOINPCALL ppi_i(UINT port) { |
| switch(port & 0x0f) { | switch(port & 0x0f) { |
| case 0: | case 0: |
| // if (!(ppi.mode & 0x10)) { | #if 0 |
| // return(ppi.porta); | if (!(ppi.mode & 0x10)) { |
| // } | return(ppi.porta); |
| } | |
| #endif /* 0 */ | |
| return(ppi.porta); | return(ppi.porta); |
| case 1: | case 1: |
| Line 120 REG8 IOINPCALL ppi_i(UINT port) { | Line 121 REG8 IOINPCALL ppi_i(UINT port) { |
| return(getportb()); | return(getportb()); |
| case 2: | case 2: |
| #if 1 | /* mode? */ |
| if (crtc.s.TXT_XL == 40) { | |
| ppi.portc |= 0x40; | |
| } | |
| else { | |
| ppi.portc &= ~0x40; | |
| } | |
| #endif | |
| return(ppi.portc); | return(ppi.portc); |
| case 3: | case 3: |
| Line 137 REG8 IOINPCALL ppi_i(UINT port) { | Line 131 REG8 IOINPCALL ppi_i(UINT port) { |
| } | } |
| // ---- | /* initialize & reset */ |
| void ppi_initialize(void) { | void ppi_initialize(void) { |
| ppi.porta = 0x00; | ppi.porta = 0x00; |
| ppi.portb = 0xff; | ppi.portb = 0xff; |
| ppi.portc = 0xff; | ppi.portc = 0xff; |
| ppi.mode = 0x9b; | ppi.mode = 0x82; |
| } | } |
| void ppi_reset(void) { | void ppi_reset(void) { |