Displaying text: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
ASM routine for displaying text with a 8x8 pixel font on the [[fix layer]]:
ASM routine for displaying text with a 8x8 pixel font on the [[fix layer]]:


<pre>
<syntaxhighlight>
;Displays text pointed by A0 at the VRAM address in D1. $FF:Next line, $00:End of text.
;Displays text pointed by A0 at the VRAM address in D1. $FF:Next line, $00:End of text.
;Uses A0, D0 and REG_VRAMMOD
;Uses A0, D0 and REG_VRAMMOD. ASCIISTART is the character 0 fix tile.
Write8Text:
Write8Text:
     move.w  d1,VRAM_ADDR
     move.w  d1,REG_VRAMADDR
     move.w  #$20,VRAM_MOD
     move.w  #$20,REG_VRAMMOD
.textmaplp:
     clr.w  d0
     clr.w  d0
textmaplp:
     move.b  (a0)+,d0
     move.b  (a0)+,d0
     tst.b  d0
     tst.b  d0
     beq    textmapend
     beq    .textmapend
     cmp.b  #$FF,d0
     cmp.b  #$FF,d0
     bne    nolinejump
     bne    .nolinejump
     addq.w  #1,d1
     addq.w  #1,d1
     move.w  d1,VRAM_ADDR
     move.w  d1,REG_VRAMADDR
     bra    textmaplp
     bra    .textmaplp
nolinejump:
.nolinejump:
     addq.w  ASCIISTART,d0
     addq.w  ASCIISTART,d0
     move.w  d0,VRAM_RW
     move.w  d0,REG_VRAMRW
     bra    textmaplp
     bra    .textmaplp
textmapend:
.textmapend:
     rts
     rts
</pre>
</syntaxhighlight>


"ASCIISTART" should be the fix tile number corresponding to ASCII value 0. This depends on what tileset you are using. Usually, onboard fix tilesets have a full 8x8 font starting at tile #0.
"ASCIISTART" should be the fix tile number corresponding to ASCII value 0. This depends on what tileset you are using. Usually, onboard fix tilesets have a full 8x8 font starting at tile #0.


The VRAM address is calculated from the desired text position: D1=#FIXMAP+(Y+2+((X+1)*32))<br>
The VRAM address is calculated from the desired text position: D1=#FIXMAP+(Y+2+((X+1)*32)), [[68k ASM defines|"FIXMAP"]] being #$7000.
[[ASM Defines|"FIXMAP"]] being #$7000.


[[Category:HowTo]]
[[Category:Code]]
[[Category:Code]]
[[Category:Graphics Code]]

Latest revision as of 09:54, 3 October 2017

ASM routine for displaying text with a 8x8 pixel font on the fix layer:

;Displays text pointed by A0 at the VRAM address in D1. $FF:Next line, $00:End of text.
;Uses A0, D0 and REG_VRAMMOD. ASCIISTART is the character 0 fix tile.
Write8Text:
    move.w  d1,REG_VRAMADDR
    move.w  #$20,REG_VRAMMOD
.textmaplp:
    clr.w   d0
    move.b  (a0)+,d0
    tst.b   d0
    beq     .textmapend
    cmp.b   #$FF,d0
    bne     .nolinejump
    addq.w  #1,d1
    move.w  d1,REG_VRAMADDR
    bra     .textmaplp
.nolinejump:
    addq.w  ASCIISTART,d0
    move.w  d0,REG_VRAMRW
    bra     .textmaplp
.textmapend:
    rts

"ASCIISTART" should be the fix tile number corresponding to ASCII value 0. This depends on what tileset you are using. Usually, onboard fix tilesets have a full 8x8 font starting at tile #0.

The VRAM address is calculated from the desired text position: D1=#FIXMAP+(Y+2+((X+1)*32)), "FIXMAP" being #$7000.