Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Speccy Wars
slenkar Wrote:is it ok to add it when its not finished?

EDIT- I added it but cant get the screenshot to show up
<!-- m --><a class="postlink" href=""> ... SpeccyWars</a><!-- m -->
I can see the screenshot, and its OK. Maybe a cache problem?
yep its workin now thanks
its playable now
its at the limits of the memory so new features are unlikely

Attached Files
.zip (Size: 8.5 KB / Downloads: 440)
here is the source code:

How could I free up some more RAM?

Attached Files
.zip (Size: 23.85 KB / Downloads: 464)
slenkar Wrote:here is the source code:

How could I free up some more RAM?
  • Have you tried to compile using -O3? (it reduces your program size by about 1Kb, it seems).
  • Also, do you really need the line function? or can use DRAW instead?
I don't understand your code Tongue so don't know if something else could be done. Why do you need more ram?
Try lowering the ORG with --org=26000?
yeh the line function allows me to do line of sight, (need all x and y coordinates of a line)

Thanks for the other tips
In main file:
PRINT AT 3,13 ; PAPER 1 ; INK 7 ; "BattleField"
  PRINT AT 5,9 ; PAPER 7 ; INK 0 ; "Q - Up"
  PRINT AT 6,9 ; PAPER 7 ; INK 0 ; "A - Down"
  PRINT AT 7,9 ; PAPER 7 ; INK 0 ; "O - Left"
  PRINT AT 8,9 ; PAPER 7 ; INK 0 ; "P - Right"
  PRINT AT 9,9 ; PAPER 7 ; INK 0 ; "M  or Space- Select"
  PRINT AT 10,3 ; PAPER 7 ;INK 0 ; "C to End Turn"
  PRINT AT 10,3 ; PAPER 7 ; INK 0 ; "You have to select units"
  PRINT AT 11,3 ; PAPER 7 ; INK 0 ; "to fight the enemy units"
  PRINT AT 15,3 ; PAPER 7 ; INK 0 ; "Press any key to start"
You can change to:
PRINT AT 3,13 ;"\{p1}\{i7}BattleField"
  PRINT  AT 5,9 ; "\{p7}\{i0}Q - Up"; AT 6,9 ;"A - Down"; AT 7,9 ; "O - Left"; AT 8,9 ; "P - Right"; AT 9,9 ; "M  or Space- Select";AT 10,3; "C to End Turn";AT 10,3 ; "You have to select units"; PRINT AT 11,3; "to fight the enemy units"; PRINT AT 15,3; "Press any key to start";

60  LET j$ = INKEY$
  IF j$ = "" THEN GOTO 60: END IF
can be replaced with
loop until j$<>""
No need to use line numbers.

PRINT AT 1,x ; PAPER 1 ; INK 0 ; " "
can be written as
PRINT AT 1,x ;"\{p1}\{i0} "

REM Reads the FRAMES counter
RETURN INT((65536 * PEEK(23674) + 256 * PEEK(23673) + PEEK(23672)))

dim millisecs as ULONG at 23672
this sets the variable millisecs at frames sysvar, so reading it will return the milliseconds, writing to it will set the frames sysvar. Any you do not need a function for it (okay, you probably need to BAND it with $FFFFFF). Do you really need ULONG?
Also check if there are undimed variables as this make them float
There is a lot of optimisation potential. I'm sure, you can save 3-5 Kb.

It looks like you define UDG multiple times. Thats what I found quickly checking the sources.
Optimising the source is a bit time consuming because you did not use indentation.

You can also change:
dim selecty as byte
dim selectx as byte

dim selectedUnit as ubyte
dim targettedUnit as ubyte
dim selecty,selectx,selectedUnit,targettedUnit as ubyte
for better readibility
And as boriel said, you can set up org to 24200 without problems. Reduce the heap to 512.
------------------------------------------------------------ redirector is dead
Visit my home page!
Another trick (not yet implemented) is: There is many arrays which are taking lot of memory. If you don't need 2 of them *at once* it's possible to map two of them in the same memory area (note: This feature IS NOT implemented; i'm still working on it). Basically, it's using DIM ... AT ... with arrays (at the moment only available with single variables).
slenkar Wrote:yeh the line function allows me to do line of sight, (need all x and y coordinates of a line)

Thanks for the other tips
Did you use Bresenham's algorithm for speed also? A classical y = x0 + mx take much less memory (althoug slower, if using FP, but FP is in ROM).

Update: Also, in the (Spanish) forum people are also talking about 128K ram management. I think we could manage so create some simple bank-switching functions and store graphs and some array/logic there.
thanks for all the tips

I used bresenham just because thats the only line function I know of, where I can get all the co-ordinates along the line.

I dont know how to use 'y = x0 + mx' , to make a line from two known points.

Forum Jump:

Users browsing this thread: 1 Guest(s)