VOGONS


turboC programming question

Topic actions

Reply 20 of 50, by ncmark

User metadata
Rank Oldbie
Rank
Oldbie

yeah I got to thinking about that this morning
it might be the easier way to do it but there is no need to read and rewrite every pixel on the screen
instead erase the old ones and redraw the new ones

Reply 21 of 50, by ncmark

User metadata
Rank Oldbie
Rank
Oldbie

For each "star" I have a row number and then the column numbers. and a function that calculates exact pixel....hmm...I could increase the row numbers and hen recycle back to zero wen they hit 200

Reply 22 of 50, by ncmark

User metadata
Rank Oldbie
Rank
Oldbie

Well I did away with reading video memory - and now it is flying across the screen! More like what I expected.
But now, I seem to have a new problem.
TurboC will not let me make a 320x200 array - so there goes making a screen buffer
Does anyone know if there is way to get around this?

Reply 23 of 50, by BloodyCactus

User metadata
Rank Oldbie
Rank
Oldbie

compile to large model / and or use farmalloc.

unsigned char far *ptr = farmalloc(320L * 200);

there you go.

--/\-[ Stu : Bloody Cactus :: [ https://bloodycactus.com :: http://kråketær.com ]-/\--

Reply 24 of 50, by TheMechanist

User metadata
Rank Newbie
Rank
Newbie
wbahnassi wrote on 2024-06-24, 05:51:

Exactly, scroll using hardware registers. Full-screen modification should be done with writes only, and even that will move you to require 386 if you do it every frame.

a good starfield has more than one layer - parallax side scrolling - so hardware scrolling won't help ...

https://youtu.be/oE2ZVhHwxAU?si=DkNlhNfLad-tyzWK

Nec Powermate 80286, 12 Mhz, 1 MB RAM, onboard Paradise VGA, 130 MB ST3144AT, ES1868 ISA soundcard, MS Dos 3.31
Unchained demo group
swap42

Reply 25 of 50, by ncmark

User metadata
Rank Oldbie
Rank
Oldbie

Well - the malloc was useful
I created a frame buffer, set up the starfield, and then copied it over
Three functions - one to clear the ram, one to set it up, and one to copy over
MUCH cleaner than the way I was doing
What I would LIKE to do is have three buffers - one for the stars, one for ships, a third to merge them together before copying
We will see

Reply 26 of 50, by BloodyCactus

User metadata
Rank Oldbie
Rank
Oldbie

the isa bus isnt built for dumping 64k buffers at high fps. if you have max like 100 or 200 stars... thats less than 1% of 320x200!

--/\-[ Stu : Bloody Cactus :: [ https://bloodycactus.com :: http://kråketær.com ]-/\--

Reply 27 of 50, by Errius

User metadata
Rank l33t
Rank
l33t

What emulators do people use to run old DOS development programs like this?

Is this too much voodoo?

Reply 28 of 50, by gerry

User metadata
Rank l33t
Rank
l33t

i (re)found this

http://www.brackeen.com/vga/basics.html

"256-Color VGA Programming in C", old school tutorials. there used to be so many for different programming tools, a fun scene in the early online world of the 90's

Errius wrote on 2024-06-25, 02:12:

What emulators do people use to run old DOS development programs like this?

dosbox 😀 would work on PCEM and similar too, and actually in win9x whether native or vm

Reply 29 of 50, by Errius

User metadata
Rank l33t
Rank
l33t

Right, the problem with DOSBox and the Borland IDEs is that the emulator appropriates the CTRL+Fkey keystrokes for emulator functions. I know about the keymapper, but I prefer not to have to mess with that just to run 1 program.

Is this too much voodoo?

Reply 30 of 50, by BloodyCactus

User metadata
Rank Oldbie
Rank
Oldbie
Errius wrote on 2024-06-25, 13:18:

Right, the problem with DOSBox and the Borland IDEs is that the emulator appropriates the CTRL+Fkey keystrokes for emulator functions. I know about the keymapper, but I prefer not to have to mess with that just to run 1 program.

personally, i just mount the folder as a drive. edit on my local machine, then in dosbox run wmake to build. i have no interest in trying to edit in archaic borland ide's.
better yet, I build with the linux port of openwatcom dos compiler and just fire dosbox up to run the exe as a test.

--/\-[ Stu : Bloody Cactus :: [ https://bloodycactus.com :: http://kråketær.com ]-/\--

Reply 31 of 50, by Errius

User metadata
Rank l33t
Rank
l33t

Yes, I've been doing something similar, using Notepad++ to edit and dropping into DOSBox to compile/run. It works, but I still have all the old Borland editor keystrokes in muscle memory and miss using the real thing.

(These keystrokes are still recognized in the newest versions of C++Builder BTW, which is cool.)

Is this too much voodoo?

Reply 32 of 50, by ncmark

User metadata
Rank Oldbie
Rank
Oldbie

Well if anyone is interested.....I have it working pretty well!
Four step process:
1..Array is cleared
2. Stars are scrolled into array
3. Anything else (ships) are added so they seem to be on top of the stars
4. Array is copied into video ram

There is no actual clearing of the video screen - the array is cleared, re-generated, and copied.
No reading of video memory.

Have gone so far as to generate some functions to write number characters to the screen ...very blocky 5x5 but it works

Reply 33 of 50, by gerry

User metadata
Rank l33t
Rank
l33t

sounds good, would be interesting to see the code.

in common with a few others also like the old IDEs, especially for shorter programs - but recognise the advantages to using modern tools to develop

Reply 34 of 50, by ncmark

User metadata
Rank Oldbie
Rank
Oldbie

actually - the code is not that bad - maybe 300 lines or so
of course, it is nowhere NEAR complete - still barebones
but still, not bad for a few days - and has forced me to learn several aspects of C I never used
Outdated but maybe a useful exercise

Reply 35 of 50, by megatron-uk

User metadata
Rank l33t
Rank
l33t

10 extra bonus points for having an entry in your makefile after a successful build of automatically firing up dosbox with the resulting binary!

My collection database and technical wiki:
https://www.target-earth.net

Reply 36 of 50, by ncmark

User metadata
Rank Oldbie
Rank
Oldbie

Laughing

Reply 37 of 50, by ncmark

User metadata
Rank Oldbie
Rank
Oldbie

HELP
So now I am stuck....on keyboard input
If you use something like getch - then you are stuck with the keyboard character rate - so if you increment a variable that controls a ship, it moves across the screen at a snail's pace

So I get the idea - when a key is pressed, just set a flag that turns on the increment, which is implemented in he video routine. And that works to an extend - but to turn it off, you have to hit a different key

It seems - there is no way to detect to when a key is let up, so it goes on until another key is pressed

I even tried converting the result in getch into a string and checking for a null string (strlen = 0) but that doesn't work

what I NEED is something that constantly checks for keypress but gives some way to report of no key was pressed - to return like a null value - so I can turn off the flag

Can't believe I have come this far......

Reply 38 of 50, by ncmark

User metadata
Rank Oldbie
Rank
Oldbie

I think I might have an idea. Store the old keypress, set the variable from getch equal to zero, and re-call getch. If key is still being held down, the value will equal the stored value. If not, the key has been let up and the flag can be reset
Kind of a kludge but that might work

Reply 39 of 50, by BloodyCactus

User metadata
Rank Oldbie
Rank
Oldbie

getch is buffered and not really what you want.. in conio you have access to kbhit for testing if a keypress is there. but if were me I'd hook the keyboard irq or read function 1 + 0 of int 0x16. (1 test buffer, 0 reads buffer with blocking)

--/\-[ Stu : Bloody Cactus :: [ https://bloodycactus.com :: http://kråketær.com ]-/\--