COMP2017 9017 Systems Programming
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
COMP2017 9017 Assignment 1
List of Acronyms
ASAN Address Sanitiser. 8, 9
PIC Position Independent Code. 8
UI User Interface. 4, 5
UX User eXperience. 4, 5
VLA Variable Length Array. 9
1 Assignment 1- [PointerPro Animate] - 12.5%
We strongly recommend reading this entire document at least twice. You are encouraged to ask questions on Ed after you have first searched, and checked for updates of this document. If the question has not been asked before, make sure your question post is of type "Question" and is under "Assignment" category → "P1" . Please follow the staff directions for using the question template.
It is important that you continually back up your assignment files onto your own machine, flash drives, external hard drives and cloud storage providers (as private). You are encouraged to submit your assignment regularly while you are in the process of completing it.
Full reproduction steps (seed, description of what you tried) MUST be given if you are enquiring about a test failure or if you believe there is a bug in the marking script.
Academic Declaration
By submitting this assignment you declare the following: I declare that I have read and understood the University of Sydney Student Plagiarism: Academic Integrity Policy, Coursework Policy and Pro cedures, and except where specifically acknowledged, the work contained in this assignment/project is my own work, and has not been copied from other sources or been previously submitted for award or assessment.
I understand that failure to comply with the Student Plagiarism: Academic Integrity Policy, Coursework Policy and Procedures can lead to severe penalties as outlined under Chapter 8 of the University of Sydney By-Law 1999 (as amended). These penalties may be imposed in cases where any significant portion of my submitted work has been copied without proper acknowledgement from other sources, including published works, the Internet, Generative AI where approved, existing programs, the work of other students, or work previously submitted for other awards or assessments.
I acknowledge that I have reviewed and understood the University of Sydney’s guidelines on the responsible use of Generative AI 1 and will adhere to them in accordance with academic integrity policies.
I realise that I may be asked to identify those portions of the work contributed by me and required to demonstrate my knowledge of the relevant material by answering oral questions or by undertaking supplementary work, either written or in the tutorial, in order to arrive at the final assessment mark.
I acknowledge that the School of Computer Science, in assessing this assignment, may reproduce it entirely, may provide a copy to another member of faculty, and/or communicate a copy of this assignment to a plagiarism checking service or in-house computer program, and that a copy of the assignment may be maintained by the service or the School of Computer Science for the purpose of future plagiarism checking.
Memory Leak Studios is developing a web-based animation service: PointerPro Animate. Their User Interface (UI)/User eXperience (UX) team has been working hard on the web interface but they still require performant and reliable animation software. As such, they have contracted you, a highly skilled systems programmer, to develop the backend software for their service.
3 Background
An animation is a sequence of images, known as frames, that are displayed at fixed time intervals.
Each frame is a 2D matrix of colour values, with each cell corresponding to a pixel position within the frame. This representation is often referred to as a bitmap2 .
Colour values can be expressed in many ways. In an effort to bring the product to market as soon as possible, you have been allowed to limit support to ARGB323 format input and output. This format comprises three 8b values for individual red, green and blue colour components as well as a fourth 8b value for alpha (often referred to as transparency). Note that these four values fit conveniently into one uint32_t value.
Animation frames are constructed by combining a collection of graphical objects known a sprites4 .
Sprites may be repositioned in each frame to give the illusion of motion of the sprite throughout the animation. While sprites are generally represented as a small bitmap, they may be constructed programmatically.
Sprites are combined by copying their bitmap representation to the frame at the desired position.
Since sprites may overlap, the alpha channel must be considered during the copying process and the order in which sprites are combined will impact the outcome of animation.
You will develop an animation generator backend that specialises in efficiently managing sprites, their motion in the frame, and the order in which they are combined.
Sprites will be constructed from either a user-provided bitmap image file in ARGB32 format or a small variety of simple shapes. In the initial release, these shapes will be rectangles (filled or unfilled) and circles (filled only). However, it is expected that the variety of shapes will grow – your implementation
You are required to implement a memory efficient solution. A significant amount of memory may be required to store sprite data, particularly if that sprite is replicated in one animation or used in multiple animations. Sprite data is to be stored only once regardless of the number of times the sprite is placed in the animation(s).
Motion will be configured in the style of a physics engine. Given the initial position p0 the position
The UI/UX team has provided an Application Programming Interface (API) for seamless integration with their work. You are required to follow this API in your design. Although best efforts have been made to ensure this API is complete and correct, you may be required to adjust your implementation based on API changes communicated by the UI/UX team.
Your backend service is required to generate animation frames from the provided canvas size, sprites and animation parameters. When generating a frame, the alpha component of bitmap sprites must be considered. You are not required to implement alpha blending; you should consider a zero alpha value as 100% transparent and non-zero as 100% opaque. That is, a sprite pixel should only be written to the frame if the alpha value is non-zero. The colour values in the final frames should have alpha set to its maximum value (0xFF).
The API documentation is provided with the source in a form that is compatible with Doxygen docu ment generator. A copy can be found in Appendix B.
The following functions are only required to be implemented by COMP9017 students:
It is recommended that COMP2017 students also implement these functions, however no marks will be awarded to COMP2017 students for doing so.
5.2 Performance requirements
Memory usage and leaks in your program will by tracked during marking by dynamically replacing symbols malloc, calloc, realloc and free. 5 You should only use the above standard dynamic memory allocation functions.
The following functions, where implementation is required, are expected to have execution time com plexity O(1):
For those interested, the API contains an optional extension if you wish to continue working on this project after final submission:
This function accepts a pointer to a user-defined function that should be used for calculating the appropriate position of a sprite at any time during the animation.
6.1 Image and movie file conversions
This assignment will require you to work with files of various formats. This section provides a guide on how to convert images to the appropriate format and how to convert frames generated by your code to image or video files.
Note: ${VAR} in this guide implies an environment variable of name “VAR” exists. You must either set an environment variable with the listed name to the appropriate value or replace that token with your desired value directly. imagemagick can be used to convert images to the format expected by AnimatePro using the following command
imagemagick can be used to convert raw pixel data into an image file using the following command:
6.2 Testing guide
It is highly recommended that you develop automated tests for your submission. For COMP2017 students, your tests will not be directly marked, but may be chosen as a short-answer question (Section 7). For COMP9017 students, you will be required to answer that question.
A testing framework has not been prescribed. You are welcome to use any method that you are familiar with. What ever you choose, your test framework should be quick to run to verify that existing functionality remains correct and issues with the functionality under development are easy to detect.
Tests should aim to test only one feature at a time to narrow the search space for bugs. However, you will find that some features depend on others. In this case, you may wish to skip such tests if the tests for functionality on which they depend are failing.
A simple framework might involve creating independent main.c files for each test, or a single main.c that accepts one (or many) arguments to select the test and it’s parameters. A bash script could then be used to orchestrate the test, compare results and, most importantly, clearly indicate which of your tests have passed and which have failed.
Visually inspecting video files or image files is time consuming, error prone and cannot be automated.
It is best to compare individual byte or pixel values of the generated frames. Inspecting bytes is easy for a computer program, but not for mere humans. You may wish to use a combination of xxd and diff. xxd reads binary data and prints that data in hexidecimal form. Since pixel values occupy 4 consecutive bytes, inspection will be easier if we tell xxd to group our data into bytes of 4. xxd will also take the endianess of the machine into consideration – we can expect the values reported by xxd to match values printed in our code.
diff reports on difference between two ASCII files. Binary data can still be processed if we first convert that binary data to ASCII using a tool such as xxd. When comparing two files (large files in particular) suppressing the printing of common lines allows us to focus only on the differences.
Tip: keep your frame size small during initial testing. Identifying the pixel position of data reported can be challening for very large frames.
As part of the in-tutorial code review in week 8, you are required to analyse your code and prepare for two of the below questions. You must supplement your answer with references to your code.
The examiner will also ask follow-up questions based on your response. COMP9017 students must answer Q4.
8 Marking
Your submission must produce an object file named animate.o using the command make animate.o. The marking script will compile this into a shared object. Thus, the flag -fPIC must be added.
You are free to (and encouraged to) add extra build rules and functions for your local testing, such as a main function or debug flags. Address Sanitiser (ASAN) is encouraged during local testing, and will be automatically added to your final submission6 .
When marking, your code will be compiled and run entirely on the Ed workspace. The aformentioned make commands will be run to compile your program and run the executable. If it does not compile in the Ed environment, then your code will receive no marks for your attempt. When submitting your work ensure that any binary files generated are not pushed onto the repository.
After your object file is compiled into a shared object, python scripts using ctypes will interact with the functions described in spec. In most cases, the script is responsible for:
Thus, you can think of the test inputs and outputs as not given from a separate program, but rather driven in the same program. In this way, your program outputs are validated before your program ends.
After submission, a subset of the tests that will be used for marking will be run on your submission.
This is to provide some feedback to you on your progress and on your understanding of the problem specification. The sequention of API calls will be reported to you such that you can reproduce a similar test in your own framework (and extend that test to improve coverage).
These tests should be used as a guide only. A hidden set of tests will be run against your submission for final marking after the submission deadline has passed.
8.4 Marking criteria
|
Marks |
Item |
Notes |
|
3/25 |
Code Style |
Manual marking |
|
2/25 |
Week 8 in-tutorial review* |
Manual marking |
|
5/25 |
Correctly generates frames with 1 sprite |
Automatic tests |
|
5/25 |
Layers sprites correctly on placement |
Automatic tests |
|
5/25 |
Rearranges layers correctly |
Automatic tests |
|
2/25 |
Generates animations correctly |
Automatic tests |
|
3/25 |
O(1) sprite placement/layer operations |
Automatic tests |
For style, refer to the style guide. You will also be marked based on the modularity and organisation of your code. For full marks, code should be organised in multiple source files, and use modular, task-specific functions. Organised data structures are essential here. Style marking is only applied for reasonable attempts at correctness.
To successfully complete this assignment:
• The code must entirely be written in the C programming language.• Free all dynamic memory that is used.• NOT declare any global variable.• NOT use any external libraries other than those in libc.• NOT use Variable Length Arrays (VLAs).• Have a clean repository. This means no object, executable, or temporary files for any commit in the repository, not just for the final commit of your submission.• Only include header files that contain declarations of functions and extern variables. Do not define functions within header files.• Must use meaningful commits and meaningful comments on commits.• Other restricted functions may come at a later date.• Any and all comments must be written only in the English language.• NOT manually use return code 42, reserved by ASAN.
Submissions breaking these restrictions will receive a deduction of up to 6 marks per breach.
The red flag items below will result in an immediate zero. Negative marks can be assigned if you do not follow the spec or if your code is unnecessarily or deliberately obfuscated:
• Any attempts to deceive or disrupt the marking system.• Use any of the below functions. You shouldn’t need to use these functions at all in your pro gram, and you are doing something terribly wrong if you are.
– _init, atexit(2), _exit(2), _Exit(3)– dlopen(3), dlsym(3), dlclose(3)– fork(2), vfork(2), execve(2), exec*(3), clone(2)– kill(2), tkill(2), tgkill(2)– getpid(2), getppid(2), ptrace(2), getpgrp(2), setpgrp(2)
• Submission has a valid makefile with the rule for the target animate.o and compiles using make animate.o.• Program is organised into multiple source and header files (for larger programs).• Not include any object file, binary, or junk data in your git repo.• If you have used AI, references.zip formatted according to EdStem slides submitted with source code.
Any memory leaks result in a 30% deduction after all other marks have been calculated, but will not decrease your mark below 40%.
We aim to resolve all spec updates within the first 3-5 days.
• Updated deadline to Apr 2nd to match course outline.• Updated circle equation to be x 2 + y 2 ≤ r 2 .• Fixed typo “funtion” in scaffold• Clarified the requirement of a clean repository.
The API documentation has been attached on the following pages for your convenience.
2026-04-01