optimise away constant by adding it to lookup-table

This commit is contained in:
hugova 2025-05-12 02:24:55 +02:00
parent d34d25ce9f
commit 55e63ff627
2 changed files with 53 additions and 52 deletions

View file

@ -1,55 +1,56 @@
binary_factor: binary_factor:
.byte %00000001, %00000010, %00000100, %00001000, %00010000, %00100000, %01000000, %10000000 .byte %00000001, %00000010, %00000100, %00001000, %00010000, %00100000, %01000000, %10000000
Bitmap = $4000
;;This is used by pixel_draw! look at it for more detail ;;This is used by pixel_draw! look at it for more detail
big_y_offset: big_y_offset:
.lobytes $0000 .lobytes $0000 + Bitmap
.hibytes $0000 .hibytes $0000 + Bitmap
.lobytes $0140 .lobytes $0140 + Bitmap
.hibytes $0140 .hibytes $0140 + Bitmap
.lobytes $0280 .lobytes $0280 + Bitmap
.hibytes $0280 .hibytes $0280 + Bitmap
.lobytes $03C0 .lobytes $03C0 + Bitmap
.hibytes $03C0 .hibytes $03C0 + Bitmap
.lobytes $0500 .lobytes $0500 + Bitmap
.hibytes $0500 .hibytes $0500 + Bitmap
.lobytes $0640 .lobytes $0640 + Bitmap
.hibytes $0640 .hibytes $0640 + Bitmap
.lobytes $0780 .lobytes $0780 + Bitmap
.hibytes $0780 .hibytes $0780 + Bitmap
.lobytes $08C0 .lobytes $08C0 + Bitmap
.hibytes $08C0 .hibytes $08C0 + Bitmap
.lobytes $0A00 .lobytes $0A00 + Bitmap
.hibytes $0A00 .hibytes $0A00 + Bitmap
.lobytes $0B40 .lobytes $0B40 + Bitmap
.hibytes $0B40 .hibytes $0B40 + Bitmap
.lobytes $0C80 .lobytes $0C80 + Bitmap
.hibytes $0C80 .hibytes $0C80 + Bitmap
.lobytes $0DC0 .lobytes $0DC0 + Bitmap
.hibytes $0DC0 .hibytes $0DC0 + Bitmap
.lobytes $0F00 .lobytes $0F00 + Bitmap
.hibytes $0F00 .hibytes $0F00 + Bitmap
.lobytes $1040 .lobytes $1040 + Bitmap
.hibytes $1040 .hibytes $1040 + Bitmap
.lobytes $1180 .lobytes $1180 + Bitmap
.hibytes $1180 .hibytes $1180 + Bitmap
.lobytes $12C0 .lobytes $12C0 + Bitmap
.hibytes $12C0 .hibytes $12C0 + Bitmap
.lobytes $1400 .lobytes $1400 + Bitmap
.hibytes $1400 .hibytes $1400 + Bitmap
.lobytes $1540 .lobytes $1540 + Bitmap
.hibytes $1540 .hibytes $1540 + Bitmap
.lobytes $1680 .lobytes $1680 + Bitmap
.hibytes $1680 .hibytes $1680 + Bitmap
.lobytes $17C0 .lobytes $17C0 + Bitmap
.hibytes $17C0 .hibytes $17C0 + Bitmap
.lobytes $1900 .lobytes $1900 + Bitmap
.hibytes $1900 .hibytes $1900 + Bitmap
.lobytes $1A40 .lobytes $1A40 + Bitmap
.hibytes $1A40 .hibytes $1A40 + Bitmap
.lobytes $1B80 .lobytes $1B80 + Bitmap
.hibytes $1B80 .hibytes $1B80 + Bitmap
.lobytes $1CC0 .lobytes $1CC0 + Bitmap
.hibytes $1CC0 .hibytes $1CC0 + Bitmap
.lobytes $1E00 .lobytes $1E00 + Bitmap
.hibytes $1E00 .hibytes $1E00 + Bitmap

View file

@ -31,7 +31,7 @@ calc_byte_to_paint:
;; the chunks are orderd from the left to the right and then looping downwards. ;; the chunks are orderd from the left to the right and then looping downwards.
;; Therefore we have that: btp_mem_pos = big_x_offset + smal_y_offset + big_y_offset + bitmap_offset ;; Therefore we have that: btp_mem_pos = big_x_offset + smal_y_offset + big_y_offset + bitmap_offset
;; We use a lookup-table for big_y_offset (see END.s) ;; We use a lookup-table for big_y_offset + bitmap_offset (see END.s)
;; (Y_pos / 8 floor)*2 ;; (Y_pos / 8 floor)*2
LDA Y_pos LDA Y_pos
LSR A LSR A
@ -57,7 +57,7 @@ calc_byte_to_paint:
AND Y_pos ;; offset to add AND Y_pos ;; offset to add
TAY TAY
Add_16 btp_mem_pos, btp_mem_pos + 1, #<Bitmap, #>Bitmap, ! ;Add_16 btp_mem_pos, btp_mem_pos + 1, #<Bitmap, #>Bitmap, !
;;Let draw some stuff ;;Let draw some stuff
LDA byte_to_paint ;; note that both bytes are used! LDA byte_to_paint ;; note that both bytes are used!