make memset work more like c:s implementation.

This commit is contained in:
hugova 2025-05-15 17:05:28 +02:00
parent cc46c68290
commit 87fd6a1b9d
8 changed files with 37 additions and 42 deletions

View file

@ -59,15 +59,14 @@
STA Screen_RAM_settings
;; Paint the bitmap black. More bitmap: https://www.c64-wiki.com/wiki/53272, https://www.c64-wiki.com/wiki/Screen_RAM#Moving_of_screen_RAM
Mov_16 B_start, B_start + 1, #<VIC_bank, #>VIC_bank
Mov_16 B_end, B_end + 1, #<$5f3f, #>$5f3f
Mov_16 A_start, A_start + 1, #<VIC_bank, #>VIC_bank
Mov_16 length, length + 1, #<$1f3f, #>$1f3f
LDA #$00
jsr memset
;; Sets the screen color to black and white
Mov_16 B_start, B_start + 1, #<Screen_RAM, #>Screen_RAM
Mov_16 B_end, B_end + 1, #<Screen_RAM_end, #>Screen_RAM_end
Mov_16 A_start, A_start + 1, #<Screen_RAM, #>Screen_RAM
Mov_16 length, length + 1, #<$03E8, #>$03E8
LDA #%11110000
jsr memset

View file

@ -50,10 +50,9 @@ end:
;;Long lines
;;Lets clear bitmap
VIC_bank = $4000
VIC_bank_end = VIC_bank + $3FFF
;;Paint the bitmap black. More bitmap: https://www.c64-wiki.com/wiki/53272, https://www.c64-wiki.com/wiki/Screen_RAM#Moving_of_screen_RAM
Mov_16 B_start, B_start + 1, #<VIC_bank, #>VIC_bank
Mov_16 B_end, B_end + 1, #<$5f3f, #>$5f3f
Mov_16 A_start, A_start + 1, #<VIC_bank, #>VIC_bank
Mov_16 length, length + 1, #<$1f40, #>$1f40
LDA #$00
jsr memset
@ -78,5 +77,4 @@ end:
BEQ end_
jmp @loop
end_:
jmp exit
.endscope

View file

@ -3,5 +3,4 @@
;; public args
A_start = $D0 ; 16-bit value (uses D1)
B_start = $D2 ; 16-bit value (uses D3)
length = $D4 ; 16-bit value (uses D5)
B_end = length + 0
length = $D4 ; 16-bit value (uses D5), this is the number of bytes

View file

@ -16,13 +16,6 @@ change_length:
DEC length +1
BPL loop
JMP loop_end
;;;;check if length hi byte is 0. if it is end this
;;LDA length + 1
;;BEQ loop_end
;;DEC length +1
;;JMP loop
y_overflow:
LDY #$00
INC B_start + 1

View file

@ -1,6 +1,6 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;; test for memcpy
;; Writes text to half the screen
;; Writes text to the screen
.scope memcpy_test
.include "mem.inc"
VIC_bank = $4000

View file

@ -4,28 +4,24 @@
;; Modifies A, X and B_start
.proc memset
.include "mem.inc"
;;put what to recursive write in Y.
LDX #$0
TAY
LDY #$00
loop:
;;write to byte
TYA
STA (B_start ,X)
STA (A_start), Y
INY
BEQ y_overflow
change_length:
DEC length
BNE loop
Add_16 B_start, B_start +1, #$01, #$00
DEC length +1
BPL loop
JMP loop_end
y_overflow:
LDY #$00
INC B_start + 1
INC A_start + 1
LDA B_start
CMP B_end
BEQ test
jmp loop
test:
LDA B_start +1
CMP B_end +1
BEQ end
jmp loop
end:
;;Dont forget to rewrite last byte
TYA
STA (B_start, X)
RTS
jmp change_length
loop_end:
RTS
.endproc

View file

@ -0,0 +1,9 @@
.scope memset_test
.include "mem.inc"
VIC_bank = $4000
len = $1f40
Mov_16 A_start, A_start + 1, #<VIC_bank, #>VIC_bank
Mov_16 length, length + 1, #<len, #>len
LDA #%01010101
JSR memset
.endscope

View file

@ -8,10 +8,11 @@
.include "STARTUP.s"
;.include "dubbel_buffer/raster_irqs.s"
;.include "routines/line/line_test.s"
.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/memory/memcpy_test.s"
.include "routines/memory/memset_test.s"
;.include "routines/triangle/triangle_test.s"
exit:
JMP exit