08-02-2022, 11:20 PM
(08-02-2022, 10:21 PM)boriel Wrote: What happens is what you suspected: this is machine code now, not BASIC, and the CPU executing is reaching the binary file ("final.bin").
Instead, jump over it with a GOTO, or better, put an END instruction before the incbin. Don't use RET in the ASM region. The compiler has an epilogue to return to the ROM BASIC safely:
Try this and tell me if it works:
Code:paper 0: ink 7: border 0: CLS
asm
ld hl,(.LABEL._art)
ld de,18432
ld bc,2048
LDIR
end asm
END: REM the program ends and returns to BASIC. This prevents executing the following lines.
art:
asm
incbin "final.bin"
end asm
Let me know!
Ok, removing the assembly instruction RET did the trick (in my code)
I'm still starting on zx basic, and actually forgot I placed some asm on other program without using ret
But it does not solve the issue with the label.
If I use the label in asm, it returns gibberish instead of the image (I'm guessing it's not pointing correctly)
If I hardcode the bin location, it will work.
Therefore, this will work:
Code:
paper 0: ink 7: border 0: CLS
asm
ld hl,50000
ld de,18432
ld bc,2048
LDIR
end asm
END: REM the program ends and returns to BASIC. This prevents executing the following lines.
art:
asm
org 50000
incbin "final.bin"
end asm
but using ".LABEL._art" (and without the org 50000) will just show a bunch of random pixels.