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
|
AND Y_pos ;; offset to add
|
||||||
TAY
|
TAY
|
||||||
|
|
||||||
;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!
|
||||||
ORA (btp_mem_pos), Y
|
ORA (btp_mem_pos), Y
|
||||||
|
|
|
@ -3,16 +3,8 @@
|
||||||
Y_pos = ARGVEC + 1
|
Y_pos = ARGVEC + 1
|
||||||
code = ARGVEC + 2
|
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
|
;; private variables
|
||||||
screen_position = $EE ; 16-bit value (uses EF)
|
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
|
;; 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
|
;; 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
|
.proc char_draw; user-procedure :clobbers (A Y) :clobbers-arguments 4
|
||||||
.include "char.inc"
|
.include "char.inc"
|
||||||
|
|
||||||
;#### TEMP INIT DATA ####
|
;;Do arithimatic to know where to read and write bytes.
|
||||||
LDA #$10
|
calculate_petski_position:
|
||||||
STA code
|
|
||||||
LDA #04
|
|
||||||
STA X_pos
|
|
||||||
LDA #02
|
|
||||||
STA Y_pos
|
|
||||||
|
|
||||||
;;Do arithimatic to know where to read and write bytes.
|
|
||||||
initial:
|
|
||||||
;We first need to clear some memory
|
;We first need to clear some memory
|
||||||
LDA #$00
|
LDA #$00
|
||||||
STA petski_position + 1
|
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.
|
;;We need the relative offset for bytes to read and write.
|
||||||
;; This is code *8 because 8byte is one character
|
;; This is code *8 because 8byte is one character
|
||||||
|
@ -32,34 +22,35 @@ initial:
|
||||||
;; Add starting position
|
;; Add starting position
|
||||||
Add_16 petski_position, petski_position + 1, #<Character_generator_ROM , #>Character_generator_ROM, !
|
Add_16 petski_position, petski_position + 1, #<Character_generator_ROM , #>Character_generator_ROM, !
|
||||||
|
|
||||||
;;Calculate screen_position to use
|
calculate_screen_position:
|
||||||
Mov_16 screen_position, screen_position + 1, #<VIC_bank, #>VIC_bank
|
;; 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
|
;; We use a lookup-table for big_y_offset + bitmap_offset (see END.s)
|
||||||
;; *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
|
|
||||||
LDA Y_pos
|
LDA Y_pos
|
||||||
STA X_pos
|
LSR A
|
||||||
Mult_16 Y_pos_offset_lo, Y_pos_offset_hi
|
LSR A
|
||||||
Mult_16 Y_pos_offset_lo, Y_pos_offset_hi
|
;; We need to remove the last digit if its still there
|
||||||
Add_16 Y_pos_offset_lo, Y_pos_offset_hi, X_pos, #$00, !
|
;; same as LSR ASR
|
||||||
;; *2^6
|
AND #%11111110
|
||||||
Mult_16 Y_pos_offset_lo, Y_pos_offset_hi
|
TAX
|
||||||
Mult_16 Y_pos_offset_lo, Y_pos_offset_hi
|
LDA big_y_offset, X
|
||||||
Mult_16 Y_pos_offset_lo, Y_pos_offset_hi
|
STA screen_position
|
||||||
Mult_16 Y_pos_offset_lo, Y_pos_offset_hi
|
INX
|
||||||
Mult_16 Y_pos_offset_lo, Y_pos_offset_hi
|
LDA big_y_offset, X
|
||||||
Mult_16 Y_pos_offset_lo, Y_pos_offset_hi
|
STA screen_position + 1
|
||||||
;; Add
|
|
||||||
Add_16 screen_position, screen_position + 1, Y_pos_offset_lo, Y_pos_offset_hi, !
|
;; Y = big_x_offset
|
||||||
initial_end:
|
LDA #%11111000
|
||||||
|
AND X_pos
|
||||||
|
STA X_pos
|
||||||
|
;; 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
|
;; One character is 8 byte, move these bytes to screen
|
||||||
LDY #$07
|
LDY #$07
|
||||||
|
|
|
@ -2,9 +2,8 @@
|
||||||
.include "char.inc"
|
.include "char.inc"
|
||||||
LDA #$10
|
LDA #$10
|
||||||
STA code
|
STA code
|
||||||
LDA #04
|
LDA #$20
|
||||||
STA X_pos
|
STA X_pos
|
||||||
LDA #02
|
|
||||||
STA Y_pos
|
STA Y_pos
|
||||||
JSR char_draw
|
JSR char_draw
|
||||||
.endscope
|
.endscope
|
||||||
|
|
Loading…
Add table
Reference in a new issue