I am using big evil corporations framework for the sega genesis to create my game and got static text and sprites working fine. I am trying to draw arbitrary text such as the player's score, level counters etc. which change over time. I tried using the same functions for static text but they don't work as they require pointers to memory address where the static text is. Here is a link to my source code which also has the framework code. Any assistance in this matter would be greatly appreciated. Sincerely, SegaDev
Although I have no idea what you're talking about, I just wanted to let you know that your link's dead
You're going to need some ram to store the text in, there are a couple of ways you can do it. 1. Just store the score in ASCII. dc.b "000000" And have your update score method do the maths necessary to update the score. Each digit needs an add, compare, branch, subtract/carry to next digit. 2. Keep the score in a dc.l and then convert that to ASCII (either in some work ram or on the stack) using div instructions. Each digit requires a div instruction and they are slow. A lot of developers use method 1, the code is faster and the score can be as many digits as you want (method 2 is limited to approximately 4 billion). For bonus points only store the score in screen memory (I don't know how practical that is on the genesis). * I say ASCII but there is no reason that "0" has to be tile 48, you could make "0" be tile 0 for code simplicity.
I've replied to your similar post on SpritesMind but here is my hex word version for completion, hopefully it'll help others too. Code: ItoA_Hex_w: ; Converts a word to hex ASCII ; a0 --- In/Out: String address ; d0 (w) In: Number to convert ; 4 nybbles + 0x + terminator, working backwards add.l #0x7, a0 ; Zero terminate move.b #0x0, -(a0) move.w #0x0, d1 ; Char ptr move.w #0x3, d2 ; 4 nybbles in a word @NybbleLp: move.b d0, d3 ; Byte to d3 andi.b #0x0F, d3 ; Bottom nybble cmp.b #0x9, d3 ble @Numeric ; Branch if in numeric range add.b #(ASCIIAlphaOffset-0xA), d3 ; In alpha range (A - F) move.b d3, -(a0) ; Back to string lsr.w #0x4, d0 ; Next nybble dbra d2, @NybbleLp ; Loop bra @End @Numeric: add.b #ASCIINumericOffset, d3 ; In numeric range (0 - 9) move.b d3, -(a0) ; Back to string lsr.w #0x4, d0 ; Next nybble dbra d2, @NybbleLp ; Loop @End: ;0X move.b #'X', -(a0) move.b #'0', -(a0) rts As mentioned above, for 10-base decimal you'll need to use divs instead of offsets, and I like the idea of storing '000000' and nudging the count up/down better than all of this anyway. I'll be using that myself
I'm getting errors when assembling the source code with that subroutine: I added the appropriate labels to framework/charmap.asm as stated and still am getting the errors: Code: ;============================================================== ; BIG EVIL CORPORATION .co.uk ;============================================================== ; SEGA Genesis Framework (c) Matt Phillips 2014 ;============================================================== ; charmap.asm - ASCII character map ;============================================================== ASCIIStart: equ 0x20 ; First ASCII code in table ASCIIMap: dc.b 0x00 ; SPACE (ASCII code 0x20) dc.b 0x28 ; ! Exclamation mark dc.b 0x2B ; " Double quotes dc.b 0x2E ; # Hash dc.b 0x00 ; UNUSED dc.b 0x00 ; UNUSED dc.b 0x00 ; UNUSED dc.b 0x2C ; ' Single quote dc.b 0x29 ; ( Open parenthesis dc.b 0x2A ; ) Close parenthesis dc.b 0x00 ; UNUSED dc.b 0x2F ; + Plus dc.b 0x26 ; , Comma dc.b 0x30 ; - Minus dc.b 0x25 ; . Full stop dc.b 0x31 ; / Slash or divide ASCIINumericOffset dc.b 0x1B ; 0 Zero dc.b 0x1C ; 1 One dc.b 0x1D ; 2 Two dc.b 0x1E ; 3 Three dc.b 0x1F ; 4 Four dc.b 0x20 ; 5 Five dc.b 0x21 ; 6 Six dc.b 0x22 ; 7 Seven dc.b 0x23 ; 8 Eight dc.b 0x24 ; 9 Nine dc.b 0x2D ; : Colon dc.b 0x00 ; UNUSED dc.b 0x00 ; UNUSED dc.b 0x00 ; UNUSED dc.b 0x00 ; UNUSED dc.b 0x27 ; ? Question mark dc.b 0x00 ; UNUSED ASCIIAlphaOffset dc.b 0x01 ; A dc.b 0x02 ; B dc.b 0x03 ; C dc.b 0x04 ; D dc.b 0x05 ; E dc.b 0x06 ; F dc.b 0x07 ; G dc.b 0x08 ; H dc.b 0x09 ; I dc.b 0x0A ; J dc.b 0x0B ; K dc.b 0x0C ; L dc.b 0x0D ; M dc.b 0x0E ; N dc.b 0x0F ; O dc.b 0x10 ; P dc.b 0x11 ; Q dc.b 0x12 ; R dc.b 0x13 ; S dc.b 0x14 ; T dc.b 0x15 ; U dc.b 0x16 ; V dc.b 0x17 ; W dc.b 0x18 ; X dc.b 0x19 ; Y dc.b 0x1A ; Z (ASCII code 0x5A) EVEN Any assistance in this matter would be greatly appreciated. Sincerely, SegaDev