'Mapconverter
'2018-08-24 build 0002
tile&
= _LOADIMAGE("plains2.bmp", 32) '_NEWIMAGE(640, 480, 32)
CONST Ts
= 17 'tile offsets CONST Tc
= 37 'tile count per line
peices% = 178
'debug information
'clear and display progress area
LINE (0, 416)-(1023, 431), _RGB(0, 0, 0), BF
LINE (0 + 16 * X%%
, 416)-(15 + 16 * X%%
, 431), _RGB32(200, 200, 15), BF
GET (0 + (X%%
* 16), 0 + (Y%%
* 16))-(15 + (X%%
* 16), 15 + (Y%%
* 16)), temp
() 'clear test area
'put test peice for reference
newtile%% = TRUE
'test the peice placing 2 copies of each found tile and XOR the test peice
' over to see if it erases
px%% = 0: py%% = 0
'first line of found tiles
'cycle through test peices and check for match
'progress bar for peices tested
LINE (0 + px%%
* Ts
, 360)-(15 + px%%
* Ts
, 375), _RGB32(0, 128, 255), BF
'current line of tiles to test
'clear test area
' _DELAY .25
'current check image
LINE (299, 199)-(316, 216), _RGB32(255, 255, 0), B
_PUTIMAGE (300, 200), tile&
, _DISPLAY, (0 + px%%
* Ts
, 0 + py%%
* Ts
)-(15 + px%%
* Ts
, 15 + py%%
* Ts
) ' _DELAY .25
'place the test copy
_PUTIMAGE (320, 200), tile&
, _DISPLAY, (0 + px%%
* Ts
, 0 + py%%
* Ts
)-(15 + px%%
* Ts
, 15 + py%%
* Ts
) ' _DELAY .25
'put the tile to check over the test copy with XOR
'zoom in on that area
' _DELAY .25
LINE (0, 0)-(127, 127), _RGB32(0, 0, 0), BF
'clear zoom layer _PUTIMAGE (0, 0), _DISPLAY, Zoom&
, (299, 200)-(336, 215) 'put test area in zoom layer _PUTIMAGE (0, 0)-(128, 64), Zoom&
, _DISPLAY, (0, 0)-(37, 15) 'put enlarged image back on display
' _DELAY .25
'get the test copy to see if it was erased
GET (320, 200)-(335, 215), temp
(257) LOCATE 13, 1:
PRINT TileCount2
'rgb brightness value(I think)
IF TileCount2
<= 256 THEN 'matchfound Match% = i%
i% = peices% + 1
px%% = px%% + 1
IF px%%
= Tc
THEN py%%
= py%%
+ 1: px%%
= 0 ' _DELAY .25
IF Match%
< 255 THEN 'matches found LOCATE 12, 1:
PRINT TileCount2
, Match%
'rgb brightness value(I think) ' _DELAY .025
Map(X%%, Y%%) = Match%
Match% = 255
Map(X%%, Y%%) = 255
' _DELAY .001
px%% = px%% + 1
IF px%%
= Tc
THEN py%%
= py%%
+ 1: px%%
= 0
IF X%%
< 65 THEN 'SCREEN tile& 'dont display if user pressed ESC ' OPEN "testmap.dat" FOR BINARY AS #1
' PUT #1, , Map()
' CLOSE
v& = v& + (r~%% + b~%% + g~%%)
TileCount = v&
v& = v& + (r~%% + b~%% + g~%%)
TileCount2 = v&