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

View file

@ -3,6 +3,7 @@
;;Not values but register position in memory
X_end = $04
Y_end = $05
;;These come from mem.inc
X_pos = $FC
Y_pos = $FB
dx = $0c
@ -11,6 +12,6 @@
dx_2 = $0cF3
V = $0809
D = $0a0b
;;These are also used in pixel_draw. Look there to find out more
byte_to_paint = $FE ;Byte with one 1 that corasponds to a pixel.
btp_mem_pos =$494A; byte to paint memory position ;Position of byte on screen
;;These come from mem.inc
byte_to_paint = $FE ;Byte with one 1 that corisponds to a pixel.
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 -*-
.proc line; X_pos =< X_end skall alltid gälla
;; note that these have same adresses as stuff in line.inc
;; This should be used as a optimisation in the future
dx = $0c
dy = $06
.include "line.inc"
dx_ = $0c
dy_ = $06
;;dx
SEC
LDA X_end
SBC X_pos
STA dx
STA dx_
BCC dx_no_underflow;; X_end >= X_pos
EOR #$ff ; Fix bit underflow
dx_no_underflow:
SEC
LDA Y_pos
SBC Y_end
STA dy
STA dy_
BCC down ;normal Y_pos < Y_end
up:; Y_pos > Y_end
STA dy
CMP dx
STA dy_
CMP dx_
BCC shallow; dy < dx
steep:
jsr line_up_inv
RTS
shallow: ;dy =< dx
lda dx
lda dx_
jsr line_up
RTS
down:
EOR #$ff ; Fix bit underflow
STA dy
CMP dx
STA dy_
CMP dx_
BCC shallow_; dy < dx
steep_:
;LDA dx
@ -42,8 +41,9 @@ steep_:
shallow_: ;dy < dx
jsr line_down
RTS
.include "line_down.s"
.include "line_down_inv.s"
.include "line_up.s"
.include "line_up_inv.s"
.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 -*-
.scope line_test
.include "line.inc"
;;for testing stuff
Y_pos_ = $0D
@ -46,17 +46,13 @@ end__:
end:
;;Long lines
;;Lets cleer bitmap
LDA #>VIC_bank
STA $FC
LDA #<VIC_bank
STA $FB
LDA #>$5f3f
STA $FE
LDA #<$5f3f
STA $FD
LDA #$0
B_start = $FCFD
B_end = $FEFF
VIC_bank = $4000
VIC_bank_end = VIC_bank + $3FFF
Mov_16 >B_start, <B_start, #<VIC_bank, #>VIC_bank
Mov_16 >B_end, <B_end, #<$5f3f, #>$5f3f
LDA #$00
jsr memset
LDA #$00
@ -80,5 +76,4 @@ end:
jmp @loop
end_:
jmp exit
.include "line.s"
.include "macros/"
.endscope

View file

@ -1,5 +1,5 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
.scope line_test_time
.include "line.inc"
;;START TIME HERE
@ -33,6 +33,10 @@
jmp @loop
end__:
;;Lets cleer bitmap
B_start = $FCFD
B_end = $FEFF
VIC_bank = $4000
VIC_bank_end = VIC_bank + $3FFF
LDA #>VIC_bank
STA $FC
LDA #<VIC_bank
@ -48,4 +52,4 @@ end__:
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 -*-
;;############ HANDLES BIG MEMORY MANAGMENTS ############
;;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
A_start = $FAFB
B_start = $FCFD
B_end = $FEFF
.include "mem.inc"
;; Let Y + A_start lower nibble represent A_start
;; therefor: A_start = Y - A_start
@ -26,7 +23,6 @@ loop:
TYA
CMP #$ff
BNE loop
;BPL loop; Branch if Y dont overflow
;; Fix overflow
LDY #$00
INC <A_start

View file

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

View file

@ -1,39 +1,31 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;;############ HANDLES BIG MEMORY MANAGMENTS ############
;;Sets big parts of memory to a certain byte.
;; Sets memory in A to all addresses from B_start to B_end
;; Modifies A, X and B_start
.proc memset
Address_start = $FBFC
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.
.include "mem.inc"
;;put what to recursive write in Y.
LDX #$0
TAY
loop:
;;write to byte
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
CMP >Address_end
LDA >B_start
CMP >B_end
BEQ test
jmp loop
test:
LDA <Address_start
CMP <Address_end
LDA <B_start
CMP <B_end
BEQ end
jmp loop
end:
;;Dont forget to rewrite last byte
TYA
STA ($FB, X)
STA (>B_start, X)
RTS
.endproc

View file

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

View file

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

View file

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