pmgraphics Posted May 4, 2019 Share Posted May 4, 2019 This bit of code prints the variable value for I and Y, as the joystick is moved left, right, up, and down. It all works fine, until moving the joystick up, decreasing Y. As the Y variable value decreases eventually the program crashes. I'm using Altirra 3.1. 10 I=10:Y=12 100 STK=PEEK(54016) 110 IF STK=247 THEN POKE SCREEN+I+20*Y,0:I=I+0.1:IF I>=18 THEN I=18 120 IF STK=251 THEN POKE SCREEN+I+20*Y,0:I=I-0.1:IF I<=1 THEN I=1 130 IF STK=254 THEN POKE SCREEN+I+20*Y,0:Y=Y-0.1:IF Y<=1 THEN Y=1 140 IF STK=253 THEN POKE SCREEN+I+20*Y,0:Y=Y+0.1:IF Y>=22 THEN Y=22 150 PRINT I,Y 160 GOTO 100 Quote Link to comment Share on other sites More sharing options...
MaPa Posted May 4, 2019 Share Posted May 4, 2019 (edited) Where is defined SCREEN variable? It's not defined so it's value is zero so you are poking zero value in address area of 21-458 (zero page with OS/BASIC variables, page one - stack etc.). No wonder it crashes Edited May 4, 2019 by MaPa Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted May 4, 2019 Share Posted May 4, 2019 (edited) You've not initialised SCREEN which you are poking too, what effect are you after, looks like you are trying to clear a previous value? [EDIT] - ha, same time as MaPa Edited May 4, 2019 by Wrathchild Quote Link to comment Share on other sites More sharing options...
pmgraphics Posted May 4, 2019 Author Share Posted May 4, 2019 I missed including this line in the small program: 5 SCREEN=PEEK(88)+256*PEEK(89) Once I included that the little program did not crash (thanks). This was to test something I tried in my larger program to slow the character down as it moves with the joystick. The game is a graphic mode 1 with redefined characters like many in the old Compute! magazines. The actual program increases and decreases I and Y by 1 to move the character one space. I tried to slow the moving down by increasing I and Y by 0.5. It worked for left and right, but going up and down the character takes large jumps to the left or right. The the little program was to see what I and Y were doing as I moved the joystick. With the little program moving up and down (Y) did not change the value of "I" (left and right), as I expected it was doing. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.