With Machine Code how much memory to leave basic

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
User avatar
Hedge1970
Manic Miner
Posts: 388
Joined: Mon Feb 18, 2019 2:41 pm

With Machine Code how much memory to leave basic

Post by Hedge1970 »

I’ve been building a game since January, it’s still chock full of challenges before I get it near to finished. So rather than find out when I’ve nearly finished I would like to get a view from those that know how much memory I will need to leave at the end of the game for loading screens and such like?

I’ve only ever built games in basic and these never really worried me but this machine code game is potentially going to use as much memory as I can get out of a 48k machine as it’s heavily Map based.

I’ve scribbled this little memory map that seems to show I have around 41.7k total but that’s using all the basic area and I assume I may need some of that to at the very least to kick the game off - Randomise Usr xyz

Any help, as always much appreciated



My memory map as per my machine on switch on.

Image
User avatar
Stefan
Manic Miner
Posts: 809
Joined: Mon Nov 13, 2017 9:51 pm
Location: Belgium
Contact:

Re: With Machine Code how much memory to leave basic

Post by Stefan »

Code: Select all

10 CLEAR VAL "23999": LOAD "" SCREEN$: LOAD "" CODE: RANDOMIZE USR VAL "24000"
You can get 24000 down a bit, but not much, unless you just write your own loader and scribble all over the entire basic area.
Ralf
Rick Dangerous
Posts: 2289
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: With Machine Code how much memory to leave basic

Post by Ralf »

Loading screen shouldn't really be any problem. You load it directly to screen memory while loading and the game later overwrites it. It doesn't occupy any memory when the game is running. Or did you mean something else?

A game need some Basic loader. But if you keep it minimal (load loading screen, load game code, run game code) then you can place your code above address 24000 or so which gives you 41.5 kB of free memory.

You need to leave some memory for stack and and interrupt vector table (if you use own interrupts).

You can reclaim later in the game memory used by system variables and you Basic program if you mess with interrupts. But it will be only about 700 bytes.
User avatar
Hedge1970
Manic Miner
Posts: 388
Joined: Mon Feb 18, 2019 2:41 pm

Re: With Machine Code how much memory to leave basic

Post by Hedge1970 »

Ralf wrote: Fri Mar 15, 2024 4:11 pm Loading screen shouldn't really be any problem. You load it directly to screen memory while loading and the game later overwrites it. It doesn't occupy any memory when the game is running. Or did you mean something else?

A game need some Basic loader. But if you keep it minimal (load loading screen, load game code, run game code) then you can place your code above address 24000 or so which gives you 41.5 kB of free memory.

You need to leave some memory for stack and and interrupt vector table (if you use own interrupts).

You can reclaim later in the game memory used by system variables and you Basic program if you mess with interrupts. But it will be only about 700 bytes.
Thank you for this I am at 24832 at the moment so good to know I have a bit of flexibility. It’s such a challenge and I don’t want to fail at the end because I underestimated something. I know I have bitten off more than I should but it’s been a life long - back of the mind - thing to write a game in machine code.
Ralf
Rick Dangerous
Posts: 2289
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: With Machine Code how much memory to leave basic

Post by Ralf »

And what kind of game are you writing if I may ask?

Are you already struggling with little memory left or are you just checking?
If memory is a problem then you need to consider some optimisations.
User avatar
Hedge1970
Manic Miner
Posts: 388
Joined: Mon Feb 18, 2019 2:41 pm

Re: With Machine Code how much memory to leave basic

Post by Hedge1970 »

Ralf wrote: Fri Mar 15, 2024 5:08 pm And what kind of game are you writing if I may ask?

Are you already struggling with little memory left or are you just checking?
If memory is a problem then you need to consider some optimisations.
No problem as yet. I am just think ahead. The code can definitely be optimised but right now I am just happy to see stuff appear and work in machine code!!! Amazing stuff :-).

The game is a survival game. However I’ve always thought Speccy games where really tough so the USP of this game is you will always finish. Infact it only requires 20mins of your time to complete. That said of course there will be a high score to beat.
User avatar
MustardTiger
Microbot
Posts: 122
Joined: Tue May 02, 2023 8:05 pm

Re: With Machine Code how much memory to leave basic

Post by MustardTiger »

I tend to use 24576/$6000. If you aren't using rom routines or anything that needs the sysvars I guess you could use that memory for buffers once the game has loaded.
User avatar
ketmar
Manic Miner
Posts: 713
Joined: Tue Jun 16, 2020 5:25 pm
Location: Ukraine

Re: With Machine Code how much memory to leave basic

Post by ketmar »

yeah, please, $6000! ;-) this will make TR-DOS-lovers life slightly easier: TR-DOS needs buffer for disk sector, and for some other data. sure, you don't have to think about crappy DOS nobody in their sane mind would use, but… why not? ;-)
Post Reply