Main Menu
Menu

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.

Show posts Menu

Messages - jaymzjulian

#1
Game Swap / Re: VxTron32 release 1.0
August 10, 2020, 01:31:24 AM
Release 1.2
-------------

Changes:
* Settings are saved into vxtron_settings.dat , so you don't have to remember them every game
* A bug was fixed in the AY player timing where it would wait unnecessarily for 10 ticks in a couple of edge cases - this should prevent a couple of frame rate drops only noticable to me ;)

Beyond that, nothing is interesting in this release - I found the player bug while finishing up my new game (running very late due to personal life reasons - yay - but should be finished in the next week or two!), and thought i'd add the settings save at the same time.

EDIT: the file is attached to the first post, so people don't get the old version by mistake! - the versions are at:

https://duckandkitty.com/vxtron32_1.2.zip
https://duckandkitty.com/vxtron32_1.1.zip

Since i can't leave both attached due to forum size limits ;)
#2
Code Swap / Lit/Culled 3d objects
August 06, 2020, 11:25:11 AM
So I was playingh aroundw ith ways to reduce my draw load, and I kind of fell back to some experiements I did a while ago about culling - the problem at the time being, gsbasic isn't fast enough to really do what I needed without me running out of cycles.

But then I had the idea to use kmeans clustering to quantize the normals to a smaller number - 6, in the case of the demo presented here - and do the culling and lighting on larger sets of polys instead.  Shockingly, this actually works out.  So the procedure ends up being:

a) Generate a set of lines and normals via "some mechanism" (I have a couple of mechanisms for this, one of which involves blender, and one of which involves generating the normals from the lines assuming the objects are vaugely built arounda center)
b) Reduce these set of normals to clusters - I'm using python's sklearn.cluster.KMeans for that!
c) in gsbasic, use vectorrotate and friends to transform the normal set - of course, you need to do the world translate/rotate as well - i.e. consider the camera!  But that's well within the realms of achievable now....

So you end up with an array of objects which happen to mesh together.  There is a couple of serious downsides this this technique, mind you:

a) because the objects aren't linked anymore, there is extra ReturnToOrigin() calls!  indeed, drawing this tree returns to origin 6 times..... we can't easily avoid this, because even if we did relative pen movement things, we don't know if part of the obhect will be drawn until the math is done!
b) things do look better if your object is made of polys rather than lines at the outset, however then you have double-draw issues.  Blender is actually really good at creating normals that don't suffer this, mind you.... essentially if you have "smooth" point normals (as are genearted by the smooth object modifier), it works out well, whereas if you have "flat" surface normals, it doens't work out so well unless you double draw edges, defeating the point of what we're trying to do here.  Of course, there is no reason NOT to smooth your normals when the object isn't filled, so..... it actually doens't matter as much as you'd think... (after all, there is no fill, hence no gouroud shading/phong shading to deal with!)


So you end up with the attached demo.  I did also attach the python I use to generate that set - it's inputs are kind of very specific, though, it's absolutely not yet a generic tool, but i figured the technique was at least worth sharing!
#3
Code Swap / Cubic interpolation
July 09, 2020, 04:39:55 PM
Everyone needs to interpolate, right?  I use this for pathing:


function cubic_interpolate(a,b,c,d,t)
  ia = -a / 2.0 + (3.0*b) / 2.0 - (3.0*c) / 2.0 + d / 2.0
  ib = a - (5.0*b) / 2.0 + 2.0*c - d / 2.0
  ic = -a / 2.0 + c / 2.0
  id = b
  return ia*t*t*t + ib*t*t + ic*t + id
endfunction


or a faster version:

function fast_cubic(a,b,c,d,t)
  return (-a / 2.0 + (3.0*b) / 2.0 - (3.0*c) / 2.0 + d / 2.0)*t*t*t + (a - (5.0*b) / 2.0 + 2.0*c - d / 2.0)*t*t + (-a / 2.0 + c / 2.0)*t + b
endfunction


fast point in a 2d dot array via inlining:
(doing 512 of these takes 360 ticks, vs 628 ticks if you call functions instead!)

      a = land[((sy-1) & (dot_horizon-1))+1, ((sx-1) & (dot_horizon-1))+1]
      b = land[((sy) & (dot_horizon-1))+1, ((sx-1) & (dot_horizon-1))+1]
      c = land[((sy+1) & (dot_horizon-1))+1, ((sx-1) & (dot_horizon-1))+1]
      d = land[((sy+2) & (dot_horizon-1))+1, ((sx-1) & (dot_horizon-1))+1]
      ya = (-a / 2.0 + (3.0*b) / 2.0 - (3.0*c) / 2.0 + d / 2.0)*yoffset*yoffset*yoffset + (a - (5.0*b) / 2.0 + 2.0*c - d / 2.0)*yoffset*yoffset + (-a / 2.0 + c / 2.0)*yoffset + b

      a = land[((sy-1) & (dot_horizon-1))+1, ((sx) & (dot_horizon-1))+1]
      b = land[((sy) & (dot_horizon-1))+1, ((sx) & (dot_horizon-1))+1]
      c = land[((sy+1) & (dot_horizon-1))+1, ((sx) & (dot_horizon-1))+1]
      d = land[((sy+2) & (dot_horizon-1))+1, ((sx) & (dot_horizon-1))+1]
      yb = (-a / 2.0 + (3.0*b) / 2.0 - (3.0*c) / 2.0 + d / 2.0)*yoffset*yoffset*yoffset + (a - (5.0*b) / 2.0 + 2.0*c - d / 2.0)*yoffset*yoffset + (-a / 2.0 + c / 2.0)*yoffset + b

      a = land[((sy-1) & (dot_horizon-1))+1, ((sx+1) & (dot_horizon-1))+1]
      b = land[((sy) & (dot_horizon-1))+1, ((sx+1) & (dot_horizon-1))+1]
      c = land[((sy+1) & (dot_horizon-1))+1, ((sx+1) & (dot_horizon-1))+1]
      d = land[((sy+2) & (dot_horizon-1))+1, ((sx+1) & (dot_horizon-1))+1]
      yc = (-a / 2.0 + (3.0*b) / 2.0 - (3.0*c) / 2.0 + d / 2.0)*yoffset*yoffset*yoffset + (a - (5.0*b) / 2.0 + 2.0*c - d / 2.0)*yoffset*yoffset + (-a / 2.0 + c / 2.0)*yoffset + b

      a = land[((sy-1) & (dot_horizon-1))+1, ((sx+2) & (dot_horizon-1))+1]
      b = land[((sy) & (dot_horizon-1))+1, ((sx+2) & (dot_horizon-1))+1]
      c = land[((sy+1) & (dot_horizon-1))+1, ((sx+2) & (dot_horizon-1))+1]
      d = land[((sy+2) & (dot_horizon-1))+1, ((sx+2) & (dot_horizon-1))+1]
      yd = (-a / 2.0 + (3.0*b) / 2.0 - (3.0*c) / 2.0 + d / 2.0)*yoffset*yoffset*yoffset + (a - (5.0*b) / 2.0 + 2.0*c - d / 2.0)*yoffset*yoffset + (-a / 2.0 + c / 2.0)*yoffset + b

      return (-ya / 2.0 + (3.0*yb) / 2.0 - (3.0*yc) / 2.0 + yd / 2.0)*xoffset*xoffset*xoffset + (ya - (5.0*yb) / 2.0 + 2.0*yc - yd / 2.0)*xoffset*xoffset + (-ya / 2.0 + yc / 2.0)*xoffset + yb
#4
Game Swap / Re: VxTron32 release 1.0
June 18, 2020, 05:13:51 PM
I'll give some consideration to both of these points.

On the speed thing, I was actually inclined to _increase_ the default - I dropped it back to the current level as a concession, but it's generally agreed in my household that it's more fun at the next fastest setting.  But, to be fair, they've had to put up with the game for a while ;).  But, if it makes the game inaccessible, then I possibly need to change it...  I thought about maybe dropping the speed back if your last game was less than N seconds, which is a possibility, and speed it up if things are the other way. 

On the title screen, I like the effect, but you're not the first to suggest that maybe it should be changed, so perhaps that is correct.... i'm deliberately drawing only part of it each frame because I like the effect of it doing that, so maybe I could have it draw even less per frame and reduce other flickering.  I don't find it a problem myself, but myself is not all people... i definitely hate it _without_ the background there (screen looked boring).  But maybe i'll try it again.
#5
Quote from: Vectrex32 on June 17, 2020, 09:32:41 PM
Tough choice. I'd like to see Wizard just to hear the speech. But an Infinite Runner game would be good for the 3D.

So I vote for an Infinite Runner game with speech! (What part of "write something small" do I not understand? :-) )

- Bob

Well, honestly, the speech engine is done, so that part is simple - even the explosion sound effects are generated the same way (I will open source that generator once I clean it up a bit!).  I've actually already written the music for the infinite runner game, too, so that part exists
#6
So I've decided to write something _small_, that i can knock out in a week or three, as a palette cleanser before trying to finish one of my other bigger games.  Which one should I do?

reference:
https://www.youtube.com/watch?v=dedw3Ji-6kE <-- this is crazy comets
https://www.youtube.com/watch?v=9Lodc0kFYuo <-- this is wizard of wor
#7
Game Swap / Re: VxTron32 release 1.0
June 17, 2020, 08:55:46 PM
Quote from: Vectrex32 on June 17, 2020, 08:32:03 PM
Stunning! Absolutely stunning! And the "vocalized" countdown is brilliant!

I die really fast in this game. I'm going to need to work at it.

- Bob

Yeah, that's why there's a speed option :)  You're not the first to suffer that....  one thought i did have, is maybe we need a way to write to the flash and save an options file, so you don't have to reset that every reboot. 

also, increasing the arena size can help with that - once you get away from the pack, you've got more room to maneuver
#8
Game Swap / Re: VxTron32 release 1.0
June 17, 2020, 08:51:03 PM
update: the uploaded zip had a corrupted music player caused by the basic combiner (playback was at 70% speed) - oops :).  I've attached a v1.1 with music that plays at the correct speed....
#9
Game Swap / VxTron32 release 1.0
June 17, 2020, 07:59:15 PM
So one near complete rewrite later, here's VxTron32 - as 3d tron game for the vectrex 32.  For the most part, it contains what it says on the tin - it's the tron light cycles game, for one or two players.  It also contains ducks.

https://www.youtube.com/watch?v=K1_07VBNwOY
another: https://www.youtube.com/watch?v=T2bl8Syi6VA

Controls for one player (third person):

joystick - move camera
button 1 - turn left
button 2 - turn right
button 3 - zoom camera in
button 4 - zoom camera out

Controls for one player (first person):

button 1 - turn left
button 2 - turn right
button 3 - peek left
button 4 - peek right

Controls for two players on one controller:

button 1 - turn left
button 2 - turn right
button 3 - turn left (player 2)
button 4 - turn right (player 2)

Un-combined source is at https://github.com/jaymzjulian/vltron

ProTip: Generally I watch the map more than the 3d display when trying to judge distance, because there is still an amount of vector drift.  You can totally play it in pure 3d, and sometimes I do, but it helped me, at least!  That applies less in first person mode....

There is theoretical support for two players on two controllers, however since I don't own two controllers, who knows if it works.  I'll put out a patch release if it does not....

Note: You need to copy all of the files in the zip to your vectrex32 for this to run (except the README.md, it doesn't read that ;)) since, in order to conserve memory, certain items are streamed from the storage.

(My next game will definitely not take six months ;))
#10
Code Swap / Re: Object Explosion Generator
May 29, 2020, 08:34:56 PM
Quote from: Vectrex32 on May 29, 2020, 08:44:03 AM
If you look up "Parkinson's Law of Data", there's a picture of you. ;-)

I'm basically a toddler - if there's a limit, i can't resist pushing at it to see where it breaks!
#11
So I keep running out of memory (this is what i get for starting to have animations, right ;)), which kind of sucks, but then it occurred to me that having a second copy of the data for my sprites in memory was kind of a problem..... and indeed, this got me back to being able to boot into the game, so I though i'd share it:


function reado32(filename)
  file = fopen(filename, "rt")
  dimensions = Int(Val(fgets(file)))
  command_count = Int(Val(fgets(file)))
  print "Reading "+command_count+"commands of "+dimensions+"d object from "+filename
  dim o[command_count, dimensions + 1]
  for j = 1 to command_count
    o[j, 1] = Int(Val(fgets(file)))
    for k = 1 to dimensions
      o[j, k+1] = Val(fgets(file))
    next
  next
  print "done!"
  return o
endfunction



The format is:
[dimensions]
[commands]
... and then [commands] list of comamnds.  I formed my test file by taking a function, and doing:

cat lightcycle.bai | sed 's/MoveTo/0/g' | sed 's/DrawTo/1/g' | sed 's/,/\r/g' | sed 's/\{/\r/g' | sed 's/}/\r/g' | sed 's/_/\r/g' | sed '/^ *$/d' > lightcycle.o32
and then filling in my dimensions(3) and vertex count (145) at the top of the file, resulting in:


3
145
0
-0.284963
-0.242065
1.085209
1
-0.284963
-0.550938
1.394082
1
-0.452639
-0.242065
1.394082
1
-0.284963
-0.242065
1.702956
#12
Code Swap / Re: Object Explosion Generator
May 29, 2020, 04:33:07 AM
Back doing vectrex stuff again, finally - when i went to integrate this into a game, i found that it could cause frame rate drops if you had complex objects (specifically, the 220 vertex cycles in vxtron) - if i exploded 1, it was fine, if i exploded 2 at once, the framerate started dropping way back.  So I added a cached mode for the ram tradeoff.


' grab 2 seconds worth of explosion - 40frams @ 20 fps                                                                  ' Note that generating more than about 10k verticies _will_ break things - for this demo, our object is
' 220 broken vertificies - this means it tkaes 220*30*4 array entries for this, or 26400 array entries for
' this precalc - so on large objects, essentially be careful!  Especially since you need to multiply that also
' out due to them being 4byte floats/ints - so after 52 frames, the v32 runs out of ram in the generation phase.
' I suspect that's also some not-so-great GC, since we use a bunch of deepcopy stuff in there, BUT... still,
' that's 183kbytes of data at that point, which DOES match with my expectations about what the v32 can handle!
'
' So the short version is, be careful about your frame rates ;)
call fill_cache(ce, 40, 20)


Then in your loop

' grab explosion based off timer
new_data = cached_explosion(ce)
' and display it!
Lines2dSprite(new_data)



It's in the vectrex32_tools github @ https://github.com/jaymzjulian/vectrex32_tools.
#13
Code Swap / Re: Easing Demo
May 08, 2020, 04:35:24 PM
Oh hey, cool - i hadn't seen that site before, either, quite useful :)
#14
General Discussion / Re: Vectrex32 and Max MSP
April 11, 2020, 08:26:08 PM
Another sample: https://github.com/jaymzjulian/vectrex32_vstemu - this implements the v.st vector generator protocol over serialusb.  I can run the processing demos with it, but i'm still trying to build vectormame.  I'll post a video if i ever manage to make that part work..... dunno if the serial will be usefully fast enough, but i guess we'll see!

I'm using https://github.com/geoffmeyers/interceptty to watch the serial instead now - so i load in my terminal, disconnect that, then run ./interceptty -e 13 -l -f char /dev/ttyS3 to see any output the v32 gives me when I messed up my code (I always messed up my code ;))

#15
General Discussion / Re: Vectrex32 and Max MSP
April 09, 2020, 01:06:32 AM
One more piece of advice on this - I'l actually doing some experimenting with serial today (implmenting a v.st vector protocol parser, so i can play star wars ;)), and I found of course, that two people not being able to be on the serial at once was a problem.  particularly, you can't debug ;).

I did find a tool around this though, which is i installed a driver that lets me share a serial port between two applications - https://www.eltima.com/article/share-com-port-between-apps/ .  others might have a better solution though!