I don’t know if everyone gets the reference: RollerCoaster Tycoon is in fact writing mostly in assembly to use the hardware more efficiently
Your game will actually likely be more efficient if written in C. The gcc compiler has become ridiculously optimized and probably knows more tricks than you do.
Especially these days. Current-gen x86 architecture has all kinds of insane optimizations and special instruction sets that the Pentium I never had (e.g. SSE). You really do need a higher-level compiler at your back to make the most of it these days. And even then, there are cases where you have to resort to inline ASM or processor-specific intrinsics to optimize to the level that Roller Coaster Tycoon is/was. (original system specs)
Yep but not if you write sloppy C code. Gotta keep those nuts and bolts tight!
If you’re writing sloppy C code your assembly code probably won’t work either
- Programming was never meant to be abstract so far from the hardware.
- 640k is enough ram for everybody.
- The come with names like rust, typescript, go, and python. Names thought up by imbeciles.
- Dev environments, environmental variables, build and make scripts, and macros, from the minds of the utter deranged.
They have played us for fools
I dabbled with making a fairly complex program for a microcontroller the other day and quickly hit the stack limit for a simple object.
It wasn’t so much that it was a large object, but to provide flexibility I was amazed how fast I filled the memory.
I’ve done heaps with memory managed languages in the past but shit as soon as I had to think about what I was doing under the hood everything got hard af.
So serious question - does anyone have any good resources for a competent programmer, but with no clue whatsoever how to manage memory in a microcontroller space and avoid fragmentation etc?
I got it to work but I’m sure I did shit job and want to be better at it.
The best book I’ve ever bought on programming, and the second best book I bought for a class in uni, was https://dl.acm.org/doi/book/10.5555/1824214 it may be worth checking out on libgen and buy if it suits your needs.
Whenever I do low-level programming on the AVR architecture, I’ll make a memory map. As in I’ll map out where I’ll put what. It may not be suitable for more complex programs, but it does the job for me. And it has enabled teamwork in assembly in the past.
If you want to work in a language that doesn’t offer memory management, but manually mapping memory isn’t feasible either, how about building your own memory management? Or perhaps use an RTOS? I’ve used freeRTOS before on various arm-based micros, and it does take a bit to get started, but after that it’s easy sailing.
Sorry for the following tangent, all semi intelligent content in this comment is found above this line.
BTW I tried CoOS once, I wouldn’t recommend it… OK it was 12 years ago, I can’t remember exactly what was wrong other than the documentation was crap, but I don’t need to remember why to hold a grudge.Bought the book! Thanks
Adobe promised that Lingo was the future of ‘PC and internet gaming’
Luckily by the time I had to learn to write that garbage I already coded in several other languages. Made it easier, but somehow more painful. I’m pretty sure that shit was designed so that executives could look at the code and pretend they understood what was going on. At least with ‘common terms’ it eliminated the need for commenting out most of the time. One line of code would take a paragraph of text lol.
try writing it it in Assembly
Small error, game crashes and takes whole PC with it burning a hole in the ground.
Just don’t make any errors. Not one.
Back into the fiery pit of hell, where it belongs!
It was really easy to crash an Apple II game and get into the assembler. And my goodness am I glad I didn’t destroy my computer as a kid randomly typing things in to see what would happen.
Remember old Apple, had to use them when learning to program, there were 2 types, one with the OS on a diskette, one with a small hard drive, and they randomly showed a large bomb in the middle of the screen and you had to reload the OS. Probably the compuler that broke everything.
That’s Mac era stuff. I’m talking about the Apple II series, which had no GUI.
Ha ha yeah, I’m confused and old 🤤 sorry about that.
Step 1: Begin writing in Assembly
Step 2: Write C
Step 3: Use C to write C#
Step 4: Implement Unity
Step 5: Write your game
Step 6: ???
Step 7: Profit
Eww Unity
Good thing I wrote my own game engine using D, and soon there will be 2 (known) games for it.
I’m on E already
petah please what’s this mean
The game Roller Coaster Tycoon was famously hand written in raw CPU instructions (called assembly language). It’s only one step removed from writing literal ones and zeros. Normally computers are programmed using a human-friendly language which is then “compiled” into CPU instructions so that the humans don’t have to deal with the tedium and complication of writing CPU instructions.
To further emphasize this, I had an assembly course in university. During my first lab, the instructor told us to add a comment explaining what every line of assembly code did, because if we didn’t, we would forget what we wrote.
I listened to his advice, but one day I was in a rush, so I didn’t leave comments. I swear, I looked away from the computer for like 2 minutes, looked back, and had no idea what I wrote. I basically had to redo my work.
It is not that much better than reading 1s and 0s. In fact in that course, we spent a lot of time converting 1s and 0s (by hand) to assembly and back. Got pretty good at it, would never even think of writing a game. I would literally rather create my own compiler and programming language than write a game in assembly.
I’m probably completely insane and deranged, but I actually like assembly. With decent reverse engineering software like Ghidra, it’s not terribly difficult to understand the intent and operation of isolated functions.
Mnemonics for the amd64 AVX extensions can go the fuck right off a bridge, though.
VCVTTPS2UQQ
might as well be my hands rolling across a keyboard, not a truncated conversation from packed single precision floats into packed unsigned quadword integers.I had a course in uni that taught us assembler on z/os. My advisor told me most students fail the course on the first try because it was so tough and my Prof for that course said if any of us managed to get at least a B in the course, he’d write us a rec letter for graduate school. That course was the most difficult and most fun I’ve ever had. I learned how to properly use registers to store my values for calculations, I learned how to use subroutines. Earned myself that B and went on to take the follow up course which was COBOL. You’re not crazy, I yearn to go back to doing low level programming, I’m mostly doing ruby for my job but I think my heart never left assembler hahaha
Ah yes, there was this guy in our tech school class that used to code golf in assembly. Was a crack in math and analytics too, which might explain it somewhat. Well, everyone is different i guess.
thanks petah
To send the point home even more, this is how in python you make a line of text display:
print("Hello World")
This is the same thing, in assembly (According to a blog I found. I can’t read this. I am not build better.)
org 0x100 ; .com files always start 256 bytes into the segment ; int 21h is going to want... mov dx, msg ; the address of or message in dx mov ah, 9 ; ah=9 - "print string" sub-function int 0x21 ; call dos services mov ah, 0x4c ; "terminate program" sub-function int 0x21 ; call dos services msg db 'Hello, World!', 0x0d, 0x0a, '$' ; $-terminated message
But python turns that cute little line up top, into that mess at the bottom.
I like python. Python is cute. Anyone can read python.
That assembly is for a DOS application. It would be more verbose for a modern Linux or Win32 application and probably require a linker script.
But python turns that cute little line up top, into that mess at the bottom.
Technically, not quite. Python is interpreted, so it’s more like “call the print function with this string parameter” gets fed into another program, which calls it’s own functions to make it happen.
Yeah over simplifying it a bit, and that’s funny that the stupid thing I found wasn’t even stupid enough.
But was mostly trying to impart that we should be happy for modern languages, because for every line you write in a modern language, it’ll do a dozen things on the back end for you that in assembly you’d need to do by hand.
Chris Sawyer is a madman.
Not Assembly, but HROT was written in Pascal by one person and runs buttery smooth.
Oooh! Know what I’m playing this weeeknd! Thanks!
This game ran so smooth.
I’ve already got a park map.
Reminder that ttd was open source even before open ttd :D
I wanna see someone make a GPU accelerated game in assembly.
Just throw the Vulkan and DX12 C APIs in the garbage and do it all yourself lol.
I don’t know exactly how much code reuse Sawyer had going back then, but if you’ve ever played Transport Tycoon (or more likely the open source version around today, OpenTTD) then you know that the interface and graphics are extremely similar. So it’s not like he started from scratch each game with nothing but a hot spinning disc and a magnetized needle.
But yeah, the main reason to put up with all the modern framework bloat is the ever-ephemeral promise of being able to write your thing once and have it ported to run anywhere with minimal to no further effort.
you need all of that when writing a game in assembly. wtf do you think assembly is?
deleted by creator