|
Post by minsoft on Oct 4, 2020 15:23:38 GMT -5
Using the BIOS function Print_Str_d to display the score uses quite a lot of cycles (seems to be about 3000 for me).
I thought it may be better to display the score using vectors, so made a font and tested it out. Oh dear...this uses over 5000 cycles to display 7 digits! I have used the BIOS function Draw_VL_mode which I know isn't very efficient...but I really need the ability to 'move' within the vector list.
Has anyone done this with more success than me? Any tips would be appreciated.
|
|
|
Post by Peer on Oct 5, 2020 11:14:25 GMT -5
Hard to say without seeing your code.
- What type of scaling are you using? Vectors as long as possible, and scale factor for drawing as low as possible? - How is your score stored? 16 bit binary word which has to be converted to decimal each frame? Or do you store the score already as decimal (saves the whole conversion time)?
Cheers, Peer
|
|
|
Post by D-Type on Oct 5, 2020 13:17:16 GMT -5
How many cycles do you have still available?
|
|
|
Post by minsoft on Oct 6, 2020 6:31:36 GMT -5
Hard to say without seeing your code.
- What type of scaling are you using? Vectors as long as possible, and scale factor for drawing as low as possible? - How is your score stored? 16 bit binary word which has to be converted to decimal each frame? Or do you store the score already as decimal (saves the whole conversion time)?
Cheers, Peer
I'm using the longest vectors I can up to 127...so I could make them twice as long but it would need twice as many vectors...I've not tried that but think the increase in no. vectors might outweigh or cancel the benefit of longer lines? I will give it a try and see.
Scale factor is 7 which is as low as I can go at the moment without making the digits too small.
I haven't yet done the coding for the score itself - I am just displaying a fixed number at the moment. If I can't get the draw cycles down enough then I won't bother using vectors...but I was planning on storing the score as BCD.
Many thanks for your help!
|
|
|
Post by minsoft on Oct 6, 2020 6:40:02 GMT -5
How many cycles do you have still available? Currently I can get away with using the BIOS string function and be under 30000 cycles but I have plenty of game logic to add so anything I can save would be a bonus.
Perhaps I will just use the BIOS function until I go over 30000 and deal with it then. I could probably cheat if necessary and not display the score until the first enemy is killed which frees up a load of cycles...
Still curious how others have done it though. Probably using methods beyond my comprehension I suspect!
|
|
|
Post by D-Type on Oct 6, 2020 6:51:26 GMT -5
The BIOS has quite a few functions to manage and manipulate scores and print them out, you might want to consider those when deciding how you're going to handle it.
The code below are my Forth test words for scores. They actually dump to serial port terminal instead of the command line, but you could display them using a BIOS print string function instead. Maybe it'll give you an idea of what's possible.
In the below code, "pad" puts the "address of an area of working memory where you can stash stuff temporarily" onto the stack.
The BIOS functions in the text below are: _Add_Score_d _Add_Score_a _Clear_score _Strip_Zeros _Compare_Score _New_High_Score
\ Score ----------------------------------------------------------------------- \ No test word needed for Clear_Score, as no params passed. You \ can just run directly from the command line.
: .score \ string_addr -- ; Print a score begin dup c@ dup $80 <> while emit 1 + repeat 2drop ;
: dump-pad/score pad 10 dump pad .score ;
: addd-dump pad _Add_Score_d dump-pad/score ; : adda-dump pad _Add_Score_a dump-pad/score ;
\ Add decimal score to 6 digit ascii text score field. \ BIOS converts decimal score to BCD and then runs _Add_Score_d. : scorea \ -- ; pad 10 dump pad _clear_score dump-pad/score #003 adda-dump \ Add & display various numbers to test boundries #020 adda-dump #100 adda-dump #255 adda-dump ;
\ Add BCD score to 6 digit ascii text score field. : scored \ -- ; pad 10 dump pad _clear_score dump-pad/score $0004 addd-dump \ Add & display various numbers to test boundries $0030 addd-dump $0200 addd-dump $1000 addd-dump $1234 addd-dump ;
: sz \ -- ; Strip Zeros. Strips leading zeros from score for display. pad 5 $30 fill \ Set first 5 bytes of pad with ASCII $30 i.e. '0' $3080 pad 5 + ! \ Set sixth byte of pad to '0' and terminate with $80 dump-pad/score 0 pad _Strip_Zeros \ First digit to start with and address of score to use dump-pad/score ;
\ Compare_Scores. Compare two BCD score strings, to determine highest. : cs \ -- ; pad _clear_score \ Clear up score area 1 pad 8 + _clear_score \ Clear up score area 2
pad $10 dump pad pad 8 + _Compare_Score 4 u.r \ No scores, result is a 0
$31 pad $d + c! \ Increment second score area pad $10 dump pad pad 8 + _Compare_Score 4 u.r \ 2nd bigger than 1st, result is a 1
$32 pad 5 + c! \ Increment first score area pad $10 dump pad pad 8 + _Compare_Score 4 u.r \ 2nd bigger than 1st, result is a 2 ;
: nhs \ -- ; New_High_Score. Sets high score to score if score is higher. pad _clear_score \ Score 1 pad 8 + _clear_score \ Score 2
$1000 pad _Add_Score_d dump-pad/score \ Set score 1 = 1000 decimal $1234 pad 8 + _Add_Score_d dump-pad/score \ Set score 2 = 1234 decimal
pad 8 + pad _New_High_Score pad 10 dump \ New high score? No pad pad 8 + _New_High_Score pad 10 dump \ New high score? Yes, set high score = score ;
|
|
|
Post by minsoft on Oct 6, 2020 16:30:07 GMT -5
The BIOS has quite a few functions to manage and manipulate scores and print them out, you might want to consider those when deciding how you're going to handle it. The code below are my Forth test words for scores. They actually dump to serial port terminal instead of the command line, but you could display them using a BIOS print string function instead. Maybe it'll give you an idea of what's possible. In the below code, "pad" puts the "address of an area of working memory where you can stash stuff temporarily" onto the stack. The BIOS functions in the text below are: _Add_Score_d _Add_Score_a _Clear_score _Strip_Zeros _Compare_Score _New_High_Score
Thanks for your reply. I perhaps should have been clearer...I am already using the following BIOS functions:
Clear_Score Add_Score_a Print_Str_d (to display the score)
However using my vector font, I am just displaying a hardcoded number. At this stage I am really just comparing the no. cycles to *draw* the score, rather than anything else. If I cannot draw the score with vectors in fewer cycles than Print_Str_d, there is no point going any further and I'll continue to use Print_Str_d.
I have gone off on a slight tangent and made a modified macro version of Add_Score_a, which doesn't strip the leading zeros, so I can at least display the score with the leading zeros as I do with my vector font. This doesn't use any more cycles to display, at least not noticeably. This doesn't really solve my original problem but if I am stuck with the raster score then I'm slightly happier with it!
|
|
|
Post by minsoft on Nov 22, 2020 17:53:44 GMT -5
I realised a while back that I had some code I'd forgotten about displaying a 'blank' string which was wasting a load of cycles while using Print_str. However I still couldn't display my vector font using less cycles...so gave up on that idea. I found some interesting stuff in this thread though, regarding speeding up Print_str: vectorgaming.proboards.com/thread/1753/anybody-who-success-speeding-print
|
|