No no, ran it on PC A fine, moved over to PC B worked on it fine then when I brought it to PC C it didn't work
SuperStrict
'a bunch of globals I need for editing
Global choosetile:Byte=0,nowtile:Byte,tilr:Byte,tilg:Byte,tilb:Byte,lcol:Byte=0,rcol:Byte=0,tilscroll:Byte=0,updatetis:Byte=1
'relevant pixmap
Global seltilmap:TPixmap=CreatePixmap(18*4,18*4,PF_RGB888)
Function EditTile()
SetColor 200,200,210;DrawRect 80,1,88,98
If Not choosetile
'Edit a tile; this code works fine
Else 'choosetile is where a menu shows up that displays a grid of 4x4 tiles and you can scroll up/down along the list.
'drawing is sluggish if I draw all the tiles to the backbuffer every loop, so they're drawn to a pixmap and updated only when necessary.
'make sure the pixmap exists. I declare the global after the main loop function, I think that's why it doesn't always get created initially
If seltilmap=Null Then seltilmap:TPixmap=CreatePixmap(18*4,18*4,PF_RGB888)
Local xcor:Byte=0,ycor:Byte=0,overm:Byte=0
'when updatetis=1 it means something outside of the tile edit dialog has been modified,
'and the pximap menu needs to be updated with the new data
If upall Then updatetis=1
If updatetis Then ClearPixels seltilmap,$FF797979 'SEE BELOW
For Local x:Byte=tilscroll*4 To tilscroll*4+15 'write the tiles to the pixmap
overm=MouseIn(xcor*18+83,4+ycor*18,16,16)
If x>tile.num-1 Then Exit
If updatetis Then WriteTile x,xcor*18+1,1+ycor*18,seltilmap
If overm Then
SetColor 0,0,0;DrawLine xcor*18+83,4+ycor*18+16,xcor*18+83+15,4+ycor*18+16
If lmb Then nowtile=x;choosetile=0
EndIf
xcor:+1
If xcor>3 xcor=0;ycor:+1
Next
DrawPixmap seltilmap,82,3 'draw the pixmap
If updatetis=1 Then updatetis=0 'reset updatetis
If Button("+",83,80,14,14) Then tile.Add 'misc. button adds another tile to the list
'handle the scroll bar
SetColor 30,30,30;DrawRect 159,4,7,18*4-2
If Button("",159,3,7,6) Then tilscroll:-1;updatetis=1
If Button("",159,18*4-3,7,6) Then tilscroll:+1;updatetis=1
SetColor 255,255,255;DrawLine 161,6,163,6;Plot 162,5; DrawLine 161,18*4-1,163,18*4-1;Plot 162,18*4
If tilscroll>Ceil(tile.num/4.0)-1 Then tilscroll=0
If tilscroll<0 Then tilscroll=Ceil(tile.num/4.0)-1
EndIf
End Function
'THis is my function I wrote to draw a tile onto a pixmap.
Function WriteTile(index:Byte,x%,y%,pmap:TPixmap)
If index>tile.num-1 Then Return 'if the tile index is nonexistant (no tile has been created at the index), return.
'NOTE: I can be sure that this line is not killing the drawing because the line ClearPixels seltilmap,$FF797979 marked 'SEE BELOW'
'does not do its job, either.
Local xcoord%=0,ycoord%=0
For Local fx:Byte=0 To 63
For Local bitpos:Byte=0 To 3
'tilr, g, & b are 2-bit colors derived from a pallet. Ignore all the bit workings; they function properly.
tilr=PeekByte(pallet.bank,NowPallet*12+ GetBits(PeekByte(tile.bank,fx+index*64),bitpos*2,2)*3 +0)
tilg=PeekByte(pallet.bank,NowPallet*12+ GetBits(PeekByte(tile.bank,fx+index*64),bitpos*2,2)*3 +1)
tilb=PeekByte(pallet.bank,NowPallet*12+ GetBits(PeekByte(tile.bank,fx+index*64),bitpos*2,2)*3 +2)
SetColor tilr,tilg,tilb
WritePixel pmap,x+xcoord,y+ycoord,($FF000000) | (tilr Shl 16) | (tilg Shl 8) | (tilb)
'xcoord & ycoord track the location on the pixmap to write, since bank data is stored in a linear fashion.
xcoord:+1
If xcoord>15 Then xcoord=0;ycoord:+1
Next
Next
End Function
|