mirror of
https://github.com/dschmenk/PLASMA.git
synced 2026-03-12 16:42:08 +00:00
Deal with running out of memory during font load a little better
This commit is contained in:
Binary file not shown.
@@ -7,11 +7,11 @@ sysflags resxtxt1|reshgr1|resxhgr1
|
||||
|
||||
var strWidth, strHeight
|
||||
char darthstr = "DartH GRaphics"
|
||||
dcgrFont(fontRead("trade54.fon"))
|
||||
musicPlay(musicRead("imperial.seq"), FALSE)
|
||||
dcgrFont(fontRead("trade54.fon")) // This font exceeds the available memory so gets truncated
|
||||
strWidth, strHeight = dcgrStrExtents(@darthstr)
|
||||
dhgrMode(DHGR_COLOR_MODE)
|
||||
screenRead("darth.dhgr")
|
||||
musicPlay(musicRead("imperial.seq"), FALSE)
|
||||
musicGetKey(0, NULL)
|
||||
dcgrColor(CLR_WHITE)
|
||||
dcgrStr((140 - strWidth) / 2, (strHeight * 7) / 8, @darthstr)
|
||||
|
||||
@@ -175,6 +175,7 @@ export def fontRead(filename)#1
|
||||
num = font_header->fnt_last - font_header->fnt_first
|
||||
if font_header->fnt_typelen & FONT_PROP
|
||||
gly_ptr = heapalloc(num * 2) // Allocate glyph ptrs right after
|
||||
memset(gly_ptr, num * 2, NULL)
|
||||
if font_header->fnt_typelen & FONT_AA
|
||||
roundup = 1
|
||||
pixbyte = 2
|
||||
@@ -199,8 +200,9 @@ export def fontRead(filename)#1
|
||||
glyph->gly_height = height
|
||||
glyph->gly_adv = adv
|
||||
else
|
||||
heaprelease(font_header)
|
||||
font_header = NULL
|
||||
font_header->fnt_last = i + font_header->fnt_first - 1 // Truncate font glyphs
|
||||
//heaprelease(font_header)
|
||||
//font_header = NULL
|
||||
break
|
||||
fin
|
||||
else
|
||||
|
||||
@@ -807,10 +807,14 @@ export def musicPlay(track, rept)#0
|
||||
//
|
||||
// Select proper sequencer based on hardware
|
||||
//
|
||||
if mbSlot > 0
|
||||
musicSequence = @mbSequence
|
||||
if track
|
||||
if mbSlot > 0
|
||||
musicSequence = @mbSequence
|
||||
else
|
||||
musicSequence = @spkrSequence
|
||||
fin
|
||||
else
|
||||
musicSequence = @spkrSequence
|
||||
musicSequence = @noSequence
|
||||
fin
|
||||
//
|
||||
// Zero out active notes
|
||||
@@ -863,10 +867,19 @@ export def musicRead(filename)#1
|
||||
seq = NULL
|
||||
ref = fileio:open(filename)
|
||||
if ref
|
||||
seq = heapalloc(heapavail - 256)
|
||||
len = fileio:read(ref, seq, heapmark - seq)
|
||||
if heapavail > 128
|
||||
len = heapavail - 32
|
||||
seq = heapalloc(len)
|
||||
fin
|
||||
if seq
|
||||
len = fileio:read(ref, seq, len)
|
||||
heaprelease(seq + len)
|
||||
else
|
||||
puts("Unable to alloc sequence.\n")
|
||||
fin
|
||||
fileio:close(ref)
|
||||
heaprelease(seq + len)
|
||||
else
|
||||
puts("Unable to open: "); puts(filename); putln
|
||||
fin
|
||||
return seq
|
||||
end
|
||||
|
||||
@@ -390,7 +390,7 @@ $(FPU): libsrc/fpu.pla $(PLVM02) $(PLASM)
|
||||
|
||||
$(FPU_MF): libsrc/fpu_mf.pla $(PLVM02) $(PLASM)
|
||||
./$(PLASM) -AMOW libsrc/fpu_mf.pla
|
||||
acme --setpc 4094 -o $(FPU) libsrc/fpu_mf.a
|
||||
acme --setpc 4094 -o $(FPU_MF) libsrc/fpu_mf.a
|
||||
|
||||
$(SANITY): samplesrc/sanity.pla $(PLVM02) $(PLASM)
|
||||
./$(PLASM) -AMOW samplesrc/sanity.pla
|
||||
|
||||
Reference in New Issue
Block a user