-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initialize the Pong sprite data at compilation time, and adjust the translation. #2
Conversation
There was an extra level of indirection in my implementation of |
Implement 16-bit shrl (new instruction). Implement movl with a 16-bit literal value. Add the 6502 ROR instruction.
VIC_II::SPRITE_ALIGNMENT: The MOS 6566/6567/6569 VIC-II expects sprite data to be aligned at 64 bytes. VIC_II::SPRITE_STARTING_BANK: Remove. VIC_II::write_multi_color_pixel(), VIC_II::write_pixel(): Make static. Write to the specified memory address. VIC_II::Sprite::Sprite(): Refactored from VIC_II::make_sprite(). VIC_II::enable_sprite(): Take a Sprite reference. sBall, sBat: Sprite images, declared at global scope. FIXME: How to ensure that the VIC_II::Sprite addresses do not end up in the range 0x1000..0x1fff or 0x9000..0x9fff (where the character generator ROM is overriding RAM)? Any portable alternative to using GCC-style __attribute__((section("sprites"))) and a linker script? Note: Declaring the sprite images as static const objects in main() would cause clang++4.0-svn279916-1 to generate code for initializing them. So, we will declare the objects in the global scope. This has been tested on a Commodore 64 with the following steps: clang++-4.0 -m32 -O3 -std=c++1z -S pong.cpp x86-to-6502 < pong.s > pong.asm edit pong.asm to define code start at 0x900 and to adapt the output invoke some 6502 assembler SYS2304 to run the output on a Commodore 64
I rebased the fork. The first commit fixes the x86-to-6502 compiler, and the second one updates the example, using the C++11 alignas() attribute in the VIC_II::Sprite declaration. |
For what it is worth, I tried writing a |
write_multi_color_line(): Replaces write_multi_color_pixel(). write_line(): Replaces write_pixel(). The generated code is not affected by this change.
write_multi_color_line(), write_line(): Remove. VIC_II::SpriteLine<bool multicolor>: A line of sprite bitmap data. The constructor converts one line of data at a time. VIC_II::Sprite<bool multicolor>: An array of SpriteLine. This change does not affect the generated binary code. In the assembler code generated by clang++-4.0, the binary data will be formatted in groups of 3 bytes instead of 3*21 bytes.
This change does not affect the generated code, other than the assembler labels for the data. The data will still be initialized at compilation time.
Finally, I figured out that by creating a |
I've merged the branch, but the |
Thanks for merging this! |
Instead of generating code for initializing the sprite data, initialize the sprite data as compile-time constants. Adjust the translation for the x86 code generated by clang version 4.0.0-svn279916-1 (Debian GNU/Linux unstable).
TODO: Generate a Commodore program file, and test this. Add precise instructions or a script for building the examples.