Friday, May 9, 2025
HomeIndie Gameworking on earliest PCs made with 1981-1982 instruments solely

working on earliest PCs made with 1981-1982 instruments solely


vdapps


#0
The Concept

After my different challenge, RTG, nearing its completion, I used to be considering what I wish to do as subsequent challenge. Given how little free time I’ve, challenge of RTG scope is an excessive amount of legal responsibility, when after 5 years of improvement, it is actually about perseverance in ending it and fewer about having enjoyable from improvement itself.

I like experiments, non-traditional approaches, challenges, I like figuring out how issues work underneath the hood at low-level, I think about myself extra programmer than artist. I am not a lot desirous about Unity, UE, and so forth the place most indie devs go, even when it means my sport will likely be extra area of interest and more durable to monetize (if ever). And I had a number of loopy concepts in previous months for some loopy video games in loopy dev environments.

Naturally, I do not need to spend one other 5 years with some super-niche sport, that is why upcoming challenge(s) ought to match these circumstances:

– brief web improvement time
– pure pastime – enjoyable to develop
– experimental in nature
– utilizing some difficult loopy tech

I do not plan to monetize such sport, so it’s going to be given at no cost, as soon as (if) it is completed.

Certainly one of concepts I had, which was consuming me, was to make a sport which can natively run on earliest IBM PC-s from 1981 with PC-DOS 1.0, and furthermore, making it solely with instruments obtainable in these instances. Loopy, proper? Return in time, test what was obtainable, and make new recent 2025 sport working natively on 1981 PCs. Naturally, due to emulators like DOSBox, the sport will likely be playable on trendy PCs as properly.

I already did some analysis, it’s doable and I believe I’ll make it, nevertheless it WILL be difficult. working on earliest PCs made with 1981-1982 instruments solely

Put together that this devlog won’t be a lot concerning the sport (even when there will likely be some sport in the long run), however about loopy tech ranting about making such sport. Put together to learn (and study) about some early 16-bit x86 peculiarities, 1982 PC-DOS 1.x improvement challenges, BIOS and early DOS calls, and so forth.. What I’ll study in that loopy journey, I will attempt to place right here.

If consequence will likely be remotely playable and a minimum of a bit enjoyable, I’ll place it at no cost on platforms like itch.io or Sport Jolt or perhaps even Steam, it relies upon, will see. For me, it is about having enjoyable from new experiment and problem. Improvement pacing will likely be completely relaxed. I am dedicated to ending RTG at first place, I’ve day job and household, so when I’ve time, I will transfer little by little, what’s necessary is: that is pastime challenge, it must be enjoyable, not legal responsibility, I need to do it, not should do it. And I definitely hope that such loopy stuff will likely be a minimum of a bit fascinating for somebody.

« Final Edit: Might 03, 2025, 02:38:55 PM by vdapps »
Logged

vdapps


#1
Improvement setting – DOSBox-X, PC-DOS 1.x

Very first thing I must sort out when creating native unique 1981 IBM PC sport is to have correct setting by which to develop. As I haven’t got previous DOS PC mendacity round, I’ve to emulate. There are a number of choices starting from relaxed use of traditional DOSBox (which may simply run previous 1981 assembler compiler, which I’ll use) as much as hard-core emulation by means of PCem or 86Box with their BIOS photographs and cycle per cycle emulation the place booting to immediate takes nearly 1 minute (like was in unique IBM PC).

I selected DOSBox-X (fork and huge enchancment of unique DOSBox) for the duty for a number of causes. I do not need to boot 1 minute to unique IBM PC photographs when going to develop, so I rejected PCem/86Box. However, traditional DOSBox just isn’t maintained for very very long time and it CAN’T imitate early PC-s very a lot. Among the causes and variations are as following:

DOSBox-X can limit emulation even to only 8086 directions with out FPU (which was the case of early PC-s), whereas DOSBox lowest is 80386 with FPU
DOSBox-X can emulate tremendous low quantities of RAM (first IBM PC-s with floppy drive(s) and PC-DOS 1.x began with 32kB of RAM) whereas DOSBox lowest is 1MB of RAM
DOSBox-X has IMGMAKE utility which may create 160/180/320kB (earliest IBM PC requirements) empty floppy photographs

I setup DOSBox-X for 8086, CGA, 128kB RAM emulation and run it, nevertheless it’s nonetheless not sufficient hard-core. DOSBox-X command immediate is kind of highly effective with lot of instructions obtainable, which was not the case of early IBM PC-s. I would like problem of creating in 1981-1982 setting which was far more spartan in comparison with DOSBox-X immediate. Only for instance, 1981 PC-DOS 1.0 supported solely 160kB floppies, no exhausting disk and no folders! Command immediate had solely few instructions obtainable in comparison with later DOS variations (and to DOSBox-X command immediate).

This leads us to subsequent step. Booting with DOSBox-X to unique PC-DOS 1.0 picture. As soon as completed that, I’ve fairly good emulation and setting of earliest PC-s with earliest PC-DOS with all their restrictions, however with out tedious lengthy boot instances (due to DOSBox-X). Now, it is extra prefer it. I am restricted to 2 160kB floppy disk photographs (as counting for drives A: and B: of early PC-s) the place A: remains to be partially occupied by PC-DOS 1.0 itself, and I’ve to cram there all wanted dev instruments plus my sources. No exhausting disk, no folders, identical as was the case of first IBM PC-s with PC-DOS 1.0.

Notice: perhaps later I’ll change to PC-DOS 1.1 which was launched in 1982, 1 12 months after first IBM PC launch. It nonetheless meets my requirement of utilizing solely 1981-1982 setting and instruments. Greatest benefit of PC-DOS 1.1 is help for double-sided floppies, which suggests 320kB per floppy picture (as a substitute of 160kB of PC-DOS 1.0), thus extra space for dev instruments and sources. Nevertheless, for now I need to problem this setup of PC-DOS 1.0 with solely 160kB per floppy picture, to see, how it’s to make precise sport in such constrained setting.

Now sufficient ranting and let’s greet my new loopy (for 12 months 2025) setting which can serve for improvement of some new loopy sport.

And lastly, when researching and studying all of this, I discovered lot of nice websites, so I am sharing it with you in case of curiosity:

DOSBox-X (I believe I launched it sufficient on this devlog):
https://dosbox-x.com/

Nice preservation website for downloading previous PC SW, I acquired PC-DOS photographs there:
https://winworldpc.com/house

Authentic IBM PC emulated machines on-line, lot of legacy SW and docs:
https://www.pcjs.org/

Nice website to find out about legacy OS-es, in fact my biggest curiosity is in DOS historical past, lot of fascinating data:
https://www.os2museum.com/wp/dos/dos-1-0-and-1-1/

Okay, now actually completed ranting, extra tremendous oldschool dev goodies will come later. Durr...?


Logged

vdapps


Cool picture! Is that actual or AI? working on earliest PCs made with 1981-1982 instruments solely

Relating to Startron on DOS. From what I find out about your challenge, it is made in C#/.NET proper? (my favourite language)

If that is so, then it will likely be actually difficult as there isn’t any C# in DOS AFAIK. Closest you will get is C++ for some final DOS-es in 90’s, however even then it will likely be lot of refactor. E.g. there isn’t any rubbish assortment, reminiscence administration it’s important to safe by your self and naturally there can be lot of rewriting to different language.

Additionally, presently I am on early 80’s PC-s and DOS-es. This implies CPU solely in 16-bit real-mode (there was nothing else in these instances). It is each’s x86 CPU-s default at startup, even trendy ones. In actual mode you’ll be able to allocate and handle max 64kB directly. You may have extra 64kB segments, between which you’ll be able to change, however handle house in actual mode remains to be as much as 1MB. However real-mode PC applications usually have to suit to notorious “lower than 640kB restrict” for some architectural causes (e.g. VGA video reminiscence at handle 0xA0000 and another stuff). Startron appears fairly huge, so it might be fairly a limitation.

Ranging from 80386 CPU, you’ll be able to change CPU to 32-bit (now additionally 64-bit) protected mode. It is loopy low-level stuff, nevertheless it’s mode by which all trendy OS-es like Home windows and Linux work from startup. Then you’ll be able to have steady 32/64-bit handle house. When you code for Home windows/Linux, you do not care, you are in protected mode already and you may allocate e.g. 1GB of reminiscence directly, no drawback.

Btw, this actual mode I discussed is legacy stuff, for backward compatibility. Even all trendy CPU-s energy up as 16-bit. Very first thing which Home windows/Linux do in very early booting is switching CPU to protected mode after which they are going to take over. However in DOS you are in that 16-bit mode by default in command line even on trendy CPU-s. If you need protected mode and 32-bit reminiscence goodies, it’s important to change to protected mode in code of your sport, and when exiting, it’s best to gracefully change again to real-mode and return again to immediate. Though there have been video games which simply did not care with switching again and also you needed to reboot your PC while you’re completed enjoying.

Anyway, I hope I will get additionally to this protected mode stuff finally with my experiments, I’ve lot of concepts. If I will bump into one thing usable for Startron (like non-tedious means of switching to protected mode, some good C++ compilers or good larger libraries to make use of), I will place it to devlog and allow you to know! Coffee And you’ll nonetheless comply with my early PC-s / DOS tech ranting right here anyway in any case. I kinda hoped it may be fascinating for somebody, even when I do know it is extremely nerdy. Smiley


Logged

vdapps


#2
Improvement setting – IBM Private Editor, IBM Macro Assembler 1.0

In earlier devlog I tackled query of emulation and OS use, so I am as near 1981-1982 expertise as attainable however with out tedious lengthy boot instances. Booting to IBM PC-DOS 1.x picture in DOSBox-X emulating early PC (8086 directions, 128kB RAM, CGA) is suiting me finest.

Naturally, simply having OS for making sport just isn’t sufficient. It is true that in early IBM PC-s customers had built-in BASIC at their disposal for programming some easy stuff and doubtless a minimum of half of video games in these early instances had been written in it. However BASIC is what it’s, quite simple, very “primary” and really sluggish (it was interpreted language, nevertheless some BASIC compilers existed as properly). Anyway, to actually know the way issues work “underneath the hood”, one of the simplest ways goes with Assembler to put in writing instantly 8086 directions, and that is one thing I need to obtain with my experimental early PC sport.

Editor

There have been no IDE-s at disposal to put in writing Assembler code in these instances, so I needed to discover some a minimum of a bit succesful editor. Now, PC-DOS got here with built-in editor known as Edlin, which was obtainable instantly in 1981 with first PC-DOS model already. Nevertheless, working with it’s extra masochistic expertise than having enjoyable from coding. Actually, attempt it. You may edit just one line at a time, after ending you have to “exit” from enhancing line. You may’t scroll textual content, simply say from which strains you need to show. If you wish to edit line you have to state line quantity first. I assume, it was made shortly for enhancing few strains lengthy .bat information, however writing sport would require a minimum of tons of strains of code, so that is no-no. First editor (which I am conscious of) which was succesful for such job got here in 1982 and it was known as IBM Private Editor. After working with it for some time I used to be assured that it will likely be adequate for a job (and in context of these early years I’d even say it was GREAT choice). Let’s take a look.

Compiler

As we have now query of editor answered, now to most necessary half. One thing which can convert written Assembler code into exe file you’ll be able to run. I already talked about I’ll go together with 8086 Assembler. BASIC was too “primary” and sluggish, C compilers not existed but in these early years for DOS (first got here in 1983), I believe there was already some Pascal compiler obtainable, however you realize, I am extra C/C++ man, furthermore Assembler is as near metallic as you will get, permitting to know most exactly how issues are working underneath the hood. Finest (and solely?) choice obtainable in these instances was IBM Macro Assembler 1.0 (which was in truth re-selled Microsoft Macro Assembler in disguise).

So workflow will likely be as following:

 – edit .asm supply(s) with Private Editor
 – compile .asm file(s) to .obj file(s) with Macro Assembler
 – hyperlink .obj file(s) into .exe with linker (LINK.EXE)

Now the final line is fascinating. Whereas Macro Assembler needed to be bought individually, LINK.EXE utility was already a part of PC-DOS itself! Any common Joe who purchased model new PC, was in a position to hyperlink .obj information into .exe with primary DOS set up. Smiley And peculiar stuff just isn’t ending right here. A part of PC-DOS set up was additionally DEBUG.EXE. Very highly effective instrument which may load up any .exe file, step directions step-by-step, observe and print-out 8086 CPU registers, making disassembly (displaying Assembler directions again from compiled binary code), show reminiscence content material in hex and ASCII and so forth.., I used to be actually shocked.

Placing it collectively

So we have now all instruments wanted. As I discussed in earlier devblog, I wished to problem if it is attainable to develop on earliest 1981 PC-s with PC-DOS 1.0 which had solely 2 x 160kB floppy drives obtainable (1982 PC revision and PC-DOS 1.1 then supported double sided floppies so typical 1982 PC was 2 x 320kB floppy drives). Floppy A: after booting has already PC-DOS 1.0 itself. Even after cleansing up not wanted stuff from primary DOS set up in floppy A: (like pattern BASIC information, utilities not wanted for improvement), free house left was nonetheless not sufficient to cram there additionally Private Editor and Macro Assembler. So I made empty 160kB picture (floppy drive B: emulation) and redistributed instruments between two floppies. Ultimately I ended up with this setup:

Floppy A:

 – PC-DOS 1.0 set up with some eliminated stuff (to free house)
 – IBM Private Editor
 – my sources with intermediate .obj information and output .exe will go right here as properly

Floppy B:

 – IBM Macro Assembler 1.0 (MASM.EXE)
 – Linker (LINK.EXE) – which got here with DOS itself

On floppy A: I can even put together some .bat information later to invoke compiler/linker from floppy B: (to keep away from all the time typing “B:MASM blabla” or “B:LINK blabla”).

After placing it collectively I can confidently reply, sure, it is attainable to develop in Assembler additionally in PC-DOS 1.0 with 2 x 160kB floppies setup. After cramming the whole lot there, there’s nonetheless some house left for sources and compiler/linker outputs.

That is all for now, leaving this devblog with screenshots of my A: and B: floppies itemizing as described above. Extra hard-core early 1981-1982 PC x86/DOS tech ranting coming later. Durr...?


Logged

vdapps


#3
Documentation, technical references and smallest PC-DOS app

Documentation, references

In earlier devlog, I gathered all instruments wanted for improvement of early IBM PC sport purely with 1981-1982 instruments. However having instruments is one factor, figuring out to work with them is one other. So earlier than writing first line of code, I gathered and studied a number of documentations, technical references and pattern Macro Assembler sources. The place to seek out these docs I discussed in considered one of earlier devlogs. Now, here’s a record:

IBM-PC Technical Reference – exhausting description of structure, reminiscence maps, even documented BIOS assembler code itemizing! (screenshot). In instance, I’d not know how you can learn keystroke from keyboard or how you can use built-in PC timer with out this reference.
PC-DOS Technical Reference – deep dive into PC-DOS, together with description how DOS hundreds app into reminiscence and move execution to its code, how you can use DOS capabilities from Assembler (well-known int 21h), but additionally very detailed description of DOS command line instructions or how you can create superior .bat information
CGA Technical Reference (CGA is among the first “graphics playing cards” for IBM PC) – how you can set video modes in CGA, reminiscence map of CGA framebuffer, CGA palettes and so forth..
IBM Macro Assembler handbook – all 8086 Assembler directions, plus Macro Assembler has lot of pseudoinstructions which one must study. Some are should (e.g. the place is code, the place knowledge, the place stack), some are to facilitate improvement (macros, defines, together with, labels, and so forth..)

First app: Good day nothing!

Some issues, which I would like for writing Assembler DOS program, I vaguely recall from teeneger instances (as nobody who as soon as programmed in Assembler for DOS will ever overlook int 10h or int 21h). Nevertheless, overwhelming majority I needed to refresh or study anew. Largely it was stuff relating to Macro Assembler syntax the place nearly each line from pattern code I needed to slowly study what and why. After gaining some confidence, I lastly opened Private Editor and began writing first Assembler strains. Quickly, I came upon that very first problem to sort out is to put in writing simply one thing which:

– will compile with out errors
– will hyperlink with out errors
– won’t crash/freeze when executed, simply return again to DOS

So, I wished an equal to empty C important perform (and nonetheless with out iconic “Good day world!”). One thing like void important() {} however in Assembler.. proper!

Oh man, result’s in screenshot. I needed to place feedback additionally to such trivial program to maintain data why there may be what there may be.

Now some technical rant relating to this minimalistic DOS app code:

– it’s important to outline stack of your program (128 bytes in my case), so stack section+offset registers will likely be set to it by DOS loader when your program is loaded and ready to run

– it’s important to outline code section + program entry level, so DOS loader will know the place to move execution (that is this final line “finish MAIN” saying: that is finish of supply, entry is MAIN proc)

– and most fascinating (I had to determine why these strains simply earlier than ret are wanted): after DOS hundreds your exe and earlier than passing execution to your code (likely with far bounce), DOS ready return handle the place it needs your software ought to return. This handle is DS:0 (DS is knowledge section register of CPU). Now, finally DS will change with time when your program will run, so for maintaining this return handle, you want to push it into stack. Full handle is DS:0 (section+offset), so two 16-bit values making up full handle should be pushed. Then final instruction in your code is ret instruction, which is “return from process”. The way it is aware of the place to return? Proper, return handle is the one on high of the stack. That x86 CPU instruction will pop 2 values from stack and move execution to deal with constituted of these 2 values.

Voilà, that is most minimal properly behaving DOS program written in Assembler.

– if you happen to do not push DS:0 into stack firstly, subsequent ret will pull from stack some random values and CPU will transfer execution to that random handle => in all probability crash/freeze.
– if you happen to do not put ret into that program, CPU will simply proceed executing what’s in reminiscence after your program => in all probability crash/freeze as properly
– if you happen to do not setup stack on this minimal program, it will likely be of zero dimension (compiler/linker will in all probability additionally object), however as you push 4 bytes into stack (two 16-bit values) => well-known “stack overflow” CPU run-time error.

However with this minimalistic program, your code will gracefully return to deal with ready for you by DOS, which can then safe displaying again command immediate to person. It is “Good day nothing”, nevertheless it works!

As I study, I put up! Extra from this close-to-metal programming journey later! Durr...?


Logged

vdapps


#4
First pixels

After taking a grip on fundamentals, familiarizing with Macro Assembler and having right exe which can gracefully exit again to DOS, issues are lastly getting extra fascinating. I can code some sport for earliest PC-s in Assembler! Thankfully, many ideas (like BIOS and DOS calls from Assembler I recall from teenage instances). So what will likely be first steps? Soo, each sport wants 2 staple items: visible output and person enter.

Vide mode setting

In case of these first 1981-1982 PC-s, there have been solely two graphics adapters obtainable: monochromatic, text-only MDA and CGA (Colour Graphics Adapter) with 16kB of reminiscence. I am going with latter choice (my DOSBox-X can also be setup for CGA emulation). Commonest graphics mode utilized by these early video games was CGA 320x200x2bpp mode (4 colours). There was additionally 640x200x1bpp monochromatic mode, which was not used so usually. Now, for 4 colours mode there have been a number of fastened palettes for what these 4 colours will be. In all probability hottest in video games was black, cyan, magenta, white. So one of many first issues can be switching graphics mode to CGA 320×200. Video providers are secured by means of interrupt vector 10h which calls into BIOS. After looking in IBM PC Technical Reference and CGA Technical Reference I shortly discovered how to do this. Voilà.

Notice: in my Assembler code examples I’ll combine text-pasting and screenshots. As rule of thumb, for more-lines examples I’ll use text-paste (as solely textual content mode in early DOS was simply 25 strains per display screen!), for few-lines examples I can use additionally screenshot from Private Editor (as reminder of native 1981-1982 setting by which I am coding). Take note, that I am working inside floppy disk photographs (that are binary in nature), so additionally sources are saved INSIDE picture information. In an effort to have my sources in repository, I made script for DOSBox-X which extracts these sources from photographs, and people I place to repo, so I can have good historical past of progress with human readable modifications. These extracted sources I am additionally utilizing for copy-pasting right here. Now again to coding!


SET_CGA_MODE proc close to

 ;set graphics mode to CGA 320×200,4colors
 ;background colour is black
 ;in BL is anticipated palette ID (0=inexperienced/crimson/yellow,1=cyan/magenta/white)
 push ax
 push bx

 ;CGA mode
 mov ax,4
 int 10h

 ;set palette (ID is in BL)
 mov ah,11
 mov bh,1
 int 10h

 ;set black background
 mov bx,0
 int 10h

 pop bx
 pop ax
 ret

SET_CGA_MODE endp


As you’ll be able to see, I positioned this code to process, so my MAIN process won’t be cluttered. This process counts that wished palette is already in BL register, thus we are able to say that it is parametrized process. Additionally be aware these push and pop directions. As I modify some registers in that process, I retailer/restore them, so caller doesn’t want to fret that values which caller can have probably precomputed in these registers will likely be modified by known as process. Technically, it is not obligatory, nevertheless it’s courtesy of each process in Assembler, even ones solely you are utilizing (except process’s intention is to return or compute one thing to some registers). Now, in my MAIN process, I simply name this and that is it, we have now CGA video mode set.

In related method, I made additionally SET_TEXT_MODE process (which is even less complicated) to name earlier than returning again to DOS.

Keyboard enter

For now, I would like keyboard enter just for ready for key press so my early DOS app experiment won’t simply return to DOS instantly after working. I need to test for ‘q’ key (as for ‘stop’), if it is not pressed, simply loop.

Keyboard enter is simply one other performance of BIOS, however now should be known as interrupt vector 16h (keyboard providers). What to do I realized in identical means as with setting video mode, simply by looking in IBM PC Technical Reference. Here is my Assembler process for studying from keyboard.


GET_CURRENT_KEY proc close to

 ;return present pressed key code in AX register
 ;ASCII code in AL, scan code in AH, zero if no key

 ;test for key press presence
 mov ah,1
 int 16h
 jnz retrievekey

 mov ax,0
 ret ;no key pressed, return with zero

 ;retrieve pressed key to AX register
 retrievekey:
 mov ah,0
 int 16h
 push ax ;retailer key to stack as we have to change AX register

 ;test if there’s not another key lurking in buffer
 ;(in case of extra keys pressed or queued presses)
 mov ah,1
 int 16h
 pop ax
 jnz retrievekey ;there may be some, repeat retrieval

 ret ;no extra keys in buffer, we have now final key in AX already, return

GET_CURRENT_KEY endp


Once more, I am utilizing this process from MAIN process to test for ‘q’ key press. If ‘q’ just isn’t pressed, simply loop again, in any other case proceed to MAIN process exit.

First pixels

Now we have video mode set and ready for ‘q’ key in empty black display screen. Let’s attempt to attract one thing, simply purely educational for now, as tryout. However how to attract one thing to CGA show? Let’s take a look what says CGA Technical Reference.

As you’ll be able to see, show buffer begins at handle 0xB8000. Drawing into that a part of reminiscence means drawing into display screen. There’s this peculiarity in CGA the place first steady reminiscence space is for even strains, and in numerous handle (0xBA000) are odd strains. One line is 320 pixels, which is 80 bytes (as mode is 2bpp, in a single byte, 4 pixels are saved.. to deal with particular person pixel you have to meddle with respective 2 bits in respective byte). By filling 8000 bytes from handle 0xB8000, we must always then fill 100 even strains, from 0 to 198 together with. It is all even strains of whole display screen. Let’s fill it with quantity 0xAA (why AA hex? as a result of it is 10101010 binary, it means in each 4 pixels quartet represented by one byte, we set all 4 pixels to paint 2 from our palette). This fashion we must always fill each even line of display screen with magenta. Now, this is Assembler code snippet:

And that is consequence:

What’s subsequent

Having issues like graphical output and keyboard enter coated, we have now most important stuff for making a sport. Subsequent is scaling up present data. Draw rectangle, line, sprite? Simply completely different algo which in the long run output to reminiscence of show buffer as proven above. Solely I’ve to put in writing that algo in Assembler, which is in fact not a lot luxurious in comparison with right this moment’s requirements, however hey, that is a problem! Anyway any longer, I can’t cowl each such process in such TLDR particulars, as e.g. line drawing algorithm just isn’t about early PC specifics, it is simply agnostic algo. So I assume there will likely be much less technological ranting and extra of the particular sport (hopefully Smiley). But when I’ll bump into one thing new which I’ll really feel is said to legacy PC Assembler programming, I’ll cowl it (shortly on my thoughts are timing points or avoiding floating level computations).

Uuuufff, that is lastly all for now, hopefully some shifting pixels quickly! Vlad out. Durr...?

« Final Edit: Right this moment at 02:49:54 PM by vdapps »
Logged

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments