Graphics Bitmaps Drawing alphabetic characters and multicolor patterns.

Slides:



Advertisements
Similar presentations
Linux device-driver issues
Advertisements

Device Drivers. Linux Device Drivers Linux supports three types of hardware device: character, block and network –character devices: R/W without buffering.
User Preferences – List Views Select “User Preference” from the File Menu.
Using our device-drivers How can an application display the data in a device special file?
Modular Programming With Functions
DOS and BIOS Interrupts DOS and BIOS interrupts are used to perform some very useful functions, such as displaying data to the monitor, reading data from.
Using VMX within Linux We explore the feasibility of executing ROM-BIOS code within the Linux x86_64 kernel.
VGA Text Mode An introduction to font selection and to reprogramming of the Character Generator ram.
Chapter 7 Process Environment Chien-Chung Shen CIS, UD
Crafting a ‘boot time’ program How we can utilize some standard ‘real-mode’ routines that reside in the PC’s ROM-BIOS firmware.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#4)
BY Kamran Yousaf Application of Computer Graphics and Animation Using C++ Language.
CS 686: Programming SuperVGA Graphics Devices Introduction: An exercise in working with graphics file formats.
Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, All rights reserved. You may modify and.
SiS 315 Graphics Engine Introduction to some capabilities of graphics accelerator hardware.
1 Homework Turn in HW2 at start of next class. Starting Chapter 2 K&R. Read ahead. HW3 is on line. –Due: class 9, but a lot to do! –You may want to get.
Structure of a C program
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Graphics Bitmaps Drawing characters glyphs and multicolor patterns.
Scientific Visualization Using imagery to aid humans in understanding a complicated phenomenon.
Using ‘random’ numbers Some ways the standard UNIX ‘rand()’ library-function can be deployed to generate graphics and sound.
CS 686: Programming SuperVGA Graphics Devices Introduction: An exercise in working with graphics file formats.
Assembly Programming Timothy C. Rice Jr., MIT. OUTLINE Basic Structure Exit to Dos Print Character Clear Screen Change BG & FG Color Set Curser Location.
Computers: Software Patrice Koehl Computer Science UC Davis.
Chapter 2 Software Tools and Assembly Language Syntax.
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
System Calls 1.
Java Programming, 3e Concepts and Techniques Chapter 2 - Part 2 Creating a Java Application and Applet.
ORG ; FOUR INT 21H and INT 10H Programming and Macros Dec Hex Bin
ECE291 Computer Engineering II Lecture 9 Josh Potts University of Illinois at Urbana- Champaign.
C++ for Engineers and Scientists Second Edition Chapter 6 Modularity Using Functions.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Programming With C.
Text-Mode Programming Question #1 What are the three levels of access to the video display when writing characters on the screen in text mode?
Lecture 10: BIOS and DOS Programming
Character Generation.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
ECE291 Lecture 12 Mode 13h Graphics. ECE 291 Lecture 12Page 2 of 27 Lecture outline Color theory Video Hardware Mode 13h Graphics File Formats.
ECE291 Computer Engineering II Lecture 15 Josh Potts University of Illinois at Urbana- Champaign.
Video systems. Lesson plan Review the code for the previous exercise Video systems Review for midterm exam.
8086 Microprocessor Interrupts By: Vijay Kumar. K Reference From Slide Share.
Kirk Scott Computer Science The University of Alaska Anchorage 1.
3 Types of Video Output for Text DOS-level INT (Int 21) Output can be easily redirected to other devices (printer, disk) Slow Speed Cannot control the.
CS1372: HELPING TO PUT THE COMPUTING IN ECE CS1372 Some Basics.
RTX - 51 Objectives  Resources needed  Architecture  Components of RTX-51 - Task - Memory pools - Mail box - Signals.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
Software Interrupt Instruction ‘int’ A ‘int’ instruction is like a special kind of subroutine call. Will discuss details later ‘int’ stands for INTERRUPT.
Graphics Concepts CS 2302, Fall /17/20142 Drawing in Android.
10H Interrupt. Option 0H – Sets video mode. Registers used: – AH = 0H – AL = Video Mode. 3H - CGA Color text of 80X25 7H - Monochrome text of 80X25 Ex:
 Programming - the process of creating computer programs.
Creating a Java Application and Applet
4. Kernel and VGA ENGI 3655 Lab Sessions. Richard Khoury2 Textbook Readings  None.
Week 4 - Friday.  What did we talk about last time?  Some extra systems programming stuff  Scope.
Chapter 7 - Functions. Functions u Code group that performs single task u Specification refers to what goes into and out of function u Design refers to.
Lecture 11 Text mode video
Direct-Access Color Graphics Chapter 11. Graphics modes C++ provides a different combination of graphics characteristics. These characteristics include.
Introduction 8051 Programming language options: Assembler or High Level Language(HLL). Among HLLs, ‘C’ is the choice. ‘C’ for 8051 is more than just ‘C’
 Backlight 에서 나온 백색광이 액정 셀을 통과하면 서 투과율이 조절되고 red, green, blue 의 color filter 를 투과해 나오는 빛의 혼합을 통해 색이 구 성됨  Color filter 는 셀사이의 빛을 차단하는 black matrix,
7-Nov Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct lecture23-24-hll-interrupts 1 High Level Language vs. Assembly.
Chapter 7 Process Environment Chien-Chung Shen CIS/UD
Computer Graphics Lecture 04 Point Taqdees A. Siddiqi
Introduction to Operating Systems
Engineering Problem Solving With C An Object Based Approach
Microprocessor and Assembly Language
Protection of System Resources
Assembly Language Programming Part 3
Microprocessor and Assembly Language
C++ for Engineers and Scientists Second Edition
Unit:08 Software Interrupts
In Today’s Class.. General Kernel Responsibilities Kernel Organization
Presentation transcript:

Graphics Bitmaps Drawing alphabetic characters and multicolor patterns

Finding the ROM fonts Standard BIOS service locates ROM fonts Designed to execute in 8086 real-mode Normal service-call protocol is followed: –Parameters are placed in CPU registers –Software interrupt instruction is executed –ROM-BIOS code performs desired service –Parameters may be returned in registers

Example # AT&T assembly language syntax mov$0x11, %ah # char. gen. services mov$0x30, %al # get font information mov$2, %bh # 8x14 font address int$0x10 # request BIOS service # the font address is returned in ES:BP # (and count of scanlines should be in CX)

Interface for Linux No C++ syntax to access CPU registers Software interrupt is privileged operation Must call kernel to obtain BIOS services How to do it isn’t very clearly documented SVGALIB Project: includes ‘LRMI’ wrapper An acronym for Linux Real-Mode Interface Idea: make it easy to invoke BIOS calls

How LRMI is used C program needs: #include “lrmi.h” Needs to do initialization: LRMI_init(); Declares: struct LRMI_regs reg = {0}; Code-example: reg.eax = 0x1130; reg.ebx = 0x0200; LRMI_int( 0x10, &reg ); int font_address = reg.ebp + 16*reg.es;

Link with ‘lrmi.o’ object-module Need to precompile ‘lrmi.c’ source-text: gcc –c lrmi.c For C++ you need overriding prototypes: extern “C” int LRMI_init( void ); # etc. #include “lrmi.h” # this comes after To compile and link your C++ program: g++ drawtext.cpp lrmi.o -o drawtext

Acknowledgement The author of ‘LRMI’ is Josh Vanderhoof His code is part of the SVGALIB package Full package can be downloaded from: Downloaded as a compressed ‘.tar’ file: Example:svgalib tar.gz Use the ‘tar’ command to ‘expand’ it: tar -xvzf svgalib tar.gz

Copying 8x14 ROM font Need to memory-map the ROM region ‘mmap()’ requires map to be 4K-aligned Size of mapped region: 0x1000 (256*16) Need to allocate a local array in RAM: static unsigned char glyph[256][16]; for (c = 0; c < 256; c++) for (r =0; r < 14; r++) glyph[ c ][ r ] = *font_addr++;

Drawing a character (in mode 19) Must memory-map the VRAM window Physical base-address is 0x000A0000 Size of VRAM window is 64K: (64<<10) Use the ascii-code as a glyph-table index Specify the character’s ‘foreground color’ Use x,y coordinates for character location So your function prototype could be: void draw_char( int ascii, int color );

Implementing ‘draw_char()’ inthres = 320, vres = 200; unsigned char *dstn = 0x000A0000; dstn += ( y * hres + x ); # where to start drawing for (r = 0; r < 14; r++) # 14-rows high { for (w = 0; w < 8; w++)# 8-pixels wide if ( glyph[ ascii ][ r ] & (0x80>>w) ) dstn[ w ] = fgcolor; dstn += hres; # drop to next screen row }

Some comparisons text mode ‘character generator’ imposes a fixed grid All characters from a common glyph-table Character backgrounds always solid color graphics mode You can freely mix numerous font styles You can place characters at any positions You can draw against backgound patterns

Using bitmap ‘patterns’ You can create interesting backgrounds Fill screen regions with a copied pattern 0xFF 0x80 0xFF 0x08 foreground color background color

Algorithm for ‘tiling’ (mode 19) unsigned charpat[ 8 ];# 8x8 2-color bitmap unsigned char*vram = 0x000A0000, color; for (int y = 0; y < vres; v++) for (int x = 0; x < hres; x++) { intr = y % 8, k = x % 8; color = ( pat[ r ] & (0x80>>k) ) ? fg : bg; vram[ y*hres + x ] = color; }

Automating pattern-creation Try these standard runtime functions; #include int rand( void ); void srand( unsigned int seed ); Can make new 8x8 patterns like this: for (k = 0; k < 8; k++) pat[ k ] = rand(); fgcolor = rand(); bgcolor = rand();

Esthetics Use a ‘brighter’ color in the foreground Use a ‘darker’ color in the background To implement this discipline we need to know how the ‘color-table’ is arranged In mode 19 there are 256 default colors Among these are 24 color-groups: –3 intensity-levels plus 3 saturation-levels

The ‘default’ colors (mode 19) Range for the 72 brightest colors: 32–103 Range for the 72 midlevel colors: Range for the 72 darkest colors: Colors 0-15 are the standard EGA colors Colors are sixteen grayscale colors Colors are solid black (default) (But all of these are fully ‘programmable’)

Choosing a random color-pair foreground color (from the ‘bright’ range): fgcolor = ( ( rand() & 0xFF ) % 72 ) + 32; Background color (from the ‘dark’ range): bgcolor = ( ( rand() & 0xFF ) % 72 ) + 104;

Using patterns with more colors Same concepts can be extended But need a larger pattern-bitmap Example: use 2 bits-per-pixel (4 colors) An 8x8 pattern that using 4 colors: unsigned shortpat2bpp[ 8 ]; unsigned charpalette4[ 4 ]; for (r = 0; r < 8; r++) pat2bpp[ r ] = rand(); for (c = 0; c < 4; c++) palette4[ c ] = rand();

Tiling with a 4-color bitmap for (y = 0; y < hres; y++) { unsigned shortbits = pat2bpp[ y % 8 ]; for (x = 0; x < hres; x++) { inti = ( bits >> ( x % 8 )&3; intcolor = palette4[ i ]; vram[ y*hres + x ] = color; }

Automating an ‘art show’ Can use a standard C runtime function: #include void sleep( int seconds ); User views your screen for fixed duration: while ( !done ) { draw_next_scene(); sleep(1); }