Post by christophertumber on Sept 7, 2014 13:58:09 GMT -5
pushr.rar (17.78 KB)
A while ago Alex Kazik created P1X3L-pushr. The original version is over on his blog:
alex.kazik.de/278/vectrex-p1x3l-pushr/
Since Alex doesn't have access to a Vectrex and was working on emulator only and emulators do a very poor job on things like flicker he wasn't aware of the problems when running on a real machine. Namely, flicker.
I decided to take it on as a bit of a practical study on optimization. Ideal since when I'm doing my projects I tend to incorporate these techniques as I go. Whereas Alex was approaching this as an introductory project and therefore using a lot of standard coding, especially BIOS routines "out of the box". And this seemed like a good opportunity to test out my previous opinions that a lot of return can be had from some fairly straight-forward and simple changes.
Prior to optimization the game was running at 25 fps on level 2 (level 2 is much more complicated layout than 1).
This was the cause of the flicker. 50 fps is ideal, anything over 40 is probably ok. Certainly over 45. The player sprite also exhibited drift, particularly when rescaled. For this reason it was broken up into three sprites. Interestingly, the outer walls do not show drift, despite being every bit as complex. This suggests that either scale effects drift or vertical and horizontal lines may mitigate drift. Further research is required.
ROM size has increased considerably - From 2K to 7K. However there remains plenty of room (25K non-bankswitched, 57K bankswitched) for additional levels, sound and music, intro screens &etc. Additionally some memory can be regained by reducing the rotation positions of the player. The original version of the game displays 32 different rotation sprites for a full circle, current version is 64. Some ROM can also be recovered from the original compressed vectors which remain in the code. Also, some RAM has been freed up since it's no longer necessary to decompress those vectors into RAM.
Note: Due to changes in vector display routines, sprites have been resized slightly. Side by side comparisons of screenshots will look slightly different (analog).
Optimizations steps were as follows:
Step 1: Optimize sprite vector lengths and scale
Result: 32 fps
Step 2: Replace jsr F_Moveto_d_7F with macro
Result: 33 fps
Step 3: Replace jsr F_Reset0Ref with macro
Result: 33 fps
Step 3: Replace F_Draw_VLp in sprites (except player)
Result: 39 fps
Step 4: Replace F_Rot_VL_Mode_a with pre-rotated player vectors with optimized scale
Result: 49 fps
Step 5: Broke player up into 3 sprites to eliminate drift & replaced F_Draw_VLp
Result: 49 fps
Frame rate is currently set at 48 fps.
Optimized binary, including source is attached. For the original, please go to Alex's blog.
A while ago Alex Kazik created P1X3L-pushr. The original version is over on his blog:
alex.kazik.de/278/vectrex-p1x3l-pushr/
Since Alex doesn't have access to a Vectrex and was working on emulator only and emulators do a very poor job on things like flicker he wasn't aware of the problems when running on a real machine. Namely, flicker.
I decided to take it on as a bit of a practical study on optimization. Ideal since when I'm doing my projects I tend to incorporate these techniques as I go. Whereas Alex was approaching this as an introductory project and therefore using a lot of standard coding, especially BIOS routines "out of the box". And this seemed like a good opportunity to test out my previous opinions that a lot of return can be had from some fairly straight-forward and simple changes.
Prior to optimization the game was running at 25 fps on level 2 (level 2 is much more complicated layout than 1).
This was the cause of the flicker. 50 fps is ideal, anything over 40 is probably ok. Certainly over 45. The player sprite also exhibited drift, particularly when rescaled. For this reason it was broken up into three sprites. Interestingly, the outer walls do not show drift, despite being every bit as complex. This suggests that either scale effects drift or vertical and horizontal lines may mitigate drift. Further research is required.
ROM size has increased considerably - From 2K to 7K. However there remains plenty of room (25K non-bankswitched, 57K bankswitched) for additional levels, sound and music, intro screens &etc. Additionally some memory can be regained by reducing the rotation positions of the player. The original version of the game displays 32 different rotation sprites for a full circle, current version is 64. Some ROM can also be recovered from the original compressed vectors which remain in the code. Also, some RAM has been freed up since it's no longer necessary to decompress those vectors into RAM.
Note: Due to changes in vector display routines, sprites have been resized slightly. Side by side comparisons of screenshots will look slightly different (analog).
Optimizations steps were as follows:
Step 1: Optimize sprite vector lengths and scale
Result: 32 fps
Step 2: Replace jsr F_Moveto_d_7F with macro
Result: 33 fps
Step 3: Replace jsr F_Reset0Ref with macro
Result: 33 fps
Step 3: Replace F_Draw_VLp in sprites (except player)
Result: 39 fps
Step 4: Replace F_Rot_VL_Mode_a with pre-rotated player vectors with optimized scale
Result: 49 fps
Step 5: Broke player up into 3 sprites to eliminate drift & replaced F_Draw_VLp
Result: 49 fps
Frame rate is currently set at 48 fps.
Optimized binary, including source is attached. For the original, please go to Alex's blog.