Qbasicnews.com
alternative pset - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: Qbasic "like" compilers/interpreters (http://qbasicnews.com/newforum/forum-5.html)
+--- Forum: FB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-15.html)
+--- Thread: alternative pset (/thread-9033.html)



alternative pset - QbBasta - 03-17-2006

screen 18,16

sub basic(byval memory as integer ptr,byval x as integer,byval y as integer,byval c as integer)
dim index as integer
index = y shl 9 + y shl 7 +x 'y * 640 + x
memory[index]=c
end sub

dim as integer ptr videomemory

screenlock:videomemory=screenptr

basic videomemory,10,10,rgb(25,0,25)
basic videomemory,638,478,rgb(25,0,25)

Why do i get a error when i wanna draw a pixel further down on the screen?
This works in 32 bit mode, but not in 16 bit?!


alternative pset - 1000101 - 03-17-2006

Because you're memory type is the wrong size.

In 16-bit mode, then memory is SHORT not INTEGER.


alternative pset - QbBasta - 03-17-2006

tried with that, but it won't work..


alternative pset - d.j.peters - 03-17-2006

Code:
option explicit
sub set16(byval memory as ushort ptr,byval x as integer,byval y as integer,byval c as ushort)
  dim index as integer
  index = y shl 9
  index+= y shl 7
  index+= x
  memory[index]=c
end sub

sub set32(byval memory as integer ptr,byval x as integer,byval y as integer,byval c as integer)
  dim index as integer
  index = y shl 9
  index+= y shl 7
  index+= x
  memory[index]=c
end sub

#define bpp 16 ' or 32

#if bpp = 16
  dim as ushort  ptr videomemory
#else
  dim as integer ptr videomemory
#endif

screen 18,bpp

screenlock
videomemory=screenptr

#if (bpp = 32)
  set32 videomemory, 10, 10, &HFFFFFF
  set32 videomemory,320,240, &HFFFFFF
  set32 videomemory,629,468, &HFFFFFF
#else
  set16 videomemory, 10, 10,&HFFFF
  set16 videomemory,320,240,&HFFFF
  set16 videomemory,629,469,&HFFFF
#endif

screenunlock

sleep