pedgarcia Posted April 28, 2020 Share Posted April 28, 2020 Hi, I am trying now to write a simple GR7 sample to show Action! speed. For that I am reading the display list information to get the address of the graphics 7+16 mode. This is the program: PROC MAIN() CARD I CARD DL=560 CARD POINTER DLADDR CARD POINTER SCR GRAPHICS(7+16) DLADDR=DL DLADDR==+4 ;FIRST BYTE START GR7 SCR=DLADDR^ FOR I=1 TO 3840 DO SCR^=135 SCR==+1 OD FOR I=1 TO 33000 DO OD RETURN It does work as expected but I have to confess I don't understand why I had to set a variable DL=560 (addresses 560/561 which points to the start of the display list) and a DLADDR pointer and lastly, associate DL to DLADDR in order for the program to work. I've tried simple do something like DLADDR=560^ without using the variable DL. Action! compiler accepts it but the program crashes the computer. My (misled) understanding tells that DLADDR=560^ would give me the same result as DLADDR=DL^ since DL=560 (and it is not a pointer). What I am missing here? Thanks again! Quote Link to comment Share on other sites More sharing options...
Alfred Posted April 28, 2020 Share Posted April 28, 2020 You could do it shorter I think. CARD DL=560 SCR=DL+4 ; address of DL@560+ skip ahead to LMS address SCR=SCR^ ; Set SCR to screen address To use just DLADDR you could do something like DLADDR = PeekC(560)+4 SCR=DLADDR^ 560^ is not a valid construct, I don't know why the compiler doesn't flag it as an error. Either you need a variable assigned to 560 like you did with DL or you need to use PEEKC to retrieve the contents at 560. Quote Link to comment Share on other sites More sharing options...
pedgarcia Posted April 28, 2020 Author Share Posted April 28, 2020 Thanks Alfred. Both options worked like a charm. I like the PeekC option as it is very similar to BASIC, although I imagine dealing with pointers directly would be faster if in a loop for example. Cheers Quote Link to comment Share on other sites More sharing options...
Alfred Posted April 28, 2020 Share Posted April 28, 2020 Just noticed, the increment is wrong in the loop. Since you're doing CARD stores, it should be: SCR==+2 Unlike Pascal, Action! doesn't increment pointers by the size of the base data type. Quote Link to comment Share on other sites More sharing options...
pedgarcia Posted April 29, 2020 Author Share Posted April 29, 2020 (edited) Hey Alfred, I understand what you say, but when I tried incrementing the variable by two, the result in screen shows I am skipping one byte. When I go back to 1, it seem to work fine. Also, changing the declaration from CARD SCR to BYTE SCR doesn't make any visible difference (Please, see the attached video to demonstrate what I did). What do you think? Thanks! (if it is not working here, there is a copy at http://www.mediafire.com/file/tq7scjihxjd5ql8/action1.mov/file) action1.mov Edited April 29, 2020 by pedgarcia Quote Link to comment Share on other sites More sharing options...
Alfred Posted April 29, 2020 Share Posted April 29, 2020 The reason SCR==+1 works is because you are poking the CARD 135 ($0087) so it is hiding the fact that you are poking a $00 as the MSB. When you change it to SCR==+2 now you see the effect of the CARD value. Change the code to: SCR^=34695 ; $8787 SCR==+2 and it should work correctly. Quote Link to comment Share on other sites More sharing options...
a8isa1 Posted April 29, 2020 Share Posted April 29, 2020 You can simplify SCR=DLADDR^ FOR I=1 TO 3840 DO SCR^=135 SCR==+1 OD with FOR SCR=DLADDR^ TO DLADDR^+3839 DO SCR^=135 OD and save 3840 additions and a like number of assignments 1 Quote Link to comment Share on other sites More sharing options...
pedgarcia Posted April 30, 2020 Author Share Posted April 30, 2020 Interesting that makes it shorter indeed! Yesterday I was playing with the SCR pointer declaration and looking at the monitor. Now I can understand how it works. If I declare it as BYTE, I can increment by one since SCR is pointing to a 8-bit BYTE. If it is declared as a pointer to a CARD, then I need to assign a 16-bit value and increment by 2 to match the size of the data the pointer is pointing to. Thanks! 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.