Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Stonemonkey

Pages: [1] 2 3 4 5 6 7 8 ... 53
1
General chat / New 6502 based machine possibly.
« on: September 13, 2019 »
Hi all, how's everyone doing? Not been around for a long time so probably don't know many here. Hi Nick.
Something came up on YouTube, actually, I'd downloaded an emulator of my first computer and I've been attempting to do something on it so after looking some things up this guy came up as recommended and he's working on something I thought might be of interest here. He's designing a 6502 based machine and using currently available off the shelf chips for sound and graphics. It's still very much in the design phase and nothing is finalised but he goes into a fair bit of detail about it's current standing and his plans in part 2.

Part 1:
https://youtu.be/ayh0qebfD2g
Part 2:
https://youtu.be/sg-6Cjzzg8s

2
Game Showcase / Re: Andromeda Wing
« on: September 11, 2017 »
Even though I had an Amiga, I think I only ever played xenon 2 on the ST and even from such l long time ago I could see the influence on your game, looks great.

3
Projects / Re: starting with android
« on: September 05, 2017 »
Cool rbz, makes me wonder if there's a way parallax mapping could be used effectively in a sprite based game.

4
Projects / Re: starting with android
« on: September 05, 2017 »
Yep, it's fairly slow. A couple of areas to improve are height map traversal, at the moment it steps through the height map 1 step at a time. The other area is reworking it in inline asm, there is some asm but doing the whole inner loop should help things a bit.
I'll have a look at your work when I get home.

5
Projects / Re: starting with android
« on: September 03, 2017 »
Finally got round to porting this onto android, it works but is a bit slower than the pc version although some improvement should be possible. It's software rendered parallax mapping, each face of the cube is made of 2 tris with the depth effect created by the mapping.

Rotate your device onto its side to get fullscreen otherwise it'll be quite small.

When installing the apk, it will ask for permissions, the program does nothing dodgy but the app (c4droid) I'm using to write this automatically adds the permission requests.

https://drive.google.com/file/d/0B4tuUL8KZB7UR2ZCcld4S3hHYTg/view?usp=drivesdk

6
General chat / Re: The Welcoming Committee
« on: September 02, 2017 »
 :hi:

Good luck with getting back into the coding

7
I can imagine exactly what it's like, I used to build electronics stuff with various kits and breadboards. Mostly analog with some logic, never went as far as processors though.

It's surprising how simple the parallax mapping is to add, as long as your vectors are in texture space, it's just a case of casting the vector across each pixel until z>pixel height. Optimizing is more difficult and I've not really done that yet other than optimizing the loop as much as possible (using abrash's mmx trick for putting u and v together for texture lookup). But I need to look at the algorithm to see if there's any better way to speed it up.

The code is a huge mess but pm me if you want to have a look.

8
Hi nino, that project sounds pretty cool, ive always fancied trying putting some hardware together. Would be great to see your results.

The thing I'm working on, it was kind of by accident. I was working on normal mapping by transforming the light and camera vectors into texture space and interpolating them across the triangle for diffuse and specular lighting with a normal map mostly using SSE code. Then realised i had the camera vector in texture space and could raycast through the heightmap of the normal map, pretty much like casting through a voxel height terrain. Turns out it's very similar to parallax occlusion mapping done in pixel shaders.

9
Freebasic / Re: Dot Tunnel
« on: November 23, 2016 »
It's based on qbasic and I think you can still run qbasic code with some settings. It might depend how you code but I find it translates to c++ quite easily and writing in some assembly is pretty easy too.

10
Freebasic / Re: Dot Tunnel
« on: November 22, 2016 »
The'any' thing just means the value in memory isnt set at the declaration.

When you declare variables in a function, the compiler writes the function to take enough memory off the stack to store all the variables within a function, that part takes the same amount of time regardless of how many variables/arrays there are.  So there's no advantage to declaring global variables over local variables in a function.

But when there's something like this in a function

Dim as integer a,b

Then the function initialises them to 0 which has to be written into the memory the variable occupies.
However, using

Dim as integer a=any,b=any

When you dont care what the value is (in the code above, screeninfo writes the screen dimensions into the variables) you can use'any' and it just leaves whatever garbage is in the memory location.

The compiler also shares memory locations between variables in different scopes (inside FOR/NEXT WHILE/WEND IF/THEN/ENDIF etc.) and you can see what's where using any, I wouldn't recommend relying on such a thing to share data between scopes though.

Code: [Select]
sub test
    scope
        dim as integer a=123,b=456
    end scope
   
    scope
        dim as integer x=any,y=any
        print "any:  "x;":";y
    end scope
   
    scope
        dim as integer s,t
        print s;":";t
    end scope
end sub

test
sleep
end

my use of it there won't have much impact but there are times with declaring arrays or allocating memory where it could have a larger impact but you have to be sure that you're not relying on any element within an array or chunk of memory being zero initially.

11
Freebasic / messing around with dot tunnel code
« on: November 22, 2016 »
what started out as meant to be some sort of tunnel code but with some modification. No idea what it is.

Code: [Select]
const pi2=3.141592*2.0

type star
as single x,y,z
as ulong colour(0 to 100),shade
as single radius
as single num_points
end type

type starfield
as integer num_stars
as star ptr star_list
as single max_z,min_z,z_speed
as ulong colourmap(0 to 255)
as ulong colourindex(0 to 100)
as ulong colourdelta(0 to 100)
end type

function create_starfield(byval num_stars as integer,_
byval radius as single,_
byval num_points as single,_
byval max_z as single,_
byval min_z as single,_
byval z_speed as single)as starfield ptr
dim as starfield ptr starfield=new starfield
starfield->star_list=new star[num_stars]
for star as integer=0 to num_stars-1
starfield->star_list[star].radius=radius+radius*sin(star/num_stars*pi2)
starfield->star_list[star].num_points=num_points
starfield->star_list[star].z=min_z+((max_z-min_z)/num_stars)*star
next
starfield->max_z=max_z
starfield->min_z=min_z
starfield->z_speed=z_speed
starfield->num_stars=num_stars
for i as integer=0 to 255
    dim as ulong red,gre,blu
    red=128+127*sin(i/256.0*3.141592*4)
    gre=128+127*sin(i/256.0*3.141592*2)
    blu=128+127*cos(i/256.0*3.141592*2)
    starfield->colourmap(i)=(red shl 16)or(gre shl 8) or blu
next
for i as integer=0 to 100
    starfield->colourindex(i)=rnd*&hffff
    starfield->colourdelta(i)=rnd*&hfff
next
return starfield
end function

sub process_starfield(byval starfield as starfield ptr)
static as single angle=0
static as single amplitude_angle=0
static as single horizontal_angle=0
static as single vertical_angle=0
for star_count as integer=0 to starfield->num_stars-1
dim as star pointer star=@starfield->star_list[star_count]
star->z-=starfield->z_speed
star->x+=(rnd-.5)*10.0
star->y+=(rnd-.5)*10.0
star->shade=(star->shade*&hfa)shr 8
if star->z<starfield->min_z then
    for i as integer=0 to star->num_points-1
        star->colour(i)=starfield->colourmap(starfield->colourindex(i) shr 8)
        'starfield->colourindex(i)=(starfield->colourindex(i)+starfield->colourdelta(i))and &hffff
    next
   
star->shade=&hffff
star->z+=starfield->max_z-starfield->min_z
star->x=(100+300*sin(amplitude_angle))*sin(angle)+300*sin(horizontal_angle)
star->y=(100+300*sin(amplitude_angle))*cos(angle)+300*sin(vertical_angle)

angle+=0.01
amplitude_angle+=.0086
horizontal_angle+=.013
vertical_angle+=0.0043

end if
next

    for i as integer=0 to 100
        'star->colour(i)=starfield->colourmap(starfield->colourindex(i) shr 8)
        starfield->colourindex(i)=(starfield->colourindex(i)+starfield->colourdelta(i))and &hffff
    next
   
end sub

sub draw_starfield(byval starfield as starfield pointer)
dim as integer w=any,h=any
screeninfo (w,h)
for star_count as integer=0 to starfield->num_stars-1
dim as star pointer star=@starfield->star_list[star_count]
for p as single=0 to star->num_points-1
dim as single x=(w shr 1)+w*(star->x+star->radius*sin(p*pi2/star->num_points))/star->z
dim as single y=(h shr 1)-w*(star->y+star->radius*cos(p*pi2/star->num_points))/star->z
dim as ulong c=star->shade shr 8
dim as ulong col=star->colour(p)
pset (x,y),((((col and &hff00ff)*c)and &hff00ff00)or(((col and &hff00)*c)and &hff0000))shr 8
next
next
end sub

sub main
screenres 640,480,32,2
screenset 0,1
dim as starfield ptr starfield=create_starfield(300,400,7,2000,10,50)
for i as integer=0 to 1000
process_starfield(starfield)
next
dim as single t=timer
while inkey<>chr(27)
    while t<timer
        process_starfield(starfield)
        t+=0.02
        wend
draw_starfield(starfield)
flip
cls
wend
end sub

main

or

Code: [Select]
const pi2=3.141592*2.0

type star
as single x,y,z,rotation
as ulong colour(0 to 100),shade
as single radius
as single num_points
end type

type starfield
as integer num_stars
as star ptr star_list
as single max_z,min_z,z_speed
as ulong colourmap(0 to 255)
as ulong colourindex(0 to 100)
as ulong colourdelta(0 to 100)
end type

function create_starfield(byval num_stars as integer,_
byval radius as single,_
byval num_points as single,_
byval max_z as single,_
byval min_z as single,_
byval z_speed as single)as starfield ptr
dim as starfield ptr starfield=new starfield
starfield->star_list=new star[num_stars]
for star as integer=0 to num_stars-1
starfield->star_list[star].radius=radius+radius*sin(star*pi2/num_stars)
starfield->star_list[star].rotation=star*pi2/num_stars*2
starfield->star_list[star].num_points=num_points
starfield->star_list[star].z=min_z+((max_z-min_z)/num_stars)*star
next
starfield->max_z=max_z
starfield->min_z=min_z
starfield->z_speed=z_speed
starfield->num_stars=num_stars
for i as integer=0 to 255
    dim as ulong red,gre,blu
    red=128+127*sin(i/256.0*3.141592*4)
    gre=128+127*sin(i/256.0*3.141592*2)
    blu=128+127*cos(i/256.0*3.141592*2)
    starfield->colourmap(i)=(red shl 16)or(gre shl 8) or blu
next
for i as integer=0 to 100
    starfield->colourindex(i)=rnd*&hffff
    starfield->colourdelta(i)=rnd*&hfff
next
return starfield
end function

sub process_starfield(byval starfield as starfield ptr)

static as single angle=0
static as single amplitude_angle=0
static as single horizontal_angle=0
static as single vertical_angle=0
for star_count as integer=0 to starfield->num_stars-1
dim as star pointer star=@starfield->star_list[star_count]
star->z-=starfield->z_speed
star->x+=(rnd-.5)*10.0
star->y+=(rnd-.5)*10.0
star->shade=(star->shade*&hf0)shr 8
if star->z<starfield->min_z then
    for i as integer=0 to star->num_points-1
        star->colour(i)=starfield->colourmap(starfield->colourindex(i) shr 8)
        'starfield->colourindex(i)=(starfield->colourindex(i)+starfield->colourdelta(i))and &hffff
    next
   
star->shade=&hffff
star->z+=starfield->max_z-starfield->min_z
star->x=(100+300*sin(amplitude_angle))*sin(angle)+300*sin(horizontal_angle)
star->y=(100+300*sin(amplitude_angle))*cos(angle)+300*sin(vertical_angle)

angle+=0.01
amplitude_angle+=.0086
horizontal_angle+=.013
vertical_angle+=0.0043

end if
next

    for i as integer=0 to 100
        'star->colour(i)=starfield->colourmap(starfield->colourindex(i) shr 8)
        starfield->colourindex(i)=(starfield->colourindex(i)+starfield->colourdelta(i))and &hffff
    next
   
end sub

sub draw_starfield(byval starfield as starfield pointer)
dim as integer w=any,h=any
screeninfo (w,h)
for star_count as integer=0 to starfield->num_stars-1
dim as star pointer star=@starfield->star_list[star_count]
for p as single=0 to star->num_points-1
dim as single x=(w shr 1)+w*(star->x+star->radius*sin(star->rotation+p*pi2/star->num_points))/star->z
dim as single y=(h shr 1)-w*(star->y+star->radius*cos(star->rotation+p*pi2/star->num_points))/star->z
dim as ulong c=star->shade shr 8
dim as ulong col=star->colour(p)
pset (x,y),((((col and &hff00ff)*c)and &hff00ff00)or(((col and &hff00)*c)and &hff0000))shr 8
next
next
end sub

sub main
screenres 640,480,32,2
screenset 0,1
dim as starfield ptr starfield=create_starfield(800,180,12,1000,10,10)
for i as integer=0 to 1000
process_starfield(starfield)
next
dim as single t=timer
while inkey<>chr(27)
    while t<timer
        process_starfield(starfield)
        t+=0.02
        wend
draw_starfield(starfield)
flip
cls
wend
end sub

main


12
Freebasic / Re: Dot Tunnel
« on: November 22, 2016 »
Here's a quick example of the sort of way I would do it, it's maybe not exactly the sort of dot tunnel you're after but it should be easy to modify although everyone's got different styles of coding.

Code: [Select]
const pi2=3.141592*2.0

type star
    as single x,y,z
    as single radius
    as single num_points
end type

type starfield
    as integer num_stars
    as star ptr star_list
    as single max_z,min_z,z_speed
end type

function create_starfield(byval num_stars as integer,_
                            byval radius as single,_
                            byval num_points as single,_
                            byval max_z as single,_
                            byval min_z as single,_
                            byval z_speed as single)as starfield ptr
    dim as starfield ptr starfield=new starfield
    starfield->star_list=new star[num_stars]
    for star as integer=0 to num_stars-1
        starfield->star_list[star].radius=radius
        starfield->star_list[star].num_points=num_points
        starfield->star_list[star].z=min_z+((max_z-min_z)/num_stars)*star
    next
    starfield->max_z=max_z
    starfield->min_z=min_z
    starfield->z_speed=z_speed
    starfield->num_stars=num_stars
    return starfield
end function

sub process_starfield(byval starfield as starfield ptr)
    static as single angle=0
    static as single amplitude_angle=0
    static as single horizontal_angle=0
    static as single vertical_angle=0
    for star_count as integer=0 to starfield->num_stars-1
        dim as star pointer star=@starfield->star_list[star_count]
        star->z-=starfield->z_speed
        if star->z<starfield->min_z then
            star->z+=starfield->max_z-starfield->min_z
            star->x=(100+300*sin(amplitude_angle))*sin(angle)+300*sin(horizontal_angle)
            star->y=(100+300*sin(amplitude_angle))*cos(angle)+300*sin(vertical_angle)
        end if
    next
    angle+=0.1
    amplitude_angle+=.086
    horizontal_angle+=.03
    vertical_angle+=0.043
end sub

sub draw_starfield(byval starfield as starfield pointer)
    dim as integer w=any,h=any
    screeninfo (w,h)
    for star_count as integer=0 to starfield->num_stars-1
        dim as star pointer star=@starfield->star_list[star_count]
        for p as single=0 to star->num_points-1
            dim as single x=(w shr 1)+w*(star->x+star->radius*sin(p*pi2/star->num_points))/star->z
            dim as single y=(h shr 1)-w*(star->y+star->radius*cos(p*pi2/star->num_points))/star->z
            pset (x,y),&hffffff
        next
    next
end sub

sub main
    screenres 640,480,32,2
    screenset 0,1
    dim as starfield ptr starfield=create_starfield(800,200,50,100000,10,100)
'dim as starfield ptr starfield=create_starfield(400,200,50,2000,10,60)
    for i as integer=0 to 1000
        process_starfield(starfield)
    next
    while inkey<>chr(27)
        process_starfield(starfield)
        draw_starfield(starfield)
        flip
        cls
    wend
end sub

main

13
Projects / Re: starting with android
« on: November 19, 2016 »
It's software.

Since I was already interpolating the camera/eye vector in texture space for the normal mapping, the parallax mapping was relatively simple to do and once I'd done it I realised it's pretty much like tracing through a voxel landscape. At the moment I'm stepping through the heightmap 1 element at a time and doing that for every pixel and that slows things down, so I'm looking around for ways to speed that up a bit.

14
Freebasic / Re: Dot Tunnel
« on: November 18, 2016 »
Pointers in freebasic are useful, but when plotting arbitrary pixels there's no point in getting the pointer then writing in that way. If you're plotting a row of consecutive pixels then it is much faster to get the pointer to the first pixel then to move the pointer to the next pixel just by adding 1 to it (the compiler knows that ulong (or uinteger on 32bit FB) is 4 bytes and adds 4 on to the pointer even though you've added 1. It does that for all data types:

dim as ubyte ptr b=some address
b+=1 'adds 1 on to the pointer

dim as ushort ptr s=some address
s+=1 'adds 2 on to the pointer

dim as ulong ptr l=some address
l+=1 'adds 4 on to the pointer

and it does it for UDTs too so it can speed up going through arrays in critical parts of code so your program isnt having to re-calculate addresses over and over.

Don't worry too much about making use of that though, get your stuff working well first then think about optimising with ideas like that later.

15
Freebasic / Re: Dot Tunnel
« on: November 18, 2016 »
cool stuff, not quite sure about the put pixel routine you have there, just do

buffer(y * screenWidth + x) =col

inside the bounds checking but without the pointer and asm stuff.

The buffer array (and all other variables for storing colours) should be ulong type, when it's signed funny things can happen with some colour processing, and ulong instead of uinteger to keep them 64 bit users happy.

16
Projects / Re: starting with android
« on: November 18, 2016 »
This is a slightly upgraded version of what I posted in what are you working on, Ive improved the stepping for the parallax occlusion mapping but might be able to improve that some more and optimise other areas a bit. It's in freebasic but I'm intending on porting it over to android c++ later. Not sure what else to try to get it to do at the moment.

17
I'm working on this.

18
Freebasic / Re: Fractal Zoomer
« on: November 10, 2016 »
You could probably speed the sse asm up a bit, the first part where dx1 and dy1 are squared could be done in parallel and then added horizontally with haddps, keeping z1 and z2 in the registers might help too. There will be other things but ive not looked too closely yet.

That kind of thing's only going to take you so far in speeding things up, for any possible significant gains you have to look at the algorithm itself and it'll be easier to do that with the code in FB rather than asm.


19
Projects / Re: Lots more remakes
« on: September 29, 2016 »
Yep, I would say competitiveness to push what they could out of more standard hardware drove a lot forward and things have changed with everyone having varying hardware, there's maybe still a similar philosophy with some categories like 4k or 64k though.

20
Projects / Re: starting with android
« on: September 11, 2016 »
Lol, I'm not sure if it is good. I started making it before using blitz basic and had it working although the graphics were just some dodgy placeholders. I posted it somewhere, maybe here, with 4 or 5 levels but i must've made them too hard for starting off with so no one really knew what to do.

Ive tried you two off the play store, nice work, that hopping one is really frustrating. My PC's pretty knackered at the moment so i dont use it for much and I'm just on android most of the time.

Pages: [1] 2 3 4 5 6 7 8 ... 53