Displaying credits: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
(Added a revised, checked version of the code)
m (Replaced D1 by D0 in the unit part of the code as D1 was displayed 2 times instead of D1 then D0)
 
(One intermediate revision by the same user not shown)
Line 18: Line 18:
move.w  d1,REG_VRAMRW          ; Write tens to VRAM
move.w  d1,REG_VRAMRW          ; Write tens to VRAM
andi.w  #$000F,d0              ; Get units
andi.w  #$000F,d0              ; Get units
ori.w  #$5030,d1             ; Same
ori.w  #$5030,d0             ; Same
move.w  d1,REG_VRAMRW          ; Write units to VRAM
move.w  d0,REG_VRAMRW          ; Write units to VRAM
</syntaxhighlight>
</syntaxhighlight>


Other version (checked, works):
<syntaxhighlight>
.creditp1:
    jsr SYS_IO
    move.b $D00034,d0
    move.w d0,d1 ;copy d0 to d1
    move.w #FIXMAP+(2*32)+2,REG_VRAMADDR ;position #FIXMAP+(X*32)+Y,REG_VRAMADDR
    nop
    move.w #$20,REG_VRAMMOD ;auto-inc
    lsr.b #4,d1 ;get tens
   
    andi.w #$000F,d1 ;mask off eventual garbage
    ori.w #$0330,d1 ;tile $30 in fix
    move.w d1,REG_VRAMRW ;write tens
    andi.w #$000F,d0 ;mask off eventual garbage
    ori.w #$0330,d0 ;tile $30 in fix
    move.w d0,REG_VRAMRW ;write units
    rte                            ; Return from interrupt
</syntaxhighlight>
Put this at the end of your vblank interrpt
[[Category:Code]]
[[Category:Code]]

Latest revision as of 10:00, 8 October 2018

The system ROM takes care of displaying the credits on the LED displays itself (see MV-LED board).

It's up to the game to display the counts on the screen when needed. SNK recommends using a 8x8 fix layer font.

The credit count for each player is stored in BCD in $D00034 for player 1, and $D00035 for player 2. These locations are in the backup RAM, to keep the credit counts in case of a power failure during play.

Note: SYSTEM_IO must be called each v-blank to update those locations.

moveq.l #0,d0
move.b  $D00034,d0             ; Read P1 credits (hex)
move.w  #$7088,REG_VRAMADDR    ; Set position in fix map, top left
move.w  d0,d1                  ; Make a copy of the BCD value
move.w  #$20,REG_VRAMMOD       ; Auto-inc fix column
lsr.b   #4,d1                  ; Get tens
andi.w  #$000F,d1              ; Mask off eventual garbage
ori.w   #$5030,d1              ; Set palette 5 and tile offset $30 (ASCII "0")
move.w  d1,REG_VRAMRW          ; Write tens to VRAM
andi.w  #$000F,d0              ; Get units
ori.w   #$5030,d0              ; Same
move.w  d0,REG_VRAMRW          ; Write units to VRAM