-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[WIP] Use template functions for SMX and SMP file #1427
base: master
Are you sure you want to change the base?
Conversation
It's probably easier to discuss most changes with code that compiles properly, but I already have some comments :) |
@@ -54,6 +54,313 @@ cdef struct pixel: | |||
uint8_t damage_modifier_2 # modifier for damage (part 2) | |||
|
|||
|
|||
cdef fused ProcessDrawingCmdsVariant: | |||
SMXLayerVariant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can call the fuse type SMXLayerVariant
instead of ProcessDrawingCmdsVariant
. SMXLayerVariant
is never used anyway.
if ProcessDrawingCmdsVariant is SMXLayerVariant: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does nothing.
if ProcessDrawingCmdsVariant is SMXMainLayer8to5Variant: | ||
elif lower_crumb == 0b00000010: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong order of lines?
cdef uint8_t palette_section_block = 0 | ||
cdef uint8_t palette_section = 0 | ||
|
||
if ProcessDrawingCmdsVariant is SMXShadowLayerVariant || ProcessDrawingCmdsVariant is SMXOutlineLayerVariant: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to use the Pythonic style to write this line:
if ProcessDrawingCmdsVariant in (SMXShadowLayerVariant, SMXOutlineLayerVariant):
And ||
is not a Python operator. Better use or
.
@@ -54,6 +54,313 @@ cdef struct pixel: | |||
uint8_t damage_modifier_2 # modifier for damage (part 2) | |||
|
|||
|
|||
cdef fused ProcessDrawingCmdsVariant: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ctypedef
instead of cdef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to declare each variant (SMXMainLayer8to5Variant, SMXMainLayer4plus1Variant, SMXOutlineLayerVariant, SMXShadowLayerVariant) with cdef class ...
like in @TheJJ 's example in the issue.
if ProcessDrawingCmdsVariant is SMXMainLayer4plus1Variant: | ||
elif lower_crumb == 0b00000010: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong order of lines?
# Process next command | ||
dpos_cmd += 1 | ||
if ProcessDrawingCmdsVariant is SMXMainLayer8to5Variant || ProcessDrawingCmdsVariant is SMXMainLayer4plus1Variant: | ||
return dpos_cmd, dpos_color, odd, row_data | ||
if ProcessDrawingCmdsVariant is SMXOutlineLayerVariant || ProcessDrawingCmdsVariant is SMXShadowLayerVariant: | ||
return dpos_cmd, dpos_cmd, chunk_pos, row_data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation is really weird here.
My recommendation would be to compare the similar-but-not-identical functions side by side (or copy them to files, and do |
Additionally, it might be beneficial to use the profiling utilities to compare the speed of the implementation before and after each change. |
@9a24f0 Do you need help with completing the PR? |
Hi, I opened this PR to keep track on my work and to receive some reviews.
@heinezen and @TheJJ I really need some walk from you two to complete GH-1370.