Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Doom 1 render
#1
I wanted to do a little toy Doom1 style render, completely in software. However gfxlib's pset command is a little slow. Does anyone have a remedy for it? Also, how would I use inline asm to fill an array?
am part of the legion of n00b. We are numerous if dumb. We will enslave you all!
Reply
#2
Code:
screen 13

dim shared as integer screen_x, screen_y
screeninfo screen_x, screen_y

dim p as ubyte ptr ' 8 bits for 8-bit color ;p

dim as integer x = 200
dim as integer y = 100
dim as integer col = 15

p = screenptr

screenlock
  p [( y * screen_x ) + x] = col

screenunlock

not tested. use a pointer to a data type ( color_depth \ 8 )

dunno asm ;P
Reply
#3
so..umm...does anyone have any ideas on how to do the asm thing?
am part of the legion of n00b. We are numerous if dumb. We will enslave you all!
Reply
#4
Cha0s's code with Inline assembler:
Code:
screen 13

dim shared as integer screen_x = 320, screen_y = 200
screeninfo screen_x, screen_y

dim p as ubyte ptr ' 8 bits for 8-bit color ;p

dim as integer x = 200
dim as integer y = 100
dim as integer col = 15

p = screenptr

screenlock
'  p [( y * screen_x ) + x] = col
' Ported to assembler:
' for more speed, try a look up table instead of mul
asm
    mov edi, [p]
    mov eax, [screen_x]
    mul dword ptr [y]
    add eax, [x]
    mov dl, [col]
    mov [edi+eax], dl
end asm

screenunlock
Reply
#5
So if I wanted to extract info from a 1d array I'd just find the pointer to it then use it like in the code?
am part of the legion of n00b. We are numerous if dumb. We will enslave you all!
Reply
#6
Quote:So if I wanted to extract info from a 1d array I'd just find the pointer to it then use it like in the code?
Sure, the above asm would work for a 2d array of bytes. For a 1d array, or something other than bytes, the asm needs to be modified slightly. It would also need to be changed to extract instead of overwrite data in the array.
Reply
#7
http://rel.betterwebber.com/junk.php?id=29

Warning: Code is FB pre-beta release. :*)
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)