| Post Your Message | |
| |
| Previous Messages | Posted By
George on 2013-01-10 18:32:54
| Re: Speed up Routine for Placing A Bitmap
Hi Chicken,
i solved the issue in assembly. It was my second try ever in this language, but i am getting slowly into it. The Basic-Try was helpful, because i know the theoretical-part in TED-graphics now.
I solved the positioning of the crosshair in assembly (crappy code, but it works). Extremly fast.
The problem now is, how to read out the keys when you press Upper-Left, Upper-Right,Down-Left, Down-right:
My code so far:
LDA #$BF STA $FD30 STA $FF08 LDA $FF08 AND #$08 ; Query keyboard for "Right" BEQ weiter_dr LDA #$BF STA $FD30 STA $FF08 LDA $FF08 AND #$01 ; Query keyboard for "left" BEQ weiter_dl LDA #$DF STA $FD30 STA $FF08 LDA $FF08 AND #$08 ; Query keyboard for "up" BEQ weiter_du LDA #$DF STA $FD30 STA $FF08 LDA $FF08 AND #$01 ; Query keyboard for "down" BEQ weiter_dd
|
|
Posted By
Chicken on 2013-01-10 07:16:16
| Re: Speed up Routine for Placing A Bitmap
Insert a "JMP xclear" somewhere near the BEQ. Branches can only reach 127 bytes backwards/forwards.
|
|
Posted By
George on 2013-01-09 18:19:56
| Re: Speed up Routine for Placing A Bitmap
Worth a try. Edit: Sprite-Basic seems to be a good tool. 24 new Basic commands, but there is no Documentation in the magazine or on the Disk-Image.
I am coding in assembler with Csabos IDE, but as the code grows, i get this error:
147 lines read, no errors in pass 1. 47: BEQ xclear "copysprite.asm",47 : Label unreachable by short branch. 1 error in pass 2.
How can i work around it?
|
|
|
Posted By
George on 2013-01-08 05:01:45
| Re: Speed up Routine for Placing A Bitmap
Hi Chicken,
thanks for the suggestion. I had something like this in mind. After sleeping over it, the most elegant way is to realize a universal software sprite routine, which maps a bitmap at every (char- or pixel-)position on screen and blend it over the background.
I always wanted to realize software-sprites on a plus 4, but i don't want to re-invent the wheel again. Are there some good tools or libraries for this?
|
|
Posted By
Chicken on 2013-01-07 15:10:50
| Re: Speed up Routine for Placing A Bitmap
If you really need the crosshairs to be moved (in pixel steps) there's no way around a proper sprite routine. However, if you can live with the fact that the crosshairs "jump" from position to position, then I would suggest this:
For every position (6x6 chars) you need 4 different bitmap parts.
1: just background 2: background + crosshairs 3: background + enemy 4: background + enemy + crosshairs
(Maybe even a fifth one: background + dying enenmy + crosshairs)
Obviously, this is very memory consuming. (Maybe you don't even need 6x6 areas but can do with smaller areas?) Furthermore, it's always the same enemy for each position. But it would keep the code very simple
Example:
crosshairs in center position, no enemies: 1 1 1 1 2 1 1 1 1
crosshairs in center position, enemy appears in upper left corner: 3 1 1 1 2 1 1 1 1
crosshairs move to upper left corner, aimed at enemy: 4 1 1 1 1 1 1 1 1
crosshairs in upper left corner, enemy appears in the right lower corner: 2 1 1 1 1 1 1 1 3
Just keep track of which positions changed and only update the areas that did. So depending on the action (number of enemies), it's just a few updates each loop.
A more elegant approach would be routines that place crosshairs and enemies at any given position (P1-P9) and restore the background underneath if moved/status changed. This would be far more flexible because different enemies could be placed anywhere (and less memory consuming). Even if this involves masking it would be simple (due to the fixed positions) in comparision to a real sprite routine which can handle "soft" movement.
|
|
Posted By
George on 2013-01-07 05:07:18
| Re: Speed up Routine for Placing A Bitmap
i optimized the procedure by eliminating all variables and calculations for one position...not usabled for my purpose.
I will covert it to assemler. Thanks for all your ideas so far...
|
|
Posted By
gerliczer on 2013-01-07 04:55:20
| Re: Speed up Routine for Placing A Bitmap
Hi George,
Judging by the screenshot you linked, you want to use sprites for a little shooter game. The ROM routine you are already using is not suitable for this purpose since it is a simple copy routine not a masking one.
You may try to use it but it will be ugly because of overwriting. Furthermore, you will need to have some additional reserved memory for storing the static background to be overwritten by the sprites but this would be necessary also if you used a proper sprite routine.
|
|
Posted By
George on 2013-01-07 04:46:31
| Re: Speed up Routine for Placing A Bitmap
Hi Gerliczer,
to get the idea..here the reference:
http://www.mobygames.com/images/shots/l/51417-snatcher-sega-cd-screenshot-shooting-sequence-kill-those-spiders.gif
|
|
Posted By
gerliczer on 2013-01-07 01:59:47
| Re: Speed up Routine for Placing A Bitmap
Hi George,
Is the content of the 9 fields static not taking the aiming sight into account?
|
|
Posted By
George on 2013-01-06 14:12:38
| Re: Speed up Routine for Placing A Bitmap
Hi gerliczer,
to be honest, i haven't understood the trick, because of my lack of experience.
The game will be like this:
Think of a full screen grid 3x3 (like tic tac toe) with a full screen backgound bitmap. There is a aiming-"cross" which can be placed in every of this nine fields by moving the joystick or keys. If the Joystick is centered, the cross will be centred too. The aiming cross is a small bitmap. Its a simple but very fast shooting game.
|
|
Posted By
gerliczer on 2013-01-06 04:43:20
| Re: Speed up Routine for Placing A Bitmap
Hi George,
I think you should use a little trick instead of copying a lot of bitmaps. Don't put the bitmaps right next to each other but leave out a one character size space between them both horizontally and vertically. This will be the area for the cursor. Draw there a kind of frame in a local bitmap color (pattern 01 and 10 if I remember correctly) and set the local color identical to the general background color. When you move the cursor you highlight the area of the new position and darken the old position by simply writing to the color matrix (and if necessary the luminance matrix). Only the corner position may need bitmap update but if you not insist on the cursor being a continuous line you replace it with some proper static graphic like a dot or asterix and only highlight and darken it via the color matrix as necessary.
|
|
Posted By
George on 2013-01-05 21:36:41
| Re: Speed up Routine for Placing A Bitmap
Hi Chicken, you seem to have great experience in this topic. I am glad you aswered.
The routine was developed with the help of some users here at this post:
http://plus4world.powweb.com/forum/23799
The original use of it was to place bitmaps at any positions for an interactive story (see screenshot at the end of that post).
I want the story to have a qucik action element and you guessed it right with your pattern (3x3). Yes there is a graphic background, which has to be restored (i will implement this later). The positions and dimensions of the bitmaps align perfectly to chars (6x6 chars), you guessed this also right. The Player bitmap (actually a simple bitmap) has to be transparent and has the function of a cursor.
The static player element must placed at this nine positions as quickly as possible.
|
|
Posted By
Chicken on 2013-01-05 21:02:47
| Re: Speed up Routine for Placing A Bitmap
You should give us more details what you intend to do exactly. Maybe a different approach would do the trick for you.
Why do you want to use bitmap mode? And is there a background graphic that needs to be restored when the "player" bitmap moves? Or is the background just black (or any other color)?
What are the 9 positions? Do they form a pattern like this?
1 2 3 4 5 6 7 8 9 Do the positions have to have pixel coordinates like 4? If they align perfectly to chars (eg 0,0 or 8,8), it could speed things up quite a bit. In fact, dedicated "copy bitmap to pos x" subroutines would be really easy and fast then. Even if the positions do not align to chars, it's still easy if the positions are always the same.
If it's always the very same "player" bitmap and the positions do not overlap, you can also draw the "player" bitmap in all 9 positions and just "hide" the ones you don't need by manipulating the color ram "underneath" (ie black on black). That's just a couple of bytes instead of moving bitmaps around. The bitmap placing routine in your post is a universal one but usually - when coding games - you don't need routines that can handle everything. Also, it helps to design the game "data" (graphics etc) in a way that makes the handling easy (eg aligning stuff to chars).
Anyway, give us more details
|
|
Posted By
George on 2013-01-05 20:08:05
| Speed up Routine for Placing A Bitmap
Hi all,
i need some help in speeding up our Bitmap-Placing procedure. Its preety quick in basic but you can't use it for really quick positioning (eg simple action games). My Goal: the same Bitmap (6x6 chars) should be placed as quick as possible at 9 different positions on screen per Joystick or keyboard klick. Maybe you see a way to speed this up. Otherwise i need help for porting it into assembly language
##LOAD_BITMAP sa=DEC("6000"): REM Pointer to Cache-Startadresse x=4:y=0 :REM Top-Left Position of Bitmap w=6:h=6 :rem Dimension Chars width/height
wb=w*8: hf=h/2: ev=((hf)-int(hf)) : if ev=0 then e=1:else e=0 if e=1 then hf=hf-1 q =sa : zi=8192 + x*8 + y*320 for k = 0 to hf POKE192,((q ) and 255) : POKE193,(((q)/256) and 255) POKE200,((zi) and 255) : POKE201,(((zi)/256)and 255) if e=1 then q = q+wb : zi = zi + 320:else e=1 POKE169,((q ) and 255) : POKE170,(((q )/256) and 255) POKE234,((zi) and 255) : POKE235,(((zi)/256) and 255) q=q+wb : zi = zi + 320 POKE2024,wb-1:POKE2036,0:SYSDEC("DA4F") next
k=0:q1 = sa+(w*h*8):q2=q1+(w*h) : z1=DEC("1800")+x+y*40:z2= DEC("1C00")+x+y*40
##COLLUMI POKE192,(q1 and 255) : POKE193,((q1/256) and 255) POKE200,(z1 and 255) : POKE201,((z1/256)and 255) q1=q1+w : z1=z1+40 : POKE169,(q2 and 255) : POKE170,((q2 /256) and 255) POKE234,(z2 and 255) : POKE235,((z2 /256) and 255) q2 = q2 + w: z2 = z2 + 40 : POKE2024,w-1: POKE2036,0:SYSDEC("DA4F") k = k+1:if k <=h then ##COLLUMI return
|
|
| |
Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon |