Skip to content

Commit

Permalink
Develop (#14)
Browse files Browse the repository at this point in the history
* adding more stuff to global
* copy large mem backward sub added
* update README.md

---------

Co-authored-by: Maciej Małecki <[email protected]>
  • Loading branch information
maciejmalecki and Maciej Małecki authored Sep 27, 2023
1 parent 53acb79 commit 0385f54
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ Check our [User's Manual](https://c64lib.github.io/user-manual/#_common) for mor

## Change log

### Changes in version 0.5.0

* New macro exposed: `c64lib_copy8`
* New macro exposed: `c64lib_copy16`
* New subroutine: `copy-large-mem-backward.asm`

### Changes in version 0.4.0

* New macro: `compress.asm\compressRLE`.
* New subroutine: `decompress_rle.asm`.
* New subroutine: `decompress-rle.asm`.

### Changes in version 0.3.0

Expand Down
2 changes: 2 additions & 0 deletions lib/mem-global.asm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
.macro @c64lib_fillScreen(address, value) { fillScreen(address, value) }
.macro @c64lib_set8(value, mem) { set8(value, mem) }
.pseudocommand @c64lib_set8 value : mem { set8 value : mem }
.pseudocommand @c64lib_copy8 source: dest { copy8 source: dest }
.pseudocommand @c64lib_copy16 source: dest { copy16 source: dest }
.macro @c64lib_set16(value, mem) { set16(value, mem) }
.macro @c64lib_copyWordIndirect(source, destinationPointer) { copyWordIndirect(source, destinationPointer) }
.macro @c64lib_cmp16(value, low) { cmp16(value, low) }
Expand Down
71 changes: 71 additions & 0 deletions lib/sub/copy-large-mem-backward.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* MIT License
*
* Copyright (c) 2017-2023 c64lib
* Copyright (c) 2017-2023 Maciej Małecki
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#import "../invoke.asm"
#import "../mem.asm"
#import "../math.asm"

/*
* Copies block of memory backward. Both source and target memory block can overlap as long as target
* block is located lower than source block.
*
* IN:
* Stack WORD - source address
* Stack WORD - target address
* Stack WORD - size
* MOD: A, X
*/
.namespace c64lib {
copyLargeMemBackward: {

invokeStackBegin(returnPtr)
pullParamW(copyCounter)
pullParamW(staNext)
pullParamW(ldaNext)

// addMem16(copyCounter, staNext)
// addMem16(copyCounter, ldaNext)
copyNextPage:
ldx #0
copyNext:
lda ldaNext:$ffff, x
sta staNext:$ffff, x
dec16(copyCounter)
cmp16(0, copyCounter)
beq end
inx
cpx #0
bne copyNext
add16(256, ldaNext)
add16(256, staNext)
jmp copyNextPage
end:

invokeStackEnd(returnPtr)
rts
// local vars
returnPtr: .word 0
copyCounter: .word 0
}
}
60 changes: 60 additions & 0 deletions spec/copy-large-mem-backward.spec.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* MIT License
*
* Copyright (c) 2017-2023 c64lib
* Copyright (c) 2017-2023 Maciej Małecki
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#import "64spec/lib/64spec.asm"
#import "../lib/invoke-global.asm"


sfspec: init_spec()

describe("copyLargeMemBackward")

it("copies 7 bytes forward non overlapping"); {
c64lib_pushParamW(dataToBeMoved)
c64lib_pushParamW(targetLocation)
c64lib_pushParamW(7)
jsr copyLargeMemForward

assert_bytes_equal 7: targetLocation: dataToBeMoved
}

it("copies 260 bytes forward non overlapping"); {
c64lib_pushParamW(largeDataToBeMoved)
c64lib_pushParamW(largeTargetLocation)
c64lib_pushParamW(260)
jsr copyLargeMemForward

assert_bytes_equal 19: largeTargetLocation: largeDataToBeMoved
}

finish_spec()

* = * "Data"
copyLargeMemForward:
#import "../lib/sub/copy-large-mem-forward.asm"
dataToBeMoved: .text "foo bar"
targetLocation: .text " "

largeDataToBeMoved: .fill 260, 127.5 + sin(toRadians(i*360/256))
largeTargetLocation: .fill 260, 0

0 comments on commit 0385f54

Please sign in to comment.