+mksmith Posted March 10, 2021 Share Posted March 10, 2021 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 'hello567890abcdefghi' '01234567890abcdefghi' end Working example plotchars_example.zip Quote Link to comment Share on other sites More sharing options...
+Karl G Posted March 10, 2021 Share Posted March 10, 2021 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. ? 2 Quote Link to comment Share on other sites More sharing options...
+Karl G Posted March 10, 2021 Share Posted March 10, 2021 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 MainLoop clearscreen 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 _skip_advance_pointer rem draw plotchars TextMem 0 0 0 20 drawscreen goto MainLoop function TextCopy for Temp = 0 to 19 TextMem[Temp] = temp1[[Temp]] next return ; End TextCopy alphadata message font 'hello567890abcdefghi' '01234567890abcdefghi' end plotchars.78b plotchars.78b.a78 3 Quote Link to comment Share on other sites More sharing options...
+mksmith Posted March 10, 2021 Author Share Posted March 10, 2021 @Karl G Awesome mate thank you - that will work great! I've done a bit with pointers in the past but they still throw up challenges!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.