How To

Illegal Memory Access

0

Kierham 2020-10-27 20:32 (Edited)

I know what that error means, but why am I getting it?
I can't show you the program because I need a screenshot and I can only get a screenshot on mobile and this site doesn't work on mobile so here is the code. Paste it into Notepad++ or something
Press a. That is what I’m having problems with.

GAMEPAD 1

SELECT=0

SELECT2=0

ROCKS=0

X=0

Y=0

BG 1

CELL SIZE 1,1

DO

BG SOURCE ROM(4)

BG COPY SELECT,SELECT2,20,16 TO 0,0

SELECT=INT(X/8)

SELECT2=INT(Y/8)

IF LEFT(0) THEN DEC X

IF RIGHT(0) THEN INC X

IF UP(0) THEN DEC Y

IF DOWN(0) THEN INC Y

IF X<0 THEN X=0

IF Y<0 THEN Y=0

IF X>407 THEN X=407

IF Y>455 THEN Y=455

IF BUTTON TAP(0,0) THEN

FOR I=1 TO 7

FOR I2=1 TO 10

IF CELL.C(I2,I)=10 THEN

PRINT "GOT ROCK"

INC ROCKS

MCELL I2,I,40

END IF

NEXT I2

NEXT I

END IF

WAIT VBL

LOOP















#1:MAIN PALETTES

002B0B0200383420003F0602003B3722

003F2A15000D0905000F0B07003F2A15



#2:MAIN CHARACTERS

00000000000000000000000000000000

00000000000000000000000000000000

00183454524A2A2B00182C6C6E763637

0000001C264A92240000001C3A76EEDC

000000000F103F3D000000000F1F3F26

00000000F834FEF600000000F8CCFE1A

FFFFFFFFFFFFFFFF0000000000000000

FFFFFFFFFFFFFFFF0000000000000000

BF5FBF5F5FBFBF5FC060C06060C0C060

FFFFFFFFFFFFFFFF0000000000000000

0000000000000000000000000000030F

000000000000003800000000000080C0

FFFFFFFFFFFFFFFF0000000000000000

FFFFFFFFFFFFFFFF0000000000000000

FFFFFFFFFFFFFFFF0000000000000000

FFFFFFFFFFFFFFFF0000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

2A21291511150101373F371B1F1B0F03

28280E4B15621000D8D8FEBDFBBEE8E0

44448F90E040300F7F7FFFFFFF7F3F0F

7613F17D0F0702FC9AFDFF8FF3FBFEFC

FFFFFFFFFFC43BC400000000003BFFC4

FFFFFFFFFFBA45BA000000000045FFBA

5F5FBF5F5FD46B146060C06060EB7F14

FFFFFFFFFFBA45BA000000000045FFBA

00000040404038071F3F3F7F7F7F3F07

0404020200000000F8F8FCFCFEFEFCE0

FFFFFFFFFFFF3FBF000000000000C0C0

FFFFFFFFFFFFFFFF0000000000000000

FFFFFFFFFFFFFFFF0000000000000000

FFFFFFFFFFFFFFFF0000000000000000

BF5FBF5F5FBFBF5FC060C06060C0C060

FFFFFFFFFFFFFFFF0000000000000000

C3300CC3300CC330FFFFFFFFFFFFFFFF

0CC3300CC3300CC3FFFFFFFFFFFFFFFF

300CC3300CC3300CFFFFFFFFFFFFFFFF

C3300CC3300CC330FFFFFFFFFFFFFFFF

0CC3300CC3300CC3FFFFFFFFFFFFFFFF

300CC3300CC3300CFFFFFFFFFFFFFFFF

00440000042002000044000004200200

00220010800210000022001080021000

00000000020F312000000000020D3E3F

00000000C0C0D87800000000C04058A8

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

5F5FBF5F5FDF5FBF6060C06060E060C0

FFFFFFFFFFFFFFFF0000000000000000

0CC3300CC3300CC3FFFFFFFFFFFFFFFF

300CC3300CC3300CFFFFFFFFFFFFFFFF

C3300CC3300CC330FFFFFFFFFFFFFFFF

0CC3300CC3300CC3FFFFFFFFFFFFFFFF

300CC3300CC3300CFFFFFFFFFFFFFFFF

C3300CC3300CC330FFFFFFFFFFFFFFFF

04002000028010000400200002801000

00120040011004400012004001100440

20404020202020003F7F7F3F3F3F3F0F

3C0C0C0603030200C4F4F4FAFDFDFEF8



#3:MAIN BG

00011410000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000605060506050605

060506050C0500000000000000000000

00000000000000000000000000000000

00000200000000000000000008050605

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000



#4:BG

000140400E050E050E050E050E050E05

0E050E050E050E050000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

000000000E050E050E050E050E050E05

0E050E050E050E050E050E050E050000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

000000000E050E050E050E050E050E05

0E050E050E050E050E050E050E050000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

000000000C0D0605060506050C050C0D

060506050C050E050E050E050E050000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000200D2801280128010805080D

28010A0420050E050E050E050E050000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000200D28012801280128012801

280108150C150E050E050E050E050000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000200D28012801280128012801

2801080506050605060506050C050000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000200D28012801280128012801

2801280128012801280128012005200D

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000200D28012801280128012801

2801280128012801280128012005200D

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

000000000C1D081D2801280128012801

28010A0428012801280128012005200D

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

000000000E1D0C1D081D280128012801

2801280128012801280108150C15200D

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

000000000E1D0E1D0C1D061506150615

061506150615061506150C150C0D080D

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

000000000E1D0E1D0E1D0E1D0E1D0E1D

0E1D0E1D0E1D0E050E050C0D080D000D

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000060506050605060506050605

06050605060506050605080D000D000D

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000220624062606220624062606

22062406260622062406260622062406

26060000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000240626062206240626062206

24062606220624062606220624062606

22060000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000260622062406260628012801

28012801240626062206240626062206

24060000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000028012801

28012801280100000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000280128012801

04012801280100000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000028012801

28012801280100000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000000000000000000000000000

00000000


GAMELEGEND 2020-10-28 00:27

strange

i ran this have no errors


GAMELEGEND 2020-10-28 00:30

to get a screen shot on lowres windows version
use ctrl + s


Kierham 2020-10-28 00:33

Oh I forgot, you press A to collect any materials on screen (so far I only have rock)


GAMELEGEND 2020-10-28 02:07 (Edited)

okay so the problem is

you are usin MCELL when the BG SOURCE is not in working RAM

usin BG SOURCE ROM(n) uses a map from ROM ENTRY n(which in this case is 4)

but if you used somthin like BG SOURCE $A000 it uses a map from workin RAM

unfortunately i can not tell you any more because that is the all my current knowledge of working RAM


was8bit 2020-10-28 07:21

Attached the corrected game... :)


was8bit 2020-10-28 07:24

The steps are this...

1) copy your entire game map that you made from FILE to ACTIVE MEMORY

2) tell NX that your background source is now ACTIVE MEMORY


was8bit 2020-10-28 07:28

When the game is playing, you

1) update your visible Bg layer as normal

2) you must then also update the map stored in ACTIVE MEMORY using the X,Y location of the item on the screen PLUS the X,Y of the upper left used in the BG COPY command


was8bit 2020-10-28 07:29 (Edited)

I took the liberty to use a SUB to simpify the movement code :)

I also placed map on BG layer 1, and the feedback text on BG layer 0 (#0 is actually on top of #1)


Kierham 2020-10-28 15:56

There are 2 rows missing of bg missing


Kierham 2020-10-28 15:58

I fixed the problem by changing 7 and 9 to 8 and 10 in my program and was8bit’s sub program


was8bit 2020-10-28 19:15

Ah, nice catch :)


was8bit 2020-10-28 19:18

The SUB I made wasn't really necessary... it's just a habit I do, because if you get a TON of code written all smoothed together it can get really confusing, especially if you don't work on the code all at once... when you leave it for a week or month, long smoothed code gets tossed away and abandoned because it takes too much effort to figure out what you were doing...

The more organized and such, the better in the long run, for me anyways :)


Log in to reply.