Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Aug 24, 2017 9:43:56 GMT -5
I'm trying to make sprites using pre-existing tiles. Kind of like using the drawtiles command.
I'm trying to feed the DATA array into the function using LblPtr& but I'm confusing myself. This code, for instance, fails:
Any insight would be greatly appreciated. I'm just not getting it on my own.
dim tiles_player0(16) as integer at mysprite dim tiles_rotate(16) as integer at myrotate
current_index = 256 index_player0 = current_index
for ii = 0 to 15 step 1 copytile lblptr&(myalt)(ii), tiles_rotate(ii)+index_player0 next
object_player0=addsprite(4,4) : propsprite object_player0,index_player0,0 movesprite object_player0, 146, 146 ' COPYTILE by Adam Welch ' Copies a tile to another DECLARE SUB COPYTILE(frommem AS INTEGER, tomem AS INTEGER) FOR i = 0 TO 15 b0 = VDPRAMREAD(frommem<<5+(i<<1)) VDPRAMWRITE tomem<<5+(i<<1), b0 NEXT END SUB
mysprite: DATAINT 48, 49, 50, 51 DATAINT 52, 53, 54, 55 DATAINT 56, 57, 58, 59 DATAINT 60, 61, 62, 63
myalt: DATAINT 48, 49, 50, 51 DATAINT 52, 10, 10, 55 DATAINT 56, 10, 58, 59 DATAINT 60, 61, 62, 63 myrotate: DATAINT 0, 4, 8, 12 DATAINT 1, 5, 9, 13 DATAINT 2, 6, 10, 14 DATAINT 3, 7, 11, 15
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Aug 24, 2017 10:54:55 GMT -5
So that function copies memory addresses from the vdp (the vdpramread should give that away).
I'm not around to test at the moment, but you should be able to rewrite it by reading the values to an integer then using vdpramwrite to write the data, and skip over the vdpramread function.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Aug 24, 2017 11:41:00 GMT -5
Thanks for the response elusive! That got me thinking of a different tactic. I'd try to pass the DATA label and use a readint() command. This works for reload zxc BUT not reload lblptr&(zxc) or any variant Failed code: dim tiles_player0(16) as integer at mysprite dim tiles_rotate(16) as integer at myrotate dim spritetemp(16) as integer dim nexttile as integer dim whichsprite as long
current_index = 256 index_player0 = current_index
whichsprite& = lblptr&(zxc) reload whichsprite&
for ii = 0 to 15 step 1 copytile readint(), tiles_rotate(ii)+index_player0 next
object_player0=addsprite(4,4) : propsprite object_player0,index_player0,0 movesprite object_player0, 146, 146 ' COPYTILE by Adam Welch ' Copies a tile to another DECLARE SUB COPYTILE(frommem AS INTEGER, tomem AS INTEGER) FOR i = 0 TO 15 b0 = VDPRAMREAD(frommem<<5+(i<<1)) VDPRAMWRITE tomem<<5+(i<<1), b0 NEXT END SUB
mysprite: DATAINT 48, 49, 50, 51 DATAINT 52, 53, 54, 55 DATAINT 56, 57, 58, 59 DATAINT 60, 61, 62, 63
zxc: DATAINT 48, 49, 50, 51 DATAINT 52, 10, 10, 55 DATAINT 56, 10, 58, 59 DATAINT 60, 61, 62, 63 myrotate: DATAINT 0, 4, 8, 12 DATAINT 1, 5, 9, 13 DATAINT 2, 6, 10, 14 DATAINT 3, 7, 11, 15
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Aug 24, 2017 15:06:24 GMT -5
This may be the final answer. lblptr& doesn't seem to work the way I'd expect. Or, it doesn't work with all the commands I need it to.
I nwantged to create a sub routine that takes a tile map that drawtiles can use and instead load that into memory for use by a sprite.
The best compromise so far is to use "reload thelabel" and call a tile map to sprite routine after that. I was hoping "reload lblptr&(thelabel)" would work.
In any case (with elusives tremendous help) here is the code: This works for BEX and SecondBASIC.
Dim tiles_rotate(16) As Integer At myrotate Dim tempint As Integer dim tempint2 as integer dim current_index as integer dim index_player0 as integer dim object_player0 as integer
current_index = 256 index_player0 = current_index
Reload mysprite
For tempint = 0 To 15 Step 1 tempint2 = ReadInt() copytile tempint2, tiles_rotate(tempint)+index_player0 Next
object_player0=AddSprite(4,4) : PropSprite object_player0,index_player0,0 MoveSprite object_player0, 146, 146 ' COPYTILE by Adam Welch ' Copies a tile to another Declare Sub COPYTILE(frommem As Integer, tomem As Integer) dim i as integer dim b0 as integer For i = 0 To 15 b0 = VdpRamRead(frommem<<5+(i<<1)) VdpRamWrite tomem<<5+(i<<1), b0 Next End Sub
mysprite: DataInt 48, 49, 50, 51 DataInt 52, 53, 54, 55 DataInt 56, 57, 58, 59 DataInt 60, 61, 62, 63 myrotate: DataInt 0, 4, 8, 12 DataInt 1, 5, 9, 13 DataInt 2, 6, 10, 14 DataInt 3, 7, 11, 15
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Oct 4, 2017 8:15:15 GMT -5
So, THIS is the payoff for using this technique. I can use Tiled to assemble sprite "parts" and then combine them later. In this image each ship has 4 sections: front. back, wings and guns. I have 8 variations of each section. Basically, 8 x 8 x 8 x 8 possible combinations.
|
|