Jump to content

Plotchars from pointer


Recommended Posts

Hi everyone,


I want to store some messages in alphadata, copy it into ram and then offset the starting point to display a different section of the message.  Now if I setup a pointer (either trying 1 or 2) it doesn't show the text but if I directly reference the ram location it does show.  Is this sort of thing possible??

 rem vars
 dim pointer = a.b

 rem copy to ram
 memcpy $2200 message 40 
 rem set pointer (try 1)
 pointer[0] = $00 : pointer[1] = $22

 rem set pointer (try 2)
 const plo = <#message
 const phi = >#message
 pointer[0] = plo : pointer[1] = phi
 rem draw
 plotchars pointer 0 0 0 20
 plotchars $2200 0 0 5 20

 alphadata message font

Working example


Link to comment
Share on other sites

6 hours ago, mksmith said:

pointer[0] = $00 : pointer[0] = $22

I assume the second part is supposed to be pointer[1] = $22 here.


At any rate, plotchars isn't setup to expect a pointer, so you can't pass a pointer to it and get a correct result. If you are copying the data into RAM anyway though, you can just have the plotchars use $2200 as the address, and instead make your own function to read from your pointer to copy data to memory, and just increment the pointer when you need to. I'll whip up a quick example momentarily if no one beats me to it. ? 

  • Like 2
Link to comment
Share on other sites

Here's an example that increments the start point of your text by 1 every time you press fire. Note that in a real game, you would probably want to do the plotchars before a savescreen, then restore it every frame instead of having to replot it. Then you could just update the text by adjusting the pointer and running the TextCopy function:


 set doublewide off
 set tv ntsc
 set zoneheight 8
 set screenheight 208
 set romsize 48k
 set mcpdevcart off
 set canary off
 displaymode 160A
 rem vars
 dim pointer = a.b
 dim FireButtonHeldBit0 = c
 dim Temp = d
 dim TextMem = $2200

 rem characters
 incgraphic gfx/font.png 160A

 rem font
 characterset font
 alphachars '0123456789abcdefghijklmnopqrstuvwxyz! >`?/.,:-_()[]&AB@*"#'

 rem palette
 P0C1 = $0f

; rem set pointer
; pointer[0] = $00 : pointer[1] = $22
 const plo = <#message
 const phi = >#message
 pointer[0] = plo : pointer[1] = phi
 rem copy to ram
 temp1 = TextCopy(pointer[0], pointer[1]) ; return value is discarded

 rem mainloop

 if !joy0fire then FireButtonHeldBit0{0} = 0 : goto _skip_advance_pointer
 if FireButtonHeldBit0{0} then goto _skip_advance_pointer
 FireButtonHeldBit0{0} = 1
 pointer[0] = pointer[0] + 1
 if CARRY then pointer[1] = pointer[1] + 1
 temp1 = TextCopy(pointer[0], pointer[1]) ; return value is discarded

 rem draw
 plotchars TextMem 0 0 0 20

 goto MainLoop

 function TextCopy
 for Temp = 0 to 19
 TextMem[Temp] = temp1[[Temp]]
; End TextCopy

 alphadata message font



  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...