Change scope and add init files

This commit is contained in:
hugova 2025-03-31 00:10:51 +02:00
parent 682a0f2fb9
commit c288254f1f
12 changed files with 86 additions and 103 deletions

View file

@ -1,3 +1,5 @@
.scope STARTUP
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;;Settings positions ;;Settings positions
CR1 = $d011; ;Graphic settings CR1 = $d011; ;Graphic settings
VIC_bank_settings = $DD00 ; Vic position VIC_bank_settings = $DD00 ; Vic position
@ -55,35 +57,18 @@ LDA #%10000000; bit_1 = True
ORA Screen_RAM_settings ORA Screen_RAM_settings
STA Screen_RAM_settings 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 ;;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
LDA #>VIC_bank Mov_16 >B_start, <B_start, #<VIC_bank, #>VIC_bank
STA $FC Mov_16 >B_end, <B_end, #<$5f3f, #>$5f3f
LDA #<VIC_bank LDA #$00
STA $FB
LDA #>$5f3f
STA $FE
LDA #<$5f3f
STA $FD
LDA #$0
jsr memset jsr memset
;;Sets the screen color to black and white ;;Sets the screen color to black and white
LDA #>Screen_RAM Mov_16 >B_start, <B_start, #<Screen_RAM, #>Screen_RAM
STA $FC Mov_16 >B_end, <B_end, #<Screen_RAM_end, #>Screen_RAM_end
LDA #<Screen_RAM
STA $FB
LDA #>Screen_RAM_end
STA $FE
LDA #<Screen_RAM_end
STA $FD
LDA #%11110000 LDA #%11110000
jsr memset jsr memset
SEI ;Disable interups (not all) SEI ;Disable interups (not all)
;;Disable BASIC ROM mohahaha ;;Disable BASIC ROM mohahaha
LDA #%11111110 LDA #%11111110
@ -94,3 +79,4 @@ STA $0001
LDA #%11111011 LDA #%11111011
AND $0001 AND $0001
STA $0001 STA $0001
.endscope

View file

@ -3,6 +3,7 @@
;;Not values but register position in memory ;;Not values but register position in memory
X_end = $04 X_end = $04
Y_end = $05 Y_end = $05
;;These come from mem.inc
X_pos = $FC X_pos = $FC
Y_pos = $FB Y_pos = $FB
dx = $0c dx = $0c
@ -11,6 +12,6 @@
dx_2 = $0cF3 dx_2 = $0cF3
V = $0809 V = $0809
D = $0a0b D = $0a0b
;;These are also used in pixel_draw. Look there to find out more ;;These come from mem.inc
byte_to_paint = $FE ;Byte with one 1 that corasponds to a pixel. byte_to_paint = $FE ;Byte with one 1 that corisponds to a pixel.
btp_mem_pos =$494A; byte to paint memory position ;Position of byte on screen btp_mem_pos =$F9FA; byte to paint memory position ;Position of byte on screen

View file

@ -1,38 +1,37 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- ;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
.proc line; X_pos =< X_end skall alltid gälla .proc line; X_pos =< X_end skall alltid gälla
;; note that these have same adresses as stuff in line.inc .include "line.inc"
;; This should be used as a optimisation in the future dx_ = $0c
dx = $0c dy_ = $06
dy = $06
;;dx ;;dx
SEC SEC
LDA X_end LDA X_end
SBC X_pos SBC X_pos
STA dx STA dx_
BCC dx_no_underflow;; X_end >= X_pos BCC dx_no_underflow;; X_end >= X_pos
EOR #$ff ; Fix bit underflow EOR #$ff ; Fix bit underflow
dx_no_underflow: dx_no_underflow:
SEC SEC
LDA Y_pos LDA Y_pos
SBC Y_end SBC Y_end
STA dy STA dy_
BCC down ;normal Y_pos < Y_end BCC down ;normal Y_pos < Y_end
up:; Y_pos > Y_end up:; Y_pos > Y_end
STA dy STA dy_
CMP dx CMP dx_
BCC shallow; dy < dx BCC shallow; dy < dx
steep: steep:
jsr line_up_inv jsr line_up_inv
RTS RTS
shallow: ;dy =< dx shallow: ;dy =< dx
lda dx lda dx_
jsr line_up jsr line_up
RTS RTS
down: down:
EOR #$ff ; Fix bit underflow EOR #$ff ; Fix bit underflow
STA dy STA dy_
CMP dx CMP dx_
BCC shallow_; dy < dx BCC shallow_; dy < dx
steep_: steep_:
;LDA dx ;LDA dx
@ -42,8 +41,9 @@ steep_:
shallow_: ;dy < dx shallow_: ;dy < dx
jsr line_down jsr line_down
RTS RTS
.include "line_down.s"
.include "line_down_inv.s"
.include "line_up.s"
.include "line_up_inv.s"
.endproc .endproc
.include "line_down.s"
.include "line_down_inv.s"
.include "line_up.s"
.include "line_up_inv.s"

View file

@ -1,5 +1,5 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- ;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
.scope line_test
.include "line.inc" .include "line.inc"
;;for testing stuff ;;for testing stuff
Y_pos_ = $0D Y_pos_ = $0D
@ -46,17 +46,13 @@ end__:
end: end:
;;Long lines ;;Long lines
;;Lets cleer bitmap ;;Lets cleer bitmap
LDA #>VIC_bank B_start = $FCFD
STA $FC B_end = $FEFF
LDA #<VIC_bank VIC_bank = $4000
STA $FB VIC_bank_end = VIC_bank + $3FFF
Mov_16 >B_start, <B_start, #<VIC_bank, #>VIC_bank
LDA #>$5f3f Mov_16 >B_end, <B_end, #<$5f3f, #>$5f3f
STA $FE LDA #$00
LDA #<$5f3f
STA $FD
LDA #$0
jsr memset jsr memset
LDA #$00 LDA #$00
@ -80,5 +76,4 @@ end:
jmp @loop jmp @loop
end_: end_:
jmp exit jmp exit
.include "line.s" .endscope
.include "macros/"

View file

@ -1,5 +1,5 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- ;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
.scope line_test_time
.include "line.inc" .include "line.inc"
;;START TIME HERE ;;START TIME HERE
@ -33,6 +33,10 @@
jmp @loop jmp @loop
end__: end__:
;;Lets cleer bitmap ;;Lets cleer bitmap
B_start = $FCFD
B_end = $FEFF
VIC_bank = $4000
VIC_bank_end = VIC_bank + $3FFF
LDA #>VIC_bank LDA #>VIC_bank
STA $FC STA $FC
LDA #<VIC_bank LDA #<VIC_bank
@ -48,4 +52,4 @@ end__:
jmp exit jmp exit
.include "line.s" .endscope

View file

@ -0,0 +1,13 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;;In use of in memcpy and memset
A_start = $FAFB
B_start = $FCFD
B_end = $FEFF
;;In use of by pixel_draw
Y_pos = $FB
X_pos = $FCFD
byte_to_paint = $FE
btp_mem_pos =$F9FA; byte to paint memory position
C = $7071
B =$7273

View file

@ -1,12 +1,9 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- ;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;;############ HANDLES BIG MEMORY MANAGMENTS ############
;;Move memory from B_start B_end to A_start , (implied address) ;;Move memory from B_start B_end to A_start , (implied address)
;; B_start and B_end gets modified under execution. ;;Modifies A,X and B_start gets modified
.proc memcpy .proc memcpy
A_start = $FAFB .include "mem.inc"
B_start = $FCFD
B_end = $FEFF
;; Let Y + A_start lower nibble represent A_start ;; Let Y + A_start lower nibble represent A_start
;; therefor: A_start = Y - A_start ;; therefor: A_start = Y - A_start
@ -26,7 +23,6 @@ loop:
TYA TYA
CMP #$ff CMP #$ff
BNE loop BNE loop
;BPL loop; Branch if Y dont overflow
;; Fix overflow ;; Fix overflow
LDY #$00 LDY #$00
INC <A_start INC <A_start

View file

@ -1,12 +1,7 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- ;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
memcpy_test: ;; test for memcpy
;; TESTING OF MEMCPY TEMPERARLY HERE BECAUSE IT WILL USE THAT :) .scope memcpy_test
X_pos = $FA
A_start = $FAFB
Y_pos = $F9
B_start = $FCFD
charset = $FB charset = $FB
B_end = $FEFF
code = $FE code = $FE
petski_position = $FEFF ;reuses code:s memory petski_position = $FEFF ;reuses code:s memory
screen_position = $FCFD screen_position = $FCFD
@ -21,7 +16,8 @@ memcpy_test:
STA X_pos STA X_pos
STA Y_pos STA Y_pos
VIC_bank = $4000
VIC_bank_end = VIC_bank + $3FFF
Mov_16 >A_start, <A_start, #<VIC_bank, #>VIC_bank Mov_16 >A_start, <A_start, #<VIC_bank, #>VIC_bank
;We first need to clear some memory ;We first need to clear some memory
;Mov_16 >A_end, >A_end, #<(VIC_bank+100), #>(VIC_bank +100) ;Mov_16 >A_end, >A_end, #<(VIC_bank+100), #>(VIC_bank +100)
@ -29,3 +25,4 @@ memcpy_test:
JSR memcpy JSR memcpy
STA <petski_position STA <petski_position
jmp exit jmp exit
.endscope

View file

@ -1,39 +1,31 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- ;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;;############ HANDLES BIG MEMORY MANAGMENTS ############ ;; Sets memory in A to all addresses from B_start to B_end
;;Sets big parts of memory to a certain byte. ;; Modifies A, X and B_start
.proc memset .proc memset
Address_start = $FBFC .include "mem.inc"
Address_end = $FDFE
;;Writes data in A
;;Adress start: $FC, $FB
;;Adress end: $FE, $FD
;;Example [ $FC =$44, $FB =$00, $FE =$45, $FD =$01, A =0]
;;writes zeros in memory from $4400 to $4501.
;;put what to recursive write in Y. ;;put what to recursive write in Y.
LDX #$0 LDX #$0
TAY TAY
loop: loop:
;;write to byte ;;write to byte
TYA TYA
STA ($FB ,X) STA (>B_start ,X)
Add_16 >Address_start, <Address_start, #$01, #$00 Add_16 >B_start, <B_start, #$01, #$00
LDA >Address_start LDA >B_start
CMP >Address_end CMP >B_end
BEQ test BEQ test
jmp loop jmp loop
test: test:
LDA <Address_start LDA <B_start
CMP <Address_end CMP <B_end
BEQ end BEQ end
jmp loop jmp loop
end: end:
;;Dont forget to rewrite last byte ;;Dont forget to rewrite last byte
TYA TYA
STA ($FB, X) STA (>B_start, X)
RTS RTS
.endproc .endproc

View file

@ -3,12 +3,9 @@
;;Screen print. Draws a pixel at a specified position. ;;Screen print. Draws a pixel at a specified position.
;; Destroys A X Y ;; Destroys A X Y
.proc pixel_draw; Draws a pixel at [Y = FB , X = FC, FD]. Y = 0 - 320, X= 0 - 200 .proc pixel_draw; Draws a pixel at [Y = FB , X = FC, FD]. Y = 0 - 320, X= 0 - 200
Y_pos = $FB .include "mem.inc"
X_pos = $FCFD Bitmap = $4000
byte_to_paint = $FE Bitmap_end = $5F3F
btp_mem_pos =$494A; byte to paint memory position
C = $7071
B =$7273
;; X = X_pos (mod 8) ;; X = X_pos (mod 8)
LDA >X_pos ; X (mod 8) LDA >X_pos ; X (mod 8)
AND #%00000111 AND #%00000111

View file

@ -5,6 +5,7 @@
;; And prints it ON X_pos, Y_pos ;; And prints it ON X_pos, Y_pos
;; Note that this is the real positions divided by 8 ;; Note that this is the real positions divided by 8
.proc char_draw .proc char_draw
Character_generator_ROM = $D000
Y_pos_offset = $F9F8 ;Reuses from Y_pos Y_pos_offset = $F9F8 ;Reuses from Y_pos
X_pos_offset = $FAF7 X_pos_offset = $FAF7
X_pos = $FA X_pos = $FA

View file

@ -1,15 +1,16 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
.debuginfo + ; Generate debug info .debuginfo + ; Generate debug info
;;Macros
.include "macros/16aritmatic.s" .include "macros/16aritmatic.s"
.include "macros/timer.s" ;;inc files
.include "routines/memory/mem.inc"
;;Code to run
.include "STARTUP.s" .include "STARTUP.s"
.include "routines/line/line_test_time.s" ;.include "routines/line/line_test_time.s"
;jsr char_draw .include "routines/memory/memcpy_test.s"
;;This is used by .s files to terminate nicely without reading includes at the end!
exit: exit:
jmp exit jmp exit
.include "routines/line/line.s"
.include "routines/text/char_draw.s"
.include "routines/memory/memset.s"
.include "routines/memory/pixel_draw.s" .include "routines/memory/pixel_draw.s"
.include "routines/memory/memset.s"
.include "routines/memory/memcpy.s" .include "routines/memory/memcpy.s"