Unformatted text preview:

Spring 2011 Prof. Hyesoon Kim• An image controller• What to learn– Graphics mode – Fixed operations – Sound • No need to write assembly code. You can use any APIs• UP/DOWN- move up/down• LEFT/RIGHT- move left/right• A- reset to original• L/R- Rotate• X/Y- Scale up/ scale down• Touch- the background should move in the same direction as the stylus. It doesn’t need to move as much as the stylus in magnitude-just the same direction.• Sound: At every 10thdegree rotation, generate sound • Demo (4/15) Friday• Report ( 5% of Lab #6): Lab 6 will be 10% of the total grade. • Final project will be 20% of the total grade – Commented code and simple descriptions – Any problems encountered and solutions• Dual screen: Main screen, sub screen • 8 Graphics Modes • Background Type– Frame buffer: manipulate each pixel– 3D: OpenGL 3D feature – Text: aka tile background– Rotation: similar to text but rotation, scale– Extended rotation: – Large bitmap• A bitmap that can be displayed on the screen• The bitmap could be larger than the physical size of the screen• Hardware scrolling, rotation, scaling, shearing • Register setsMain 2D EngineModeBG0BG1BG2BG3Mode 0Text/3DTextTextTextMode 1Text/3DTextTextRotationMode 2Text/3DTextRotationRotationMode 3Text/3DTextTextExtendedMode 4Text/3DTextRotationExtendedMode 5Text/3DTextExtendedExtendedMode 63D-Large Bitmap-Frame BufferDirect VRAM display as a bitmap• Frame buffer can be used by only one screen SUB 2D EngineModeBG0BG1BG2BG3Mode 0Text/3DTextTextTextMode 1Text/3DTextTextRotationMode 2Text/3DTextRotationRotationMode 3Text/3DTextTextExtendedMode 4Text/3DTextRotationExtendedMode 5Text/3DTextExtendedExtended• initVideo• initBackground/* Set the video mode on the main screen. */videoSetMode(MODE_5_2D | // Set the graphics mode to Mode 5DISPLAY_BG2_ACTIVE | // Enable BG2 for displayDISPLAY_BG3_ACTIVE); //Enable BG3 for display/* Set the video mode on the sub screen. */videoSetModeSub(MODE_5_2D | // Set the graphics mode to Mode 5DISPLAY_BG3_ACTIVE); // Enable BG3 for displayBankControl RegisterSizeVRAM_AVRAM_A_CR128KBVRAM_BVRAM_B_CR128KBVRAM_CVRAM_C_CR128KBVRAM_DVRAM_D_CR128KBVRAM_EVRAM_E_CR64KBVRAM_FVRAM_F_CR16KBVRAM_GVRAM_G_CR16KBVRAM_HVRAM_H_CR32KBVRAM_IVRAM_I_CR32KBVRAM works as working space for display.A certain memory space will be drawn depending on Mode9 banks• We need to allocate right amount of video memory to the correct memory address for a mode– Large enough to have the bitmap void initVideo() {/** Map VRAM to display a background on the main and sub screens.* The vramSetMainBanks function takes four arguments, one for each of the* major VRAM banks. We can use it as shorthand for assigning values to* each of the VRAM bank's control registers.* We map banks A and B to main screen background memory. This gives us* 256KB, which is a healthy amount for 16-bit graphics.* We map bank C to sub screen background memory.* We map bank D to LCD. This setting is generally used for when we aren't* using a particular bank.*/vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000,VRAM_B_MAIN_BG_0x06020000,VRAM_C_SUB_BG_0x06200000,VRAM_D_LCD);// graphics mode setting (previous slide code) }• BG_{32x32|32x64|64x32|64x64}; used for text backgrounds • BG_RS_{16x16|32x32|64x64|128x128}; used for rotation backgrounds • BG_BMP{8|16}_{128x128|256x256|512x256|512x512}: extended rotation background variants, bit per pixel and resolution • BG_BMP8_1024x512 and BG_BMP8_512x1024: is used only for MODE 6 • BG_WRAP_ON: if you scroll to the end of the image, it will wrap. This way, you can "scroll forever". • BG_PRIORITY(n) or BG_PRIORITY_n: the priority of the background: 0 is the highest priority, 3 the lowest. A background with a higher priority will be printed on top of backgrounds with lower priorities. If there is a sprite with the same priority, it will be printed on top of the background. • BG_MOSAIC_ON: You have to set this flag if you want to use the mosaic effect (see below). • BG_TILE_BASE(n): each tile-block is 16KB. This parameter selects, which block we want to use. For tile-based backgrounds only. • BG_MAP_BASE(n): each map-block is 2KB. This parameter selects, which block we want to use. For tile-based backgrounds only. • BG_BMP_BASE(n): each bitmap-block is 16KB. This parameter selects, which block we want to use. For bitmap backgrounds only.• BGn_X0: this controls where the left origin of the screen maps to the background • BGn_Y0: this controls where the top of the screen maps to the background • With n = 0,1,2 or 3. If we use an extended rotation background we have even more registers: • BGn_XDX: this controls the x-axis scaling, it's a 0.8.8 fixed point number. If you don't want to scale at all, set it to 1.0 (which is 1 << 8). Increase the value to "zoom out." F0or example, 2.0 (1 << 9) will show the background at half its width. • BGn_XDY: this is for rotating and shearing • BGn_YDX: this is for rotating and shearing • BGn_YDY: this controls the y-axis scaling and works the same as BGn_XDX. • BGn_CX: this controls where the left origin of the screen maps to the background (in 0.8.8 fixed point, too). • BGn_CY: this controls where the top of the screen maps to the background (in 0.8.8 fixed point, too). • With n = 2 or 3 and the same for the sub screen (SUB_BG2_X0 etc.). • When using a rotation background or extended rotation background the BGn_CX and BGn_CY registers replace BGn_X0 and BGn_Y0./* Set up affine background 3 on main as a 16-bit color background. */ REG_BG3CNT = BG_BMP16_256x256 | BG_BMP_BASE(0) | // The starting place in memory BG_PRIORITY(3); // A low priority /* Set the affine transformation matrix for the main screen background 3 * to be the identity matrix. */ REG_BG3PA = 1 << 8;REG_BG3PB = 0; REG_BG3PC = 0;REG_BG3PD = 1 << 8; /* Place main screen background 3 at the origin (upper left of the * screen). */ REG_BG3X = 0; REG_BG3Y = 0;• Each background is also transformed by its affine transformation matrix • X-> Ax+B• 4 registers [ABCD]• A: REG_BG3PA, B:REG_BG3PB, C:REG_BG3PC, D: REG_BG3PD• Use integer operators to calculate floating point operations • Fixed point integer 12.23 1223+20. 41 + 2041-------------- --------------32.64 3264 12.23 1223x 20.41 x 2041-------------- --------------249.61 2496143• a 1.15.16 fixed point number: one bit sign, 15-bit


View Full Document

GT CS 4803 - LECTURE NOTES

Download LECTURE NOTES
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view LECTURE NOTES and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view LECTURE NOTES 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?