FAQ  •  Register  •  Login

Speccy Wars

Moderator: nitrofurano

<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Fri Apr 19, 2013 1:41 pm

Re: 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
http://www.boriel.com/wiki/en/index.php ... SpeccyWars

I can see the screenshot, and its OK. Maybe a cache problem?
<<

slenkar

Posts: 282

Joined: Sun Feb 13, 2011 3:33 am

Location: Kentucky US, used to be Birmingham UK

Post Fri Apr 19, 2013 3:18 pm

Re: Speccy Wars

yep its workin now thanks
<<

slenkar

Posts: 282

Joined: Sun Feb 13, 2011 3:33 am

Location: Kentucky US, used to be Birmingham UK

Post Sat Apr 27, 2013 5:05 pm

Re: Speccy Wars

its playable now
its at the limits of the memory so new features are unlikely
Attachments
wars.zip
(8.5 KiB) Downloaded 205 times
<<

slenkar

Posts: 282

Joined: Sun Feb 13, 2011 3:33 am

Location: Kentucky US, used to be Birmingham UK

Post Thu May 02, 2013 3:15 pm

Re: Speccy Wars

here is the source code:



How could I free up some more RAM?
Attachments
wars.zip
(23.85 KiB) Downloaded 214 times
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Thu May 02, 2013 6:36 pm

Re: Speccy Wars

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 :P so don't know if something else could be done. Why do you need more ram?
Try lowering the ORG with --org=26000?
<<

slenkar

Posts: 282

Joined: Sun Feb 13, 2011 3:33 am

Location: Kentucky US, used to be Birmingham UK

Post Thu May 02, 2013 10:50 pm

Re: Speccy Wars

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
<<

LCD

Posts: 596

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Thu May 02, 2013 11:24 pm

Re: Speccy Wars

In main file:
  Code:
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:
  Code:
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";


  Code:
60  LET j$ = INKEY$
  IF j$ = "" THEN GOTO 60: END IF

can be replaced with
  Code:
Do
 j$=inkey$
loop until j$<>""

No need to use line numbers.

  Code:
PRINT AT 1,x ; PAPER 1 ; INK 0 ; " "

can be written as
  Code:
PRINT AT 1,x ;"\{p1}\{i0} "


  Code:
FUNCTION millisecs AS ULONG
REM Reads the FRAMES counter
RETURN INT((65536 * PEEK(23674) + 256 * PEEK(23673) + PEEK(23672)))
END FUNCTION


  Code:
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:
  Code:
dim selecty as byte
dim selectx as byte

dim selectedUnit as ubyte
dim targettedUnit as ubyte

to
  Code:
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.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Thu May 02, 2013 11:26 pm

Re: Speccy Wars

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).
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Thu May 02, 2013 11:42 pm

Re: Speccy Wars

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 speccy.org (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.
<<

slenkar

Posts: 282

Joined: Sun Feb 13, 2011 3:33 am

Location: Kentucky US, used to be Birmingham UK

Post Fri May 03, 2013 6:54 pm

Re: Speccy Wars

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.
Previous

Return to Gallery

Who is online

Users browsing this forum: No registered users and 1 guest

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO