'SJ Zeros PureQB ModeQ graphics routines
'This is just a very simple batch of routines I
'slapped together to show that ModeQ can be done
'in PureQB. To use them, set the video mode using
'setModeQ, put dots on the screen using putd(x,y,colour)
'exit the program at the end using deinit, or you'll
'be stuck in modeQ.
'I left out a PUT compatible statement and text stuff
'but if there's demand I'll release a new one later.
'Trust me when I say, it's an easy piece of code to
'write.
DECLARE SUB deinit ()
DECLARE SUB putd (x%, y%, colr%)
DEFINT A-Z
DECLARE SUB setModeQ ()
setModeQ
WHILE INKEY$ = ""
c = INT(RND(1) * 255)
FOR a = 0 TO 255
FOR b = 0 TO 255
putd a, b, c
NEXT b
NEXT a
WEND
deinit
SUB deinit ()
CLS
SCREEN 13: SCREEN 0: WIDTH 80
END
END SUB
STATIC SUB putd (x, y, colr)
POKE (x * 256&) + y, colr
END SUB
DEFSNG A-Z
SUB setModeQ ()
DEF SEG = &HA000
'begin with standard 320x200x256 mode
SCREEN 13
'to reprogram the CRT controller,
'remove write protect from the registers
OUT &H3D4, &H11: OUT &H3D5, INP(&H3D5) AND &H7F
OUT &H3D4, &H0: OUT &H3D5, &H5F 'Hor. Total
OUT &H3D4, &H1: OUT &H3D5, &H3F 'Hor. Display enable end
OUT &H3D4, &H2: OUT &H3D5, &H40 'blank start
OUT &H3D4, &H3: OUT &H3D5, &H82 'blank end
OUT &H3D4, &H4: OUT &H3D5, &H4E 'retrace start
OUT &H3D4, &H5: OUT &H3D5, &H9A 'retrace end
OUT &H3D4, &H6: OUT &H3D5, &H23 'vertical total
OUT &H3D4, &H7: OUT &H3D5, &HB2 'overflow register
OUT &H3D4, &H8: OUT &H3D5, &H0 'preset row scan
OUT &H3D4, &H9: OUT &H3D5, &H61 'max scan line/char height
OUT &H3D4, &H10: OUT &H3D5, &HA 'vertical retrace start
OUT &H3D4, &H11: OUT &H3D5, &HAC 'vertical retrace end
OUT &H3D4, &H12: OUT &H3D5, &HFF 'vertical display enable end
OUT &H3D4, &H13: OUT &H3D5, &H20 'offset/logical width
OUT &H3D4, &H14: OUT &H3D5, &H40 'underlinde location
OUT &H3D4, &H15: OUT &H3D5, &H7 'vertical blank start
OUT &H3D4, &H16: OUT &H3D5, &H17 'vertical blank end
OUT &H3D4, &H17: OUT &H3D5, &HA3 'mode control
OUT &H3C4, &H1: OUT &H3C5, &H1 'clock mode register
OUT &H3C4, &H4: OUT &H3C5, &HE 'memory mode register
OUT &H3CE, &H5: OUT &H3CF, &H40 'mode register
OUT &H3CE, &H6: OUT &H3CF, &H5 'misc. register
OUT &H3C0, &H10 + 32: OUT &H3C1, &H41 'mode control
'reprotect the registers
OUT &H3D4, &H11: OUT &H3D5, INP(&H3D5) OR &H80
END SUB