Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

256x256x256 Mode Q

Status
Not open for further replies.

KenshinHimura

Programmer
May 8, 2003
91
0
0
US
Does ne1 know how to get this in qbasic?
 
no, i don't know. it's not possible in pure qb (i think) without some asm. (why'd you want 256x256x256 anyways?)
 
I've looked at the specs for ModeQ, and I'm almost positive I can get this running. Please give me a few days, and I will try to get some sample code running. Looks like it should run fast. :)
 
Yep, I think I have it. I just need to test it on another machine, and if that works, I'll post the code here for you to see. It's quite simple, since mode Q is a chained mode.
 
'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
 
You see I'm going to be writing an NES emulator and I heard this is the best Mode for one. Well, I searched everywhere trying to find specs on Mode Q and only found one place (that didn't explain it well). Thx SJZero, but I sort of wanted to write the whole routine and things myself and just get the info on how to initialize it here after all I don't just wanna rip your routine (since I truly want to understand the whole thing and if I take some1 elses code I wouldn't learn). Could you tell me where you find the info on it since I could barely find any. Thx :)
 
Unfortnately, the only thing I could find on modeQ myself was a poorly documented pascal program, which I based the init code on. Take what you see above, by all means. It's in the public domain for everyone to use now. :)

If you're interested in how to plot a pixel, my putd statement covers it pretty simply: memory location(past 0xa000, which the setModeQ command sets with the DEF SEG, along with setting up the video mode) = x * 256 + y. It's so simple because it's a chained mode, meaning the video memory is set up so you can just write the colour of the pixel in, unlike ModeX, where you have to switch planes around.
 
wow. really sj, you should write a tutorial on setting new screen modes (modex, etc. etc.) and how memory works. make it well and it could be a winner.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top