About programming in int 10h video mode

Started by daniellam, November 08, 2008, 06:16:26 PM

Previous topic - Next topic

daniellam

HI,
Currently I m trying create a list of numbers on the console window. I started by activating the "int 10h" with base address B8000h with mode "02". Then it gave me access to each cell within the size of 25x80 screen buffer. And I use "es:[cell index]" to control what to display on the screen at certain character cell. But my list is way too longer that only 25 rows won't be enough to display all.

Q.1) Is there a way to activate the scroll bar attribute that could actually put the bar at the right of the window, and works out pretty well when user move the cursor on the bar and drag down to see the rest of the list?

Q.2) I used the "int 16h" (ax is 0 in this case) read key interrupt to sort of stop the screen buffer. If I want to actaully read a key from user's input by int 16h, and if that key matches a specific key then the screen will display other things. For example, if the key read in is "Page Down", then I will display a new screen with consecutive pages of the remaining list that I have mentioned above.

P.S.
the code is enclosed in CSEG SEGMENT 'code', ASSUME CS:CSEG, DS:CSEG

MichaelW

Creating a fully functional scroll bar would be difficult, even in a high-level language. Scrolling the text up or down under keyboard control should be much easier. One possible method would be to use a variable to store the index of the first (top) visible item, update the index in response to user input, and then update the display from top to bottom starting with the first visible item at the top. Most of the program logic would be in the code that updates the index. This is a quick example that shows one method of trapping the relevant keys, using the MASM simplified segment definitions and high-level syntax to simplify the coding.

;---------------------------------------------
; Equates for scan code values returned in AH
; for int 16h functions 0, 1, 10h, and 11h.
;---------------------------------------------
SCUP    equ 48h
SCDOWN  equ 50h
SCPGUP  equ 49h
SCPGDN  equ 51h
SCHOME  equ 47h
SCEND   equ 4fh
SCESC   equ 1

.model small
.stack
.data
    _up   db "UP",13,10,"$"
    _down db "DOWN",13,10,"$"
    _pgup db "PGUP",13,10,"$"
    _pgdn db "PGDN",13,10,"$"
    _home db "HOME",13,10,"$"
    _end  db "END",13,10,"$"
    ___   db "?",13,10,"$"
.code
.startup
  looper:
    mov ah, 0
    int 16h
    .IF ah==SCESC
      jmp fini
    .ELSEIF ah==SCUP
      mov dx, OFFSET _up
    .ELSEIF ah==SCDOWN
      mov dx, OFFSET _down
    .ELSEIF ah==SCPGUP
      mov dx, OFFSET _pgup
    .ELSEIF ah==SCPGDN
      mov dx, OFFSET _pgdn
    .ELSEIF ah==SCHOME
      mov dx, OFFSET _home
    .ELSEIF ah==SCEND
      mov dx, OFFSET _end
    .ELSE
      mov dx, OFFSET ___
    .ENDIF
    mov ah, 9
    int 21h
    jmp looper
  fini:
.exit
end

eschew obfuscation