--- hatari/src/falcon/videl.c 2019/04/09 08:53:21 1.1.1.9 +++ hatari/src/falcon/videl.c 2019/04/09 08:54:34 1.1.1.10 @@ -76,7 +76,8 @@ const char VIDEL_fileid[] = "Hatari vide #include "screen.h" #include "stMemory.h" #include "videl.h" - +#include "video.h" /* for bUseHighRes variable, maybe unuseful (Laurent) */ +#include "vdi.h" /* for bUseVDIRes variable, maybe unuseful (Laurent) */ #define Atari2HostAddr(a) (&STRam[a]) #define VIDEL_COLOR_REGS_BEGIN 0xff9800 @@ -119,6 +120,8 @@ Uint16 vfc_counter; /* counter for VFC static void VIDEL_memset_uint32(Uint32 *addr, Uint32 color, int count); static void VIDEL_memset_uint16(Uint16 *addr, Uint16 color, int count); static void VIDEL_memset_uint8(Uint8 *addr, Uint8 color, int count); +static void Videl_ColorReg_WriteWord(void); + /** * Called upon startup and when CPU encounters a RESET instruction. @@ -166,10 +169,13 @@ void VIDEL_MemorySnapShot_Capture(bool b } /** - * Monitor write access to ST/E color palette registers + * Monitor write access to Falcon color palette registers */ -void VIDEL_ColorRegsWrite(void) +void VIDEL_FalconColorRegsWrite(void) { + uint32_t color = IoMem_ReadLong(IoAccessBaseAddress & ~3); + color &= 0xfcfc00fc; /* Unused bits have to be set to 0 */ + IoMem_WriteLong(IoAccessBaseAddress & ~3, color); videl.hostColorsSync = false; } @@ -957,9 +963,7 @@ bool VIDEL_renderScreen(void) VIDEL_ConvertScreenNoZoom(vw, vh, videl.save_scrBpp, nextline); } - - HostScreen_renderEnd(); - HostScreen_update1(false); + HostScreen_update1(HostScreen_renderEnd(), false); return true; } @@ -2021,3 +2025,191 @@ static void VIDEL_memset_uint8(Uint8 *ad { memset(addr, color, count); } + + + +/** + * Write to videl ST palette registers (0xff8240-0xff825e) + * + * [Laurent]: The following note should be verified on Falcon before being applied. + * + * Note that there's a special "strange" case when writing only to the upper byte + * of the color reg (instead of writing 16 bits at once with .W/.L). + * In that case, the byte written to address x is automatically written + * to address x+1 too (but we shouldn't copy x in x+1 after masking x ; we apply the mask at the end) + * Similarly, when writing a byte to address x+1, it's also written to address x + * So : move.w #0,$ff8240 -> color 0 is now $000 + * move.b #7,$ff8240 -> color 0 is now $707 ! + * move.b #$55,$ff8241 -> color 0 is now $555 ! + * move.b #$71,$ff8240 -> color 0 is now $171 (bytes are first copied, then masked) + */ +void Videl_ColorReg_WriteWord(void) +{ + Uint16 col; + Uint32 addr = IoAccessCurrentAddress; + + videl.hostColorsSync = false; + + if (bUseHighRes || bUseVDIRes) /* Don't store if hi-res or VDI resolution */ + return; + + /* Note from laurent: The following special case should be verified on the real Falcon before uncommenting */ + /* Handle special case when writing only to the upper byte of the color reg */ +// if ( ( nIoMemAccessSize == SIZE_BYTE ) && ( ( IoAccessCurrentAddress & 1 ) == 0 ) ) +// col = ( IoMem_ReadByte(addr) << 8 ) + IoMem_ReadByte(addr); /* copy upper byte into lower byte */ + /* Same when writing only to the lower byte of the color reg */ +// else if ( ( nIoMemAccessSize == SIZE_BYTE ) && ( ( IoAccessCurrentAddress & 1 ) == 1 ) ) +// col = ( IoMem_ReadByte(addr) << 8 ) + IoMem_ReadByte(addr); /* copy lower byte into upper byte */ + /* Usual case, writing a word or a long (2 words) */ +// else + col = IoMem_ReadWord(addr); + + col &= 0xfff; /* Mask off to 4096 palette */ + + addr &= 0xfffffffe; /* Ensure addr is even to store the 16 bit color */ + + IoMem_WriteWord(addr, col); +} + +/* + * [NP] TODO : due to how .L accesses are handled in ioMem.c, we can't call directly + * Video_ColorReg_WriteWord from ioMemTabFalcon.c, we must use an intermediate + * function, else .L accesses will not change 2 .W color regs, but only one. + * This should be changed in ioMem.c to do 2 separate .W accesses, as would do a real 68000 + */ + +void Videl_Color0_WriteWord(void) +{ + Videl_ColorReg_WriteWord(); +} + +void Videl_Color1_WriteWord(void) +{ + Videl_ColorReg_WriteWord(); +} + +void Videl_Color2_WriteWord(void) +{ + Videl_ColorReg_WriteWord(); +} + +void Videl_Color3_WriteWord(void) +{ + Videl_ColorReg_WriteWord(); +} + +void Videl_Color4_WriteWord(void) +{ + Videl_ColorReg_WriteWord(); +} + +void Videl_Color5_WriteWord(void) +{ + Videl_ColorReg_WriteWord(); +} + +void Videl_Color6_WriteWord(void) +{ + Videl_ColorReg_WriteWord(); +} + +void Videl_Color7_WriteWord(void) +{ + Videl_ColorReg_WriteWord(); +} + +void Videl_Color8_WriteWord(void) +{ + Videl_ColorReg_WriteWord(); +} + +void Videl_Color9_WriteWord(void) +{ + Videl_ColorReg_WriteWord(); +} + +void Videl_Color10_WriteWord(void) +{ + Videl_ColorReg_WriteWord(); +} + +void Videl_Color11_WriteWord(void) +{ + Videl_ColorReg_WriteWord(); +} + +void Videl_Color12_WriteWord(void) +{ + Videl_ColorReg_WriteWord(); +} + +void Videl_Color13_WriteWord(void) +{ + Videl_ColorReg_WriteWord(); +} + +void Videl_Color14_WriteWord(void) +{ + Videl_ColorReg_WriteWord(); +} + +void Videl_Color15_WriteWord(void) +{ + Videl_ColorReg_WriteWord(); +} + +/** + * display Videl registers values (for debugger info command) + */ +void Videl_Info(Uint32 dummy) +{ + if (ConfigureParams.System.nMachineType != MACHINE_FALCON) { + fprintf(stderr, "Not Falcon - no Videl!\n"); + return; + } + + fprintf(stderr, "$FF8006.b : monitor type : %02x\n", IoMem_ReadByte(0xff8006)); + fprintf(stderr, "$FF8201.b : Video Base Hi : %02x\n", IoMem_ReadByte(0xff8201)); + fprintf(stderr, "$FF8203.b : Video Base Mi : %02x\n", IoMem_ReadByte(0xff8203)); + fprintf(stderr, "$FF8205.b : Video Count Hi : %02x\n", IoMem_ReadByte(0xff8205)); + fprintf(stderr, "$FF8207.b : Video Count Mi : %02x\n", IoMem_ReadByte(0xff8207)); + fprintf(stderr, "$FF8209.b : Video Count Lo : %02x\n", IoMem_ReadByte(0xff8209)); + fprintf(stderr, "$FF820A.b : Sync mode : %02x\n", IoMem_ReadByte(0xff820a)); + fprintf(stderr, "$FF820D.b : Video Base Lo : %02x\n", IoMem_ReadByte(0xff820d)); + fprintf(stderr, "$FF820E.w : offset to next line : %04x\n", IoMem_ReadWord(0xff820e)); + fprintf(stderr, "$FF8210.w : VWRAP - line width : %04x\n", IoMem_ReadWord(0xff8210)); + fprintf(stderr, "$FF8260.b : ST shift mode : %02x\n", IoMem_ReadByte(0xff8260)); + fprintf(stderr, "$FF8264.w : Horizontal scroll register : %04x\n", IoMem_ReadWord(0xff8264)); + fprintf(stderr, "$FF8266.w : Falcon shift mode : %04x\n", IoMem_ReadWord(0xff8266)); + fprintf(stderr, "\n"); + fprintf(stderr, "$FF8280.w : HHC - Horizontal Hold Counter : %04x\n", IoMem_ReadWord(0xff8280)); + fprintf(stderr, "$FF8282.w : HHT - Horizontal Hold Timer : %04x\n", IoMem_ReadWord(0xff8282)); + fprintf(stderr, "$FF8284.w : HBB - Horizontal Border Begin : %04x\n", IoMem_ReadWord(0xff8284)); + fprintf(stderr, "$FF8286.w : HBE - Horizontal Border End : %04x\n", IoMem_ReadWord(0xff8286)); + fprintf(stderr, "$FF8288.w : HDB - Horizontal Display Begin : %04x\n", IoMem_ReadWord(0xff8288)); + fprintf(stderr, "$FF828A.w : HDE - Horizontal Display End : %04x\n", IoMem_ReadWord(0xff828a)); + fprintf(stderr, "$FF828C.w : HSS - Horizontal SS : %04x\n", IoMem_ReadWord(0xff828c)); + fprintf(stderr, "$FF828E.w : HFS - Horizontal FS : %04x\n", IoMem_ReadWord(0xff828e)); + fprintf(stderr, "$FF8290.w : HEE - Horizontal EE : %04x\n", IoMem_ReadWord(0xff8290)); + fprintf(stderr, "\n"); + fprintf(stderr, "$FF82A0.w : VFC - Vertical Frequency Counter : %04x\n", IoMem_ReadWord(0xff82a0)); + fprintf(stderr, "$FF82A2.w : VFT - Vertical Frequency Timer : %04x\n", IoMem_ReadWord(0xff82a2)); + fprintf(stderr, "$FF82A4.w : VBB - Vertical Border Begin : %04x\n", IoMem_ReadWord(0xff82a4)); + fprintf(stderr, "$FF82A6.w : VBE - Vertical Border End : %04x\n", IoMem_ReadWord(0xff82a6)); + fprintf(stderr, "$FF82A8.w : VDB - Vertical Display Begin : %04x\n", IoMem_ReadWord(0xff82a8)); + fprintf(stderr, "$FF82AA.w : VDE - Vertical Display End : %04x\n", IoMem_ReadWord(0xff82aa)); + fprintf(stderr, "$FF82AC.w : VSS - Vertical SS : %04x\n", IoMem_ReadWord(0xff82ac)); + fprintf(stderr, "\n"); + fprintf(stderr, "$FF82C0.w : VCO - Video control : %04x\n", IoMem_ReadWord(0xff82c0)); + fprintf(stderr, "$FF82C2.w : VMD - Video mode : %04x\n", IoMem_ReadWord(0xff82c2)); + fprintf(stderr, "\n-------------------------\n"); + + fprintf(stderr, "Video base : %08x\n", + (IoMem_ReadByte(0xff8201)<<16) + + (IoMem_ReadByte(0xff8203)<<8) + + IoMem_ReadByte(0xff820d)); + fprintf(stderr, "Video count : %08x\n", + (IoMem_ReadByte(0xff8205)<<16) + + (IoMem_ReadByte(0xff8207)<<8) + + IoMem_ReadByte(0xff8209)); +}