MEGA65 / open-roms

A project to create unencumbered open-source ROMs for use on selected retro computers
Other
263 stars 18 forks source link

Dangerous automatic CLR within LOAD #24

Open FeralChild64 opened 5 years ago

FeralChild64 commented 5 years ago

The 'cmd_load.s' contains:

;; XXX - C64 BASIC apparently doesn't clear variables after a LOAD in the
;; middle of a program. For safety, we do.
jsr basic_do_clr

This can break BASIC programs utilizing LOAD to fetch sprite data, machine code, and other binary data, like this code:

100 DN = 8: REM <- set device number
110 LOAD "SPRITE DATA 1", DN, 1
120 LOAD "SPRITE DATA 2", DN, 1: REM <- this will try to load from device #0 

IMHO this CLR is only safe if data is loaded to memory starting from TXTTAB ($2B-$2C, by default pointing to $0801) - if not, you can be sure this is some programming trick as in the snipped above.