sgdk: vdp.h Source File

sgdk

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

vdp.h
Go to the documentation of this file.

    00001
    00020 #ifndef _VDP_H_
    00021 #define _VDP_H_
    00022
    00023
    00028 #define GFX_DATA_PORT           0xC00000
    00029
    00033 #define GFX_CTRL_PORT           0xC00004
    00034
    00038 #define GFX_HVCOUNTER_PORT      0xC00008
    00039
    00044 #define VDP_FIFOEMPTY_FLAG      (1 << 9)
    00045
    00049 #define VDP_FIFOFULL_FLAG       (1 << 8)
    00050
    00054 #define VDP_VINTPENDING_FLAG    (1 << 7)
    00055
    00059 #define VDP_SPROVERFLOW_FLAG    (1 << 6)
    00060
    00064 #define VDP_SPRCOLLISION_FLAG   (1 << 5)
    00065
    00069 #define VDP_ODDFRAME_FLAG       (1 << 4)
    00070
    00074 #define VDP_VBLANK_FLAG         (1 << 3)
    00075
    00079 #define VDP_HBLANK_FLAG         (1 << 2)
    00080
    00084 #define VDP_DMABUSY_FLAG        (1 << 1)
    00085
    00089 #define VDP_PALMODE_FLAG        (1 << 0)
    00090
    00095 #define VDP_PLAN_A              VDP_BG_A
    00096
    00100 #define VDP_PLAN_B              VDP_BG_B
    00101
    00105 #define VDP_PLAN_WINDOW         VDP_WINDOW
    00106
    00111 #define VDP_BG_A                bga_addr
    00112
    00116 #define VDP_BG_B                bgb_addr
    00117
    00121 #define VDP_WINDOW              window_addr
    00122
    00126 #define VDP_HSCROLL_TABLE       hscrl_addr
    00127
    00131 #define VDP_SPRITE_TABLE        slist_addr
    00132
    00136 #define VDP_MAPS_START          maps_addr
    00137
    00142 #define HSCROLL_PLANE           0
    00143
    00147 #define HSCROLL_TILE            2
    00148
    00152 #define HSCROLL_LINE            3
    00153
    00158 #define VSCROLL_PLANE           0
    00159
    00163 #define VSCROLL_COLUMN          1
    00164
    00168 #define VSCROLL_2TILE           VSCROLL_COLUMN
    00169
    00175 #define INTERLACED_NONE         0
    00176
    00181 #define INTERLACED_MODE1        1
    00182
    00187 #define INTERLACED_MODE2        2
    00188
    00193 #define FONT_LEN    96
    00194
    00199 #define TILE_SIZE               32
    00200 #define TILE_INDEX_MASK         (0xFFFF / TILE_SIZE)
    00201
    00206 #define TILE_SPACE              VDP_MAPS_START
    00207
    00212 #define TILE_MAXNUM             (TILE_SPACE / TILE_SIZE)
    00213
    00217 #define TILE_MAXINDEX           (TILE_MAXNUM - 1)
    00218
    00222 #define TILE_SYSTEMINDEX        0x0000
    00223
    00227 #define TILE_SYSTEMLENGTH       16
    00228
    00231 #define TILE_SYSTEMLENGHT       TILE_SYSTEMLENGTH
    00232
    00236 #define TILE_USERINDEX          (TILE_SYSTEMINDEX + TILE_SYSTEMLENGTH)
    00237
    00241 #define TILE_FONTINDEX          (TILE_MAXNUM - FONT_LEN)
    00242
    00246 #define TILE_SPRITEINDEX        (TILE_FONTINDEX - spriteVramSize)
    00247
    00251 #define TILE_USERLENGTH         ((userTileMaxIndex - TILE_USERINDEX) + 1)
    00252
    00255 #define TILE_USERLENGHT         TILE_USERLENGTH
    00256
    00260 #define TILE_USERMAXINDEX       userTileMaxIndex
    00261
    00265 #define TILE_SYSTEM             (TILE_SYSTEMINDEX * TILE_SIZE)
    00266
    00270 #define TILE_USER               (TILE_USERINDEX * TILE_SIZE)
    00271
    00275 #define TILE_FONT               (TILE_FONTINDEX * TILE_SIZE)
    00276
    00281 #define PAL0                    0
    00282
    00286 #define PAL1                    1
    00287
    00291 #define PAL2                    2
    00292
    00296 #define PAL3                    3
    00297
    00302 #define GFX_READ_VRAM_ADDR(adr)     (((0x0000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0x00))
    00303
    00307 #define GFX_READ_CRAM_ADDR(adr)     (((0x0000 + ((adr) & 0x7F)) << 16) + 0x20)
    00308
    00312 #define GFX_READ_VSRAM_ADDR(adr)    (((0x0000 + ((adr) & 0x3F)) << 16) + 0x10)
    00313
    00318 #define GFX_WRITE_VRAM_ADDR(adr)    (((0x4000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0x00))
    00319
    00323 #define GFX_WRITE_CRAM_ADDR(adr)    (((0xC000 + ((adr) & 0x7F)) << 16) + 0x00)
    00324
    00328 #define GFX_WRITE_VSRAM_ADDR(adr)   (((0x4000 + ((adr) & 0x3F)) << 16) + 0x10)
    00329
    00334 #define GFX_DMA_VRAM_ADDR(adr)      (((0x4000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0x80))
    00335
    00339 #define GFX_DMA_CRAM_ADDR(adr)      (((0xC000 + ((adr) & 0x7F)) << 16) + 0x80)
    00340
    00344 #define GFX_DMA_VSRAM_ADDR(adr)     (((0x4000 + ((adr) & 0x3F)) << 16) + 0x90)
    00345
    00350 #define GFX_DMA_VRAMCOPY_ADDR(adr)  (((0x4000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0xC0))
    00351
    00356 #define GFX_VERT_SCROLL(adr)        GFX_WRITE_VSRAM_ADDR(adr)
    00357
    00361 #define GFX_HORZ_SCROLL(adr)        GFX_WRITE_VRAM_ADDR(VDP_SCROLL_H + (adr))
    00362
    00367 #define GET_VDPSTATUS(flag)         ((*(vu16*)(GFX_CTRL_PORT)) & (flag))
    00368
    00372 #define IS_PALSYSTEM                GET_VDPSTATUS(VDP_PALMODE_FLAG)
    00373
    00378 #define GET_HVCOUNTER               (*(vu16*)(GFX_HVCOUNTER_PORT))
    00379
    00383 #define GET_HCOUNTER                (GET_HVCOUNTER & 0xFF)
    00384
    00388 #define GET_VCOUNTER                (GET_HVCOUNTER >> 8)
    00389
    00390
    00395 typedef enum
    00396 {
    00397     BG_A = 0, BG_B = 1, WINDOW = 2
    00398 } VDPPlane;
    00399
    00400
    00401 // used by define
    00402 extern u16 window_addr;
    00403 extern u16 bga_addr;
    00404 extern u16 bgb_addr;
    00405 extern u16 hscrl_addr;
    00406 extern u16 slist_addr;
    00407 extern u16 maps_addr;
    00408 extern u16 userTileMaxIndex;
    00409
    00414 extern u16 screenWidth;
    00419 extern u16 screenHeight;
    00426 extern u16 planeWidth;
    00433 extern u16 planeHeight;
    00440 extern u16 windowWidth;
    00447 extern u16 planeWidthSft;
    00454 extern u16 planeHeightSft;
    00461 extern u16 windowWidthSft;
    00462
    00463
    00470 void VDP_init();
    00471
    00478 void VDP_resetScreen();
    00479
    00488 u8   VDP_getReg(u16 reg);
    00498 void VDP_setReg(u16 reg, u8 value);
    00499
    00504 u8   VDP_getEnable();
    00511 void VDP_setEnable(u8 value);
    00512
    00519 u16  VDP_getScanlineNumber();
    00527 u16  VDP_getScreenHeight();
    00534 void VDP_setScreenHeight224();
    00541 void VDP_setScreenHeight240();
    00548 u16  VDP_getScreenWidth();
    00553 void VDP_setScreenWidth256();
    00558 void VDP_setScreenWidth320();
    00559
    00564 u16  VDP_getPlaneWidth();
    00569 u16  VDP_getPlaneHeight();
    00586 void VDP_setPlaneSize(u16 w, u16 h, bool setupVram);
    00591 void VDP_setPlanSize(u16 w, u16 h);
    00592
    00601 u8 VDP_getHorizontalScrollingMode();
    00610 u8 VDP_getVerticalScrollingMode();
    00631 void VDP_setScrollingMode(u16 hscroll, u16 vscroll);
    00632
    00637 u8 VDP_getBackgroundColor();
    00642 void VDP_setBackgroundColor(u8 value);
    00643
    00648 u8   VDP_getAutoInc();
    00653 void VDP_setAutoInc(u8 value);
    00654
    00659 u8 VDP_getDMAEnabled();
    00666 void VDP_setDMAEnabled(u8 value);
    00671 u8 VDP_getHVLatching();
    00678 void VDP_setHVLatching(u8 value);
    00685 void VDP_setHInterrupt(u8 value);
    00690 void VDP_setHilightShadow(u8 value);
    00691
    00696 u8   VDP_getHIntCounter();
    00704 void VDP_setHIntCounter(u8 value);
    00705
    00710 u16 VDP_getBGAAddress();
    00715 u16 VDP_getBGBAddress();
    00720 u16 VDP_getAPlanAddress();
    00725 u16 VDP_getBPlanAddress();
    00730 u16 VDP_getWindowAddress();
    00735 u16 VDP_getWindowPlanAddress();
    00740 u16 VDP_getSpriteListAddress();
    00745 u16 VDP_getHScrollTableAddress();
    00746
    00756 void VDP_setBGAAddress(u16 value);
    00766 void VDP_setBGBAddress(u16 value);
    00771 void VDP_setAPlanAddress(u16 value);
    00776 void VDP_setBPlanAddress(u16 value);
    00786 void VDP_setWindowAddress(u16 value);
    00791 void VDP_setWindowPlanAddress(u16 value);
    00801 void VDP_setSpriteListAddress(u16 value);
    00811 void VDP_setHScrollTableAddress(u16 value);
    00812
    00825 void VDP_setScanMode(u16 mode);
    00826
    00837 void VDP_setWindowHPos(u16 right, u16 pos);
    00848 void VDP_setWindowVPos(u16 down, u16 pos);
    00849
    00855 void VDP_waitDMACompletion();
    00860 void VDP_waitFIFOEmpty();
    00861
    00871 bool VDP_waitVInt();
    00883 bool VDP_waitVBlank(bool forceNext);
    00892 bool VDP_waitVSync();
    00902 void VDP_waitVActive(bool forceNext);
    00903
    00911 u16 VDP_getAdjustedVCounter();
    00912
    00925 void VDP_showFPS(u16 asFloat);
    00934 void VDP_showCPULoad();
    00935
    00936
    00937 #endif // _VDP_H_

All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines