anyone got any good websites on these commands? I know about them, but it is how to use them that's got me stumped. like, &h60. this writes to the keyboard buffer (i think) but what about other addresses? anyone got any information about this? i know varseg, varptr def seg, poke and peek write to the memory, but what about inp and int, out, wait, etc. etc. any help is appreciated. btw, here's some code to crunch on. it's a scrolling engine. try to modify it, get a few fps out of it! happy coding!
'Program: Pure QBasic pixel by pixel tile engine
'Author: Jesse Regier aka...
'
' É͸ Ö· Ö ·Ö ɸ
' ÈÍ» ºº º ºº È»
' ÖÄÄĺÄӽĽÄÓ½ÄÔ¼Ä
' ÈÍÍͼ
'
'E-mail: theregiers@sk.sympatico.ca
'ICQ: 37962076
'Website: Darkle - '
'Notes:
' I wrote this as a small experiment to see how fast of a tile
' scrolling engine could be made using only QBasic's intrinsic
' functionality. I was impressed by how fast it actually is once
' been *compiled*. There are a few bugs that will become apparent if
' you play around with this long enough... I didn't do any bounds
' checking, you'll notice it as soon as you go too far left or up.
' There isn't too much for documentation... the code is all simple
' enough that anyone should be able to figure it out, if you can't
' well then you've got a lot of learning to do... Bonne chance!
'
' Bored? Optimize this simple engine... see if you can squeeze
' a few more frames per second out of it.... and send me a copy!
'
DEFINT A-Z
CONST screenw = 320, screenh = 200
CONST mw = 99, mh = 99
CONST MaxTiles = 5
CONST tw = 20, th = 20
CONST tsize = (tw * th + 1) \ 2 + 1
DIM map(mw, mh)
DIM Tiles(tsize, MaxTiles - 1)
DIM scanline(1 TO tw)
DIM soffset AS LONG
'create map
FOR x = 0 TO mw
FOR y = 0 TO mh
map(x, y) = RND * (MaxTiles - 1)
NEXT
NEXT
'create tiles
DEF SEG = VARSEG(Tiles(0, 0))
offset = VARPTR(Tiles(0, 0))
FOR tile = 0 TO MaxTiles - 1
Tiles(0, tile) = tw * 8
Tiles(1, tile) = th
offset = offset + 4
FOR x = 0 TO tw - 1
FOR y = 0 TO th - 1
POKE offset, tile
offset = offset + 1
NEXT
NEXT
NEXT
DEF SEG
SCREEN 13
x = mw * tw \ 2
y = mh * th \ 2
time! = TIMER
DO
'clear the key buffer
DEF SEG = 0
POKE (1050), PEEK(1052)
DEF SEG
'get keypress and handle it
SELECT CASE INP(96)
CASE 1: EXIT DO
CASE 72: y = y - 1
CASE 75: x = x - 1
CASE 77: x = x + 1
CASE 80: y = y + 1
END SELECT
sx.b = -(x MOD tw)
sy = -(y MOD th)
tx.b = x \ tw
ty = y \ th
DO
sx = sx.b
tx = tx.b
DO
t = map(tx, ty)
IF ((sx >= 0) AND (sy >= 0) AND (sx <= (screenw - tw)) AND (sy <= (screenh - th))) THEN
PUT (sx, sy), Tiles(0, t), PSET
ELSEIF ((sx >= 0) AND (sx <= (screenw - tw)) AND (sy > (screenh - th))) THEN
h = Tiles(1, t)
Tiles(1, t) = (screenh - sy)
PUT (sx, sy), Tiles(0, t), PSET
Tiles(1, t) = h
ELSE
tseg = VARSEG(Tiles(0, t))
toffset = VARPTR(Tiles(2, t))
IF sx < 0 THEN
px = 0
toffset = toffset - sx
w = tw + sx
woff = -sx
soff = screenw - (tw - woff)
ELSEIF sx > (screenw - tw) THEN
px = sx
w = screenw - sx
woff = (sx + tw) - screenw
soff = screenw - (tw - woff)
ELSE
w = tw
px = sx
soff = screenw - tw
woff = 0
END IF
IF sy < 0 THEN
py = 0
toffset = toffset - (sy * tw)
h = th + sy
ELSEIF sy > (screenh - th) THEN
py = sy
h = screenh - sy
ELSE
py = sy
h = th
END IF
soffset = CLNG(py) * screenw + px
FOR py = 1 TO h
'peek the scanline into a temp buffer
DEF SEG = tseg
FOR px = 1 TO w
scanline(px) = PEEK(toffset)
toffset = toffset + 1
NEXT
'poke the temp buffer onto the screen
DEF SEG = &HA000
FOR px = 1 TO w
POKE (soffset), scanline(px)
soffset = soffset + 1
NEXT
toffset = toffset + woff
soffset = soffset + soff
NEXT
END IF
tx = tx + 1
sx = sx + tw
LOOP UNTIL sx > 319
ty = ty + 1
sy = sy + th
LOOP UNTIL sy > 199
f = f + 1
IF (time! + 1) < TIMER THEN
fps$ = STR$(f)
time! = TIMER
f = 0
END IF
LOCATE 22: PRINT fps$
LOOP
'Program: Pure QBasic pixel by pixel tile engine
'Author: Jesse Regier aka...
'
' É͸ Ö· Ö ·Ö ɸ
' ÈÍ» ºº º ºº È»
' ÖÄÄĺÄӽĽÄÓ½ÄÔ¼Ä
' ÈÍÍͼ
'
'E-mail: theregiers@sk.sympatico.ca
'ICQ: 37962076
'Website: Darkle - '
'Notes:
' I wrote this as a small experiment to see how fast of a tile
' scrolling engine could be made using only QBasic's intrinsic
' functionality. I was impressed by how fast it actually is once
' been *compiled*. There are a few bugs that will become apparent if
' you play around with this long enough... I didn't do any bounds
' checking, you'll notice it as soon as you go too far left or up.
' There isn't too much for documentation... the code is all simple
' enough that anyone should be able to figure it out, if you can't
' well then you've got a lot of learning to do... Bonne chance!
'
' Bored? Optimize this simple engine... see if you can squeeze
' a few more frames per second out of it.... and send me a copy!
'
DEFINT A-Z
CONST screenw = 320, screenh = 200
CONST mw = 99, mh = 99
CONST MaxTiles = 5
CONST tw = 20, th = 20
CONST tsize = (tw * th + 1) \ 2 + 1
DIM map(mw, mh)
DIM Tiles(tsize, MaxTiles - 1)
DIM scanline(1 TO tw)
DIM soffset AS LONG
'create map
FOR x = 0 TO mw
FOR y = 0 TO mh
map(x, y) = RND * (MaxTiles - 1)
NEXT
NEXT
'create tiles
DEF SEG = VARSEG(Tiles(0, 0))
offset = VARPTR(Tiles(0, 0))
FOR tile = 0 TO MaxTiles - 1
Tiles(0, tile) = tw * 8
Tiles(1, tile) = th
offset = offset + 4
FOR x = 0 TO tw - 1
FOR y = 0 TO th - 1
POKE offset, tile
offset = offset + 1
NEXT
NEXT
NEXT
DEF SEG
SCREEN 13
x = mw * tw \ 2
y = mh * th \ 2
time! = TIMER
DO
'clear the key buffer
DEF SEG = 0
POKE (1050), PEEK(1052)
DEF SEG
'get keypress and handle it
SELECT CASE INP(96)
CASE 1: EXIT DO
CASE 72: y = y - 1
CASE 75: x = x - 1
CASE 77: x = x + 1
CASE 80: y = y + 1
END SELECT
sx.b = -(x MOD tw)
sy = -(y MOD th)
tx.b = x \ tw
ty = y \ th
DO
sx = sx.b
tx = tx.b
DO
t = map(tx, ty)
IF ((sx >= 0) AND (sy >= 0) AND (sx <= (screenw - tw)) AND (sy <= (screenh - th))) THEN
PUT (sx, sy), Tiles(0, t), PSET
ELSEIF ((sx >= 0) AND (sx <= (screenw - tw)) AND (sy > (screenh - th))) THEN
h = Tiles(1, t)
Tiles(1, t) = (screenh - sy)
PUT (sx, sy), Tiles(0, t), PSET
Tiles(1, t) = h
ELSE
tseg = VARSEG(Tiles(0, t))
toffset = VARPTR(Tiles(2, t))
IF sx < 0 THEN
px = 0
toffset = toffset - sx
w = tw + sx
woff = -sx
soff = screenw - (tw - woff)
ELSEIF sx > (screenw - tw) THEN
px = sx
w = screenw - sx
woff = (sx + tw) - screenw
soff = screenw - (tw - woff)
ELSE
w = tw
px = sx
soff = screenw - tw
woff = 0
END IF
IF sy < 0 THEN
py = 0
toffset = toffset - (sy * tw)
h = th + sy
ELSEIF sy > (screenh - th) THEN
py = sy
h = screenh - sy
ELSE
py = sy
h = th
END IF
soffset = CLNG(py) * screenw + px
FOR py = 1 TO h
'peek the scanline into a temp buffer
DEF SEG = tseg
FOR px = 1 TO w
scanline(px) = PEEK(toffset)
toffset = toffset + 1
NEXT
'poke the temp buffer onto the screen
DEF SEG = &HA000
FOR px = 1 TO w
POKE (soffset), scanline(px)
soffset = soffset + 1
NEXT
toffset = toffset + woff
soffset = soffset + soff
NEXT
END IF
tx = tx + 1
sx = sx + tw
LOOP UNTIL sx > 319
ty = ty + 1
sy = sy + th
LOOP UNTIL sy > 199
f = f + 1
IF (time! + 1) < TIMER THEN
fps$ = STR$(f)
time! = TIMER
f = 0
END IF
LOCATE 22: PRINT fps$
LOOP