Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Crash when creating UDGs using ASM (possibly not a bug)
#1
Hi there,

I can't for the life of me work out why I've hit this wall. I'm currently designing the graphics for my game, keeping character maps in one file and test harness in another. It crashes out with "J Invalid I/O device, 30:1".

The code in the character file, called, _graphics.bas is as follows:

Code:
graphicsroom:
ASM
DEFB 000, 254, 254, 254, 254, 254, 254, 254 ; A - roof A
DEFB 000, 000, 254, 254, 254, 254, 254, 254 ; B - roof B
DEFB 254, 254, 000, 069, 170, 069, 170, 000 ; C - top wall
DEFB 085, 168, 085, 000, 170, 069, 170, 000 ; D - bottom wall
DEFB 000, 000, 000, 000, 000, 126, 126, 126 ; E - wall cap
DEFB 060, 060, 060, 060, 060, 060, 060, 000 ; F - vert wall (shared)
DEFB 124, 124, 124, 124, 124, 124, 124, 000 ; G - vert wall (left)
DEFB 062, 062, 062, 062, 062, 062, 062, 000 ; F - vert wall (right)
DEFB 000, 000, 000, 000, 000, 000, 000, 000 ; G -
DEFB 000, 000, 000, 000, 000, 000, 000, 000 ; H -
DEFB 000, 000, 000, 000, 000, 000, 000, 000 ; I -
DEFB 238, 136, 136, 000, 238, 136, 136, 000 ; J - floor A
DEFB 254, 170, 212, 170, 212, 170, 212, 000 ; K - floor B

END ASM

And the scratch file to display them is:

Code:
#include "_graphics.bas"

POKE UINTEGER 23675, @graphicsroom

let toproof$ = chr(144) + chr(145)
let caproof$ = chr(148)
let topwall$ = chr(146) + chr(146)
let botwall$ = chr(147) + chr(147)
let sharewall$ = chr(149)
let lefwall$ = chr(150)
let rigwall$ = chr(151)
let floorA$ = chr(155) + chr(155)
let floorB$ = chr(156) + chr(156)


border 0 : paper 0 : ink 7 : bright 1 : cls

print "  " + caproof$ + toproof$ + toproof$ + toproof$ + caproof$

bright 1 : print "  " + sharewall$; : bright 0 : print topwall$ + topwall$ + topwall$; : bright 1 : print sharewall$

bright 1 : print "  " + lefwall$; : bright 0 : print botwall$ + botwall$ + botwall$; : bright 1 : print rigwall$

bright 1 : ink 7 : print "  " + sharewall$; : bright 0 : ink 1 : print floorA$ + floorA$; : INK 2 : PRINT floorB$; : bright 1 : ink 7 : print sharewall$

bright 1 : ink 7 : print "  " + lefwall$; : bright 0 : ink 1 : print floorA$ + floorA$; : INK 2: PRINT floorB$; : bright 1 : ink 7 : print rigwall$

I have determined that if the last DEFB line in the graphics file is replaced with...

Code:
DEFB 254, 170, 212, 170, 212, 170, 000, 000 ; K - floor B

i.e. substituting the last 212 with 000, there is no crash. If I replace it with 001, all of the graphics corrupt but still run. Other values either work as expected or produce crashes. Adding another line after DEFB, i.e. graphic character L, causes it to crash.

It may be me as I'm still learning zxbc. I'm using the latest downloadable version on Mac. I've tried running this with an older download from earlier this year and it also crashes.

Thanks,


Steve
Reply
#2
Ah, I think I've found the answer - something to be with unreserved memory or something. I'm using britlion's tutorial to make the UDGs but I see this seems to be something discussed a few years ago and there's a better way of making graphics. I'll try that.

--

And the better way is to declare the UDGs in an array and call that.
Reply
#3
Hmmm. It seems my response didn't arrive yesterday.
What happens is that execution is entering the ASM region and your program will mostly crash.
Put a GOTO immediately before the ASM sentence and jump over that region:
Code:
GOTO continue_program
graphicsroom:
ASM
DEFB 000, 254, 254, 254, 254, 254, 254, 254 ; A - roof A
...
END ASM
continue_program:
Reply
#4
Ah cool. Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)