|
Post by christophertumber on Nov 27, 2014 22:59:45 GMT -5
Well this was specifically for debugging values BTW - How sure are you that the value will never be $80 since if it is, it will be displayed at "-0"? I guess that's not really a problem sinc it's easily differentiated from "0" but still...
|
|
|
Post by mikiex on Nov 28, 2014 13:44:53 GMT -5
Well this was specifically for debugging values BTW - How sure are you that the value will never be $80 since if it is, it will be displayed at "-0"? I guess that's not really a problem sinc it's easily differentiated from "0" but still... wait, I'm trying to figure out if that can happen... but I convert only single digits 0 to 9 to ascii..
|
|
|
Post by mikiex on Nov 28, 2014 14:02:33 GMT -5
I'm all ears for any tips you can provide. I'm just trying to keep conversations going While this forum has a great community, it's always difficult to sustain technical discussions as there's never that many people both coding and wanting to talk about it. BCD is an option with its own trade-offs. Namely RAM. Since you need a byte per digit, a value up to 65535 is six bytes (you can't really get around the $80 terminator) vs two bytes for an unsigned integer. That may not seem like much, but let's say you have a high score table with 10 scores, that's a difference of 40 bytes RAM. This can quickly become a limiting factor, for example if you have different game modes where you want multiple score tables. If you want the flexibility of being able to display larger values, things start to get out of hand. 24-bit unsigned is 3 bytes but 9 bytes in BCD. 32-bit is 11 bytes BCD... Well thats not just keeping the conversation going, you have a valid point! ... I'm thinking about a single players score on screen in my case... but a highscore table I didn't think much about because it makes more sense if you are going to store that on a cart. I did start making writing a small double dabble (https://en.wikipedia.org/wiki/Double_dabble) routine, but realised I didn't need it for this case. I've no idea how you deal with 32bit numbers on the 6809 yet either
|
|
|
Post by christophertumber on Nov 28, 2014 14:49:12 GMT -5
wait, I'm trying to figure out if that can happen... but I convert only single digits 0 to 9 to ascii.. Here: Reg_To_Decimal: tfr a,b ;transfer a copy of a to b tstb ;test a to check if neg bpl Reg_DA ;branch if plus (positive) nega ;else is negative so negate a to be positive ldb #45 ;"-" sign
This results in performing a NEGA on $80. Which is $00.... This could be an issue, if, for example you're moving an object around the screen by incrementing X and Y without doing any edge of screen bounding.
|
|
|
Post by christophertumber on Nov 28, 2014 14:49:40 GMT -5
I've no idea how you deal with 32bit numbers on the 6809 yet either Painfully
|
|
|
Post by christophertumber on Nov 30, 2014 1:25:01 GMT -5
BTW - I believe I posted this before in a thread about intensity, but here's a routine to print a hexadecimal value.
;At entry, value to print should be in register A
draw_hex: sta Temporary_Variable ;Store the intensity variable so we can use it again ldx #Hex ;Point the X register at the start of the hexadecimal character table
lsra ;Move upper nybble (4 bits) to lower nybble (4 bits) lsra lsra lsra ldb a,x ;Get Hexadecimal character stb Temporary_String ;Store it as the first character in our string
lda Temporary_Variable ;Get intensity variable again anda #$0F ;Get lower nybble only ldb a,x ;Get Hexadecimal character stb Temporary_String+1 ;Store it as the second character in our string lda #$80 ;Set End of String sta Temporary_String+2
ldu #Temporary_String ;Point U register at start of string jsr display_string ;Print it jsr reset0ref rts
Hex: fcc "0" fcc "1" fcc "2" fcc "3" fcc "4" fcc "5" fcc "6" fcc "7" fcc "8" fcc "9" fcc "A" fcc "B" fcc "C" fcc "D" fcc "E" fcc "F"
|
|
|
Post by JasonH on Dec 11, 2014 14:16:01 GMT -5
Hi - just found this site, looking forward to reading through everything! I've done a tiny bit of this myself, and have everything I need to do this... Other than the time of actually learning it all!
|
|
|
Post by gauze on Dec 12, 2014 1:30:13 GMT -5
in the code up currently there is a bug in the 3rd to last line instead of lda $80 ;string terminator it should be lda #$80 ;string terminator
|
|
|
Post by mikiex on Dec 17, 2014 17:00:56 GMT -5
in the code up currently there is a bug in the 3rd to last line instead of lda $80 ;string terminator it should be lda #$80 ;string terminator Both seem to work for me using AS09 anyway?
|
|
|
Post by christophertumber on Dec 17, 2014 22:30:42 GMT -5
Both seem to work for me using AS09 anyway? Well, it's 50/50 that the contents of memory location $80 will be negative...
|
|
|
Post by mikiex on Dec 18, 2014 8:38:16 GMT -5
Both seem to work for me using AS09 anyway? Well, it's 50/50 that the contents of memory location $80 will be negative... ah I get it now..... this is why I shouldn't be allowed near code really Thanks Gauze/Chris
|
|
|
Post by christophertumber on Dec 18, 2014 10:52:45 GMT -5
ah I get it now..... this is why I shouldn't be allowed near code really Thanks Gauze/Chris Meh, we all have more to learn...
|
|
|
Post by gauze on Jan 3, 2015 23:18:21 GMT -5
hey christopher, I was looking over your old programming primer I printed out and it seems this is no longer valid code for tables
" LDA #1 STA level ... LDX #number_aliens_table ;Setup the start of the table LDA level,X ;Get the number of aliens and put it in A . . . number_aliens_table: fcb #00,#10,#12,#14,#16,#18,#20 ;The table"
the fcb line throws a syntax error, and even fixing that the "lda level,x" line doesn't work correctly, while
ldx #table lda level lda a,x
seems to be fine, any idea why this might be? Just changes in the assembler? Ancient brainfart?
|
|
|
Post by christophertumber on Jan 4, 2015 1:02:08 GMT -5
The fcb issue is a change to the assembler (or incompatibility with other assembler - similar to the lowercase opcodes and assembler instructions requirement). At least assuming you're using the assembler I am, you can no longer use # in fcb/fdb type statements to indicate decimals. $ for hex and % for binary work so it's a strange inconsistency.
Not sure why I would have thought "lda level,x" would ever work so I'll go with brain fart. Your fix makes a lot more sense.
|
|
|
Post by gauze on Jan 4, 2015 10:08:55 GMT -5
I just checked and it's true '#' is out but '$' and '%' work, very inconsistent syntax. (and yes I am using the kingswood assembler)
I'm surprised I was right about the indexed addressing thing with the levels, I was sick as a dog last couple days and didn't trust myself! (Not that I am not dense on my best days).
|
|