C&CG RTS

Got a brilliant program idea? Let us know!

Moderator: MaxCoderz Staff

Post Reply
User avatar
Matthias1992
New Member
Posts: 16
Joined: Mon 13 Jul, 2009 6:23 pm

C&CG RTS

Post by Matthias1992 »

I am planning on making a RTS game, I think it will be with modern guns. It is slightly based on Command and Conquer generals (in the design) and based on The Total War series in gamplay. Don't get me wrong, you won't be able to zoom but you will have predefined armies, there is no base from where you build your army it will all be choosen using a predefined amount of money.
To still your hunger for new concpets, some concept art...
Image

You can grab the image here: http://farm5.static.flickr.com/4009/442 ... c751_o.jpg

edit: I can just smell questions may arise about which programming language I will use, well I have figured that a combination of TI-BASIC and ASM works best for me. Simplybecause I lack the skill to program the whole game in assembly. So what I'll do is make routines for the sprites to be drawn and I can call them from a BASIC prgm like so:

Code: Select all

0:Asm(prgmGH    ;this for example could be a ClearScreen routine
some more code...
11:Asm(prgmGH   ;this could be drawing a tank at the current values of X and Y
etc...
So it is going to be the ease of use in variables and lists from BASIC and the graphical superiority of ASM, together a COMMANDROUS combination! (COMMANDER is the game title, just I case you did not catch the joke...ooh well)

So what are your thoughts about this? Is it dangerous to combine ASM and BASIC like this? (I mean certain ASM routines might disturb the values in OP1-6 and thus cause the values of certain variables to screw up?
User avatar
Matthias1992
New Member
Posts: 16
Joined: Mon 13 Jul, 2009 6:23 pm

Re: C&CG RTS

Post by Matthias1992 »

OK, I have encountered a slight problem. Whenever I want to draw something I have to bring the graphscreen up. I know how to do this in basic and it works...but not entirely. Whenever I code a small BASIC prgm that changes the X value of the sprite so that it should move I get a blank graph screen until I break the program and goto the graphscreen manually, then I see everything...
Now I did copy a sprite routine from the net so I do not really know where this problem hides...Also I know there are some optimizations possible but this works and that is what counts for me, after it works the way i WANT it to work i'll optimize...

So here is the code I use

Code: Select all

crz1spriteroutine:
	;| Input: c is operator (1=and, 2=or, 3=xor)                          |
	;|        d is x-position (min. -7, max. 95)                          |
	;|        e is y-position (min. -7, max. 63)                          |
	;|        ix is sprite-address                                        |
	;| Destroys: a, bc, de, hl, ix, (currow), (curcol)                    |
	;+--------------------------------------------------------------------+
.nolist
#include "ti83plus.inc"
#define ProgStart 9D95h
.list
.org ProgStart -2
.db t2ByteTok, tAsmCmp
getvars:
	LD IY, flags
	res plotLoc, (IY+plotFlags)
	B_CALL(_BufClr)
	B_CALL(_ZeroOP1)
	LD A, 'D'					;DIRECTIE variabele
	LD (OP1+1), A
	B_CALL(_RclVarSym)
	B_CALL(_ConvOP1)
	PUSH AF
	B_CALL(_ZeroOP1)
	LD A, 'T'
	LD (OP1+1), A
	B_CALL(_RclVarSym)
	B_CALL(_ConvOP1)
	PUSH AF
	B_CALL(_ZeroOP1)
	LD A, 'X'
	LD (OP1+1), A
	B_CALL(_RclVarSym)
	B_CALL(_ConvOP1)
	PUSH AF
	B_CALL(_ZeroOP1)
	LD A, 'Y'
	LD (OP1+1), A
	B_CALL(_RclVarSym)
	B_CALL(_ConvOP1)
	LD E, A ;getting the Y var
	POP AF
	LD D, A
	LD C, 2 ;choosing the OR
	POP AF
	OR A 
	JP Z, TANKS
	CP 1
	JP Z, DROIDS     
	CP 2
	JP Z, TREE
	;HIER CP's TOEVOEGEN VOOR MUREN, PLANES EN MEER!
	RET
TANKS:
	POP AF
	OR A
	JP Z, IXtankU
	CP 1
	JP Z, IXtankR
	CP 2
	JP Z, IXtankD
	CP 3
	JP Z, IXtankL
	RET
DROIDS:
	POP AF
	OR A
	JP Z, IXdroidU
	CP 1
	JP Z, IXdroidR
	CP 2
	JP Z, IXdroidD
	CP 3
	JP Z, IXdroidL
	RET
TREE:
	POP AF
	OR A
	JP Z, IXTree_1
	CP 1
	JP Z, IXTree_2
	RET
GRASS:
	POP AF
	OR A
	JP Z, IXGrass_1
	CP 1
	JP Z, IXGrass_2
IXtankD:
	LD IX, tankD
	JP begindraw
IXtankL:
	LD IX, tankL
	JP begindraw
IXtankU:
	LD IX, tankU
	JP begindraw
IXtankR:
	LD IX, tankR
	JP begindraw
IXdroidU:
	LD IX, droidU
	JP begindraw
IXdroidR:
	LD IX, droidR
	JP begindraw
IXdroidD:
	LD IX, droidD
	JP begindraw
IXdroidL:
	LD IX, droidL
	JP begindraw
IXTree_1:
	LD IX, Tree_1
	JP begindraw
IXTree_2:
	LD IX, Tree_2
	JP begindraw
IXGrass_1:
	LD IX, Grass_1
	JP begindraw
IXGrass_2:
	LD IX, Grass_2
;ONDERSTE HOEFT GEEN JP
;|                         DRAWING ROUTINE                            |
;|         (programmed by Pelle Kersaan a.k.a. Cerzus, ©2003)         |
;|                       (cerzus69@hotmail.com)                       |
begindraw:
	ld b, 8
	push bc	
	ld hl, 0	
	ld (CurRow), hl
	ld a,e
	ld b,7
crz1topoffcheck:
	inc a
	jr z,crz1topoff
	djnz crz1topoffcheck
	ld c,e
	add hl,bc
	add hl,bc
	add hl,bc
	add hl,hl
	add hl,hl
	ld a,e
	sub 56
	ld b,7
crz1bottomoffcheck:
	dec a
	jr z,crz1bottomoff
	djnz crz1bottomoffcheck
	jr crz1checkxpos
crz1topoff:
	push bc
	ld a,8
	sub b
	ld c,a
	ld b,0
	add ix,bc
	pop bc
crz1bottomoff:
	ld a,b
	pop bc
	ld b,a
	push bc
crz1checkxpos:
	ld a,d
	ld b,7
crz1leftoffcheck:
	inc a
	jr z,crz1leftoff
	djnz crz1leftoffcheck
	ld c,d
	srl c
	srl c
	srl c
	add hl,bc
	ld a,d
	sub 88
	ld b,7
crz1rightoffcheck:
	dec a
	jr z,crz1rightoff
	djnz crz1rightoffcheck
	jr crz1finishscreenpos
crz1leftoff:
	ld a,10b
	ld (currow),a
	dec hl
	jr crz1finishscreenpos
crz1rightoff:
	ld a,01b
	ld (currow),a
crz1finishscreenpos:
	ld bc,plotsscreen
	add hl,bc
	ld a,d
	pop de
	and 00000111b
	jr z,crz1aligned
	ld (curcol),a
crz1nonaligned:
	ld b,(ix+0)
	ld a,e
	cp 1
	jr nz,crz1orxorshift
	ld c,11111111b
	ld a,(curcol)
crz1andshiftloop:
	srl b
	rr c
	ex af,af'
	ld a,b
	add a,10000000b
	ld b,a
	ex af,af'
	dec a
	jr nz,crz1andshiftloop
	jr crz1endshiftloop
crz1orxorshift:
	ld c,00000000b
	ld a,(curcol)
crz1orxorshiftloop:
	srl b
	rr c
	dec a
	jr nz,crz1orxorshiftloop
crz1endshiftloop:
	ld a,(currow)
	and 10b	
	call z,crz1putsprite
	ld b,c
	inc hl
	ld a,(currow)
	and 01b
	call z,crz1putsprite
	inc ix
	ld bc,11
	add hl,bc
	dec d
	jr nz,crz1nonaligned
	ret
crz1aligned:
	ld b,(ix+0)
	call crz1putsprite
	inc ix
	ld bc,12
	add hl,bc
	dec d
	jr nz,crz1aligned
	ret
crz1putsprite:
	ld a,e
	dec a
	call z,crz1putand
	ld a,e
	cp 2
	call z,crz1putor
	ld a,e
	cp 3
	call z,crz1putxor
	ret
crz1putand:
	ld a,(hl)
	and b
	ld (hl),a
	ret
crz1putor:
	ld a,(hl)
	or b
	ld (hl),a
	ret
crz1putxor:
	ld a,(hl)
	xor b
	ld (hl),a
	ret
tankD:
	.db %01111110
	.db %10111101
	.db %10100101
	.db %10100101
	.db %10111101
	.db %10011001
	.db %10111101
	.db %01011010
	RET
tankL:
	.db %01111110
	.db %10000001
	.db %01011111
	.db %11110011
	.db %11110011
	.db %01011111
	.db %10000001
	.db %01111110
	RET
tankU:
	.db %01011010
	.db %10111101
	.db %10011001
	.db %10111101
	.db %10100101
	.db %10100101
	.db %10111101
	.db %01111110
	RET
tankR:
	.db %01111110
	.db %10000001
	.db %11111010
	.db %11001111
	.db %11001111
	.db %11111010
	.db %10000001
	.db %01111110
	RET
droidU:
	.db %00000000
	.db %00011100
	.db %00100010
	.db %00101010
	.db %00110110
	.db %00110110
	.db %00101010
	.db %00011100
droidR:
	.db %00000000
	.db %00000000
	.db %01111100
	.db %10110010
	.db %11001010
	.db %10110010
	.db %01111100
	.db %00000000
droidD:
	.db %00111000
	.db %01010100
	.db %01101100
	.db %01101100
	.db %01010100
	.db %01000100
	.db %00111000
	.db %00000000	
droidL:
	.db %00000000
	.db %00111110
	.db %01001101
	.db %01010011
	.db %01001101
	.db %00111110
	.db %00000000
	.db %00000000
Tree_1:
	.db %00011000
	.db %01100110
	.db %01001010
	.db %10100001
	.db %10001001
	.db %01000010
	.db %01100110
	.db %00011000
Tree_2:
	.db %00011000
	.db %01100110
	.db %01010010
	.db %10000001
	.db %10100001
	.db %01001010
	.db %01100110
	.db %00011000
Grass_1:
	.db %00001000
	.db %01000110
	.db %01000000
	.db %10001000
	.db %00000001
	.db %01001010
	.db %01100110
	.db %00101000
Grass_2:
	.db %00011000
	.db %01001010
	.db %01010010
	.db %00000001
	.db %10001001
	.db %01001010
	.db %01000000
	.db %00001000
.end
.end
And here is the BASIC code I use.

Code: Select all

ClrDraw
Lbl A
0->K
While K !=26
getKey->K
X+(K=26)->X
End
DispGraph
Asm(prgmGCOM
Goto A
I know this ^ code is not that good but It is just a test...and it does not do the trick...


Anyone any suggestions? (should this be posted under prograamming help? because on the other hand this is related to the original topic, my project.)
User avatar
benryves
Maxcoderz Staff
Posts: 3089
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: C&CG RTS

Post by benryves »

Looks interesting so far, though I think you'd have a better response on a more active forum than MaxCoderz. :( Incidentally, I think this thread should be in "Announce Your Projects" - would you like me to move it?

To copy the graph buffer to the LCD you can use the grBufCpy B_CALL.
User avatar
Matthias1992
New Member
Posts: 16
Joined: Mon 13 Jul, 2009 6:23 pm

Re: C&CG RTS

Post by Matthias1992 »

Well I think we can better keep it here...I am not all to good at finishing things...
I tried using the BufCpy command but I get grain as a result. Where would you place it?
User avatar
calc84maniac
Regular Member
Posts: 112
Joined: Wed 18 Oct, 2006 7:34 pm
Location: The ex-planet Pluto
Contact:

Re: C&CG RTS

Post by calc84maniac »

You should disable interrupts before you use shadow registers. (I notice you use the ex af,af' instruction)
~calc84maniac has spoken.

Projects:
F-Zero 83+
Project M (Super Mario for 83+)
User avatar
Matthias1992
New Member
Posts: 16
Joined: Mon 13 Jul, 2009 6:23 pm

Re: C&CG RTS

Post by Matthias1992 »

I added the DI instruction but I did not really help. The problem is that I can not see the Updated screen of the drawn sprite. For example if I had a simple for loop that increments X every iteration then I can only see the black stripe (stripe because all the sprites rendere on top of each other with an offset of X)rendering was set to OR)) it causes after the loop has finished. Shortly siad, I can move my sprites but If the were to move from A to B I only get to see their state at B, I can not see any in-between frames...
User avatar
benryves
Maxcoderz Staff
Posts: 3089
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: C&CG RTS

Post by benryves »

Call GrBufCpy (not BufCpy) when you've finished rendering a frame and wish to present it to the user. This routine copies the image data from the graph buffer to the RAM on the LCD driver chip.
User avatar
Matthias1992
New Member
Posts: 16
Joined: Mon 13 Jul, 2009 6:23 pm

Re: C&CG RTS

Post by Matthias1992 »

I have tried grBufCpy (I meant grBufCpy not BufCpy a couple of comments up) but it does not seems to work. Well,. I am convinced it does work but honestly I have no clue where to place it...I'll be looking throught that code another time I think, you see I did not write that sprite routine....

But thanks for your help anyway....

Oh and can't I just copy it directly onto the screen, does it have to go through the plotsScreen buffer?

Thanks!
User avatar
benryves
Maxcoderz Staff
Posts: 3089
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: C&CG RTS

Post by benryves »

Matthias1992 wrote:Oh and can't I just copy it directly onto the screen, does it have to go through the plotsScreen buffer?
In theory you could, but accessing the LCD memory is slow and you'd end up with flicker as it drew the sprites one by one. It looks better to draw everything to plotSScreen first then copy to the LCD when you're done.

In your case, it may be worth writing a routine that just called GrBufCpy (e.g. 50:Asm(prgmGH) and use that.
User avatar
Matthias1992
New Member
Posts: 16
Joined: Mon 13 Jul, 2009 6:23 pm

Re: C&CG RTS

Post by Matthias1992 »

Thanks! that worked!
Post Reply