CS2260 Media Device Architectures Timing Code, Organizing C Files, First Project - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

CS2260 Media Device Architectures Timing Code, Organizing C Files, First Project

Description:

One way is to keep track of where the circle is drawn in each page and redraw ... Detour: making a general bitmap Print() routine ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 11
Provided by: michael1692
Category:

less

Transcript and Presenter's Notes

Title: CS2260 Media Device Architectures Timing Code, Organizing C Files, First Project


1
CS2260 Media Device ArchitecturesTiming Code,
Organizing C Files, First Project
2
Revisit assignment 2, 4b
  • This is the use pageflipping to move a circle in
    mode 5 assignment
  • Need to erase the circle in each page
  • One way is to keep track of where the circle is
    drawn in each page and redraw the circle in the
    background color
  • Another way is to clear the whole page by
    redrawing every pixel in the background color
  • A number of you did this you may have noticed
    that the circle moves slowly
  • Lets time how long it takes to clear the screen

3
Timing ClearScreen()
  • REG_TM0D 0
  • REG_TM1D 0
  • REG_TM0CNT TIMER_FREQUENCY_SYSTEM
    TIMER_ENABLE
  • REG_TM1CNT TIMER_OVERFLOW TIMER_ENABLE
  • ClearScreen()
  • REG_TM0CNT TIMER_ENABLE
  • REG_TM1CNT TIMER_ENABLE
  • Now how do we print out the timer value?

4
Detour making a general bitmap Print() routine
  • Wed like to be able to easily print in bitmap
    mode 3, 4 or 5
  • The book gives us code for drawing in mode 3
  • One approach manually modify the code and copy
    and paste it into your program
  • Better Build a general Print() library that you
    can reuse in any bitmap mode program
  • Need to make the routines work in any bitmap mode
  • Need to define a .h file that provides the
    defines and function prototypes of your library
  • Need to tell Ham to use the library

5
Details of modifying Print()
  • Work an example in Ham

6
DMA
  • Direct memory access (DMA) uses a special piece
    of hardware, the DMA controller, to move data
    around
  • The CPU is paused during DMA access
  • DMA cant move data faster than the clock rate
  • At last two clock cycles per word (16 bit) moved,
    usually more because of memory wait states

7
Long story short
  • Dont clear the whole screen unless you really
    have to
  • For simple things, like moving a circle or
    playing Pong, it is easy to figure out what needs
    to be erased, so just erase that
  • Speaking of Pong

8
First project
  • Build a simple racquet ball game
  • Bounce a ball against a wall
  • Slowly speed up the ball the score is how many
    seconds you keep the ball bouncing

9
Issues to think about
  • Which graphics mode should we use?
  • We want to avoid artifacts
  • Dont need a lot of color
  • Mode 4 high resolution, have a second page for
    artifact-free drawing, enough color (256)
  • We dont have a paddle controller how can we
    make moving a paddle more interesting with button
    controls?
  • Dual speed press A to move faster
  • What do we need to draw? How should we draw it?

10
More issues
  • How should we count seconds as they go by?
  • How should the ball bounce?
  • If it hits a stationary paddle or wall
  • If it hits a moving paddle
  • Angle of incidence angle of reflection
  • Perhaps add to the angle of reflection as you
    move out from the center of paddle
  • Perhaps add to the angle of reflection in the
    direction of movement if you hit a moving paddle
  • How should we indicate increasing difficulty?
Write a Comment
User Comments (0)
About PowerShow.com