mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-01-10 06:30:41 +00:00
Load/Save sprites to a file
This commit is contained in:
parent
cec1252ff6
commit
bc532f4458
@ -1,6 +1,8 @@
|
|||||||
import sprite
|
import sprite
|
||||||
predef spriteCompile(w, h, srcptr)#1
|
predef spriteCompile(w, h, srcptr)#1
|
||||||
predef spriteDup(sprtsrc)#1
|
predef spriteDup(sprtsrc)#1
|
||||||
|
predef spriteRead(filestr)#1
|
||||||
|
predef spriteSave(filestr, sprtptr)#1
|
||||||
predef spriteDraw(sprtptr)#0
|
predef spriteDraw(sprtptr)#0
|
||||||
predef spriteDrawXor(sprtptr)#0
|
predef spriteDrawXor(sprtptr)#0
|
||||||
predef spriteUnDraw(sprtptr)#0
|
predef spriteUnDraw(sprtptr)#0
|
||||||
|
@ -65,30 +65,30 @@ byte = $02,$06,$0A,$0E,$12,$16,$1A,$1E
|
|||||||
byte = $02,$06,$0A,$0E,$12,$16,$1A,$1E
|
byte = $02,$06,$0A,$0E,$12,$16,$1A,$1E
|
||||||
byte = $03,$07,$0B,$0F,$13,$17,$1B,$1F
|
byte = $03,$07,$0B,$0F,$13,$17,$1B,$1F
|
||||||
byte = $03,$07,$0B,$0F,$13,$17,$1B,$1F
|
byte = $03,$07,$0B,$0F,$13,$17,$1B,$1F
|
||||||
word hgrscan[] = $0000,$0400,$0800,$0C00,$1000,$1400,$1800,$1C00
|
word //hgrscan[] = $0000,$0400,$0800,$0C00,$1000,$1400,$1800,$1C00
|
||||||
word = $0080,$0480,$0880,$0C80,$1080,$1480,$1880,$1C80
|
word // = $0080,$0480,$0880,$0C80,$1080,$1480,$1880,$1C80
|
||||||
word = $0100,$0500,$0900,$0D00,$1100,$1500,$1900,$1D00
|
word // = $0100,$0500,$0900,$0D00,$1100,$1500,$1900,$1D00
|
||||||
word = $0180,$0580,$0980,$0D80,$1180,$1580,$1980,$1D80
|
word // = $0180,$0580,$0980,$0D80,$1180,$1580,$1980,$1D80
|
||||||
word = $0200,$0600,$0A00,$0E00,$1200,$1600,$1A00,$1E00
|
word // = $0200,$0600,$0A00,$0E00,$1200,$1600,$1A00,$1E00
|
||||||
word = $0280,$0680,$0A80,$0E80,$1280,$1680,$1A80,$1E80
|
word // = $0280,$0680,$0A80,$0E80,$1280,$1680,$1A80,$1E80
|
||||||
word = $0300,$0700,$0B00,$0F00,$1300,$1700,$1B00,$1F00
|
word // = $0300,$0700,$0B00,$0F00,$1300,$1700,$1B00,$1F00
|
||||||
word = $0380,$0780,$0B80,$0F80,$1380,$1780,$1B80,$1F80
|
word // = $0380,$0780,$0B80,$0F80,$1380,$1780,$1B80,$1F80
|
||||||
word = $0028,$0428,$0828,$0C28,$1028,$1428,$1828,$1C28
|
word // = $0028,$0428,$0828,$0C28,$1028,$1428,$1828,$1C28
|
||||||
word = $00A8,$04A8,$08A8,$0CA8,$10A8,$14A8,$18A8,$1CA8
|
word // = $00A8,$04A8,$08A8,$0CA8,$10A8,$14A8,$18A8,$1CA8
|
||||||
word = $0128,$0528,$0928,$0D28,$1128,$1528,$1928,$1D28
|
word // = $0128,$0528,$0928,$0D28,$1128,$1528,$1928,$1D28
|
||||||
word = $01A8,$05A8,$09A8,$0DA8,$11A8,$15A8,$19A8,$1DA8
|
word // = $01A8,$05A8,$09A8,$0DA8,$11A8,$15A8,$19A8,$1DA8
|
||||||
word = $0228,$0628,$0A28,$0E28,$1228,$1628,$1A28,$1E28
|
word // = $0228,$0628,$0A28,$0E28,$1228,$1628,$1A28,$1E28
|
||||||
word = $02A8,$06A8,$0AA8,$0EA8,$12A8,$16A8,$1AA8,$1EA8
|
word // = $02A8,$06A8,$0AA8,$0EA8,$12A8,$16A8,$1AA8,$1EA8
|
||||||
word = $0328,$0728,$0B28,$0F28,$1328,$1728,$1B28,$1F28
|
word // = $0328,$0728,$0B28,$0F28,$1328,$1728,$1B28,$1F28
|
||||||
word = $03A8,$07A8,$0BA8,$0FA8,$13A8,$17A8,$1BA8,$1FA8
|
word // = $03A8,$07A8,$0BA8,$0FA8,$13A8,$17A8,$1BA8,$1FA8
|
||||||
word = $0050,$0450,$0850,$0C50,$1050,$1450,$1850,$1C50
|
word // = $0050,$0450,$0850,$0C50,$1050,$1450,$1850,$1C50
|
||||||
word = $00D0,$04D0,$08D0,$0CD0,$10D0,$14D0,$18D0,$1CD0
|
word // = $00D0,$04D0,$08D0,$0CD0,$10D0,$14D0,$18D0,$1CD0
|
||||||
word = $0150,$0550,$0950,$0D50,$1150,$1550,$1950,$1D50
|
word // = $0150,$0550,$0950,$0D50,$1150,$1550,$1950,$1D50
|
||||||
word = $01D0,$05D0,$09D0,$0DD0,$11D0,$15D0,$19D0,$1DD0
|
word // = $01D0,$05D0,$09D0,$0DD0,$11D0,$15D0,$19D0,$1DD0
|
||||||
word = $0250,$0650,$0A50,$0E50,$1250,$1650,$1A50,$1E50
|
word // = $0250,$0650,$0A50,$0E50,$1250,$1650,$1A50,$1E50
|
||||||
word = $02D0,$06D0,$0AD0,$0ED0,$12D0,$16D0,$1AD0,$1ED0
|
word // = $02D0,$06D0,$0AD0,$0ED0,$12D0,$16D0,$1AD0,$1ED0
|
||||||
word = $0350,$0750,$0B50,$0F50,$1350,$1750,$1B50,$1F50
|
word // = $0350,$0750,$0B50,$0F50,$1350,$1750,$1B50,$1F50
|
||||||
word = $03D0,$07D0,$0BD0,$0FD0,$13D0,$17D0,$1BD0,$1FD0
|
word // = $03D0,$07D0,$0BD0,$0FD0,$13D0,$17D0,$1BD0,$1FD0
|
||||||
word hcolor[] = $0000,$552A,$2A55,$7F7F,$8080,$D5AA,$AAD5,$FFFF
|
word hcolor[] = $0000,$552A,$2A55,$7F7F,$8080,$D5AA,$AAD5,$FFFF
|
||||||
word hmask = $8081,$8082,$8084,$8088,$8090,$80A0,$80C0
|
word hmask = $8081,$8082,$8084,$8088,$8090,$80A0,$80C0
|
||||||
word = $8180,$8280,$8480,$8880,$9080,$A080,$C080
|
word = $8180,$8280,$8480,$8880,$9080,$A080,$C080
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
include "inc/cmdsys.plh"
|
include "inc/cmdsys.plh"
|
||||||
include "inc/hgrlib.plh"
|
include "inc/hgrlib.plh"
|
||||||
|
include "inc/fileio.plh"
|
||||||
|
|
||||||
struc t_sprite
|
struc t_sprite
|
||||||
var s_xpos
|
var s_xpos
|
||||||
@ -8,7 +9,6 @@ struc t_sprite
|
|||||||
byte s_underofst[2]
|
byte s_underofst[2]
|
||||||
byte s_undery[2]
|
byte s_undery[2]
|
||||||
byte s_pitch
|
byte s_pitch
|
||||||
// var s_width
|
|
||||||
var s_height
|
var s_height
|
||||||
var s_size
|
var s_size
|
||||||
var s_mask[14]
|
var s_mask[14]
|
||||||
@ -46,7 +46,6 @@ export def spriteCompile(w, h, srcptr)#1
|
|||||||
sprtptr->s_pitch = bytewidth
|
sprtptr->s_pitch = bytewidth
|
||||||
spritesize = bytewidth * h
|
spritesize = bytewidth * h
|
||||||
sprtptr=>s_size = spritesize
|
sprtptr=>s_size = spritesize
|
||||||
// sprtptr=>s_width = w
|
|
||||||
sprtptr=>s_height = h
|
sprtptr=>s_height = h
|
||||||
sprtptr=>s_under[0] = heapalloc(spritesize)
|
sprtptr=>s_under[0] = heapalloc(spritesize)
|
||||||
sprtptr=>s_under[1] = heapalloc(spritesize)
|
sprtptr=>s_under[1] = heapalloc(spritesize)
|
||||||
@ -74,7 +73,6 @@ export def spriteDup(sprtsrc)#1
|
|||||||
spritesize = sprtsrc=>s_size
|
spritesize = sprtsrc=>s_size
|
||||||
sprtdup=>s_size = spritesize
|
sprtdup=>s_size = spritesize
|
||||||
sprtdup->s_pitch = sprtsrc->s_pitch
|
sprtdup->s_pitch = sprtsrc->s_pitch
|
||||||
// sprtdup=>s_width = sprtsrc=>s_width
|
|
||||||
sprtdup=>s_height = sprtsrc=>s_height
|
sprtdup=>s_height = sprtsrc=>s_height
|
||||||
sprtdup=>s_under[0] = heapalloc(spritesize)
|
sprtdup=>s_under[0] = heapalloc(spritesize)
|
||||||
sprtdup=>s_under[1] = heapalloc(spritesize)
|
sprtdup=>s_under[1] = heapalloc(spritesize)
|
||||||
@ -86,6 +84,56 @@ export def spriteDup(sprtsrc)#1
|
|||||||
sprtdup->s_underofst[1] = 255
|
sprtdup->s_underofst[1] = 255
|
||||||
return sprtdup
|
return sprtdup
|
||||||
end
|
end
|
||||||
|
export def spriteRead(filestr)#1
|
||||||
|
var sprtptr, spritesize
|
||||||
|
byte refnum, i
|
||||||
|
|
||||||
|
sprtptr = 0
|
||||||
|
refnum = fileio:open(@filestr)
|
||||||
|
if refnum
|
||||||
|
sprtptr = heapalloc(t_sprite)
|
||||||
|
if fileio:read(refnum, sprtptr, t_sprite) == t_sprite
|
||||||
|
spritesize = sprtptr=>s_size
|
||||||
|
sprtptr=>s_under[0] = heapalloc(spritesize)
|
||||||
|
sprtptr=>s_under[1] = heapalloc(spritesize)
|
||||||
|
for i = 0 to 13
|
||||||
|
sprtptr=>s_map[i] = heapalloc(spritesize)
|
||||||
|
sprtptr=>s_mask[i] = heapalloc(spritesize)
|
||||||
|
fileio:read(refnum, sprtptr=>s_map[i], spritesize)
|
||||||
|
fileio:read(refnum, sprtptr=>s_mask[i], spritesize)
|
||||||
|
next
|
||||||
|
sprtptr->s_underofst[0] = 255 // Mark as under not valid
|
||||||
|
sprtptr->s_underofst[1] = 255
|
||||||
|
else
|
||||||
|
heaprelease(sprtptr)
|
||||||
|
sprtptr = 0
|
||||||
|
fin
|
||||||
|
fileio:close(refnum)
|
||||||
|
fin
|
||||||
|
return sprtptr
|
||||||
|
end
|
||||||
|
export def spriteSave(filestr, sprtptr)#1
|
||||||
|
var spritesize
|
||||||
|
byte refnum, i
|
||||||
|
|
||||||
|
fileio:destroy(@filestr)
|
||||||
|
if fileio:create(@filestr, $06, $0000) == FILE_ERR_OK
|
||||||
|
refnum = fileio:open(@filestr)
|
||||||
|
if refnum
|
||||||
|
if fileio:write(refnum, sprtptr, t_sprite) == t_sprite
|
||||||
|
spritesize = sprtptr=>s_size
|
||||||
|
for i = 0 to 13
|
||||||
|
fileio:write(refnum, sprtptr=>s_map[i], spritesize)
|
||||||
|
fileio:write(refnum, sprtptr=>s_mask[i], spritesize)
|
||||||
|
next
|
||||||
|
fin
|
||||||
|
fileio:close(refnum)
|
||||||
|
return 0
|
||||||
|
fin
|
||||||
|
fin
|
||||||
|
return -1
|
||||||
|
end
|
||||||
|
|
||||||
export def spriteDraw(sprtptr)#0
|
export def spriteDraw(sprtptr)#0
|
||||||
byte ofst, map, y
|
byte ofst, map, y
|
||||||
var width, height
|
var width, height
|
||||||
|
Loading…
x
Reference in New Issue
Block a user