Category : BASIC Source Code
Archive   : SHAKE.ZIP
Filename : SHAKE.BAS

 
Output of file : SHAKE.BAS contained in archive : SHAKE.ZIP

'ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸
'³ (C) 1987 HUMBLEWARE Custom Programming Author: Lawrence A. Westhaver ³
'³ 247 Paul Martin Drive, Baltimore MD 21227 (301) 799-1975 ³
'³ Visit the QuickBASIC BBS at (301) 799-8564 ³
'ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͵
'³ ³
'³ FILENAME: SHAKE.BAS LAST UPDATE: 12-26-1988 ³
'³ ³
'³ DESCRIPTION: Demonstrates a technique used by some arcade games to ³
'³ shake the screen during simulated explosions. Instead of ³
'³ redrawing the screen in a different position over and over ³
'³ again to shake the screen, it is quicker to reprogram the ³
'³ CRT controllers viewport into video memory. This allows ³
'³ the screen image to be shifted around without having to ³
'³ physically move any of the video memory data. ³
'³ ³
'³ BACKGROUND: The ROM BIOS data area contains a two byte word that ³
'³ tells us the location of the first of two communications ³
'³ ports for the 6845 CRT controller chip. Once we have the ³
'³ location of the controllers first communication port in ³
'³ hand we can then begin sending information to the CRT ³
'³ controller to reprogram it. ³
'³ ³
'³ The controller chip has 18 registers that can be used to ³
'³ set up various features of the video display. Unfortunately ³
'³ these registers are not directly accessable. The controller ³
'³ chip uses two ports to handle all communications with these ³
'³ registers, the ADDRESS port and the DATA port. ³
'³ ³
'³ For example, if we needed to place a value of 2 into ³
'³ register 6 of the CRT controller chip we would need to do ³
'³ the following: ³
'³ ³
'³ 1) Put 6 into ÄÄ ADDRESS port ÄÄÄ¿ Register 0 ³
'³ 2) Put 2 into ÄÄ DATA port ÄÄÄÄÄÄ´ Register 1 ³
'³ ³ Register 2 ³
'³ ³ Register 3 ³
'³ ³ Register 4 ³
'³ ³ Register 5 ³
'³ ÀÄÄÄ Register 6 now = 2 ³
'³ ...... . ³
'³ Register 17 ³
'³ Register 18 ³
'³ ³
'³ Now how do we do this in QuickBASIC? Well, the following ³
'³ code will accomplish the task. ³
'³ ³
'³ 'point to ROM BIOS data area ³
'³ DEF SEG = 0 ³
'³ ³
'³ 'fetch CRT communications ports location ³
'³ CRTControllerPort& = PEEK(&H463) + (PEEK(&H464) * 256&) ³
'³ ³
'³ 'restore segment pointer to BASIC's data area again ³
'³ DEF SEG ³
'³ ³
'³ 'tell CRT controller I want access to register 6 ³
'³ OUT CRTControllerPort& + 0, 6 ³
'³ ³
'³ 'tell CRT controller to put value 2 into register 6 ³
'³ OUT CRTControllerPort& + 1, 2 ³
'³ ³
'³ NOTE: This routine should work on any IBM compatible video card. ³
'³ ³
'³ ** MODIFYING THIS ROUTINE TO ALTER OTHER REGISTERS MAY ** ³
'³ ** CAUSE DAMAGE TO YOUR VIDEO EQUIPMENT ** ³
'³ ³
'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ


CLS

'draw frame within screen for reference
LOCATE 9, 11
PRINT CHR$(201); STRING$(58, 205); CHR$(187)

FOR I% = 10 TO 19
LOCATE I%, 11
PRINT CHR$(186)
LOCATE I%, 70
PRINT CHR$(186)
NEXT I%

LOCATE 20, 11
PRINT CHR$(200); STRING$(58, 205); CHR$(188)

LOCATE 12, 30
PRINT "Lets see what's shaking!"

LOCATE 13, 33
PRINT "Press ESC to Quit"

LOCATE 16, 20
PRINT "Press [" + CHR$(24) + "] or [" + CHR$(25) + "] to change Low Register 0"

LOCATE 17, 20
PRINT "Press [" + CHR$(27) + "] or [" + CHR$(26) + "] to change High Register 0"


'get address of CRT controller port from BIOS data area
DEF SEG = 0
CRTControllerPort& = PEEK(&H463) + (PEEK(&H464) * 256&)
DEF SEG


'shake screen until escape key is pressed
DO UNTIL KeyHit$ = CHR$(27)

'up key - increase lowbyte register value
IF KeyHit$ = CHR$(0) + CHR$(72) THEN
Lbyte% = Lbyte% + 1
IF Lbyte% > 255 THEN Lbyte% = 0
END IF

'down key - decrease lowbyte register value
IF KeyHit$ = CHR$(0) + CHR$(80) THEN
Lbyte% = Lbyte% - 1
IF Lbyte% < 0 THEN Lbyte% = 255
END IF

'right key - increase highbyte register value
IF KeyHit$ = CHR$(0) + CHR$(77) THEN
Hbyte% = Hbyte% + 1
IF Hbyte% > 63 THEN Hbyte% = 0
END IF

'left key - decrease highbyte register value
IF KeyHit$ = CHR$(0) + CHR$(75) THEN
Hbyte% = Hbyte% - 1
IF Hbyte% < 0 THEN Hbyte% = 63
END IF

'update register values display
IF KeyHit$ <> "" THEN
LOCATE 16, 61: PRINT STRING$(5, 32)
LOCATE 16, 61: PRINT Lbyte%
LOCATE 17, 61: PRINT STRING$(5, 32)
LOCATE 17, 61: PRINT Hbyte%
END IF

'program address register
OUT CRTControllerPort& + 0, 12
'program data register
OUT CRTControllerPort& + 1, Hbyte%

'program address register
OUT CRTControllerPort& + 0, 13
'program data register
OUT CRTControllerPort& + 1, Lbyte%

'pause approximately 1/100 of a second for effect
Start! = TIMER
DO WHILE TIMER < Start! + .01
LOOP


'restore default viewport into video RAM

'program address register
OUT CRTControllerPort& + 0, 12
'program data register
OUT CRTControllerPort& + 1, 0

'program address register
OUT CRTControllerPort& + 0, 13
'program data register
OUT CRTControllerPort& + 1, 0

'pause approximately 1/100 of a second for effect
Start! = TIMER
DO WHILE TIMER < Start! + .01
LOOP


'capture any keypress waiting
KeyHit$ = INKEY$


'do it again
LOOP