rewrite memcpy to work more like c:s implementation
This commit is contained in:
parent
3295b71f6b
commit
f8dbfd86f9
4 changed files with 29 additions and 42 deletions
|
@ -3,4 +3,5 @@
|
|||
;; public args
|
||||
A_start = $D0 ; 16-bit value (uses D1)
|
||||
B_start = $D2 ; 16-bit value (uses D3)
|
||||
B_end = $D4 ; 16-bit value (uses D5)
|
||||
length = $D4 ; 16-bit value (uses D5)
|
||||
B_end = length + 0
|
||||
|
|
|
@ -1,33 +1,31 @@
|
|||
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||
|
||||
;;Move memory from B_start B_end to A_start , (implied address)
|
||||
;;Modifies A,X and B_start gets modified
|
||||
;;Move length bytes from A_start address to lenght bytes starting at B_start.
|
||||
.proc memcpy
|
||||
.include "mem.inc"
|
||||
|
||||
;; Let Y + A_start lower nibble represent A_start
|
||||
;; therefor: A_start = Y - A_start
|
||||
;; With Y we mean what Y will represent later aka >B_start
|
||||
Sub_16 A_start, A_start + 1, B_start, #$00
|
||||
|
||||
;;Lets move B_start lover-nibble to Y
|
||||
LDY B_start
|
||||
LDA #$00
|
||||
STA B_start
|
||||
LDY #$00
|
||||
loop:
|
||||
Lag_16 B_end, B_end + 1, A, B_start, end_loop
|
||||
LDA (B_start), Y
|
||||
STA (A_start), Y
|
||||
;Tip save time by counting downward, fast to check if Y ==0 // hugo
|
||||
INY
|
||||
TYA
|
||||
CMP #$ff
|
||||
BEQ y_overflow
|
||||
change_length:
|
||||
DEC length
|
||||
BNE loop
|
||||
;; Fix overflow
|
||||
LDY #$00
|
||||
INC A_start + 1
|
||||
INC B_start + 1
|
||||
|
||||
;;check if length hi byte is 0. if it is end this
|
||||
LDA length + 1
|
||||
BEQ loop_end
|
||||
|
||||
DEC length +1
|
||||
JMP loop
|
||||
end_loop:
|
||||
y_overflow:
|
||||
LDY #$00
|
||||
INC B_start + 1
|
||||
INC A_start + 1
|
||||
|
||||
jmp change_length
|
||||
loop_end:
|
||||
|
||||
RTS
|
||||
.endproc
|
||||
|
|
|
@ -1,25 +1,13 @@
|
|||
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||
;; test for memcpy
|
||||
;; Writes text to half the screen
|
||||
.scope memcpy_test
|
||||
charset = $FB
|
||||
code = $FE
|
||||
petski_position = $FE ;16-bit value (uses FF), reuses code:s memory
|
||||
screen_position = $FC ;16-bit value (uses FD)
|
||||
|
||||
Mov_16 B_start, B_start + 1, #<$D000, #>$D000
|
||||
;#### TEMP INIT DATA ####
|
||||
Mov_16 B_end, B_end + 1, #<($D000+$1F3F), #>($D000 +$1F3F)
|
||||
LDA #$10
|
||||
STA code
|
||||
LDA #$10
|
||||
STA X_pos
|
||||
STA Y_pos
|
||||
|
||||
.include "mem.inc"
|
||||
VIC_bank = $4000
|
||||
VIC_bank_end = VIC_bank + $3FFF
|
||||
Character_generator_ROM = $D000
|
||||
len = $1f40
|
||||
Mov_16 A_start, A_start + 1, #<VIC_bank, #>VIC_bank
|
||||
LDA #$00
|
||||
Mov_16 B_start, B_start + 1, #<Character_generator_ROM, #>Character_generator_ROM
|
||||
Mov_16 length, length + 1, #<len, #>len
|
||||
JSR memcpy
|
||||
STA petski_position
|
||||
jmp exit
|
||||
.endscope
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
;.include "routines/line/line_test.s"
|
||||
;.include "routines/text/char_draw_test.s"
|
||||
.include "routines/pixel/pixel_test.s"
|
||||
;.include "routines/memory/memcpy_test.s"
|
||||
;.include "routines/pixel/pixel_test.s"
|
||||
.include "routines/memory/memcpy_test.s"
|
||||
;.include "routines/triangle/triangle_test.s"
|
||||
exit:
|
||||
JMP exit
|
||||
|
|
Loading…
Add table
Reference in a new issue