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 - ben_g

Pages: 1 ... 53 54 [55] 56 57 ... 71
811
ASM / Re: Texture drawing
« on: August 11, 2011, 02:17:09 pm »
The camera stays at the same position, and the arguments passed to the triangle drawing routine are always the same, so I wonder why it draws it correctly the first time, and only draws a part of it the other times.

BTW: by filling the graphic buffer every frame, I noticed that the rest of the triangle is drawn white, but it is still drawn.

812
ASM / Re: Texture drawing
« on: August 08, 2011, 07:47:30 pm »
I discovered an other problem: when i combine it wih my 3D engine, this happens:

For an instant, it's drawn correctely, then only a part is drawn

Does anyody knows what might be causing this?

813
Web Programming and Design / Re: Happy 20th birthday, World Wide Web
« on: August 08, 2011, 03:32:35 pm »
which is 20 years old? the internet itself, HTTP, or HTML-based websites?

814
ASM / Re: Trig in ASM
« on: August 07, 2011, 05:34:29 pm »
I use this routine for a sin in my z80 project:
Quote from: Z80 Assembly
SinA:
  ;calculates the sine of a as a fixed point number
  ;IN: a
  ;OUT: hl = sin(a)
    LD     h, 0
    LD     l, a
    add hl, hl
    LD     DE, sine_table
    ADD    HL, DE
    LD     A, (HL)
    INC    HL
    LD     H, (HL)
    LD     L, A
    RET
sine_table:
.dw    0, 6, 13, 19, 25, 31, 38, 44, 50, 56, 62, 68, 74, 80, 86, 92, 98, 104, 109, 115, 121, 126, 132, 137, 142
.dw    147, 152, 157, 162, 167, 172, 177, 181, 185, 190, 194, 198, 202, 206, 209, 213, 216, 220, 223, 226, 229, 231, 234
.dw    237, 239, 241, 243, 245, 247, 248, 250, 251, 252, 253, 254, 255, 255, 256, 256, 256, 256, 256, 255, 255, 254, 253
.dw    252, 251, 250, 248, 247, 245, 243, 241, 239, 237, 234, 231, 229, 226, 223, 220, 216, 213, 209, 206, 202, 198, 194
.dw    190, 185, 181, 177, 172, 167, 162, 157, 152, 147, 142, 137, 132, 126, 121, 115, 109, 104, 98, 92, 86, 80, 74, 68
.dw    62, 56, 50, 44, 38, 31, 25, 19, 13, 6, 0, -6, -13, -19, -25, -31, -38, -44, -50, -56, -62, -68, -74, -80, -86, -92
.dw    -98, -104, -109, -115, -121, -126, -132, -137, -142, -147, -152, -157, -162, -167, -172, -177, -181, -185, -190,
.dw    -194, -198, -202, -206, -209, -213, -216, -220, -223, -226, -229, -231, -234, -237, -239, -241, -243, -245, -247
.dw    -248, -250, -251, -252, -253, -254, -255, -255, -256, -256, -256, -256, -256, -255, -255, -254, -253, -252, -251
.dw    -250, -248, -247, -245, -243, -241, -239, -237, -234, -231, -229, -226, -223, -220, -216, -213, -209, -206, -202
.dw    -198, -194, -190, -185, -181, -177, -172, -167, -162, -157, -152, -147, -142, -137, -132, -126, -121, -115, -109
.dw    -104, -98, -92, -86, -80, -74, -68, -62, -56, -50, -44, -38, -31, -25, -19, -13, -6

Generated by the BBify'r (http://clrhome.tk/resources/bbify/)

and for tan, I use sin(x)/sin(x+90°), which has the same result

I hope this is what you are looking for.

BTW: look up tables are big, so i would only reccomend them when you really need the speed.

815
If you just do it in englih, then you can shorten it further by changing the name to 'New post by'.

816
Math and Science / Re: Interval arithmetic questions
« on: August 07, 2011, 02:23:08 pm »
I think the result would be ERR:DIM MISMATCH, so it's undefined.

817
Gaming Discussion / Re: who plays GTA (Grand Theft Auto)
« on: August 07, 2011, 02:02:28 pm »
I have GTA vice city, GTA san andreas, and GTA 4, but i only play GTA4, becouse vice city and san andreas aren't installed on this computer, and i lost the CD's.

I also have Red dead rendemtion, an other game in the GTA style, also made by rockstar games.

818
TI Z80 / Re: zStart - an app that runs on ram clears
« on: August 06, 2011, 04:17:46 pm »
Is it possible to make an option that the clock won't get reset on a ram clear?

819
ASM / Re: Texture drawing
« on: August 06, 2011, 03:05:29 pm »
Maybe it does help. If i know how it should be done, then i might be able to rewrite it in asm. And i need a good sorting algorithm for when i'm going to add z-ordering to the engine.

EDIT: I just found a mistake in my code, and now, the triangle is fully drawn, but still just solid black.

EDIT2: I just noticed an other mistake in the source, which made texture mapping impossible. This was not the full cause of the texture not being mapped, however, ass the routine is still drawing a solid black triangle.

EDIT3: Finally!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


the third mistake was caused by a very stupid mistake: I have a text file in the project folder named 'Routines.txt', in which all names of all routines in my app are written, with the arguments and the registers that they destroy. A while ago, i replaced the fixed-point multiplication routine, which had other arguments, so this problem was caused by an outdated routines file

EDIT4: it now draws only 1.29 triangles every second, but I'm optimizing it right now. The first thing I'll do is replace the fixed-point math for every pixel with a much simpler one, which only has to be calculated for each horizontal line. The rest of the line can then be calculated with a simple add command. An other optimization I'll try to add is calling getPixel only once for every scan line, instead of every pixel, then using a right rotation to get the mask.

820
ASM / Re: Texture drawing
« on: August 05, 2011, 02:28:11 pm »
did that basic to assembly source conversion thing work at all?
nope, I haven't found any program that actually converts anything, so I've ported it manually, but i must have made a mistake, ass this is clearly not doing what it should do.

BTW: this routine draws the triangle from top to bottom, which means that the points needs to be in the right order, so does anybody knows a routine to sort the points based on their Y coordinate?

821
It's a great tool. I already used it a few times when i posted asm source code.

BTW: those terms and conditions, I don't really know how you can agree with them :p
And nobody has said anything abouth this. I think nobody here checks them.

822
ASM / Re: Texture drawing
« on: August 04, 2011, 03:50:22 pm »
I've got goo news and bad news: the good news: I've got affine texture mapping to work on a computer. The bad news: I can't get it to work on a calc.
what am I doing wrong?
Computer
Calculator
Everything works just the way it's supposed to.In the first step (TriangleDrawLoop1), it just draws black pixels,
and in the secound draw loop, nothing is drawn.
Spoiler For GML source code:
dx1 = (x2-x1)/(y2-y1)
dx2 = (x3-x2)/(y3-y2)
dx3 = (x3-x1)/(y3-y1)
du1 = (u2-u1)/(y2-y1)
du2 = (u3-u2)/(y3-y2)
du3 = (u3-u1)/(y3-y1)
dv1 = (v2-v1)/(y2-y1)
dv2 = (v3-v2)/(y3-y2)
dv3 = (v3-v1)/(y3-y1)

tx1 = x1
tx2 = x1
tu1 = u1
tu2 = u1
tv1 = v1
tv2 = v1

surf = surface_create(24,24)
surface_set_target(surf)
draw_sprite(sprite0,-1,0,0)
surface_reset_target();

for(ty = y1; ty < y2; ty += 1){
    //draw_line(tx1,ty,tx2,ty)
    for(tx = tx2; tx <= tx1; tx += 1){
        if(tx1==tx2){
            tmp = 0
        }else{
            tmp = (tx - tx2)/(tx1-tx2)
        }
        draw_point_color(tx,ty,surface_getpixel(surf,floor((1-tmp)*tu2+tmp*tu1),floor((1-tmp)*tv2+tmp*tv1)))
    }
    tx1 += dx1
    tx2 += dx3
    tu1 += du1
    tu2 += du3
    tv1 += dv1
    tv2 += dv3
}


for(ty = y2; ty <= y3; ty += 1){
    //draw_line(tx1,ty,tx2,ty)
    for(tx = tx2; tx <= tx1; tx += 1){
        if(tx1==tx2){
            tmp = 0
        }else{
            tmp = (tx - tx2)/(tx1-tx2)
        }
        draw_point_color(tx,ty,surface_getpixel(surf,floor((1-tmp)*tu2+tmp*tu1),floor((1-tmp)*tv2+tmp*tv1)))
    }
    tx1 += dx2
    tx2 += dx3
    tu1 += du2
    tu2 += du3
    tv1 += dv2
    tv2 += dv3
}
draw_surface_stretched(surf,300,0,100,100)
surface_free(surf)

A surface is almost the same as a sprite.
Spoiler For z80 source:
DrawTriangle:
  ld a, (x1)
  ld b, a
  ld a, (x2)
  sub b
  ld h, a
  ld l, 0
  ld a, (y1)
  ld b, a
  ld a, (y2)
  sub b
  ld d, a
  ld e, 0
  call DivFP
  ld (dx1), hl
  ld a, (x2)
  ld b, a
  ld a, (x3)
  sub b
  ld h, a
  ld l, 0
  ld a, (y2)
  ld b, a
  ld a, (y3)
  sub b
  ld d, a
  ld e, 0
  call DivFP
  ld (dx2), hl
  ld a, (x1)
  ld b, a
  ld a, (x3)
  sub b
  ld h, a
  ld l, 0
  ld a, (y1)
  ld b, a
  ld a, (y3)
  sub b
  ld d, a
  ld e, 0
  call DivFP
  ld (dx3), hl
  ld a, (u1)
  ld b, a
  ld a, (u2)
  sub b
  ld h, a
  ld l, 0
  ld a, (y1)
  ld b, a
  ld a, (y2)
  sub b
  ld d, a
  ld e, 0
  call DivFP
  ld (du1), hl
  ld a, (u2)
  ld b, a
  ld a, (u3)
  sub b
  ld h, a
  ld l, 0
  ld a, (y2)
  ld b, a
  ld a, (y3)
  sub b
  ld d, a
  ld e, 0
  call DivFP
  ld (du2), hl
  ld a, (u1)
  ld b, a
  ld a, (u3)
  sub b
  ld h, a
  ld l, 0
  ld a, (y1)
  ld b, a
  ld a, (y3)
  sub b
  ld d, a
  ld e, 0
  call DivFP
  ld (du3), hl
  ld a, (v1)
  ld b, a
  ld a, (v2)
  sub b
  ld h, a
  ld l, 0
  ld a, (y1)
  ld b, a
  ld a, (y2)
  sub b
  ld d, a
  ld e, 0
  call DivFP
  ld (dv1), hl
  ld a, (v2)
  ld b, a
  ld a, (v3)
  sub b
  ld h, a
  ld l, 0
  ld a, (y2)
  ld b, a
  ld a, (y3)
  sub b
  ld d, a
  ld e, 0
  call DivFP
  ld (dv2), hl
  ld a, (v1)
  ld b, a
  ld a, (v3)
  sub b
  ld h, a
  ld l, 0
  ld a, (y1)
  ld b, a
  ld a, (y3)
  sub b
  ld d, a
  ld e, 0
  call DivFP
  ld (dv3), hl

  ld a, (x1)
  ld h, a
  ld l, 0
  ld (tx1), hl
  ld (tx2), hl
  ld a, (u1)
  ld h, a
  ld l, 0
  ld (tu1), hl
  ld (tu2), hl
  ld a, (v1)
  ld h, a
  ld l, 0
  ld (tv1), hl
  ld (tv2), hl

  ld a, (y1)
  ld (_ty), a

TriangleDrawLoop1:
  ld hl, (tx2)
  ld a, h
  ld (temp), a

TrianglePlotLoop1:
  ld hl, (tx1)
  ld de, (tx2)
  subFP
  push hl
  ld a, (temp)
  ld h, a
  ld l, 0
  ld de, (tx2)
  subFP
  pop de
  call DivFP
  ld (temp2), hl   ;tmp = temp2
  ld hl, $0100
  ld de, (temp2)
  subFP
  ld bc, (tu2)
  call MulFP
  push de
  ld hl, (temp2)
  ld bc, (tu1)
  call MulFP
  pop hl
  add hl, de
  ld a, h
  ld (temp3), a      ;u = temp3
  ld hl, $0100
  ld de, (temp2)
  subFP
  ld bc, (tv2)
  call MulFP
  push de
  ld hl, (temp2)
  ld bc, (tv1)
  call MulFP
  pop hl
  add hl, de
  ld a, h
  ld (temp3+1), a   ;v = temp3+1

  ld a, (temp3+1)
  ld l, a
  ld h, 0

  ld de, texture
  add hl, de

  ld a, (temp3)
  ld b, a
  inc b
  ld a, (hl)
  ld c, a
TshiftLoop1:
  rl   c
  djnz   TshiftLoop1

  push af
 
  ld a, (_ty)
  ld l, a
  ld a, (temp)      ;tx = temp
  call GetPixel
  ld b, a
  pop af
  jr c, TSetPixel1

TResPixel1:
  ld a, b
  cpl
  and (hl)
  ld (hl), a
  jr TEndPlot1

TSetPixel1:
  ld a, b
  or (hl)
  ld (hl), a

TEndPlot1:
  ld hl, temp
  inc (hl)
  ld a, (tx1+1)
  cp (hl)
  jp nc, TrianglePlotLoop1

  ld hl, (tx1)
  ld de, (dx1)
  add hl, de
  ld (tx1), hl
  ld hl, (tx2)
  ld de, (dx3)
  add hl, de
  ld (tx2), hl

  ld hl, _ty
  inc (hl)
  ld a, (y2)
  cp (hl)
  jp nc, TriangleDrawLoop1

  ld a, (x2)
  ld h, a
  ld l, 0
  ld (tx1), hl

TriangleDrawLoop2:
  ld hl, (tx2)
  ld a, h
  ld (temp), a

TrianglePlotLoop2:
  ld hl, (tx1)
  ld de, (tx2)
  subFP
  push hl
  ld a, (temp)
  ld h, a
  ld l, 0
  ld de, (tx2)
  subFP
  pop de
  call DivFP
  ld (temp2), hl   ;tmp = temp2
  ld hl, $0100
  ld de, (temp2)
  subFP
  ld bc, (tu2)
  call MulFP
  push de
  ld hl, (temp2)
  ld bc, (tu1)
  call MulFP
  pop hl
  add hl, de
  ld a, h
  ld (temp3), a      ;u = temp3
  ld hl, $0100
  ld de, (temp2)
  subFP
  ld bc, (tv2)
  call MulFP
  push de
  ld hl, (temp2)
  ld bc, (tv1)
  call MulFP
  pop hl
  add hl, de
  ld a, h
  ld (temp3+1), a   ;v = temp3+1

  ld a, (temp3+1)
  ld l, a
  ld h, 0

  ld de, texture
  add hl, de

  ld a, (temp3)
  ld b, a
  inc b
  ld a, (hl)
  ld c, a
TshiftLoop2:
  rl   c
  djnz   TshiftLoop2

  push af
 
  ld a, (_ty)
  ld l, a
  ld a, (temp)      ;tx = temp
  call GetPixel
  ld b, a
  pop af
  jr c, TSetPixel2

TResPixel2:
  ld a, b
  cpl
  and (hl)
  ld (hl), a
  jr TEndPlot2

TSetPixel2:
  ld a, b
  or (hl)
  ld (hl), a

TEndPlot2:
  ld hl, temp
  inc (hl)
  ld a, (tx1+1)
  cp (hl)
  jp nc, TrianglePlotLoop2

  ld hl, (tx1)
  ld de, (dx2)
  add hl, de
  ld (tx1), hl
  ld hl, (tx2)
  ld de, (dx3)
  add hl, de
  ld (tx2), hl

  ld hl, _ty
  inc (hl)
  ld a, (y2)
  cp (hl)
  jp nc, TriangleDrawLoop2

  ret



getPixel:
   ld   h, 0
   ld   d, h
   ld   e, l
   
   add   hl, hl
   add   hl, de
   add   hl, hl
   add   hl, hl
   
   ld   e, a
   srl   e
   srl   e
   srl   e
   add   hl, de
   
   ld   de, PlotSScreen
   add   hl, de
   
   and   7
   ld   b, a
   ld   a, $80
   ret   z
   
   rrca
   djnz   $-1
   ret

Generated by the BBCode Converter (http://clrhome.tk/resources/bbify/)

What am i doing wrong?

823
Other / Re: Unlimited Detail!
« on: August 03, 2011, 07:08:40 pm »
Memory is indeed a problem: for example: after 2:20 in the video: "Elephant contains 530 906 polygons": A model usually contains almost the same amount of vertices than ploygons, and each vertix contains an int (to store the id of the vertex) and 3 floats(to save it's position). Ints and floats are each 4 bytes, so to store each point, you need 4*4=16 bytes.
With polygons, they almost always mean triangles, and for each triangle, you need to store it's id and the points it's made of. So each triangle is stored as 16 bytes. this means that the elephant is approximately (530 906 * 4)*2 = 4 247 248 bytes = 4147kb = 4mb. So only one model of the scene is already 4 megabytes, and this is witout the texture. for that, you'll need another megabyte, so witouth the texture image itself, it's a bit over 5 mb large. And this isn't the only model in the scene.

824
Introduce Yourself! / Re: Hi (again)
« on: August 03, 2011, 03:24:16 pm »
Hi and welcome to omnimaga. You should receive your peanuts soon.

and I've never heard of boxhead either, sorry

825
Other / Re: Unlimited Detail!
« on: August 03, 2011, 02:29:14 pm »
this can be real, but it's almost impossible to make a game which can fit on any portable storage device with a realistic world in such high detail. You'll need very powerful compression techniques to put what's seen in the video on a DVD. It's possible, but until we can easly store large amounts of data on a computer, it's very unpractical.

Pages: 1 ... 53 54 [55] 56 57 ... 71