Skip to content

Commit 0385f54

Browse files
maciejmaleckiMaciej Małecki
andauthored
Develop (#14)
* adding more stuff to global * copy large mem backward sub added * update README.md --------- Co-authored-by: Maciej Małecki <external.maciej.malecki@kuehne-nagel.com>
1 parent 53acb79 commit 0385f54

4 files changed

Lines changed: 140 additions & 1 deletion

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@ Check our [User's Manual](https://c64lib.github.io/user-manual/#_common) for mor
88

99
## Change log
1010

11+
### Changes in version 0.5.0
12+
13+
* New macro exposed: `c64lib_copy8`
14+
* New macro exposed: `c64lib_copy16`
15+
* New subroutine: `copy-large-mem-backward.asm`
16+
1117
### Changes in version 0.4.0
1218

1319
* New macro: `compress.asm\compressRLE`.
14-
* New subroutine: `decompress_rle.asm`.
20+
* New subroutine: `decompress-rle.asm`.
1521

1622
### Changes in version 0.3.0
1723

lib/mem-global.asm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
.macro @c64lib_fillScreen(address, value) { fillScreen(address, value) }
3131
.macro @c64lib_set8(value, mem) { set8(value, mem) }
3232
.pseudocommand @c64lib_set8 value : mem { set8 value : mem }
33+
.pseudocommand @c64lib_copy8 source: dest { copy8 source: dest }
34+
.pseudocommand @c64lib_copy16 source: dest { copy16 source: dest }
3335
.macro @c64lib_set16(value, mem) { set16(value, mem) }
3436
.macro @c64lib_copyWordIndirect(source, destinationPointer) { copyWordIndirect(source, destinationPointer) }
3537
.macro @c64lib_cmp16(value, low) { cmp16(value, low) }
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* MIT License
3+
*
4+
* Copyright (c) 2017-2023 c64lib
5+
* Copyright (c) 2017-2023 Maciej Małecki
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
*/
25+
#import "../invoke.asm"
26+
#import "../mem.asm"
27+
#import "../math.asm"
28+
29+
/*
30+
* Copies block of memory backward. Both source and target memory block can overlap as long as target
31+
* block is located lower than source block.
32+
*
33+
* IN:
34+
* Stack WORD - source address
35+
* Stack WORD - target address
36+
* Stack WORD - size
37+
* MOD: A, X
38+
*/
39+
.namespace c64lib {
40+
copyLargeMemBackward: {
41+
42+
invokeStackBegin(returnPtr)
43+
pullParamW(copyCounter)
44+
pullParamW(staNext)
45+
pullParamW(ldaNext)
46+
47+
// addMem16(copyCounter, staNext)
48+
// addMem16(copyCounter, ldaNext)
49+
copyNextPage:
50+
ldx #0
51+
copyNext:
52+
lda ldaNext:$ffff, x
53+
sta staNext:$ffff, x
54+
dec16(copyCounter)
55+
cmp16(0, copyCounter)
56+
beq end
57+
inx
58+
cpx #0
59+
bne copyNext
60+
add16(256, ldaNext)
61+
add16(256, staNext)
62+
jmp copyNextPage
63+
end:
64+
65+
invokeStackEnd(returnPtr)
66+
rts
67+
// local vars
68+
returnPtr: .word 0
69+
copyCounter: .word 0
70+
}
71+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* MIT License
3+
*
4+
* Copyright (c) 2017-2023 c64lib
5+
* Copyright (c) 2017-2023 Maciej Małecki
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
*/
25+
#import "64spec/lib/64spec.asm"
26+
#import "../lib/invoke-global.asm"
27+
28+
29+
sfspec: init_spec()
30+
31+
describe("copyLargeMemBackward")
32+
33+
it("copies 7 bytes forward non overlapping"); {
34+
c64lib_pushParamW(dataToBeMoved)
35+
c64lib_pushParamW(targetLocation)
36+
c64lib_pushParamW(7)
37+
jsr copyLargeMemForward
38+
39+
assert_bytes_equal 7: targetLocation: dataToBeMoved
40+
}
41+
42+
it("copies 260 bytes forward non overlapping"); {
43+
c64lib_pushParamW(largeDataToBeMoved)
44+
c64lib_pushParamW(largeTargetLocation)
45+
c64lib_pushParamW(260)
46+
jsr copyLargeMemForward
47+
48+
assert_bytes_equal 19: largeTargetLocation: largeDataToBeMoved
49+
}
50+
51+
finish_spec()
52+
53+
* = * "Data"
54+
copyLargeMemForward:
55+
#import "../lib/sub/copy-large-mem-forward.asm"
56+
dataToBeMoved: .text "foo bar"
57+
targetLocation: .text " "
58+
59+
largeDataToBeMoved: .fill 260, 127.5 + sin(toRadians(i*360/256))
60+
largeTargetLocation: .fill 260, 0

0 commit comments

Comments
 (0)