Jump to content
  • 0

Text box on collision?


Jabba
 Share

Question

Is it possible to make a text box on collision with say a door ala Skyword sword? In SS when you walk into a door for someones house you've visited the name of the house owner appears in a text box. I'm looking to do something similar in MM or OoT, preferably MM :) Any help would be appreciated. :)

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Love me some practice!

 

Door.c

#include <mips.h>

#define LINK_XYZ 0x802245D4

/* Code snippet taken from ZZT and spinout */
void SetTextRGBA(void *, u8, u8, u8, u8);
void SetTextXY(void *, u16, u16);
void SetTextString(void *, char *, ...);
typedef struct
{
	 u32 x;
	 u32 y;
	 u32 z;
}
CoordR;
/* End of code snippet */

void _start (void) {
	 asm volatile ("la $gp, _gp");
	 CoordR *Link = (void*)LINK_XYZ;
	 CoordR Door[];
/* ^^ A variable which holds the XYZ coordinates of the doors;
you have to fill it in yourself */

/* An if statement which compares Link's current coordinates
with the coordinates of the door */
	 if ((Link->x <= Door->x) && (Link->y <= Door->y) && (Link->z <= Door->z)) {
		  SetTextRGBA(a0, 0, 0, 0, 255);
		  SetTextXY(a0, 0, 7);
		  SetTextString(a0, "Faggot's Room!n#%02X%02X%02X", 0);
	 }
/* Insert some code to make the text go away upon opening the
door... possibly an if statement which is based upon pad input
or current animation */

asm volatile ("jr $ra");
}

 

Door.x

/* ========================================================================
*
* n64ld.x
*
* GNU Linker script for building an image that is set up for the N64
* but still has the data factored into sections.  It is not directly
* runnable, and it contains the debug info if available.  It will need
* a 'loader' to perform the final stage of transformation to produce
* a raw image.
*
* Copyright (c) 1999 Ground Zero Development, All rights reserved.
* Developed by Frank Somers <frank@g0dev.com>
* Modifications by hcs (halleyscometsoftware@hotmail.com)
*
* $Header: /cvsroot/n64dev/n64dev/lib/alt-libn64/n64ld.x,v 1.2 2006/08/11 15:54:11 halleyscometsw Exp $
*
* ========================================================================
*/
OUTPUT_FORMAT ("elf32-bigmips", "elf32-bigmips", "elf32-littlemips")
OUTPUT_ARCH (mips)
EXTERN (_start)
ENTRY (_start)
SECTIONS {
   /* Start address of code is 1K up in uncached, unmapped RAM.  We have
	* to be at least this far up in order to not interfere with the cart
	* boot code which is copying it down from the cart
	*/
   . = 0x80600000 ;  /* Door.c  */
   SetTextRGBA = 0x800FB3AC; /* Set RGB routine */
   SetTextXY = 0x800FB41C; /* Set XY routine */
   SetTextString = 0x800FBCB4; /* Text draw routine  */

   /* The text section carries the app code and its relocation addr is
	* the first byte of the cart domain in cached, unmapped memory
	*/
   .text : {
	  FILL (0)
	  __text_start = . ;
	  *(.init)
	  *(.text)
	  *(.ctors)
	  *(.dtors)
	  *(.rodata)
	  *(.fini)
	  __text_end  = . ;
   }

   /* Data section has relocation address at start of RAM in cached,
	* unmapped memory, but is loaded just at the end of the text segment,
	* and must be copied to the correct location at startup
	*/
   .data : {
	  /* Gather all initialised data together.  The memory layout
	   * will place the global initialised data at the lowest addrs.
	   * The lit8, lit4, sdata and sbss sections have to be placed
	   * together in that order from low to high addrs with the _gp symbol
	   * positioned (aligned) at the start of the sdata section.
	   * We then finish off with the standard bss section
	   */
	  FILL (0xaa)
	  __data_start = . ;
		 *(.data)
		 *(.lit8)
		 *(.lit4) ;
	 /* _gp = ALIGN(16) + 0x7ff0 ;*/
/*  _gp = . + 0x7ff0; */
  . = ALIGN(16);
  _gp = . ;
		 *(.sdata)
	  __data_end = . ;
/*
	  __bss_start = . ;
		 *(.scommon)
		 *(.sbss)
		 *(COMMON)
		 *(.bss)
	  /* XXX Force 8-byte end alignment and update startup code */
	  __bss_end = . ;
*/
   }

   .bss (NOLOAD) :  {
		__bss_start = . ;
		*(.scommon)
*(.sbss)
*(COMMON)
*(.bss)
__bss_end = . ;
end = . ;
   }
}

I made this probably a lot more complicated than it has to be, but I can't think of any other way. For a hook, you can change the JR RA at the end of the osWriteBackDCacheAll to a J 0x80600000.

 

Anybody who can fix up my code, please do so because I'm still learning, too, and would like to increase my knowledge. Also, that code won't compile the way it is right now; you'll have to finish it up yourself but I'm pretty sure you get the basic idea.

 

EDIT: I just realized that the above hack wouldn't work because I'm only making comparisons with one set of XYZ coordinates when, really, boundries are made up of more than one point or set of XYZ coordinates.

Link to comment
Share on other sites

  • 0

It would probably be simpler to create a new actor that detects proximity based on its origin and point it to textures to overlay on the screen based on its variable, since the default text printer is ugly. For detecting Link's position, you'd use raycasting, I believe.

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.