[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Can we have a "Games made in Assembly" thread? Some

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 110
Thread images: 7

File: RollerCoaster_Tycoon_Screenshot.png (37KB, 375x281px) Image search: [Google]
RollerCoaster_Tycoon_Screenshot.png
37KB, 375x281px
Can we have a "Games made in Assembly" thread?

Some months ago I saw a thread about it and I found some gold.

Is there any good game, or a simple game, made in NASM?
>>
>>42389644
>RollerCoaster Tycoon
>Scottish game developer Chris Sawyer originally wanted to create a sequel to his highly successful Transport Tycoon, but after becoming obsessed with roller coasters, he changed the project into RollerCoaster Tycoon. Sawyer wrote RollerCoaster Tycoon in x86 assembly language, which was rare for a game published in the late 1990s. Some functions were written in C for interaction with the Windows operating system.[1]
>Some functions were written in C for interaction with the Windows operating system.[1]
Any else find it comical that he had to move from assembly to a higher-level language just so he could interact with the OS?
>>
>>42389644
Which CPUs and GPUs being as powerful as they are today, is there truly any need for assembly in games these days?
Even mobile devices are getting pretty powerful these days
>>
>>42389644
well, I don't really know about this, but the demoscene is full of this:
http://en.wikipedia.org/wiki/Demoscene
>>
>>42389808
Was there ever a demoscene general on /g/? Can we get a demoscene general going? I'd love to see one, especially since the graphics programming general died, which is where I got most of my demoscene help
>>
>>42389695
Not really. It's still the reality now.

Typically you write C to interact with OS'.

And I can even see people using some unspecified functional & very syntactically powerful languages to do this, in the not too distant future.
>>
>>42389644
http://board.flatassembler.net/topic.php?t=15746&postdays=0&postorder=asc&start=0

I can't seem to find the link though I'm logged out right now. Maybe it'll show up when you log in but this is a pretty impressive and fun geometry wars clone written in asm. There are some other games that are pretty fun.

There's also this tutorial which is pretty neat:
http://www.madwizard.org/programming/tutorials/mosaic/

idk if this is what you're looking for but a significant majority of old games were written in assembly language. These days it's hard to beat good compilers speed-wise. You can still beat them size-wise if you're good though.
>>
>>42389774
Just because computers are much more powerful doesn't mean there's no need for super efficient assembly code in game and graphics engines. People aren't happy when it takes a top of the line computer to run a game that looks like shit and chugs when the physics get busy.
>>
File: gridawesome.png (987KB, 834x716px) Image search: [Google]
gridawesome.png
987KB, 834x716px
>>42389864
oops img of GW clone
>>
>>42389844
Yup, that has happened before. But it doesn't always succeed. Maybe if you created some webm, started a new thread and kept it going...?
>>
>>42389695
he didn't have to; you can call winapi stuff just fine from assembly. he probably did it for ease of handling all the winapi hungarian crap...
>>
File: corneroids swastika.png (301KB, 922x985px) Image search: [Google]
corneroids swastika.png
301KB, 922x985px
I think corneroids was built in assembly.
A real shame the dev went awol, its still the best minecraft in space thats out there.
>>
Every console game NES generation and earlier was made in assembly.
>>
>>42389875
That compilers are getting more powerful means that they now *mostly* provide efficient assembly code, anyways.

It's also increasingly necessary that *magic* in hardware or software does the distribution of software tasks across all the CPU/GPU, anyways. You're not going to code that in-depth in assembly, and as such a large motivation for assembly disappears.

Assembly is getting less and less important... I'm sure it'll still be used in a decade, but I predict it's going to be increasingly niche (even more than today).
>>
I once downloaded copys of old games and their source code from some website and looked at the .asm files to see what it was like.

Well shit, everything was weird as fuck and i couldnt understand a thing. So i like at he documentation of the game development and found the sprite code for the torches and fire effect in game. Looked through the code and i couldnt make out what it was doing...
>>
how exactly to you draw something to the screen using ASM

how do the graphics libraries do it?
>>
>>42389890
>webm
you can download webms directly from youtube, with youtube-dl

here is one video
https://youtu.be/lwFVlNytq0Q
(got it from http://www.phoronix.com/scan.php?page=news_item&px=MTY2ODc )
>>
>>42389915
i had heard that the koei garbage was written in some crappy C dialect; unsurprising, considering how bad those games were
>>
>>42389997
>I once downloaded copys of old games and their source code from some website and looked at the .asm files to see what it was like.

What games?

>>42389915
16-bit games all asm as well.

>>42390069
You call up the graphics libraries which then process the function and write it to the VRAM. Derp?
>>
>>42389922
>going to be increasingly niche
Niche in the sense that it'll still be incredibly important but used by few, not as in hobby neckbeard shit.
>>
>>42390087
The games were also quite unusually huge (512-768k) which isn't typical of NES titles.
>>
>>42389695
I take it C would have been used for I/O functions (saving and loading files and graphics output)
>>
>>42390097
And soon by very, very, very few.

The ASM instructions are turning almost purely into a dictionary for a compiler, and the algorithms when and how to use them in the generation of machine code are already written in a more abstract, higher-level language.
>>
>>42390270
so they couldnt do I/O in assembly?

>wut?
>>
>>42390270
I think so. Although as for the latter, Windows 9x allowed you to blit directly to VRAM while NT did not (they finally added this to XP)
>>
>>42390292

>>42389902
>>
>>42390270
Yeah the game mostly used assembly for calculations and data storage/handing.
>>
>>42389850
How does one use multiple languages in one project?
>>
WHY DON'T WE JUST HAVE OUR CPUS USE C++ AS INSTRUCTION SETS?!??
>>
I'm still baffled as fuck to how you're supposed to draw shit to the screen with assembly, let alone C.

He also basically made a physics engine in assembly for the roller coasters when they go up and down and swerve and turn and fucking CRASH

How do you fucking even
>>
>>42390504
That would be even bigger and have more baggage than x86.
>>
>>42390434
Easy:

>write module in ASM
>write module in C
>your compiler merges them together into one executable
>the C part just becomes subroutines in the main program that it calls up.

At least in the DOS days, you'd compile programs into an intermediate format know as a LNK file and then run it through LINK.EXE to turn it into an executable, and you could merge multiple LNK files produced with MASM, C, or whatever. Dunno how it works nowadays though.
>>
>>42390558
>I'm still baffled as fuck to how you're supposed to draw shit to the screen with assembly, let alone C.
What. All you do is have a table with your graphics data and then call up DirectX functions for screen output.
>He also basically made a physics engine in assembly for the roller coasters when they go up and down and swerve and turn and fucking CRASH
As for math operations and FP, you'd just use x87 instructions for that shit.
>>
File: image.jpg (20KB, 350x265px) Image search: [Google]
image.jpg
20KB, 350x265px
>>42390618

o ok
>>
Writing large-scale projects in ASM isn't all that hard; in fact I'd say it's easier with modern OSes because you have features like DirectX for easy graphics handling. The main reason it's not done much is portability.
>>
>>42390675
so youre saying that simple ASM programs can run on a mac/windows/linux?
>>
File: 1397015816807.jpg (99KB, 799x426px) Image search: [Google]
1397015816807.jpg
99KB, 799x426px
>>42389644
>>
>>42390799
Since Macs use x86 nowadays, it's probably not that hard. You'd mostly just have to change the OS calls while the core code (for doing calculations and whatnot) would not need to be changed at all.
>>
>>42390618
What is x87?

(forgive me for such a clueless n00b question)
>>
>>42390836

It's like C++ is to C.

So it's basically like x86++
>>
>>42390836
x87 - the math coprocessor part of x86 CPUs. It was a separate chip in olden times (because manufacturing limitations) but on the main CPU since the 486.
>>
>>42390836
The co-processor instruction set. Before 2000ish it was costly to integrate floating point (FP) mathematics into the standard processor (Such as the Intel i386/486) and not every computer needed it. The x87 instruction set served as the sidecar to the main processor and gave added functions.

As time progressed and the original Pentium was released, there was a far lesser need for a co-processor as it was already integrated into the Pentium CPU and the rest is history.
>>
x87 is mostly just needed by math-intensive software. In days of yore, you would install one if you were running Lotus 123 or AutoCAD, but games didn't use it except occasionally flight simulators.

Since it's part of the main CPU since the mid-90s, games and whatnot use x87 instructions commonly now.
>>
>>42390892
No, that would be the 386 aka IA-32.
Like C++, IA-32 took a relatively simple but somewhat ugly core and added some useful features along with a bunch of crap nobody ever uses.
>>
>>42389644
Check ticalc.org which as assembly files for like everything calculator wise.

I'm pretty much hacking away at my Ti-84+ SE with alternate operating systems like KnightOS. I can't get BAOS to work yet, but I'll get Tilem working soon.

Z80 assembly is pretty kickass. It's actually more readable and it has nice macros for the Ti-84. I'm not sure about m68k ASM yet.
>>
>>42390948

Shut up faggot I'm right and you're wrong
>>
>>42390993
Nope, he'S right. x87 has nothing to do with abstraction of the language syntax.
>>
>>42390948
x86 was always padded with useless instructions. When was the last time you ever used ESC or XLAT?
>>
test
>>
>>42391119
Consider me retarded,
A less bloated instruction set = faster and/or more efficient cpu?
>>
>>42391331
It doesn't really affect performance, it's just that x86 has lots of instructions that are seldom used or needed.
>>
File: tbasm_title.png (2KB, 322x335px) Image search: [Google]
tbasm_title.png
2KB, 322x335px
Tom Bombem
http://www.deater.net/weave/vmwprod/tb1/

It's ASCII game, several versions, at least one is i386 asm on Linux.
>>

MOV DX,MESS1
MOV AH,9
INT 21h
MOV AX,4C00h
INT 21h

MESS1 DB 'OP is a faggot',0Dh,0Ah,'$'

>>
>>42391609
Is dat sum oldskool DOS code?
>>
>>42389774
The "unused resources = wasted resources" motto is very harmful for modern computing.
Why should we need any optimization at all them? Just write everything in Python and throw more cores and RAM at it?
>>
>>42390069
You can call any functions you like from assembly. They're just memory addresses in the end. The only thing you need to know is the function signature and the calling conventions of your operating system.

We're currently doing a project for university where we implement a trigonometrical library in x86 assembly only, but using printf or other functions from the C stdl for debugging really only requires you to link against the C stdl with gcc (which leaves your assembly code intact)
>>
>>42391739
As explained earlier, there's no reason RCT couldn't call Windows API functions in asm, but Chris Sawyer likely used C for convenience reasons.
>>
>>42390892
>>42390836
Basically the instruction set for the FPU (floating point unit)
>>
>>42391644
Yeah that's the old Print String function (INT 21h, Function 9). It was part of the original DOS 1.x API and was essentially lifted straight from CP/M, which had a similar "Output String" function (strings have to be terminated with a $, just as they were in CP/M)

Officially, Microsoft said that Function 9 was obsolete and in DOS 2.x and up, you're supposed to open the screen as an output file with INT 21h, Function 3D and then write to it with Function 40h, but their own software often uses Function 9 anyway.
>>
>>42391331
>A less bloated instruction set = faster and/or more efficient cpu?
More or less.
>>
>>42390573
It's still the same. You compile the parts individually, and link them together to form the final binary/executable.
>>
>>42390799
It's functionally no different from compiling and executing C code, which is supported under all major operating systems. Only thing to watch out for is to make sure you're using an instruction set compatible with the underlying hardware.
>>
Pretty much most of the games on Sega Genesis are assembly, but with a different instruction set than x86.

Most technically impressive one is probably Gunstar Heroes.
>>
>>42392024
Almost all console games pre-5th gen were written in assembly.
>>42391903
Obviously - you can't use instructions that the target CPU doesn't support.
>>
>Ctrl+f "Spyro
>0 results
>>
>>42392024
Genesis is 68000
>>
>>42392207
Spyro probably used C++ like every PS1 game.
>>
>>42392221
PS1 and N64 had RISC CPUs - you really don't want to program those in assembly.
>>
>>42392277
>>42392221
IIRC, the official programmer's reference manual for the PS1 stated that programming in assembly is not recommended.
>>
Here is a graphics engine written in assembly for the Nintendo 3DS. Quite impressive what they can pull out of the miniscule hardware. Assembly still has it's using if you want every ounce of performance out of the hardware (given you know what you are doing).

https://www.youtube.com/watch?v=bwUOoXX5fDY
>>
>>42392277
True, but Saturn games quite often employed assembly because Sega's dev kit was pretty limited and shitty and because the awkward dual CPU setup meant that you needed as fast code as possible.
>>
same >>42392304
Oh btw the tech demo actually runs at 60fps, so you should be able to find a proper 60fps version as youtube doesnt support more than 30fps.
>>
Couple days ago, I don't know how big the damagae is yet, should make the Bitcoin price change a bit, here's the link pastebin 7pbmALJa
>>
On 8-bit computers, assembly was typically the only option but IBM PCs it was common to use HLLs from Day 1.
>>
>>42391739
>We're currently doing a project for university where we implement a trigonometrical library in x86 assembly only

Does it have to be in only x86 or can you cheat and use the x87 instructions?
>>
>>42392344
is this manual spamming in every thread or did they break through the captcha?

looks like someone who doesn't speak english
>>
>>42391739
>>42392583
Shouldn't be hard. They included trigonometric functions on 8-bit BASICs which had a couple of bytes or something.
>>
>>42391609
Or,


MOV AX,3 ;set 80x25 text mode
INT 10h
PUSH DS ;save old data segment
MOV AX, B800h ;segment with text mode VRAM
MOV DS,AX ;put in DS
XOR BX,BX ;clear BX in preparation for the loop
XOR SI,SI ;set SI to point to start of VRAM
LOOP1:
CLD ;clear direction flag
MOV DI,MESS1 ;get address of message
MOV CX,0Fh ;number of bytes to copy
REP MOVSB ;put them into VRAM
INC BX ;increment BX counter
CMP BX,7D0 ;have we done the entire text buffer?
JNZ LOOP1 ;if not, go back and do it again
POP DS ;restore old data segment
MOV AX,4C00h ;exit to DOS
INT 21h

MESS1 DB 'OP is a faggot '

>>
>>42393374
Fug, 4chan messed up the spacing of the comments.
>>
>>42393374
Did I fall asleep and wake up in 1988? Kindly provide a version that works in modern Windoze console mode.
>>
>>42393438
Oh bitch, bitch, bitch.
>>
>>42393480
Just Saiyan...
>>
>>42393374
Oh nuts, I just realized I fucked something up here. Nvm.
>>
>>42392304
>https://www.youtube.com/watch?v=bwUOoXX5fDY
it makes you wonder just how inefficient the official 3ds compilers must be if other devs can't match that level of graphical fidelity in their games.
>>
Fixed.

MOV AX,3                          ;set 80x25 text mode
INT 10h
PUSH CS ;make sure code and data segment are the same
POP DS
PUSH ES ;save old ES
MOV AX,B800h ;segment with text mode VRAM
MOV ES,AX ;put in ES
XOR BX,BX ;clear BX in preparation for the loop
XOR SI,SI ;set SI to point to start of VRAM
LOOP1:
CLD ;clear direction flag
MOV DI,MESS1 ;get address of message
MOV CX,0Fh ;number of bytes to copy
ES:
REP MOVSB ;put them into VRAM
INC BX ;increment BX counter
CMP BX,7D0 ;have we done the entire text buffer?
JNZ LOOP1 ;if not, go back and do it again
POP ES ;restore old extra segment
MOV AX,4C00h ;exit to DOS
INT 21h

MESS1 DB 'OP is a faggot '

>>
>>42393783
I forgot that the string has to be pulled from the data segment which isn't the same as the VRAM. Thus, DI gets its data out of the data segment and SI puts it in the extra segment (the ES: tag is there to tell the CPU not to shoot it into the data segment). The string is in the code segment so the PUSH CS/POP DS bit is just to make sure the data segment is the same location.

Anyway, MOVSB (if you don't know) works by taking the byte from the offset address in DI and copies it into the address in SI, then increments both index registers (provided the direction flag is cleared; setting it decrements the registers). REP is there to keep executing the instruction until CX is zero. Then we just loop back until we've done the entire 2000 bytes of the text screen (the program fills the whole screen with the string), then restore ES to its old value, and exit out to DOS. DI is reset to the start of the string each time we go through the loop while SI is untouched so it can keep incrementing to cover the entire video buffer.
>>
>>42390270
do you even syscall?
>>
>>42390279
This. If you are considering to program anything in an assembly language then you're doing it wrong. Everyone who's not a complete retard will write the stuff that has to be fast in C (or C++), then profile it and see if anything is too slow. If it is then you put some inline-assembly into the C(++) code and there you go.
>>
>>42393866
I bet he's never heard of kernel mode assembly either.
>>
>>42393858
You also have STOSx which takes the 8/16/32/64-bit value in AL/AX/EAX/RAX and copies it to the offset in DI/EDI/RDI and LODSx which does the same in reverse. Then SCASx which compares the value in AL/AX/EAX/RAX to the one in the address pointed at by DI/EDI/RDI and raises the Zero Flag if positive. Finally, COMPSx which compares the value in the address pointed at by DI/EDI/RDI with the one in SI/ESI/RSI and same thing.

In all cases, REPZ/REPNZ can be used for looping execution of the instructions and the direction flag is used to indicate whether the index registers are incremented or decremented.
>>
>>42393783
>>42393858
>>42393918
>>42391609
So... where do I start learning this?
>>
>>42393964
Taking a course in embedded systems programming and then applying the knowledge gained to other instruction sets would be one way to go about it.
>>
>>42391609
>tfw I once did Fizzbuzz in ASM
>didn't save it
>cba to do it again
>>
>>42393964
A few Google searches will find you all the info on x86 asm you'd ever want and then some.

The examples I posted are oldskool DOS though; you can just use Windoze console mode for this on a modern machine.
>>
>>42393980
Most embedded systems courses will have you program C or VHDL.
>>
>>42393989
This. Mostly for the reason posted in >>42393883
>>
>>42393987
Ok then. Time to search.
>>
>>42393987
Console mode works differently though because you'd have 32/64-bit code instead of 16-bit and would call the Windows text output function instead of blitting right to the VRAM.
>>
>>42393858
>>42393783
Thank Jesus that we never have to worry about memory segments again.
>>
>>42394101
Yes...
>>
>>42393783
>>42393374
>>42391609

mips asm
.data
str: .asciiz "OP is a faggot"
.text
ori $v0, $v0, 4
la $a0, str
syscall


nice, isn't it ?
>>
File: 3312313.jpg (188KB, 480x724px) Image search: [Google]
3312313.jpg
188KB, 480x724px
Is learning assembler even practival if you are not going to write OS?
>>
>ctrl-F
>Elite
>no results

Shame on you.
>>
>>42394290
If you write VMs, interpreters or compilers in any form (even regex compilers or SQL vms), yes.
>>
>>42394260
If I had a little more time, I'd show you how to do that on a Commodore 64 ;)
>>
>>42394323
I'd think it would be easier on there since you have no goddamn segments to deal with.
>>
>>42393964
if you want a basic crash course you could look at some of the 90s cracking tutorials that are on the internet (there's tons of them). They explain a fair amount of asm for a non-cs educated person to learn (purely in a cracking context).
>>
>>42394064
You can blit to the VRAM on Windows, right? That's been possible since Windows 95.
>>
>>42394416
Thank you, I'll search for that.
>>
>>42393783
Proper assembler syntax would be MOV DI, OFFSET MESS1. Otherwise it will just load DI with the contents of the memory location rather than the address itself. Also you would want to put your data before the start of the program as it compiles faster that way.

JMP START

MESS1 DB 'OP is a faggot '

START:
MOV AX,3 ;set 80x25 text mode
INT 10h
PUSH CS ;make sure code and data segment are the same
POP DS
PUSH ES ;save old ES
MOV AX,B800h ;segment with text mode VRAM
MOV ES,AX ;put in ES
XOR BX,BX ;clear BX in preparation for the loop
XOR SI,SI ;set SI to point to start of VRAM
LOOP1:
CLD ;clear direction flag
MOV DI,OFFSET MESS1 ;get address of message
MOV CX,0Fh ;number of bytes to copy
ES:
REP MOVSB ;put them into VRAM
INC BX ;increment BX counter
CMP BX,7D0 ;have we done the entire text buffer?
JNZ LOOP1 ;if not, go back and do it again
POP ES ;restore old extra segment
MOV AX,4C00h ;exit to DOS
INT 21h

Thread posts: 110
Thread images: 7


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.