Draw Text To Screen [Star / Riidefi]
#1
Draw Text To Screen [Star / Riidefi]

This code will display the specified text on the television screen.

(NTSC-U)
C200A3F0 00000007
9421FF80 BC410008
806DA358 80630044
80630000 3D808002
618C23E0 7D8903A6
4E800421 B8410008
38210080 80010014
60000000 00000000
C2009640 0000000E
9421FF80 BC410008
38600000 388000DC
38A00001 4800002D
44726177 20546578
7420546F 20536372
65656E20 62792053
74617220 26205269
69646566 69000000
7CC802A6 3FE08002
63EC1DF0 7D8903A6
4E800421 63EC1DD0
7D8903A6 4E800421
B8410008 38210080
81830000 00000000

(PAL)
C200A430 00000007
9421FF80 BC410008
806DA360 80630044
80630000 3D808002
618C2480 7D8903A6
4E800421 B8410008
38210080 80010014
60000000 00000000
C2009680 0000000E
9421FF80 BC410008
38600000 388000DC
38A00001 4800002D
44726177 20546578
7420546F 20536372
65656E20 62792053
74617220 26205269
69646566 69000000
7CC802A6 3FE08002
63EC1E90 7D8903A6
4E800421 63EC1E70
7D8903A6 4E800421
B8410008 38210080
81830000 00000000

(NTSC-J)
C200A38C 00000007
9421FF80 BC410008
806DA360 80630044
80630000 3D808002
618C23A0 7D8903A6
4E800421 B8410008
38210080 80010014
60000000 00000000
C20095DC 0000000E
9421FF80 BC410008
38600000 388000DC
38A00001 4800002D
44726177 20546578
7420546F 20536372
65656E20 62792053
74617220 26205269
69646566 69000000
7CC802A6 3FE08002
63EC1DB0 7D8903A6
4E800421 63EC1D90
7D8903A6 4E800421
B8410008 38210080
81830000 00000000

(NTSC-K)
C200A538 00000007
9421FF80 BC410008
806DA380 80630044
80630000 3D808002
618C24E0 7D8903A6
4E800421 B8410008
38210080 80010014
60000000 00000000
C2009788 0000000E
9421FF80 BC410008
38600000 388000DC
38A00001 4800002D
44726177 20546578
7420546F 20536372
65656E20 62792053
74617220 26205269
69646566 69000000
7CC802A6 3FE08002
63EC1EF0 7D8903A6
4E800421 63EC1ED0
7D8903A6 4E800421
B8410008 38210080
81830000 00000000

Code:
#============================================================#
#                          Source                            #
#------------------------------------------------------------#
# bLoadStaticRel Function Return Address Ports:              #
# RMCE - 0x8000A3F0                                          #
# RMCP - 0x8000A430                                          #
# RMCJ - 0x8000A38C                                          #
# RMCK - 0x8000A538                                          #
#============================================================#

.macro push_stack size, registers
      stwu r1, \size(r1)
      stmw \registers, 8(r1)
.endm

.macro absolute_bl register, address
      lis \register, \address@h
      ori \register, \register, \address@l
      mtctr \register
      bctrl
.endm

.macro pop_stack registers, size
      lmw \registers, 8(r1)
      addi r1, r1, \size
.endm

.set region, ''

.if     (region == 'E' || region == 'e') # RMCE
        .set nw4r_db_DirectPrint_SetupFB, 0x800223E0
.elseif (region == 'P' || region == 'p') # RMCP
        .set nw4r_db_DirectPrint_SetupFB, 0x80022480
.elseif (region == 'J' || region == 'j') # RMCJ
        .set nw4r_db_DirectPrint_SetupFB, 0x800223A0
.elseif (region == 'K' || region == 'k') # RMCK
        .set nw4r_db_DirectPrint_SetupFB, 0x800224E0
.else # Invalid Region
        .abort
.endif

# Function Prologue...
push_stack -128, r2

# Get the Render Mode (RKSystem->m_pVideo->m_pRenderMode)
.if     (region == 'E' || region == 'e') # RMCE
        lwz r3, -0x5CA8(r13)
.elseif (region == 'P' || region == 'p') # RMCP
        lwz r3, -0x5CA0(r13)
.elseif (region == 'J' || region == 'j') # RMCJ
        lwz r3, -0x5CA0(r13)
.elseif (region == 'K' || region == 'k') # RMCK
        lwz r3, -0x5C80(r13)
.endif

lwz r3, 0x44(r3)
lwz r3, 0(r3)

# Call nw4r::db::DirectPrint_SetupFB
absolute_bl r12, nw4r_db_DirectPrint_SetupFB

# Function Epilogue...
pop_stack r2, 128

# Original Instruction
lwz r0, 20(r1)

#============================================================#
#                          Source                            #
#------------------------------------------------------------#
# Draw Debug Bar Call Address Ports:                         #
# RMCE - 0x80009640                                          #
# RMCP - 0x80009680                                          #
# RMCJ - 0x800095DC                                          #
# RMCK - 0x80009788                                          #
#============================================================#

.macro push_stack size, registers
      stwu r1, \size(r1)
      stmw \registers, 8(r1)
.endm

.macro DirectPrint_absolute_bl register, address
      ori \register, r31, \address@l
      mtctr \register
      bctrl
.endm

.macro pop_stack registers, size
      lmw \registers, 8(r1)
      addi r1, r1, \size
.endm

.set region, ''

.if     (region == 'E' || region == 'e') # RMCE
        .set nw4r_db_DirectPrint_Printf, 0x80021DF0
        .set nw4r_db_DirectPrint_StoreCache, 0x80021DD0
.elseif (region == 'P' || region == 'p') # RMCP
        .set nw4r_db_DirectPrint_Printf, 0x80021E90
        .set nw4r_db_DirectPrint_StoreCache, 0x80021E70
.elseif (region == 'J' || region == 'j') # RMCJ
        .set nw4r_db_DirectPrint_Printf, 0x80021DB0
        .set nw4r_db_DirectPrint_StoreCache, 0x80021D90
.elseif (region == 'K' || region == 'k') # RMCK
        .set nw4r_db_DirectPrint_Printf, 0x80021EF0
        .set nw4r_db_DirectPrint_StoreCache, 0x80021ED0
.else # Invalid Region
        .abort
.endif

# Function Prologue...
push_stack -128, r2

li r3, 0   # X coordinate of text start
li r4, 220 # Y coordinate of text start
li r5, 1   # Wrap text

bl branch_link_write_printf_statement

.string "Draw Text To Screen by Star & Riidefi\0\0"

branch_link_write_printf_statement:
mflr r6 # Store the pointer to the String into r6

lis r31, 0x8002

# Call nw4r::db::DirectPrint_Printf
DirectPrint_absolute_bl r12, nw4r_db_DirectPrint_Printf

# Call nw4r::db::DirectPrint_StoreCache
DirectPrint_absolute_bl r12, nw4r_db_DirectPrint_StoreCache

# Function Epilogue...
pop_stack r2, 128

# Original Instruction
lwz r12, 0(r3)

Notes:
- The text will flicker since we only set up 1 of the 2 framebuffers to be output to via DirectPrint.

Code Creators: Star, Riidefi
[Image: GiVNKqR.png]
Reply
#2
How can I remove the borders? I can't get it to work. Is there any other function that writes only the text and not the box I can call?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)