[ / / / / / / / / / / / / / ] [ dir / animu / arepa / asmr / cafechan / hypno / leftpol / sw / vg ][Options][ watchlist ]

/tech/ - Technology

You can now write text to your AI-generated image at https://aiproto.com It is currently free to use for Proto members.
Name
Email
Subject
Comment *
File
Select/drop/paste files here
Password (Randomized for file and post deletion; you may also set your own.)
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Expand all images

File (hide): c206aaa536ffa5c⋯.webm (2.55 MB, 730x486, 365:243, part3.webm) (h) (u) [play once] [loop]

[–]

 No.922852[Watch Thread][Show All Posts]

I'm making a C64 demo and I'm working on one specific part and I'd appreciate some help. I can't figure out how to rotate an image on the X axis. Let me explain how this effect works first.

It's what is called on the C64 a FPP effect (flexible pixel position) meaning you can display any line of graphics on any line on the screen. My effect covers 120 lines of the screen and the graphics (the font of the scrolltext) is 21 lines high.

So I have a 120 bytes (actually 256 but the 121-255 bytes are unused) array and the values stored there decide on the line of graphics to be displayed. So, if you just put there 0,1,2,3,4,5.... you'll have a normal image. If you do 0,0,1,1,2,2,3,3,4,4... it will be double height. If you do 0,1,0,2,0,3,0,4,0,5.... you will make 1 pixel gaps between lines (blinds effect ?)

Now with this setup it's possible to make a pseudo 3D effect. By calculating which lines are displayed on the screen you can rotate the image on the Y axis. Do that 2 times and You can display 2 sides of the virtual cube. That's my problem, I can't come up with this algorithm. If you look on the internet for such things you will find tutorials or academic papers on rotation of bitmaps and such, but these are exact pixel perfect calculations, obviously this is not what I need or even could calculate in real time on the Commodore... It's just a manipulation of the lines order. Any ideas ?

video related, it's what I have right now (stretching, blinds)

I can describe some other C64 effects if someone's interested.

 No.922861>>922862

Can't you just oscillate the vertical scale using a plain sin function / some other function which bounces between 1 and -1?

You would also need to make sure that the text is always vertically centered too.


 No.922862>>922866

I'll explain this FPP routine. FPP itself is a fucking clever trick, but all the magic is still in these tables.

On C64 you have 8 sprites and they have their registers like X/Y position, double width, double height, the color etc. Sprites are 24x21 pixels. There's a bug in the VIC that allows you to stretch the sprites. It's done be just turning on and off the double width register for the sprite you want to stretch, it will display the same line again, not incrementing the pointer that points to the new line of graphics. Why exactly it works like this you can read in the VIC article (among other things about the VIC)

http://www.zimmers.net/cbmpics/cbm/c64/vic-ii.txt

So what do you do with that ? You can line up 8 sprites and stretch them for however you want (set / unset double width register on every line) but that will just display the same line of graphics on the same screen. But... you can change the pointer to the sprite graphics on every line too. So you stretch (like I do for 120 lines) and on every line you change the sprite pointer to one of 21 sprites. Each of these 21 sprites has it's first line filled with graphics, the rest is blank. (C64 effects fragment your memory like motherfucker !) So now by selecting on of the 21 sprites you can pick any line of graphics on any line on the screen. But that's for one sprite, we want more, preferably all of them. How ?

You place 8 sprites next to each other, each 1 pixel higher. and you start doing the FPP routine at the line where sprite 1 begins.

Now you are stretching the 1st line of sprite 1, second line of sprite 2, third line of sprite 3 etc... Now you can prepare 21 sprites where the first 8 lines are the lines of graphics for your 8 sprites and you can do a 8 pixel wide graphic that way ! For this effect I have to read the font and create such sprites on the fly.

>>922861

Why do you post 3 times ? Keep in mind I am on a 8 bit CPU without any multiplification or division. I also have about 10-15% of the CPU time to calculate this table, the rest is spent on the basic effect and updating the font.


 No.922866>>922867

>>922862

>Why do you post 3 times ?

I edited my post twice to be more specific. Refresh the page and the other two will disappear.

If you want to rotate along the X axis, you need to be able to stretch vertically. Figure out yourself how to accomplish that; drawing a subset of lines that is centered vertically.

>Keep in mind I am on a 8 bit CPU

Not my problem you chose weak hardware to make this on even though better hardware is available for low prices.


 No.922867>>922884 >>922885

File (hide): ccfb57ebfa166ac⋯.webm (1.77 MB, 730x486, 365:243, bosse.webm) (h) (u) [play once] [loop]

>>922866

I can stretch vertically just fine, but this is more about squishing, deciding which lines to show and which to not show. As I said, I have a simple table of indexes where each number specifies the line of graphics (from 0 to 21) and it's just about aranging these lines. I made a couple of such tables by hand and can switch between them, which makes this sort of effect, but I want to calculate it real time so I can control the speed and direction.

this video shows exactly what I mean. It's even harder for this part because it's in the side border, mine isn't.

>Not my problem you chose weak hardware to make this on even though better hardware is available for low prices.

C64 is in the tittle, why do you post here then. And the "better hardware for low prices". lmao. Like I'm using the C64 as my main computer or something, or I need this graphics rotation on just any platform because... ? What were you thinking ? Seeing as you had to edit your post twice I guess you don't think just shitpost away.


 No.922884>>922891

>>922867

So are you looking for a rotation that is in perspective or orthogonal?

>What were you thinking

It sounded like you were complaining about it being to heard to do since the hardware you are running is limited. If you are making a demo for it, you set this difficulty upon yourself so you shouldn't complain.


 No.922885>>922891

>>922867

>I want to calculate it real time so I can control the speed and direction.

It's been forever, but on PC for effects like that we'd calculate (on startup) a fixed 256 entry table that was a shitty approximation of sin() which got used for everything involving rotations. Pulling out a value was via adding to a counter per frame that would be shifted to use as an 8 bit index into the table, allowing for it to go slow enough to reuse the same value across multiple frames. And for oscillating rotations the value added to the counter would be chosen this way too. Then to add the extra twisting you'll see on a lot of these it would also add an additional increment per scan line.


 No.922891>>922895

>>922885

I'm using precalculated sin tables too, I just don't know what to do with these values to calculate the rotation.

By using the sinus values as the line numbers themselfs (especially 2 added sinuses with different increment values) gives cool results, but not this.

The blinds or stretching in the video I posted in OP uses such tables of course, for the blinds the value read is how many lines of screen to skip and for stretch how many times should the same line be displayed (or to be more precise, it is used as jmp address into unrolled constant graphics setting routine, so if you jump further you draw less lines and you can also draw lines "upside down")

>>922884

I'm not complaining, I'm saying your proposition won't work in this computer.


 No.922892

Here's a snippet of code that calculates the "blinds" effect


FppCalcSub:
// the graphics start from 128 and go up to 149, 128 is the first line. 128+22 is blank line
ldx #128
// index to the sinus table
ldy FPP_TABLE_INDEX_1
clc
-:
// loading the skip value (0-5) and adding it to the FPP_TAB pointer. FPP_TAB is this 120 bytes table
// that decides what graphics are displayed on which line
.tablePtr = *+2
lda fppSkip_good, y
// if zero skip addition (too little raster time to do this for all the lines)
beq +
adc .FppStore
sta .FppStore
+:
.FppStore=*+1
stx FPP_TAB

iny
inx
inc .FppStore
// if still not 21th line of graphics, go back and keep on drawing
cpx #128+22
bne -
// restore the pointer to FPP_TAB (#< means the low byte of the 16bit addr)
lda #<FPP_TAB
sta .FppStore
inc FPP_TABLE_INDEX_1
bne ++
// switch the inc to dec and vice versa if the counter wraps to zero to spice up
// the movement paterns
.incPtrTable=*
inc .tablePtr
ldx #$ee ; inc $xxxx opcode
lda .incPtrTable
cmp #$ee
bne +
ldx #$ce ; dec $xxxx opcode
+:
stx .incPtrTable
++:

rts


 No.922895

>>922891

>I'm using precalculated sin tables too, I just don't know what to do with these values to calculate the rotation.

When I last did it I was too young to understand trig so I just winged it. But today it should be easy to understand. Just look up how to do rotations and projections, I'd recommend looking into doing it with a linear algebra rotation matrix since matrix math comes into play in a bunch of things (e.g. convolution kernels for the classic PC bouncing lens effect). Do the math in something convenient like python, then translate what you find works to your code. Everything can be written in terms of sin/cos and then those can be replaced with lookups into your approximation.




[Return][Go to top][Catalog][Screencap][Nerve Center][Cancer][Update] ( Scroll to new posts) ( Auto) 5
9 replies | 1 images | Page ?
[Post a Reply]
[ / / / / / / / / / / / / / ] [ dir / animu / arepa / asmr / cafechan / hypno / leftpol / sw / vg ][ watchlist ]