BydoEmpire Posted December 29, 2020 Share Posted December 29, 2020 (edited) Hi all. After 2 years away, I finally got some time to pick up a game I had started. Some of the code is based on tutorial projects so it might look familiar. I want to be able to change the screen map room-to-room. I've been trying to (if this were C) create a pointer to the screen data, which is stored as alphadata. Snippets: rem ** screen and map variables, ideally it's a pointer to current screen alphadata dim currentscreen=l dim currentscreenhi=m ... rem ** const pointers to the alphadata - this probably isn't correct rem ** I have two screens - screenmap00 and screenmap01 const screen00lo=#<screenmap00 const screen00hi=#>screenmap00 const screen01lo=#<screenmap01 const screen01hi=#>screenmap01 rem ** I was hoping I could update the map I want based on this (for now, hard-coded to screenmap01 to test) currentscreen=screen01lo currentscreenhi=screen001hi ... rem ** seems to be plotting garbage data, passing in screenmap00 or screenmap01 works fine, of course plotmap currentscreen 1 0 0 20 12 ... alphadata screenmap00 tileset_colortest 'abcdef fgfghi' 'hi hi' 'hi hi' 'fg fg' 'h ' 'h ' 'h dddddd ' 'h ' 'hi hi' 'hihihihihh hi' 'hi dehi' 'fgfgfg fgfgfg' end alphadata screenmap01 tileset_colortest 'abcdef fgfghi' 'hi hi' 'hiiii hi' 'fg fg' ' i' ' i' ' dd dd i' ' i' 'hi hi' 'hihi i hi' 'hi i dehi' 'fgfgfg ffgfgfg' end ------------------------------------------ Looking at the assembly from the .list.txt file, the addresses seem to check out 2b 1108 802b .L0165 ;; currentscreen = screen01lo 1109 802b 1110 802b a9 ef LDA #screen01lo 1111 802d 85 f1 STA currentscreen 1112 802f .L0166 ;; currentscreenhi = screen01hi 1113 802f 1114 802f a9 8b LDA #screen01hi 1115 8031 85 f2 STA currentscreenhi 0x8bef is the address screenmap01 is at: 4117 8bef screenmap01 4118 8bef 02 .byte.b (<tileset_colortest + $02) 4119 8bf0 04 .byte.b (<tileset_colortest + $04) 4120 8bf1 06 .byte.b (<tileset_colortest + $06) Edited December 29, 2020 by BydoEmpire Quote Link to comment Share on other sites More sharing options...
BydoEmpire Posted December 29, 2020 Author Share Posted December 29, 2020 (edited) This is throwing me for a loop: currentscreenhi and currentscreen are 01a1 and 01a0 respectively: 154 10000 ???? 01 a1 currentscreenhi = var97 156 10000 ???? 01 a0 currentscreen = var96 they get assigned the correct location of screenmap01 (0x8bf1): 1115 802b 1116 802b a9 f1 LDA #screen01_ptr_lo 1117 802d 8d a0 01 STA currentscreen 1118 8030 .L0166 ;; currentscreenhi = screen01_ptr_hi 1119 8030 1120 8030 a9 8b LDA #screen01_ptr_hi 1121 8032 8d a1 01 STA currentscreenhi plotmap gets the map file pointer from what seems to be currentscreen (01a0) 1370 8191 a9 a0 lda #<currentscreen 1371 8193 85 42 sta temp1 1372 8195 1373 8195 a9 01 lda #>currentscreen 1374 8197 85 43 sta temp2 AHA, it's passing in 01a0 instead of the contents of currentscreen (0x8bf1). Not sure exactly how to fix yet, but it's been helpful to at least write this down and logically walk through it. The list.txt file has been SUPER helpful. Q: Can you pass in a (non-const) pointer/variable to plotmap? Q: Do I have to (or should I) just copy the "current" screenmap data to some other location (like $2200) and always pass that in? Edited December 29, 2020 by BydoEmpire Quote Link to comment Share on other sites More sharing options...
BydoEmpire Posted December 29, 2020 Author Share Posted December 29, 2020 Yeah, that worked fine. I just copy the current alphadata to $2200 and use that block for everything. Don't need to change screens too often, so it should be fine. I *would* like to know if there's a way to use my initial approach, just to satisfy my curiosity. Quote Link to comment Share on other sites More sharing options...
+Karl G Posted December 29, 2020 Share Posted December 29, 2020 The problem is that plotmap has no idea that it's dealing with a pointer, so it would just treat currentscreen like a normal memory address (the address of the L variable, in your case). 1 1 Quote Link to comment Share on other sites More sharing options...
RevEng Posted December 29, 2020 Share Posted December 29, 2020 35 minutes ago, BydoEmpire said: I *would* like to know if there's a way to use my initial approach, just to satisfy my curiosity. The "plotmap" command in your example doesn't just use "currentscreen". It creates a ton of character display objects, each of them pointing to some offset of "currentscreen". So each of these display objects would need to be recalculated and modified under-the-hood, which is a lot more work than just changing one pointer. It could be done if it was really required, but most game designs would be better served by one of the more common screen change models... 1. use plotmap with a ram buffer of characters, and change the ram buffer contents whenever required. (it sounds like this is what you settled on) 2. use clearscreen and use plotmap to point to some other rom. (with the understanding this may take a few frames to happen, and you likely want to black the screen while it happens) 1 Quote Link to comment Share on other sites More sharing options...
BydoEmpire Posted December 29, 2020 Author Share Posted December 29, 2020 Thanks so much, I really appreciate the pointers (pun intended). The 7800basic community is so helpful, and all or the examples made it pretty easy to get up and running for the most part. 1 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.