Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411430 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 20, 2024, 02:22:55 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)The happy programmer room
Pages: 1 ... 219 220 [221] 222 223 ... 279
Print
Author Topic: The happy programmer room  (Read 677825 times)
Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW
« Reply #4400 on: September 29, 2016, 03:53:59 PM »

I've been a professional programmer for over 10 years.  I've been on the Microsoft Office team, I worked on Magic: The Gathering Online, I've written flight-test software for Boeing.

Nothing I've ever done has made me happier than this:



I grew up playing Atari consoles, dreamed of making Atari games, and after 30 years, it's finally a reality.  It should be in the AtariAge store by the end of the year.
Logged



What would John Carmack do?
InfiniteStateMachine
Level 10
*****



View Profile
« Reply #4401 on: September 29, 2016, 04:07:21 PM »

Awesome! and congrats!

When do we get to see some screenshots from the game?
Logged

AntonTesh
Level 0
**



View Profile WWW
« Reply #4402 on: September 29, 2016, 06:42:06 PM »

Extremely rarely do I find a use for bitwise operators on my own in day-to-day coding (traditional bit flags don't count!), but today I did! It's nothing special, but the rarity of it still makes it a bit exciting for me. d;

How often do y'all find yourself coming up with bitwise solutions (when not on a microprocessor or something, of course; I mean modern game/application programming in particular)?

I haven't used them since college when we wrote an assembly emulator. I've seen them used in my day job's legacy software but have no need to use them currently. What did you use it for?
Logged

oahda
Level 10
*****



View Profile
« Reply #4403 on: September 30, 2016, 12:59:50 AM »

Magic: The Gathering Online
It doesn't work on my iPad, so it must be your fault! Outraged

Atari
Cartridge and all?

I haven't used them since college when we wrote an assembly emulator. I've seen them used in my day job's legacy software but have no need to use them currently. What did you use it for?
I had a bunch of enum values and I wanted to see if every single one was the same. I could've done something like if (a == b && b == c && c == d …), but it's bulky. Figured out I could do if (a & b & c & d … > 0), assuming enumeration starts from one and every consecutive value is an increasing power of two (like bit flags). Also nicer in a loop with an indefinite amount of values.

This way each value has one 1 bit in a different place, so the bitwise and only yields 1 in that position if both values have 1 there (which they only do if they are the same number when only powers of two are used). Otherwise the bit is set to 0. This means that if any number at all differs, the end result will be zero. Otherwise the end result will be the number that all values are equal to, i.e. greater than zero (which is why enumeration can't start at zero, because binary zero has no 1 bit).

(tried spelling the numbers out in letters when talking about decimal numbers and writing them with digits when talking about bits—hope it isn't too difficult to keep track of which is which!)
Logged

bateleur
Level 10
*****



View Profile
« Reply #4404 on: September 30, 2016, 02:50:39 AM »

I grew up playing Atari consoles, dreamed of making Atari games, and after 30 years, it's finally a reality.
Hand Metal LeftKiss Congratulations!

Atari was a feature of my childhood too. I am suitably impressed.
Logged

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #4405 on: September 30, 2016, 05:14:58 AM »

Magic: The Gathering Online
It doesn't work on my iPad, so it must be your fault! Outraged

Atari
Cartridge and all?

I haven't used them since college when we wrote an assembly emulator. I've seen them used in my day job's legacy software but have no need to use them currently. What did you use it for?
I had a bunch of enum values and I wanted to see if every single one was the same. I could've done something like if (a == b && b == c && c == d …), but it's bulky. Figured out I could do if (a & b & c & d … > 0), assuming enumeration starts from one and every consecutive value is an increasing power of two (like bit flags). Also nicer in a loop with an indefinite amount of values.

This way each value has one 1 bit in a different place, so the bitwise and only yields 1 in that position if both values have 1 there (which they only do if they are the same number when only powers of two are used). Otherwise the bit is set to 0. This means that if any number at all differs, the end result will be zero. Otherwise the end result will be the number that all values are equal to, i.e. greater than zero (which is why enumeration can't start at zero, because binary zero has no 1 bit).

(tried spelling the numbers out in letters when talking about decimal numbers and writing them with digits when talking about bits—hope it isn't too difficult to keep track of which is which!)

 At first I was wondering why people were using bitshifts for each enum value. Now I understand why!
Logged

oahda
Level 10
*****



View Profile
« Reply #4406 on: September 30, 2016, 08:01:07 AM »

Yeah, it can look a bit clearer depending on who you ask. I personally just assigned decimal values of 1, 2, 4, 8 and so on. Tongue
Logged

AntonTesh
Level 0
**



View Profile WWW
« Reply #4407 on: September 30, 2016, 11:30:22 AM »

I had a bunch of enum values and I wanted to see if every single one was the same. I could've done something like if (a == b && b == c && c == d …), but it's bulky. Figured out I could do if (a & b & c & d … > 0), assuming enumeration starts from one and every consecutive value is an increasing power of two (like bit flags). Also nicer in a loop with an indefinite amount of values.

This way each value has one 1 bit in a different place, so the bitwise and only yields 1 in that position if both values have 1 there (which they only do if they are the same number when only powers of two are used). Otherwise the bit is set to 0. This means that if any number at all differs, the end result will be zero. Otherwise the end result will be the number that all values are equal to, i.e. greater than zero (which is why enumeration can't start at zero, because binary zero has no 1 bit).

(tried spelling the numbers out in letters when talking about decimal numbers and writing them with digits when talking about bits—hope it isn't too difficult to keep track of which is which!)

Ohhh nice! I think if (a == b && b == c && c == d …) is more readable if others are looking at your code but that's a super clever way to check Smiley
Logged

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #4408 on: September 30, 2016, 12:30:18 PM »

I already though C# had the best xml parsing environment with XDocument then I found YaxLib. Reduced 30 lines of code to 2 with less chance for errors! Smiley


https://github.com/sinairv/YAXLib

Logged

Cheezmeister
Level 3
***



View Profile
« Reply #4409 on: September 30, 2016, 08:58:54 PM »

Quote
How often do y'all find yourself coming up with bitwise solutions (when not on a microprocessor or something, of course; I mean modern game/application programming in particular)?

Only when using an API that uses them. Struct of bools is clearer, typesafe and probably optimizes to bits, anyway.

...oh wait, flags don't count? Well then...pretty much never. Coincidentally though I very recently did. ID3 tags have this really weird packing scheme for the size field, so I had to shift bytes by 7, 14 and 21 bits respectively to reconstruct a 28-bit (yes, twenty-eight) integer.
Logged

෴Me෴ @chzmstr | www.luchenlabs.com ቒMadeቓ RA | Nextris | Chromathud   ᙍMakingᙌCheezus II (Devlog)
pturecki
Level 0
***



View Profile WWW
« Reply #4410 on: October 01, 2016, 07:48:18 AM »

Hello to everyone! (I post first time here)
Nothing special... I just want to say that refactoring and optimizing code is awesome when the results are considerable and visible (especially in a short time) and surprising a bit :D

A bit more details:
Debug builds of our game (see HERE) started running so slow that normal debugging was almost impossible. So I was refactoring the code all day yesterday (game uses my own engine written from scratch so there are a lot of places to optimize) and the FPS (in debug build) rose from 20 to 43! on a sample map (VC++ profiler was very helpful).

Cheers and have a nice weekend too! Smiley
Logged

standardcombo
Level 8
***


><)))°>


View Profile
« Reply #4411 on: October 01, 2016, 11:06:46 AM »

Extremely rarely do I find a use for bitwise operators on my own in day-to-day coding (traditional bit flags don't count!), but today I did! It's nothing special, but the rarity of it still makes it a bit exciting for me. d;

How often do y'all find yourself coming up with bitwise solutions (when not on a microprocessor or something, of course; I mean modern game/application programming in particular)?

Does bit shifting count as bitwise? I always use it to divide or multiply integers by 2, 4, 8. It's faster on the cpu. Got used to it after working in j2me for years.

I've been a professional programmer for over 10 years.  I've been on the Microsoft Office team, I worked on Magic: The Gathering Online, I've written flight-test software for Boeing.

Nothing I've ever done has made me happier than this:



I grew up playing Atari consoles, dreamed of making Atari games, and after 30 years, it's finally a reality.  It should be in the AtariAge store by the end of the year.

Congrats! Is this the gameplay?



Logged

Dacke
Level 10
*****



View Profile
« Reply #4412 on: October 02, 2016, 02:21:17 AM »

Does bit shifting count as bitwise? I always use it to divide or multiply integers by 2, 4, 8. It's faster on the cpu. Got used to it after working in j2me for years.

Aren't compilers smart enough to do that substitution themselves when you divide by a constant?
Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
standardcombo
Level 8
***


><)))°>


View Profile
« Reply #4413 on: October 02, 2016, 06:46:59 AM »

You tell me. I don't double check the compiler's work. Either way it's the same amount of typing, one operator and two operands. Back in the day such optimizations were important if you were trying to squeeze your game into 63 kilobytes and run at playable speed, not to mention fixed point math. I suppose fixed point math is still applicable use of bit operations if you are trying to make a deterministic simulation across platforms.

I can think of a couple more applications. If you are trying to cram information into vertex data for a special shader you might need bitwise operations to make full use of all bits. Also custom hash key algorithm, as well as pseudo random number generation can be done with bit math.
« Last Edit: October 02, 2016, 07:08:53 AM by standardcombo » Logged

Dacke
Level 10
*****



View Profile
« Reply #4414 on: October 02, 2016, 06:55:38 AM »

Turns out, yes they do!

Most compilers will go even further than reducing division by powers of 2 into shifts - they'll often convert integer division by a constant into a series of multiplication, shift, and addition instructions to get the result instead of using the CPU's built-in divide instruction (if there even is one).


Btw I love bit fiddling and even beat some old bit fiddling high scores in a machine programming course I took. So it kind of hurts me to always find out I don't need to use it.
Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW
« Reply #4415 on: October 02, 2016, 10:00:17 AM »

Congrats! Is this the gameplay?

That's the Atari 8-bit computer port.  The Atari 8-bit computer line has the same hardware as the 5200, so porting between one and the other is a breeze.

I didn't do the porting.  The game's source is released under the GPL and some industrious individuals decided to port it.  The original port had to drop the three-player mode, but the same people just released a second port that includes it.
Logged



What would John Carmack do?
InfiniteStateMachine
Level 10
*****



View Profile
« Reply #4416 on: October 03, 2016, 08:36:36 AM »

Hello to everyone! (I post first time here)
Nothing special... I just want to say that refactoring and optimizing code is awesome when the results are considerable and visible (especially in a short time) and surprising a bit :D

A bit more details:
Debug builds of our game (see HERE) started running so slow that normal debugging was almost impossible. So I was refactoring the code all day yesterday (game uses my own engine written from scratch so there are a lot of places to optimize) and the FPS (in debug build) rose from 20 to 43! on a sample map (VC++ profiler was very helpful).

Cheers and have a nice weekend too! Smiley

Gotta love those kinds of measurable bumps in perf. What did the changes you did relate to? Data locality?
Logged

pturecki
Level 0
***



View Profile WWW
« Reply #4417 on: October 03, 2016, 02:30:48 PM »

Quote from: InfiniteStateMachine
Gotta love those kinds of measurable bumps in perf. What did the changes you did relate to? Data locality?

The most significant was adding caching support for point light shadow maps (and for visibility queries for them) for static geometry. It added +15 FPS. I have already done this for spot lights so it was not so difficult (I assumed that point lights would not need a shadows, but it's not true now).

I have an actor iterator called very often and it is based on two std::vectors. I replaced indexing std::vector by opearations on pointers and it gave +3 FPS (stl containers in debug are horrible).

And the rest are small math improvement (frustum vs oriented bbox, caching inv transform in actors instead of calculating it each time) and a few small changes (eliminating some frequent dynamic allocations).

I didn't even check how this changes improved release build performance (serious optimizations are still ahead of me, and it will be a lot of work).

----

And about bit operations: I use them for example in code that fills textures with data. Also in our game (lasers & mirrors=devices) devices have discrete rotations (8 directions) and for example to check if two lasers are on the same line I use code:
Code:
(dir1 & 3) == (dir2 & 3)
getting next direction (rotate left/right):
Code:
dir = (dir + 1) & 7
and a few similar operations...
But bit operations will always remind me of multiplication in assembler by 320 (320 = 256 + 64) in VGA 13h 320x200 mode Wink I remember well to this day when I was thinking about why this code works (or similar):
Code:
mov  ax, y
xchg al, ah
mov  di, ax
shr  ax, 2
add  di, ax
add  di, x
and 'di' register contains address of the pixel (x,y). Everything became clear when I realized that
Code:
xchg al, ah == shl ax, 8
So again for clarity:
Code:
mov  ax, y
xchg al, ah    ; ax = y * 256
mov  di, ax    ; di = y * 256
shr  ax, 2     ; ax = y * 64 (== 256 >> 2)
add  di, ax    ; di = y * 256 + y * 64
add  di, x     ; di = y * 256 + y * 64 + x
Assembler is cool (and I didn't use it for ages) :/ Sorry for the small offtop (at least I hope it's a bit interesing).
Logged

standardcombo
Level 8
***


><)))°>


View Profile
« Reply #4418 on: October 04, 2016, 10:29:14 AM »

I think assembly is fun in a hardware project. For example in college I wrote software for a street intersection and later drivers for 8-bit hardware. In modern OS and engines it's a drag to have to sometimes go into assembly to figure out bugs... I avoid that shit like the plague.
Logged

Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW
« Reply #4419 on: October 04, 2016, 03:11:58 PM »

My Atari project(s) are 100% assembly.  I don't see any point in doing homebrew for old consoles in anything but assembly.
Logged



What would John Carmack do?
Pages: 1 ... 219 220 [221] 222 223 ... 279
Print
Jump to:  

Theme orange-lt created by panic