Displaying credits: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
(Created page with "The system ROM takes care of displaying the credits on the LED displays itself (see MV-LED board). The credit count for each player is stored in $D00034 for player 1,...")
 
m (Removed BCD conversion)
Line 1: Line 1:
The [[system ROM]] takes care of displaying the credits on the LED displays itself (see [[MV-LED]] board).
The [[system ROM]] takes care of displaying the credits on the LED displays itself (see [[MV-LED]] board).
The credit count for each player is stored 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.


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


Hex to BCD conversion (untested):
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.
<syntaxhighlight>
moveq.l #0,d0        ; Clear D0
move.b  $D00034,d0  ; Read P1 credits (hex)
move.w  d0,d1        ; Make a copy
divu.w  #10,d0      ; Credits / 10
swap    d0          ; Take care of remainder first
sub.b  d1,d0        ; Get units
move.b  d0,d1
andi.b  #$0F,d1      ; Mask off tens
swap    d0          ; Go back to quotient
lsl.b  #4,d0        ; Shift tens to left digit
or.b    d1,d0        ; Mix tens and units
</syntaxhighlight>


If $0C is in $D00034 we get $12, which is $0C in decimal but stored as hex. It's now trivial to get fix tile numbers for display on the fix layer.
'''Note''': [[SYSTEM_IO]] must be called each v-blank to update those locations.


<syntaxhighlight>
<syntaxhighlight>
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  #$7088,REG_VRAMADDR    ; Set position in fix map, top left
move.w  d0,d1                  ; Make a copy of the BCD value
move.w  d0,d1                  ; Make a copy of the BCD value

Revision as of 03:41, 6 October 2017

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,d1              ; Same
move.w  d1,REG_VRAMRW          ; Write units to VRAM