Author Topic: Abandoned projects  (Read 1795 times)

0 Members and 1 Guest are viewing this topic.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17296
  • Karma: 489
  • evil/good
    • View Profile
    • My Homepage
Abandoned projects
« on: June 03, 2012 »


Because I never seem to finish anything these days and haven't posted code for an age..

Anyway I have been drinking tonight and I got pissed off with the cheapo TV I have to use as a monitor.. Basically it can barely do 60hz and everything looks as choppy as hell on it so I had a bash at trying to make something that looked smooth.

The effect sucks but there's source in there for the brave (I'll surely never look at this code again)

It would be cool to see other peoples abandoned projects / code snippets..
Shockwave ^ Codigos
Challenge Trophies Won:

Offline jace_stknights

  • Amiga 1200
  • ****
  • Posts: 364
  • Karma: 32
  • PEEK & POKE are not MOVEM!
    • View Profile
    • ST Knights WebSite
Re: Abandoned projects
« Reply #1 on: June 04, 2012 »
Great! Took a quick look a the code, but didn't understand why you used assembly  ???
Challenge Trophies Won:

Offline egons

  • C= 64
  • **
  • Posts: 31
  • Karma: 0
    • View Profile
Re: Abandoned projects
« Reply #2 on: June 04, 2012 »
nice twister :clap:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5243
  • Karma: 393
    • View Profile
Re: Abandoned projects
« Reply #3 on: June 04, 2012 »
Great! Took a quick look a the code, but didn't understand why you used assembly  ???
It'll possibly be the tiniest smidge quicker than using memcpy. Tiny. :)

It is a nice shiny twister though :)

Jim
Challenge Trophies Won:

Offline jace_stknights

  • Amiga 1200
  • ****
  • Posts: 364
  • Karma: 32
  • PEEK & POKE are not MOVEM!
    • View Profile
    • ST Knights WebSite
Re: Abandoned projects
« Reply #4 on: June 04, 2012 »
It'll possibly be the tiniest smidge quicker than using memcpy. Tiny. :)

yep have to make a closer look at all this and re-open my x86 assembly book  :P
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5243
  • Karma: 393
    • View Profile
Re: Abandoned projects
« Reply #5 on: June 04, 2012 »
Code: [Select]
mov eax,dword ptr[TC]
mov ecx, [slice]
mov edi, [PP]
rep stosd
This says
move the colour into register eax
move the number of pixels into ecx
move the address of the first pixel to fill into edi
do it - copy eax to edi for ecx times.

It's equivalent to the C code
Code: [Select]
for (int i = 0; i < ecx; i++)
  *edi++ = eax;

Jim
Challenge Trophies Won:

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4118
  • Karma: 181
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: Abandoned projects
« Reply #6 on: June 04, 2012 »
Where to begin - I'll have to check one of my abandoned computers for some abandoned code. That'll be old.
You are our 9001st visitor.
Challenge Trophies Won:

Offline jace_stknights

  • Amiga 1200
  • ****
  • Posts: 364
  • Karma: 32
  • PEEK & POKE are not MOVEM!
    • View Profile
    • ST Knights WebSite
Re: Abandoned projects
« Reply #7 on: June 04, 2012 »
Yep I saw it was a loop to copy datas, but the compiler is not good enough to make the same thing? That's why I'm a bit disturbed... nothing seems to be so optimised as it should be to bypass the compiler  ???
Challenge Trophies Won:

Offline maracuja

  • C= 64
  • **
  • Posts: 31
  • Karma: 4
    • View Profile
Re: Abandoned projects
« Reply #8 on: June 04, 2012 »
Code: [Select]
mov eax,dword ptr[TC]
mov ecx, [slice]
mov edi, [PP]
rep stosd
This says
move the colour into register eax
move the number of pixels into ecx
move the address of the first pixel to fill into edi
do it - copy eax to edi for ecx times.

It's equivalent to the C code
Code: [Select]
for (int i = 0; i < ecx; i++)
  *edi++ = eax;

Jim

It’s not really exact, you must be divide ecx by 4 and iterate on i+=4 to be stricto sensu exact with the asm code. But the general idea you’re reason ;)

stosd = store in edi pointer the value of eax 4 bytes by 4 bytes. :) (store dword)

Offline jace_stknights

  • Amiga 1200
  • ****
  • Posts: 364
  • Karma: 32
  • PEEK & POKE are not MOVEM!
    • View Profile
    • ST Knights WebSite
Re: Abandoned projects
« Reply #9 on: June 04, 2012 »
AAh ah! For years people always told me that compilers are strongs nowadays. And my little finger tells me it is not so true.  ;D
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5243
  • Karma: 393
    • View Profile
Re: Abandoned projects
« Reply #10 on: June 04, 2012 »
Quote
It’s not really exact, you must be divide ecx by 4 and iterate on i+=4 to be stricto sensu exact with the asm code. But the general idea you’re reason ;)

stosd = store in edi pointer the value of eax 4 bytes by 4 bytes. :) (store dword)

No, I'm right. It writes ecx dwords not ecx bytes.

Jim
Challenge Trophies Won:

Offline padman

  • Senior Member
  • Pentium
  • ********
  • Posts: 835
  • Karma: 153
    • View Profile
Re: Abandoned projects
« Reply #11 on: June 04, 2012 »
Ok, here's one of my abandoned projects (sorry no source code available due to crappiness  ;D) I already posted it on FB once, but I guess it won't do any harm to repost it here... It was supposed to become some sort of Supercars remake thing. Just tested it on Win7 x64, so it should run on most computers.
 
You need to press F1 to start the opponent. Key UP/LEFT/RIGHT to steer or with a joystick LEFT/RIGHT to steer and button to "accelerate".

You'll see there's a lot of unhandled stuff left. Especially some errors with the bridge/tunnel thing and sometimes weird behavior regarding the collision detection or both respectively. Oh and please don't drive in the wrong direction, it'll sooner or later fuck up everything... You've been warned. ;)

Anyway, enjoy!  ;)
Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1062
  • Karma: 152
    • View Profile
    • Raizor's Dev Blog
Re: Abandoned projects
« Reply #12 on: June 04, 2012 »
That looks great Padman. I used to love the Supercars games on Amiga, which the screenshot reminds me of a lot :)
raizor

Challenge Trophies Won:

Offline maracuja

  • C= 64
  • **
  • Posts: 31
  • Karma: 4
    • View Profile
Re: Abandoned projects
« Reply #13 on: June 04, 2012 »
Quote
It’s not really exact, you must be divide ecx by 4 and iterate on i+=4 to be stricto sensu exact with the asm code. But the general idea you’re reason ;)

stosd = store in edi pointer the value of eax 4 bytes by 4 bytes. :) (store dword)

No, I'm right. It writes ecx dwords not ecx bytes.

Jim

4 bytes = 1 dword ?
Here your loop ecx which contains the iterations numbers  of stosd will be repeat. So if ecx = 2 , stosd will be call twice so the value of eax will be move twice so eight bytes, i guess.


Wait, Oh ok ! your pointer *edi is a 4 bytes address ! So ok, you musn’t divide by four. :) Mea Culpa !
« Last Edit: June 04, 2012 by maracuja »

Offline TinDragon

  • Pentium
  • *****
  • Posts: 642
  • Karma: 24
    • View Profile
    • J2K's blog
Re: Abandoned projects
« Reply #14 on: June 04, 2012 »
Screenie looks cool Padman, but the file in the zip doesnt seem to work i get a black lowres screen and had to manually close it for not responding.

Offline Kirl

  • Senior Member
  • Pentium
  • ********
  • Posts: 986
  • Karma: 219
    • View Profile
    • Homepage
Re: Abandoned projects
« Reply #15 on: June 04, 2012 »
Good one padman and cool twister too shockwave! :clap:

I just remembered a Mario galaxy 2d project which I abandoned because of really messy code. Found the test file on my site, I'll upload the source on request. The idea was to make the first few levels from smb as seperate planets with mario galaxy like physics. Been planning to do a re-write from scratch for a long time.

Play it here: http://kirl.nl/mg2d.swf
Click on planet surface to set focus (if you click in the air you'll create another planet!)
up/down = zoom in and out (there's a few planets you can't reach if you zoom out really far)
left/right = walk
Ctrl = jump
« Last Edit: June 05, 2012 by Kirl »
www.kirl.nl
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4365
  • Karma: 226
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Abandoned projects
« Reply #16 on: June 05, 2012 »
@Padman:
I love those kind of racers ... good start!

@Kirl:
Man, this is a cool concept. Wished you finish this!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5243
  • Karma: 393
    • View Profile
Re: Abandoned projects
« Reply #17 on: June 05, 2012 »
AAh ah! For years people always told me that compilers are strongs nowadays. And my little finger tells me it is not so true.  ;D

Visual Studio:
Code: [Select]
#include <string.h>
#include <stdio.h>

int a[1024];

int main(int argc, char **argv)
{
int c = 1024;
int *b = a;
while (c--)
*b++ = 0xABADCAFE;

printf("%d", (int)a[0]);
return 0;
}

Output
Code: [Select]
; Listing generated by Microsoft (R) Optimizing Compiler Version 16.00.40219.01

TITLE C:\source\opt\opt.c
.686P
.XMM
include listing.inc
.model flat

INCLUDELIB MSVCRT
INCLUDELIB OLDNAMES

_DATA SEGMENT
COMM _a:DWORD:0400H
_DATA ENDS
PUBLIC ??_C@_02DPKJAMEF@?$CFd?$AA@ ; `string'
PUBLIC _main
EXTRN __imp__printf:PROC
; COMDAT ??_C@_02DPKJAMEF@?$CFd?$AA@
; File c:\source\opt\opt.c
CONST SEGMENT
??_C@_02DPKJAMEF@?$CFd?$AA@ DB '%d', 00H ; `string'
; Function compile flags: /Ogsp
CONST ENDS
; COMDAT _main
_TEXT SEGMENT
_argc$ = 8 ; size = 4
_argv$ = 12 ; size = 4
_main PROC ; COMDAT
; Line 7
push edi
; Line 11
mov eax, -1414673666 ; abadcafeH
mov ecx, 1024 ; 00000400H
mov edi, OFFSET _a
rep stosd
; Line 13
push DWORD PTR _a
push OFFSET ??_C@_02DPKJAMEF@?$CFd?$AA@
call DWORD PTR __imp__printf
pop ecx
pop ecx
; Line 15
xor eax, eax
pop edi
; Line 16
ret 0
_main ENDP
_TEXT ENDS
END

i.e:
Code: [Select]
mov eax, -1414673666 ; abadcafeH
mov ecx, 1024 ; 00000400H
mov edi, OFFSET _a
rep stosd

Looks pretty good to me!

<edit>first version contained a buffer overflow! :P<edit>

Jim
« Last Edit: June 05, 2012 by Jim »
Challenge Trophies Won:

Offline jace_stknights

  • Amiga 1200
  • ****
  • Posts: 364
  • Karma: 32
  • PEEK & POKE are not MOVEM!
    • View Profile
    • ST Knights WebSite
Re: Abandoned projects
« Reply #18 on: June 05, 2012 »
So that's what I wrote: for simple things, we don't have to use assembly! that's the case in the Shocky code (and this is why I ask why he done it). And for other things, assembly is simply the best... for optimisation ways.
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17296
  • Karma: 489
  • evil/good
    • View Profile
    • My Homepage
Re: Abandoned projects
« Reply #19 on: June 05, 2012 »
So that's what I wrote: for simple things, we don't have to use assembly! that's the case in the Shocky code (and this is why I ask why he done it). And for other things, assembly is simply the best... for optimisation ways.

For rendering solid horizontal lines I tend to use that simple little loop because it's short to type and possibly a little bit quicker than using loops and pointers if I don't want to include crt.bi for memcpy.  I don't really think that it matters much on modern PC's though, I find it's possible to software render 800*600 without too much trouble (depending on what you're doing)...  Arguably I could have made more of a saving if I'd used look up tables for the sin, there's probably at least half a dozen other things in there that can be optimised too :)

Padman, your game really reminds me of supercars too!  A nice concept, just begging to have more cars on the track and weapons :)

Kirl, I really like the 360 degree platformer, it's kind of weird running upside-down, maybe less confusing if the planet rotated and the character stayed central :)  Cool concept though, especially as you can jump from planet to planet!
Shockwave ^ Codigos
Challenge Trophies Won: