make char_draw faster using lookup-table
This commit is contained in:
parent
55e63ff627
commit
3295b71f6b
4 changed files with 30 additions and 50 deletions
|
@ -57,8 +57,6 @@ calc_byte_to_paint:
|
|||
AND Y_pos ;; offset to add
|
||||
TAY
|
||||
|
||||
;Add_16 btp_mem_pos, btp_mem_pos + 1, #<Bitmap, #>Bitmap, !
|
||||
|
||||
;;Let draw some stuff
|
||||
LDA byte_to_paint ;; note that both bytes are used!
|
||||
ORA (btp_mem_pos), Y
|
||||
|
|
|
@ -3,16 +3,8 @@
|
|||
Y_pos = ARGVEC + 1
|
||||
code = ARGVEC + 2
|
||||
|
||||
;; 16-bit value, we reuse bytes from X_pos
|
||||
X_pos_offset_hi = $ED
|
||||
X_pos_offset_lo = X_pos
|
||||
;; 16-bit value, we reuse bytes from Y_pos
|
||||
Y_pos_offset_hi = $EC
|
||||
Y_pos_offset_lo = Y_pos
|
||||
|
||||
;; private variables
|
||||
screen_position = $EE ; 16-bit value (uses EF)
|
||||
temp_value = $EC ; 16-bit value (uses ED)
|
||||
|
||||
;; What you will see bellow is .. interesting. I want to reuse
|
||||
;; code and I need it for a 16-bit pointer. Because 6502 pointers expect the bytes to be besides each other
|
||||
|
|
|
@ -7,21 +7,11 @@
|
|||
.proc char_draw; user-procedure :clobbers (A Y) :clobbers-arguments 4
|
||||
.include "char.inc"
|
||||
|
||||
;#### TEMP INIT DATA ####
|
||||
LDA #$10
|
||||
STA code
|
||||
LDA #04
|
||||
STA X_pos
|
||||
LDA #02
|
||||
STA Y_pos
|
||||
|
||||
;;Do arithimatic to know where to read and write bytes.
|
||||
initial:
|
||||
calculate_petski_position:
|
||||
;We first need to clear some memory
|
||||
LDA #$00
|
||||
STA petski_position + 1
|
||||
STA Y_pos_offset_hi
|
||||
STA X_pos_offset_hi
|
||||
|
||||
;;We need the relative offset for bytes to read and write.
|
||||
;; This is code *8 because 8byte is one character
|
||||
|
@ -32,34 +22,35 @@ initial:
|
|||
;; Add starting position
|
||||
Add_16 petski_position, petski_position + 1, #<Character_generator_ROM , #>Character_generator_ROM, !
|
||||
|
||||
;;Calculate screen_position to use
|
||||
Mov_16 screen_position, screen_position + 1, #<VIC_bank, #>VIC_bank
|
||||
calculate_screen_position:
|
||||
;; Therefore we have that: btp_mem_pos = big_x_offset + smal_y_offset + big_y_offset + bitmap_offset
|
||||
|
||||
;; Add the X_pos has a offset multiplier of *8 because 1 chunk = 8 addresses
|
||||
;; *8
|
||||
Mult_16 X_pos_offset_lo, X_pos_offset_hi
|
||||
Mult_16 X_pos_offset_lo, X_pos_offset_hi
|
||||
Mult_16 X_pos_offset_lo, X_pos_offset_hi
|
||||
;; Add
|
||||
Add_16 screen_position, screen_position + 1, X_pos, #$00, !
|
||||
|
||||
;; And Y_pos has a offset multiplier of "screen length" = 320 = (2*2 +1)*2^6
|
||||
;;Y_pos*2*2 +1 |Lets reuse X_pos for storage
|
||||
;; We use a lookup-table for big_y_offset + bitmap_offset (see END.s)
|
||||
LDA Y_pos
|
||||
LSR A
|
||||
LSR A
|
||||
;; We need to remove the last digit if its still there
|
||||
;; same as LSR ASR
|
||||
AND #%11111110
|
||||
TAX
|
||||
LDA big_y_offset, X
|
||||
STA screen_position
|
||||
INX
|
||||
LDA big_y_offset, X
|
||||
STA screen_position + 1
|
||||
|
||||
;; Y = big_x_offset
|
||||
LDA #%11111000
|
||||
AND X_pos
|
||||
STA X_pos
|
||||
Mult_16 Y_pos_offset_lo, Y_pos_offset_hi
|
||||
Mult_16 Y_pos_offset_lo, Y_pos_offset_hi
|
||||
Add_16 Y_pos_offset_lo, Y_pos_offset_hi, X_pos, #$00, !
|
||||
;; *2^6
|
||||
Mult_16 Y_pos_offset_lo, Y_pos_offset_hi
|
||||
Mult_16 Y_pos_offset_lo, Y_pos_offset_hi
|
||||
Mult_16 Y_pos_offset_lo, Y_pos_offset_hi
|
||||
Mult_16 Y_pos_offset_lo, Y_pos_offset_hi
|
||||
Mult_16 Y_pos_offset_lo, Y_pos_offset_hi
|
||||
Mult_16 Y_pos_offset_lo, Y_pos_offset_hi
|
||||
;; Add
|
||||
Add_16 screen_position, screen_position + 1, Y_pos_offset_lo, Y_pos_offset_hi, !
|
||||
initial_end:
|
||||
;; Y += smal_y_offset
|
||||
LDA #%00000111 ; A = y (mod 8)
|
||||
AND Y_pos ;; offset to add
|
||||
CLC
|
||||
ADC X_pos
|
||||
Add_16 screen_position, screen_position + 1, A, #$00
|
||||
|
||||
move_data:
|
||||
|
||||
;; One character is 8 byte, move these bytes to screen
|
||||
LDY #$07
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
.include "char.inc"
|
||||
LDA #$10
|
||||
STA code
|
||||
LDA #04
|
||||
LDA #$20
|
||||
STA X_pos
|
||||
LDA #02
|
||||
STA Y_pos
|
||||
JSR char_draw
|
||||
.endscope
|
||||
|
|
Loading…
Add table
Reference in a new issue