Blame | Last modification | View Log | Download
ifndef G9KLIB_INCdefine G9KLIB_INCifndef G9K_DISABLE_DIRECT_EXPORT;----------------------------------------------------------------------------;; General Functions overview ;;----------------------------------------------------------------------------;EXPORT G9k.Reset ; Reset and initialize the Gfx9000EXPORT G9k.SetScreenMode ; Set screen modeEXPORT G9k.SetVramWrite ; Set vram write addressEXPORT G9k.SetVramRead ; Set vram read addressEXPORT G9k.Detect ; Detect presence of the Gfx9000EXPORT G9k.DisplayEnable ; Enable displayEXPORT G9k.DisplayDisable ; Disable displayEXPORT G9k.SpritesEnable ; Enable sprites/mouse cursorEXPORT G9k.SpritesDisable ; Disable sprites/mouse cursorEXPORT G9k.WritePalette ; Write palette data to the Gfx9000EXPORT G9k.ReadPalette ; Read palette data from the Gfx9000EXPORT G9k.SetAdjust ; Adjust Gfx9000 displayEXPORT G9k.SetBackDropColor; Set backdrop colorEXPORT G9k.SetScrollX ; Set scroll X Layer AEXPORT G9k.SetScrollY ; Set scroll Y Layer AIFNDEF G9K_DISABLE_PATTERNEXPORT G9k.SetScrollXB ; Set scroll X Layer BEXPORT G9k.SetScrollYB ; Set scroll Y Layer BENDIFEXPORT G9k.SetScrollMode ; Set scroll modeEXPORT G9k.Close ; Closes a G9B or VFF file;----------------------------------------------------------------------------;; Blitter Function overview ;;----------------------------------------------------------------------------;EXPORT G9k.DrawFilledBox ; Draw filled boxEXPORT G9k.DrawBox ; Draw boxEXPORT G9k.DrawLine ; Draw line (simple)EXPORT G9k.SetupCopyRamToXY ; Setup parameters for Ram to XY copyEXPORT G9k.CopyRamToXY ; Copy data from Ram to XYEXPORT G9k.SetupCopyXYToRam ; Setup parameters for XY to Ram copyEXPORT G9k.CopyXYToRam ; Copy data from XY to RamEXPORT G9k.CopyXYToXY ; Copy XY to XYEXPORT G9k.CopyXYToRegisterXY; Copy XY(struct) to XY (registers)EXPORT G9k.CopyVramToXY ; Copy Linear vram address to XYEXPORT G9k.CopyXYToVram ; Copy XY to Linear vram addressEXPORT G9k.CopyVramToVram ; Copy vram linear to vram linearEXPORT G9k.SetCmdWriteMask ; Set blitter command write maskEXPORT G9k.SetCmdColor ; Set blitter command colorEXPORT G9k.SetCmdBackColor ; Set command back ground colorEXPORT G9k.CopyRamToVram ; Copy data from ram to Linear vram address;----------------------------------------------------------------------------;; Font Function overview ;; ---------------------------------------------------------------------------;; DEFINE G9K_DISABLE_VFF to disable inclution of vff functionsIFNDEF G9K_DISABLE_VFFEXPORT G9k.OpenVff ; Open a VFF fileEXPORT G9k.LoadFont ; Loads a VFF(V9990 font format) file from diskEXPORT G9k.SetFont ; Set a font as defaultEXPORT G9k.PrintString ; Print a zero terminated stringEXPORT G9k.PutChar ; Print a characterEXPORT G9k.Locate ; Set X and Y coordinates for putcharENDIF;----------------------------------------------------------------------------;; Gfx9000 bitmap functions ;;----------------------------------------------------------------------------;; DEFINE G9K_DISABLE_G9B to disable inclution of G9B functionsIFNDEF G9K_DISABLE_G9BEXPORT G9k.OpenG9B ; Open a G9B fileEXPORT G9k.ReadG9BPalette ; Read palette data from disk to Gfx9000EXPORT G9k.ReadG9B ; Read data from disk to Gfx9000 VRAM X,YEXPORT G9k.ReadG9BLinear ; Read data from disk to Gfx9000 Linear VRAM AddressEXPORT G9k.CalcG9BVramSize ; Calculate vram size of A G9B fileENDIF;----------------------------------------------------------------------------;; Gfx9000 pattern functions ;;----------------------------------------------------------------------------;; DEFINE G9K_DISABLE_PATTERN to disable inclution of pattern functionsIFNDEF G9K_DISABLE_PATTERNEXPORT G9k.SetPatternData ; Set pattern dataEXPORT G9k.GetPatternData ; Get partern dataEXPORT G9k.SetPattern ; Set patternEXPORT G9k.GetPattern ; Get patternENDIF;----------------------------------------------------------------------------;; Gfx9000 Interrupt functions ;;----------------------------------------------------------------------------;EXPORT G9k.SetIntLine;----------------------------------------------------------------------------;; Macro overview ;;----------------------------------------------------------------------------;; G9kCmdWait - Wait for Blitter command completion; G9kWriteReg - Write Gfx9000 register; G9kReadReg - Read Gfx9000 register; G9kWaitVsync - Wait for Vertical SyncENDIF;----------------------------------------------------------------------------;; V9990 register and port defines ;;----------------------------------------------------------------------------;; Port definesG9K_VRAM EQU 60h ; R/WG9K_PALETTE EQU 61h ; R/WG9K_CMD_DATA EQU 62h ; R/WG9K_REG_DATA EQU 63h ; R/WG9K_REG_SELECT EQU 64h ; WG9K_STATUS EQU 65h ; RG9K_INT_FLAG EQU 66h ; R/WG9K_SYS_CTRL EQU 67h ; WZX_EVA_CTRL EQU 0xc0 ; R/W;G9K_OUTPUT_CTRL EQU ZX_EVA_CTRL; Bit defines G9K_SYS_CTRLG9K_SYS_CTRL_SRS EQU 2 ; Power on reset stateG9K_SYS_CTRL_MCKIN EQU 1 ; Select MCKIN terminalG9K_SYS_CTRL_XTAL EQU 0 ; Select XTAL; Register definesG9K_WRITE_ADDR EQU 0 ; WG9K_READ_ADDR EQU 3 ; WG9K_SCREEN_MODE0 EQU 6 ; R/WG9K_SCREEN_MODE1 EQU 7 ; R/WG9K_CTRL EQU 8 ; R/WG9K_INT_ENABLE EQU 9 ; R/WG9K_INT_V_LINE_LO EQU 10 ; R/WG9K_INT_V_LINE_HI EQU 11 ; R/WG9K_INT_H_LINE EQU 12 ; R/WG9K_PALETTE_CTRL EQU 13 ; WG9K_PALETTE_PTR EQU 14 ; WG9K_BACK_DROP_COLOR EQU 15 ; R/WG9K_DISPLAY_ADJUST EQU 16 ; R/WG9K_SCROLL_LOW_Y EQU 17 ; R/WG9K_SCROLL_HIGH_Y EQU 18 ; R/WG9K_SCROLL_LOW_X EQU 19 ; R/WG9K_SCROLL_HIGH_X EQU 20 ; R/WG9K_SCROLL_LOW_Y_B EQU 21 ; R/WG9K_SCROLL_HIGH_Y_B EQU 22 ; R/WG9K_SCROLL_LOW_X_B EQU 23 ; R/WG9K_SCROLL_HIGH_X_B EQU 24 ; R/WG9K_PAT_GEN_TABLE EQU 25 ; R/WG9K_LCD_CTRL EQU 26 ; R/WG9K_PRIORITY_CTRL EQU 27 ; R/WG9K_SPR_PAL_CTRL EQU 28 ; WG9K_SC_X EQU 32 ; WG9K_SC_Y EQU 34 ; WG9K_DS_X EQU 36 ; WG9K_DS_Y EQU 38 ; WG9K_NX EQU 40 ; WG9K_NY EQU 42 ; WG9K_ARG EQU 44 ; WG9K_LOP EQU 45 ; WG9K_WRITE_MASK EQU 46 ; WG9K_FC EQU 48 ; WG9K_BC EQU 50 ; WG9K_OPCODE EQU 52 ; W; Register Select optionsG9K_DIS_INC_READ EQU 64G9K_DIS_INC_WRITE EQU 128; Bit defines G9K_SCREEN_MODE0 (register 6)G9K_SCR0_STANDBY EQU 192 ; Stand by modeG9K_SCR0_BITMAP EQU 128 ; Select Bit map modeG9K_SCR0_P2 EQU 64 ; Select P1 modeG9K_SCR0_P1 EQU 0 ; Select P1 modeG9K_SCR0_DTCLK EQU 32 ; Master Dot clock not dividedG9K_SCR0_DTCLK2 EQU 16 ; Master Dot clock divided by 2G9K_SCR0_DTCLK4 EQU 0 ; Master Dot clock divided by 4G9K_SCR0_XIM2048 EQU 12 ; Image size = 2048G9K_SCR0_XIM1024 EQU 8 ; Image size = 1024G9K_SCR0_XIM512 EQU 4 ; Image size = 512G9K_SCR0_XIM256 EQU 0 ; Image size = 256G9K_SCR0_16BIT EQU 3 ; 16 bits/dotG9K_SCR0_8BIT EQU 2 ; 8 bits/dotG9K_SCR0_4BIT EQU 1 ; 4 bits/dotG9K_SCR0_2BIT EQU 0 ; 2 bits/dot; Bit defines G9K_SCREEN_MODE1 (register 7)G9K_SCR1_C25M EQU 64 ; Select 640*480 modeG9K_SCR1_SM1 EQU 32 ; Selection of 263 lines during non interlace , else 262G9K_SCR1_SM EQU 16 ; Selection of horizontal frequency 1H=fsc/227.5G9K_SCR1_PAL EQU 8 ; Select PAL, else NTSCG9K_SCR1_EO EQU 4 ; Select of vertical resoltion of twice the non-interlace resolutionG9K_SCR1_IL EQU 2 ; Select InterlaceG9K_SCR1_HSCN EQU 1 ; Select High scan mode; Bit defines G9K_CTRL (Register 8)G9K_CTRL_DISP EQU 128 ; Display VRAMG9K_CTRL_DIS_SPD EQU 64 ; Disable display sprite (cursor)G9K_CTRL_YSE EQU 32 ; /YS EnableG9K_CTRL_VWTE EQU 16 ; VRAM Serial data bus control during digitizationG9K_CTRL_VWM EQU 8 ; VRAM write control during digitizationG9K_CTRL_DMAE EQU 4 ; Enable DMAQ outputG9K_CTRL_VRAM512 EQU 2 ; VRAM=512KBG9K_CTRL_VRAM256 EQU 1 ; VRAM=256KBG9K_CTRL_VRAM128 EQU 0 ; VRAM=128KB; Bit defines G9K_INT_ENABLE (register 9)G9K_INT_IECE EQU 4 ; Command end interrupt enable controlG9K_INT_IEH EQU 2 ; Display position interrupt enableG9K_INT_IEV EQU 1 ; Int. enable during vertical retrace line interval; Bit Defines G9K_PALETTE_CTRL (Register 13)G9K_PAL_CTRL_YUV EQU 192 ; YUV modeG9K_PAL_CTRL_YJK EQU 128 ; YJK modeG9K_PAL_CTRL_256 EQU 64 ; 256 color modeG9K_PAL_CTRL_PAL EQU 0 ; Pallete modeG9K_PAL_CTRL_YAE EQU 32 ; Enable YUV/YJK RGB mixing mode; Bit defines G9K_LOP (Register 45)G9K_LOP_TP EQU 16G9K_LOP_WCSC EQU 12G9K_LOP_WCNOTSC EQU 3G9K_LOP_WCANDSC EQU 8G9K_LOP_WCORSC EQU 14G9K_LOP_WCEORSC EQU 6; Bit defines G9K_ARGG9K_ARG_MAJ EQU 1G9K_ARG_NEG EQU 2G9K_ARG_DIX EQU 4G9K_ARG_DIY EQU 8; Blitter Commands G9K_OPCODE (Register 52)G9K_OPCODE_STOP EQU 00h ; Command being excuted is stoppedG9K_OPCODE_LMMC EQU 10h ; Data is transferred from CPU to VRAM rectangle areaG9K_OPCODE_LMMV EQU 20h ; VRAM rectangle area is painted outG9K_OPCODE_LMCM EQU 30h ; VRAM rectangle area is transferred to CPUG9K_OPCODE_LMMM EQU 40h ; Rectangle area os transferred from VRAM to VRAMG9K_OPCODE_CMMC EQU 050h ; CPU character data is color-developed and transferred to VRAM rectangle areaG9K_OPCODE_CMMK EQU 060h ; Kanji ROM data is is color-developed and transferred to VRAM rectangle areaG9K_OPCODE_CMMM EQU 070h ; VRAM character data is color-developed and transferred to VRAM rectangle areaG9K_OPCODE_BMXL EQU 080h ; Data on VRAM linear address is transferred to VRAM rectangle areaG9K_OPCODE_BMLX EQU 090h ; VRAM rectangle area is transferred to VRAM linear addressG9K_OPCODE_BMLL EQU 0A0h ; Data on VRAM linear address is transferred to VRAM linear addressG9K_OPCODE_LINE EQU 0B0h ; Straight line is drawer on X-Y co-ordinatesG9K_OPCODE_SRCH EQU 0C0h ; Border color co-ordinates on X-Y are detectedG9K_OPCODE_POINT EQU 0D0h ; Color code on specified point on X-Y is read outG9K_OPCODE_PSET EQU 0E0h ; Drawing is executed at drawing point on X-Y co-ordinatesG9K_OPCODE_ADVN EQU 0F0h ; Drawing point on X-Y co-ordinates is shifted; Bit defines G9K_STATUSG9K_STATUS_TR EQU 128G9K_STATUS_VR EQU 64G9K_STATUS_HR EQU 32G9K_STATUS_BD EQU 16G9K_STATUS_MSC EQU 4G9K_STATUS_EO EQU 2G9K_STATUS_CE EQU 1; Mode select defines for SetScreenModeG9K_MODE_P1 EQU 0 ; Pattern mode 0 256 212G9K_MODE_P2 EQU 1 ; Pattern mode 1 512 212G9K_MODE_B1 EQU 2 ; Bitmap mode 1 256 212G9K_MODE_B2 EQU 3 ; Bitmap mode 2 384 240G9K_MODE_B3 EQU 4 ; Bitmap mode 3 512 212G9K_MODE_B4 EQU 5 ; Bitmap mode 4 768 240G9K_MODE_B5 EQU 6 ; Bitmap mode 5 640 400 (VGA)G9K_MODE_B6 EQU 7 ; Bitmap mode 6 640 480 (VGA)G9K_MODE_B7 EQU 8 ; Bitmap mode 7 1024 212 (Undocumented v9990 mode); Fixed VRAM addressesG9K_SCRA_PAT_NAME_TABLE EQU 07C000hG9K_SCRB_PAT_NAME_TABLE EQU 07E000hG9K_P1_SPR_ATTRIB_TABLE EQU 03FE00hG9K_P2_SPR_ATTRIB_TABLE EQU 07BE00hG9K_CURSOR0_ATTRIB EQU 07FE00hG9K_CURSOR1_ATTRIB EQU 07FE08hG9K_CURSOR0_PAT_DATA EQU 07FF00hG9K_CURSOR1_PAT_DATA EQU 07FF80hG9K_RED EQU 32G9K_GREEN EQU 1024G9K_BLUE EQU 1G9K_WRITE_MASK_LAYER_A EQU 000FFhG9K_WRITE_MASK_LAYER_B EQU 0FF00h;----------------------------------------------------------------------------;; G9k Structs ;;----------------------------------------------------------------------------;STRUCT G9B_OBJECTfileHandle WORD ; Dos2 file handle of the openend G9B filebitDepth BYTE ; 2,4,8 or 16 bitcolorType BYTE ; 0=64 color palette mode,64=256 color fixed ,128=YJK and 192=YUV modenrColors BYTE ; Number of colors in palette modewidth WORD ; Widthheight WORD ; Heightcompression BYTE ; 0 = no compression, other value = compression useddataSize D24 ; 24 bit data sizeENDSG9B_COMPRESSION_BITBUST EQU 1; struct VFF objectSTRUCT VFF_OBJECTfileHandle WORD ; Dos2 file handle of the openend VFF filename BLOCK 16,0 ; vff font namewidth BYTE ; widthheight BYTE ; heightpitch BYTE ; 0 = Fixed : 1 = Variable (Still unsused)dataSize WORD ; Data sizeptrOffsetTable WORD ; Pointer to a font offset tablevramOffset WORD ; Pointer to base address of font in vram starting at #70000ramFont BYTE ; 0 font data in vram, 1 font data in ramENDSSTRUCT G9K_BOXleft WORDtop WORDwidth WORDheight WORDENDSSTRUCT G9K_COPY_XY_XYsourceX WORDsourceY WORDdestX WORDdestY WORDwidth WORDheight WORDENDSSTRUCT G9K_COPY_VRAM_XYsourceAddress D24destX WORDdestY WORDwidth WORDheight WORDENDSSTRUCT G9K_COPY_XY_VRAMsourceX WORDsourceY WORDdestAddress D24width WORDheight WORDENDSSTRUCT G9K_COPY_VRAM_VRAMsrcAddress D24destAddress D24nrBytes D24ENDS;----------------------------------------------------------------------------;; ;G9k Error codes ;;----------------------------------------------------------------------------;; Error codes_NOVFF EQU 1 ; Input file is not a VFF file_NOG9B EQU 2 ; Input file is not a G9B file;----------------------------------------------------------------------------;; ;Gfx9000 Macro's ;;----------------------------------------------------------------------------;MACRO G9kCmdWait; Wait for command execution completion; Modifies AIN A,(G9K_STATUS)RRAJR C,$-3ENDMMACRO G9kWriteReg register,data; Write gfx9000 register; modifies: ALD A,registerOUT (G9K_REG_SELECT),ALD A,dataOUT (G9K_REG_DATA),AENDMMACRO G9kReadReg register; Read Gfx9000 register; Result in ALD A,registerOUT (G9K_REG_SELECT),AIN A,(G9K_REG_DATA)ENDMMACRO G9kWaitVsync; Wait for VsyncIN A,(G9K_STATUS)AND A,G9K_STATUS_VRJR NZ,$-4IN A,(G9K_STATUS)AND A,G9K_STATUS_VRJR Z,$-4ENDMMACRO G9kWaitComReady; Wait for Command data readyIN A,(G9K_STATUS)RLAJR NC,$-3ENDMdefine MAKE_LAYERB_ADDR << 1define MAKE_LAYERA_ADDR << 1endif